@@ -1,5 +1,6 @@
11namespace Skrepka
22
3+open Avalonia.Layout
34open Fabulous.Avalonia
45
56open type Fabulous.Avalonia.View
@@ -14,37 +15,42 @@ module ViewChat =
1415 let name = contactName model.Contacts pk
1516 let msgs = messagesFor pk model.Messages
1617
17− (VStack(8.) {
18− HStack(8.) {
18+ (Grid([ Dimension.Auto; Dimension.Auto; Dimension.Star; Dimension.Auto ], [ Dimension.Star ]) {
19+ (HStack(8.) {
1920 backButton (SetPage Conversations)
2021
2122 TextBlock(name).fontSize(20.).centerVertical ()
22− }
23−
24− viewErrorBanner model.Error
25−
26− ScrollViewer(
27− VStack(4.) {
28− if msgs.IsEmpty then
29− TextBlock("No messages yet").padding(8.).fontSize (14.)
30− else
31− for m in msgs do
32− let prefix, tick =
33− match m.Direction with
34− | Outgoing DeliveryStatus.Delivered -> "You: ", " \u2713"
35− | Outgoing DeliveryStatus.Sent -> "You: ", ""
36− | Incoming -> "", ""
37−
38− TextBlock($"{prefix}{m.Body}{tick}").padding(8.).fontSize (14.)
39− }
40− )
41−
42− HStack(8.) {
23+ })
24+ .gridRow (0)
25+
26+ (viewErrorBanner model.Error).gridRow (1)
27+
28+ (if msgs.IsEmpty then
29+ AnyView(TextBlock("No messages yet").padding(8.).fontSize (14.))
30+ else
31+ let reversed = List.rev msgs
32+
33+ AnyView(
34+ ScrollViewer(
35+ ItemsRepeater(reversed, fun m ->
36+ let prefix, tick =
37+ match m.Direction with
38+ | Outgoing DeliveryStatus.Delivered -> "You: ", " \u2713"
39+ | Outgoing DeliveryStatus.Sent -> "You: ", ""
40+ | Incoming -> "", ""
41+
42+ TextBlock($"{prefix}{m.Body}{tick}").padding(8.).fontSize (14.))
43+ )
44+ ))
45+ .gridRow (2)
46+
47+ (HStack(8.) {
4348 TextBox(compose, fun text -> SetPage(Chat(pk, text)))
4449 .watermark("Message...")
45− .horizontalAlignment (Avalonia.Layout.HorizontalAlignment.Stretch)
50+ .horizontalAlignment (HorizontalAlignment.Stretch)
4651
4752 Button("Send", DoSend)
48− }
53+ })
54+ .gridRow (3)
4955 })
5056 .margin (12.)