diff --git a/Kordophone/Shared/ContentView.swift b/Kordophone/Shared/ContentView.swift index cf94910..ff3de22 100644 --- a/Kordophone/Shared/ContentView.swift +++ b/Kordophone/Shared/ContentView.swift @@ -23,22 +23,25 @@ struct ContentView: View { } } + private var showLoginSheet: Binding { + Binding { + !connection.authenticated + } set: { _ in + // swallow + } + + } + @ViewBuilder private var content: some View { - if !connection.authenticated { - LoginView { info in - Task { - await connection.connect(info: info) - } + NavigationView { + ConversationListWrapper(selectedConversation: $selectedConversation) + selectedConversation.map { + ConversationViewWrapper(conversation: $0) } } - else { - NavigationView { - ConversationListWrapper(selectedConversation: $selectedConversation) - selectedConversation.map { - ConversationViewWrapper(conversation: $0) - } - } + .sheet(isPresented: showLoginSheet) { + loginOverlay } } diff --git a/Kordophone/Shared/ConversationList.swift b/Kordophone/Shared/ConversationList.swift index 922ae04..b4ebdb5 100644 --- a/Kordophone/Shared/ConversationList.swift +++ b/Kordophone/Shared/ConversationList.swift @@ -44,5 +44,8 @@ struct ConversationListWrapper : View { .onAppear { refresh() } + .onChange(of: connection.authenticated) { newValue in + refresh() + } } } diff --git a/Kordophone/Shared/LoginView.swift b/Kordophone/Shared/LoginView.swift index c6fd60d..9c73375 100644 --- a/Kordophone/Shared/LoginView.swift +++ b/Kordophone/Shared/LoginView.swift @@ -20,6 +20,7 @@ struct LoginView : View { password: password))) } } + .padding() } }