scan/paste menu

This commit is contained in:
spaced4ndy
2024-05-06 13:08:34 +04:00
parent c7bc2cc890
commit c7d045a4fa
3 changed files with 34 additions and 43 deletions
@@ -18,7 +18,6 @@ struct ChatsView: View {
@State private var searchShowingSimplexLink = false
@State private var searchChatFilteredBySimplexLink: String? = nil
@State private var newChatMenuOption: NewChatMenuOption? = nil // TODO remove?
@AppStorage(DEFAULT_SHOW_UNREAD_AND_FAVORITES) private var showUnreadAndFavorites = false
@AppStorage(DEFAULT_ONE_HAND_UI) private var oneHandUI = true
+27 -42
View File
@@ -48,6 +48,7 @@ struct HomeView: View {
destination: chatView
) {
// ZStack {
VStack {
switch homeTab {
case .contacts: contactsView()
@@ -109,20 +110,20 @@ struct HomeView: View {
}
}
private func bottomToolbar() -> some View {
HStack {
settingsButton()
Spacer()
contactsButton()
Spacer()
chatsButton()
Spacer()
newChatButton()
}
.padding(.horizontal, 12)
.padding(.horizontal)
.frame(maxWidth: .infinity)
}
// private func bottomToolbar() -> some View {
// HStack {
// settingsButton()
// Spacer()
// contactsButton()
// Spacer()
// chatsButton()
// Spacer()
// newChatButton()
// }
// .padding(.horizontal, 12)
// .padding(.horizontal)
// .frame(maxWidth: .infinity)
// }
@ViewBuilder private func settingsButton() -> some View {
let user = chatModel.currentUser ?? User.sampleData
@@ -183,16 +184,21 @@ struct HomeView: View {
private func newChatButton() -> some View {
Menu {
Button {
newChatMenuOption = .newContact
} label: {
Text("Add contact")
}
Button {
newChatMenuOption = .newGroup
} label: {
Text("Create group")
}
Button {
newChatMenuOption = .scanPaste
} label: {
Text("Scan / Paste link")
}
Button {
newChatMenuOption = .newContact
} label: {
Text("Add contact")
}
} label: {
iconLabel("square.and.pencil", "New chat")
}
@@ -200,10 +206,10 @@ struct HomeView: View {
.sheet(item: $newChatMenuOption) { opt in
switch opt {
case .newContact: NewChatView(selection: .invite)
case .scanPaste: NewChatView(selection: .connect, showQRCodeScanner: true)
case .newGroup: AddGroupView()
}
}
// NewChatView(selection: .connect, showQRCodeScanner: true)
}
private func iconLabel(_ image: String, _ title: LocalizedStringKey) -> some View {
@@ -217,10 +223,6 @@ struct HomeView: View {
}
}
private func settingsView() -> some View {
SettingsView(showSettings: $showSettings)
}
private func contactsView() -> some View {
// TODO
VStack {
@@ -229,8 +231,7 @@ struct HomeView: View {
}
@ViewBuilder private func chatsView() -> some View {
// TODO onboarding buttons (remove?)
// TODO for reversed chat list start at bottom
// TODO reverse scale effect for swipe actions
if oneHandUI {
ChatsView()
.padding(.vertical, 5)
@@ -240,22 +241,6 @@ struct HomeView: View {
}
}
@ViewBuilder private func newChatView() -> some View {
// TODO doesn't fit
// TODO alerts don't work
// TODO dismiss on connect
// TODO dismiss when creating group
// TODO chat stopped (see chatsStoppedIcon in ChatsView)
switch newChatMenuOption {
case .newContact:
NewChatView(selection: .invite)
case .newGroup:
AddGroupView()
case nil:
EmptyView()
}
}
@ViewBuilder private func chatView() -> some View {
if let chatId = chatModel.chatId, let chat = chatModel.getChat(chatId) {
ChatView(chat: chat).onAppear {
@@ -10,6 +10,7 @@ import SwiftUI
enum NewChatMenuOption: Identifiable {
case newContact
case scanPaste
case newGroup
var id: Self { self }
@@ -25,6 +26,11 @@ struct NewChatMenuButton: View {
} label: {
Text("Add contact")
}
Button {
newChatMenuOption = .scanPaste
} label: {
Text("Scan / Paste link")
}
Button {
newChatMenuOption = .newGroup
} label: {
@@ -39,6 +45,7 @@ struct NewChatMenuButton: View {
.sheet(item: $newChatMenuOption) { opt in
switch opt {
case .newContact: NewChatView(selection: .invite)
case .scanPaste: NewChatView(selection: .connect, showQRCodeScanner: true)
case .newGroup: AddGroupView()
}
}