on master help sign in
Extract backButton component and use withBottomBar layout for Add Contact page
commitc4559f61f0ab85426e46bd324c27d5e0f09d2d6c authoriko <mail@iko.soy> dateSat 18 Apr 2026, 09:23 (6 months ago) parent7704455
4 files changed+61−40
client/Buttons.fs+27 client/ViewAddContact.fs+31−30 client/ViewChat.fs+2−5 client/ViewEditProfile.fs+1−5
client/Buttons.fs+27
@@ -162,6 +162,33 @@ module Buttons =
162162 .onTapped (fun _ -> msg)
163163 }
164164
165+ let backButton (msg: 'msg) =
166+ Component("back-button") {
167+ let! pressed = Context.State(false)
168+ let offset = if pressed.Current then 2. else 4.
169+
170+ (Grid() {
171+ shadowRect offset
172+
173+ Rectangle().fill (SolidColorBrush(Colors.White))
174+
175+ Image("avares://Skrepka/Assets/Images/left.png", Stretch.Uniform)
176+ .width(24.)
177+ .height(24.)
178+ .center ()
179+
180+ borderRect ()
181+ })
182+ .width(48.)
183+ .height(48.)
184+ .background(Brushes.Transparent)
185+ .onPointerPressed(fun _ -> pressed.Set true)
186+ .onPointerReleased(fun _ -> pressed.Set false)
187+ .onPointerExited(fun _ -> pressed.Set false)
188+ .margin(8.)
189+ .onTapped (fun _ -> msg)
190+ }
191+
165192 let smallTextButton (text: string) (msg: 'msg) =
166193 Component($"small-button-{text}") {
167194 let! pressed = Context.State(false)
client/ViewAddContact.fs+31−30
@@ -8,6 +8,8 @@ open type Fabulous.Avalonia.View
88module ViewAddContact =
99
1010 open AppTypes
11+ open Buttons
12+ open Styles
1113
1214 let private qrBytes (text: string) =
1315 use qr = new QRCoder.QRCodeGenerator()
@@ -16,42 +18,41 @@ module ViewAddContact =
1618 png.GetGraphic(8, [| 0uy; 0uy; 0uy |], [| 255uy; 255uy; 255uy |])
1719
1820 let viewAddContact model cpk cnn =
19− ScrollViewer(
20− (VStack(16.) {
21− HStack(8.) {
22− Image("avares://Skrepka/Assets/Images/left.png", Stretch.Uniform)
23− .width(24.)
24− .height(24.)
25− .onTapped (fun _ -> SetPage Conversations)
21+ let content =
22+ ScrollViewer(
23+ (VStack(16.) {
24+ match model.Auth with
25+ | Identified(id, _) ->
26+ let ob = hexToOb id.PubKeyHex
2627
27− TextBlock("Add Contact").fontSize (20.)
28− }
28+ TextBlock("Your key (share with contact):").foreground (SolidColorBrush(Colors.DimGray))
2929
30− match model.Auth with
31− | Identified(id, _) ->
32− let ob = hexToOb id.PubKeyHex
30+ Image(Styles.cachedBitmap (qrBytes ob), Stretch.Uniform)
31+ .maxWidth(200.)
32+ .centerHorizontal ()
3333
34− TextBlock("Your key (share with contact):").foreground (SolidColorBrush(Colors.DimGray))
34+ TextBlock(truncKey id.PubKeyHex)
35+ .fontSize(12.)
36+ .foreground(SolidColorBrush(Colors.DimGray))
37+ .centerText ()
38+ | NoIdentity -> ()
3539
36− Image(Styles.cachedBitmap (qrBytes ob), Stretch.Uniform)
37− .maxWidth(200.)
38− .centerHorizontal ()
40+ viewErrorBanner model.Error
3941
40− TextBlock(truncKey id.PubKeyHex)
41− .fontSize(12.)
42− .foreground(SolidColorBrush(Colors.DimGray))
43− .centerText ()
44− | NoIdentity -> ()
42+ TextBlock("Public Key:")
43+ TextBox(cpk, fun text -> SetPage(AddContact(text, cnn))).watermark ("sampel-palnet-...")
4544
46− viewErrorBanner model.Error
45+ TextBlock("Nickname:")
46+ TextBox(cnn, fun text -> SetPage(AddContact(cpk, text)))
4747
48− TextBlock("Public Key:")
49− TextBox(cpk, fun text -> SetPage(AddContact(text, cnn))).watermark ("sampel-palnet-...")
48+ Button("Save Contact", DoSaveContact).centerHorizontal ()
49+ })
50+ .margin (20.)
51+ )
5052
51− TextBlock("Nickname:")
52− TextBox(cnn, fun text -> SetPage(AddContact(cpk, text)))
53+ let bar =
54+ HStack(8.) {
55+ backButton (SetPage Conversations)
56+ }
5357
54− Button("Save Contact", DoSaveContact).centerHorizontal ()
55− })
56− .margin (20.)
57− )
58+ withBottomBar bar content
client/ViewChat.fs+2−5
@@ -1,6 +1,5 @@
11namespace Skrepka
22
3−open Avalonia.Media
43open Fabulous.Avalonia
54
65open type Fabulous.Avalonia.View
@@ -9,6 +8,7 @@ module ViewChat =
98
109 open Store
1110 open AppTypes
11+ open Buttons
1212
1313 let viewChat model pk compose =
1414 let name = contactName model.Contacts pk
@@ -16,10 +16,7 @@ module ViewChat =
1616
1717 (VStack(8.) {
1818 HStack(8.) {
19− Image("avares://Skrepka/Assets/Images/left.png", Stretch.Uniform)
20− .width(24.)
21− .height(24.)
22− .onTapped (fun _ -> SetPage Conversations)
19+ backButton (SetPage Conversations)
2320
2421 TextBlock(name).fontSize(20.).centerVertical ()
2522 }
client/ViewEditProfile.fs+1−5
@@ -34,11 +34,7 @@ module ViewEditProfile =
3434
3535 let bar =
3636 HStack(8.) {
37− Image("avares://Skrepka/Assets/Images/left.png", Stretch.Uniform)
38− .width(24.)
39− .height(24.)
40− .margin(8.)
41− .onTapped (fun _ -> SetPage Settings)
37+ backButton (SetPage Settings)
4238 (button Secondary "save" DoSaveProfile).margin (8.)
4339 }
4440