diff --git a/iOS/MasterTimeline/MasterTimelineViewController.swift b/iOS/MasterTimeline/MasterTimelineViewController.swift index c453568db..1f67dadd5 100644 --- a/iOS/MasterTimeline/MasterTimelineViewController.swift +++ b/iOS/MasterTimeline/MasterTimelineViewController.swift @@ -495,7 +495,6 @@ private extension MasterTimelineViewController { var snapshot = NSDiffableDataSourceSnapshot() snapshot.appendSections([0]) snapshot.appendItems(coordinator.articles, toSection: 0) - print("********* article count: \(coordinator.articles.count)") dataSource.apply(snapshot, animatingDifferences: animate) { [weak self] in self?.restoreSelectionIfNecessary() diff --git a/iOS/Settings/Account/SettingsAddAccountView.swift b/iOS/Settings/Account/SettingsAddAccountView.swift index 5e2fa01e1..2bd52139c 100644 --- a/iOS/Settings/Account/SettingsAddAccountView.swift +++ b/iOS/Settings/Account/SettingsAddAccountView.swift @@ -11,34 +11,16 @@ import Account struct SettingsAddAccountView : View { @Environment(\.presentationMode) var presentation - @State private var selectedAccountType: AccountType = nil var body: some View { Form { - - Button(action: { - self.selectedAccountType = AccountType.onMyMac - }) { + NavigationLink(destination: SettingsLocalAccountView(name: "")) { SettingsAccountLabelView(accountImage: "accountLocal", accountLabel: Account.defaultLocalAccountName) } - - Button(action: { - self.selectedAccountType = AccountType.feedbin - }) { + NavigationLink(destination: SettingsFeedbinAccountView(viewModel: SettingsFeedbinAccountView.ViewModel())) { SettingsAccountLabelView(accountImage: "accountFeedbin", accountLabel: "Feedbin") } - - } - .sheet(item: $selectedAccountType) { accountType in - if accountType == .onMyMac { - SettingsLocalAccountView(name: "", onDismiss: { self.presentation.wrappedValue.dismiss() }) - } - if accountType == .feedbin { - SettingsFeedbinAccountView(viewModel: SettingsFeedbinAccountView.ViewModel(), onDismiss: { self.presentation.wrappedValue.dismiss() }) - } - } - .navigationBarTitle(Text("Add Account"), displayMode: .inline) } } diff --git a/iOS/Settings/Account/SettingsDetailAccountView.swift b/iOS/Settings/Account/SettingsDetailAccountView.swift index 567ad8508..8e3365245 100644 --- a/iOS/Settings/Account/SettingsDetailAccountView.swift +++ b/iOS/Settings/Account/SettingsDetailAccountView.swift @@ -71,7 +71,7 @@ struct SettingsDetailAccountView : View { var settingsFeedbinAccountView: SettingsFeedbinAccountView { let feedbinViewModel = SettingsFeedbinAccountView.ViewModel(account: viewModel.account) - return SettingsFeedbinAccountView(viewModel: feedbinViewModel, onDismiss: {}) + return SettingsFeedbinAccountView(viewModel: feedbinViewModel) } class ViewModel: ObservableObject { diff --git a/iOS/Settings/Account/SettingsFeedbinAccountView.swift b/iOS/Settings/Account/SettingsFeedbinAccountView.swift index 0c71d2c79..04f74a65c 100644 --- a/iOS/Settings/Account/SettingsFeedbinAccountView.swift +++ b/iOS/Settings/Account/SettingsFeedbinAccountView.swift @@ -17,49 +17,41 @@ struct SettingsFeedbinAccountView : View { @State var busy: Bool = false @State var error: String = "" - // This is a hack around the fact that onDismiss isn't being called by the sheet modifier. - var onDismiss: () -> Void - var body: some View { - NavigationView { - Form { - Section(header: - HStack { - Spacer() - SettingsAccountLabelView(accountImage: "accountFeedbin", accountLabel: "Feedbin").padding() - Spacer() - } - ) { - TextField("Email", text: $viewModel.email).textContentType(.emailAddress) - SecureField("Password", text: $viewModel.password) + Form { + Section(header: + HStack { + Spacer() + SettingsAccountLabelView(accountImage: "accountFeedbin", accountLabel: "Feedbin").padding() + Spacer() } - Section(footer: - HStack { - Spacer() - Text(verbatim: error).foregroundColor(.red) - Spacer() - } - ) { - HStack { - Spacer() - Button(action: { self.addAccount() }) { - if viewModel.isUpdate { - Text("Update Account") - } else { - Text("Add Account") - } + ) { + TextField("Email", text: $viewModel.email).textContentType(.emailAddress) + SecureField("Password", text: $viewModel.password) + } + Section(footer: + HStack { + Spacer() + Text(verbatim: error).foregroundColor(.red) + Spacer() + } + ) { + HStack { + Spacer() + Button(action: { self.addAccount() }) { + if viewModel.isUpdate { + Text("Update Account") + } else { + Text("Add Account") } - .disabled(!viewModel.isValid) - Spacer() } + .disabled(!viewModel.isValid) + Spacer() } } - .disabled(busy) - .navigationBarTitle(Text(""), displayMode: .inline) - .navigationBarItems(leading: - Button(action: { self.dismiss() }) { Text("Cancel") } - ) } +// .disabled(busy) // Maybe someday we can do this, but right now it crashes on the iPad + .navigationBarTitle(Text(""), displayMode: .inline) } private func addAccount() { @@ -71,14 +63,14 @@ struct SettingsFeedbinAccountView : View { let credentials = Credentials.basic(username: emailAddress, password: viewModel.password) Account.validateCredentials(type: .feedbin, credentials: credentials) { result in - + self.busy = false - + switch result { case .success(let authenticated): - + if (authenticated != nil) { - + var newAccount = false let workAccount: Account if self.viewModel.account == nil { @@ -87,39 +79,38 @@ struct SettingsFeedbinAccountView : View { } else { workAccount = self.viewModel.account! } - + do { - + do { try workAccount.removeCredentials() } catch {} try workAccount.storeCredentials(credentials) - + if newAccount { workAccount.refreshAll() { result in } } - + self.dismiss() - + } catch { self.error = "Keychain error while storing credentials." } - + } else { self.error = "Invalid email/password combination." } - + case .failure: self.error = "Network error. Try again later." } - + } } private func dismiss() { presentation.wrappedValue.dismiss() - onDismiss() } class ViewModel: ObservableObject { @@ -164,7 +155,7 @@ struct SettingsFeedbinAccountView : View { #if DEBUG struct SettingsFeedbinAccountView_Previews : PreviewProvider { static var previews: some View { - SettingsFeedbinAccountView(viewModel: SettingsFeedbinAccountView.ViewModel(), onDismiss: {}) + SettingsFeedbinAccountView(viewModel: SettingsFeedbinAccountView.ViewModel()) } } #endif diff --git a/iOS/Settings/Account/SettingsLocalAccountView.swift b/iOS/Settings/Account/SettingsLocalAccountView.swift index e0aa6a44f..13f6ee53e 100644 --- a/iOS/Settings/Account/SettingsLocalAccountView.swift +++ b/iOS/Settings/Account/SettingsLocalAccountView.swift @@ -13,36 +13,30 @@ struct SettingsLocalAccountView : View { @Environment(\.presentationMode) var presentation @State var name: String - // This is a hack around the fact that onDismiss isn't being called by the sheet modifier. - var onDismiss: () -> Void - var body: some View { - NavigationView { - Form { - Section(header: - HStack { - Spacer() - SettingsAccountLabelView(accountImage: "accountLocal", accountLabel: Account.defaultLocalAccountName).padding() - Spacer() - } - ) { - HStack { - TextField("Name", text: $name) - } + Form { + Section(header: + HStack { + Spacer() + SettingsAccountLabelView(accountImage: "accountLocal", accountLabel: Account.defaultLocalAccountName).padding() + Spacer() } - Section { - HStack { - Spacer() - Button(action: { self.addAccount() }) { - Text("Add Account") - } - Spacer() - } + ) { + HStack { + TextField("Name", text: $name) + } + } + Section { + HStack { + Spacer() + Button(action: { self.addAccount() }) { + Text("Add Account") + } + Spacer() } } - .navigationBarTitle(Text(""), displayMode: .inline) - .navigationBarItems(leading: Button(action: { self.dismiss() }) { Text("Cancel") } ) } + .navigationBarTitle(Text(""), displayMode: .inline) } private func addAccount() { @@ -53,7 +47,6 @@ struct SettingsLocalAccountView : View { private func dismiss() { presentation.wrappedValue.dismiss() - onDismiss() } } @@ -61,7 +54,7 @@ struct SettingsLocalAccountView : View { #if DEBUG struct SettingsLocalAccountView_Previews : PreviewProvider { static var previews: some View { - SettingsLocalAccountView(name: "", onDismiss: {}) + SettingsLocalAccountView(name: "") } } #endif