@@ -1,5 +1,6 @@
11namespace Skrepka
22
3+open Avalonia.Media
34open Fabulous.Avalonia
45
56open type Fabulous.Avalonia.View
@@ -8,22 +9,46 @@ module ViewAddContact =
89
910 open AppTypes
1011
12+ let private qrBytes (text: string) =
13+ use qr = new QRCoder.QRCodeGenerator()
14+ use data = qr.CreateQrCode(text, QRCoder.QRCodeGenerator.ECCLevel.M)
15+ use png = new QRCoder.PngByteQRCode(data)
16+ png.GetGraphic(8, [| 0uy; 0uy; 0uy |], [| 255uy; 255uy; 255uy |])
17+
1118 let viewAddContact model cpk cnn =
12− (VStack(16.) {
13− HStack(8.) {
14− Button("< Back", SetPage Conversations)
19+ ScrollViewer(
20+ (VStack(16.) {
21+ HStack(8.) {
22+ Button("< Back", SetPage Conversations)
23+
24+ TextBlock("Add Contact").fontSize (20.)
25+ }
26+
27+ match model.Auth with
28+ | Identified(id, _) ->
29+ let ob = hexToOb id.PubKeyHex
30+
31+ TextBlock("Your key (share with contact):").foreground (SolidColorBrush(Colors.DimGray))
32+
33+ Image(Styles.cachedBitmap (qrBytes ob), Stretch.Uniform)
34+ .maxWidth(200.)
35+ .centerHorizontal ()
1536
16− TextBlock("Add Contact").fontSize (20.)
17− }
37+ TextBlock(truncKey id.PubKeyHex)
38+ .fontSize(12.)
39+ .foreground(SolidColorBrush(Colors.DimGray))
40+ .centerText ()
41+ | NoIdentity -> ()
1842
19− viewErrorBanner model.Error
43+ viewErrorBanner model.Error
2044
21− TextBlock("Public Key:")
22− TextBox(cpk, fun text -> SetPage(AddContact(text, cnn))).watermark ("sampel-palnet-...")
45+ TextBlock("Public Key:")
46+ TextBox(cpk, fun text -> SetPage(AddContact(text, cnn))).watermark ("sampel-palnet-...")
2347
24− TextBlock("Nickname:")
25− TextBox(cnn, fun text -> SetPage(AddContact(cpk, text)))
48+ TextBlock("Nickname:")
49+ TextBox(cnn, fun text -> SetPage(AddContact(cpk, text)))
2650
27− Button("Save Contact", DoSaveContact).centerHorizontal ()
28− })
29− .margin (20.)
51+ Button("Save Contact", DoSaveContact).centerHorizontal ()
52+ })
53+ .margin (20.)
54+ )