From 13b34c90de2cf979e3237b7933464799d558f84f Mon Sep 17 00:00:00 2001 From: fmodf Date: Wed, 7 Aug 2024 20:08:46 +0200 Subject: [PATCH] wip --- .../Resources/Strings/Localizable.strings | 2 +- .../Screens/Chats/ChatsCreateMainScreen.swift | 76 +++++++++++++++---- 2 files changed, 62 insertions(+), 16 deletions(-) diff --git a/ConversationsClassic/Resources/Strings/Localizable.strings b/ConversationsClassic/Resources/Strings/Localizable.strings index cc5e6b2..8458afc 100644 --- a/ConversationsClassic/Resources/Strings/Localizable.strings +++ b/ConversationsClassic/Resources/Strings/Localizable.strings @@ -44,7 +44,7 @@ "Chat.textfieldPrompt" = "Type a message"; "Chats.Create.Main.title" = "Create"; -"Chats.Create.Main.createGroup" = "Create puplic group"; +"Chats.Create.Main.createGroup" = "Create public group"; "Chats.Create.Main.createPrivateGroup" = "Create private group"; "Chats.Create.Main.findGroup" = "Find public group"; diff --git a/ConversationsClassic/View/Screens/Chats/ChatsCreateMainScreen.swift b/ConversationsClassic/View/Screens/Chats/ChatsCreateMainScreen.swift index 8509dca..d70b51b 100644 --- a/ConversationsClassic/View/Screens/Chats/ChatsCreateMainScreen.swift +++ b/ConversationsClassic/View/Screens/Chats/ChatsCreateMainScreen.swift @@ -24,21 +24,27 @@ struct ChatsCreateMainScreen: View { // List List { - CreateRoomRowButton( + ChatsCreateRowButton( title: L10n.Chats.Create.Main.createGroup, - image: "person.2.square.stack", + image: "person.2.fill", action: {} ) - CreateRoomRowButton( + ChatsCreateRowButton( title: L10n.Chats.Create.Main.createPrivateGroup, - image: "person.2.square.stack", + image: "person.2.fill", action: {} ) - CreateRoomRowButton( + ChatsCreateRowButton( title: L10n.Chats.Create.Main.findGroup, - image: "person.2.square.stack", + image: "magnifyingglass", action: {} ) + + // for contacts list + let rosters = store.state.rostersState.rosters.filter { !$0.locallyDeleted } + if rosters.isEmpty { + ChatsCreateRowSeparator() + } } .listStyle(.plain) @@ -48,29 +54,44 @@ struct ChatsCreateMainScreen: View { } } -private struct CreateRoomRowButton: View { +private struct ChatsCreateRowButton: View { var title: String var image: String var action: () -> Void var body: some View { - HStack(spacing: 16) { - Image(systemName: image) - .font(.head2) - .foregroundColor(.Material.Elements.active) - .padding(.leading, 16) - Text(title) - .font(.body1) - .foregroundColor(.Material.Text.main) + VStack(alignment: .center, spacing: 0) { Spacer() + HStack(alignment: .center, spacing: 16) { + Image(systemName: image) + .font(.head2) + .foregroundColor(.Material.Elements.active) + .padding(.leading, 16) + Text(title) + .font(.body1) + .foregroundColor(.Material.Text.main) + Spacer() + } + Spacer() + Rectangle() + .frame(maxWidth: .infinity) + .frame(height: 1) + .foregroundColor(.Material.Background.dark) } .sharedListRow() + .frame(height: 48) .onTapGesture { action() } } } +private struct ChatsCreateRowSeparator: View { + var body: some View { + Text("aa") + } +} + // import SwiftUI // // struct CreateConversationMainScreen: View { @@ -134,3 +155,28 @@ private struct CreateRoomRowButton: View { // } // } // + +// Preview +#if DEBUG + struct ChatsCreateMainScreen_Previews: PreviewProvider { + static var previews: some View { + ChatsCreateMainScreen(isPresented: .constant(true)) + .environmentObject(pStore) + } + + static var pStore: AppStore { + let state = pState + return AppStore(initialState: state, reducer: AppState.reducer, middlewares: []) + } + + static var pState: AppState { + var state = AppState() + + state.rostersState.rosters = [ + .init(contactBareJid: "test@me.com", subscription: "both", ask: true, data: .init(groups: [], annotations: [])) + ] + + return state + } + } +#endif