on master help sign in
Refactor textField to support watermark and use smallImageButton for send and settings
commit5387e6dbfa7925b596fd00e5c8e9f993e1fccfc0 authoriko <mail@iko.soy> dateTue 21 Apr 2026, 21:03 (6 months ago) parent442423c
7 files changed+11−30
client/Assets/Images/send.png client/Buttons.fs+3−18 client/TextFields.fs+2−2 client/ViewAddContact.fs+1−1 client/ViewChat.fs+2−6 client/ViewConversations.fs+2−2 client/ViewEditProfile.fs+1−1
client/Assets/Images/send.pngnew file

Binary file not shown.

client/Buttons.fs+3−18
@@ -131,13 +131,8 @@ module Buttons =
131131 .onTapped (fun _ -> msg)
132132 }
133133
134− let smallImageButton (img: byte[] option) (msg: 'msg) =
135− let key =
136− match img with
137− | None -> "img-button"
138− | Some i -> $"img-button-{hash i}"
139−
140− Component(key) {
134+ let smallImageButton (asset: string) (msg: 'msg) =
135+ Component($"img-button-{asset}") {
141136 let! pressed = Context.State(false)
142137 let offset = if pressed.Current then 2. else 4.
143138
@@ -146,17 +141,7 @@ module Buttons =
146141
147142 Rectangle().fill (SolidColorBrush(Colors.White))
148143
149− match img with
150− | None ->
151− ViewBox(
152− Image("avares://Skrepka/Assets/Images/user.png", Stretch.Uniform)
153− .width(32.)
154− .height(32.)
155− .margin (8.)
156− )
157−
158− | Some i ->
159− Image(Styles.cachedBitmap i, Stretch.UniformToFill).width(32.).height(32.).clipToBounds (true)
144+ Image(asset, Stretch.Uniform).width(24.).height(24.).center ()
160145
161146 borderRect ()
162147 })
client/TextFields.fs+2−2
@@ -29,9 +29,9 @@ module TextFields =
2929 .Name("PART_BorderElement"))
3030 [ setter ] ]
3131
32− let textField value msg =
32+ let textField watermark value msg =
3333 (Grid() {
34− TextBox(value, msg).fontFamily(Constants.fontFamily).verticalAlignment(VerticalAlignment.Stretch).verticalContentAlignment(VerticalAlignment.Center).background(SolidColorBrush(Colors.White))
34+ TextBox(value, msg).watermark(watermark).fontFamily(Constants.fontFamily).verticalAlignment(VerticalAlignment.Stretch).verticalContentAlignment(VerticalAlignment.Center).background(SolidColorBrush(Colors.White))
3535 Rectangle().stroke(Colors.Black).strokeThickness (4.)
3636 }).styles (whiteBg ())
3737
client/ViewAddContact.fs+1−1
@@ -52,7 +52,7 @@ module ViewAddContact =
5252 if hasError then
5353 errorTextField cpk (fun key -> SetPage(AddContact(key)))
5454 else
55− textField cpk (fun key -> SetPage(AddContact(key)))
55+ textField "" cpk (fun key -> SetPage(AddContact(key)))
5656
5757
5858 if isValid then
client/ViewChat.fs+2−6
@@ -87,15 +87,11 @@ module ViewChat =
8787 (Grid([ Dimension.Auto; Dimension.Star; Dimension.Auto ], [ Dimension.Auto ]) {
8888 (backButton (SetPage Conversations)).gridColumn (0)
8989
90− TextBox(compose, fun text -> SetPage(Chat(pk, text)))
91− .watermark("Message...")
92− .fontFamily(Constants.fontFamily)
93− .verticalAlignment(VerticalAlignment.Stretch)
94− .verticalContentAlignment(VerticalAlignment.Center)
90+ (textField "Message..." compose (fun text -> SetPage(Chat(pk, text))))
9591 .margin(8.)
9692 .gridColumn (1)
9793
98− (smallButton Primary "Send" DoSend).gridColumn (2)
94+ (smallImageButton "avares://Skrepka/Assets/Images/send.png" DoSend).gridColumn (2)
9995 })
10096 .horizontalAlignment (HorizontalAlignment.Stretch)
10197
client/ViewConversations.fs+2−2
@@ -91,8 +91,8 @@ module ViewConversations =
9191 .centerText ()
9292
9393 (Grid([ Dimension.Auto; Dimension.Star; Dimension.Auto ], [ Dimension.Auto ]) {
94− (smallImageButton None (SetPage Settings)).gridColumn (0)
95− (textField "" Search).margin(8.).verticalAlignment(VerticalAlignment.Stretch).gridColumn (1)
94+ (smallImageButton "avares://Skrepka/Assets/Images/user.png" (SetPage Settings)).gridColumn (0)
95+ (textField "" "" Search).margin(8.).verticalAlignment(VerticalAlignment.Stretch).gridColumn (1)
9696 (smallTextButton "+" (SetPage(AddContact("")))).gridColumn (2)
9797 })
9898 .horizontalAlignment (HorizontalAlignment.Stretch)
client/ViewEditProfile.fs+1−1
@@ -21,7 +21,7 @@ module ViewEditProfile =
2121 imageButton photo DoPickPhoto
2222
2323 TextBlock("Name").fontFamily(Constants.fontFamily).fontWeight(FontWeight.Bold).margin (0, 24, 0, -8)
24− (textField displayName (fun text -> SetPage(EditProfile(text, bio, photo)))).margin (0, 0, 0, 8)
24+ (textField "" displayName (fun text -> SetPage(EditProfile(text, bio, photo)))).margin (0, 0, 0, 8)
2525
2626
2727 TextBlock("Bio").fontFamily(Constants.fontFamily).fontWeight(FontWeight.Bold).margin (0, 0, 0, -8)