Add Import/Export OPML action sheet.

This commit is contained in:
Maurice Parker 2019-06-15 18:19:20 -05:00
parent 8dcf4966fb
commit dc75737c97
2 changed files with 46 additions and 7 deletions

View File

@ -20,9 +20,9 @@ struct SettingsLocalAccountView : View {
SettingsAccountLabelView(accountImage: "accountLocal", accountLabel: Account.defaultLocalAccountName).padding()
) {
HStack {
Spacer()
TextField($name, placeholder: Text("Name (Optional)"))
Spacer()
Text("Name")
Divider()
TextField($name, placeholder: Text("(Optional)"))
}
}
Section {

View File

@ -12,7 +12,9 @@ import Account
struct SettingsView : View {
@ObjectBinding var viewModel: ViewModel
@State var showImportSubscriptions = false
@State var showExportSubscriptions = false
var body: some View {
NavigationView {
List {
@ -76,10 +78,21 @@ struct SettingsView : View {
Text(interval.description()).tag(interval)
}
}
Text("Import Subscriptions...")
Text("Export Subscriptions...")
Button(action: {
self.showImportSubscriptions = true
}) {
Text("Import Subscriptions...")
}
.presentation(showImportSubscriptions ? importSubscriptionsActionSheet : nil)
Button(action: {
self.showExportSubscriptions = true
}) {
Text("Export Subscriptions...")
}
.presentation(showExportSubscriptions ? exportSubscriptionsActionSheet : nil)
}
.foregroundColor(.primary)
}
.listStyle(.grouped)
.navigationBarTitle(Text("Settings"), displayMode: .inline)
@ -87,6 +100,32 @@ struct SettingsView : View {
}
}
var importSubscriptionsActionSheet: ActionSheet {
var buttons = [ActionSheet.Button]()
for account in viewModel.accounts {
let button = ActionSheet.Button.default(Text(verbatim: account.nameForDisplay)) {
self.showImportSubscriptions = false
// Call doc picker here...
}
buttons.append(button)
}
buttons.append(.cancel { self.showImportSubscriptions = false })
return ActionSheet(title: Text("Import Subscriptions..."), message: Text("Select the account to import your OPML file into."), buttons: buttons)
}
var exportSubscriptionsActionSheet: ActionSheet {
var buttons = [ActionSheet.Button]()
for account in viewModel.accounts {
let button = ActionSheet.Button.default(Text(verbatim: account.nameForDisplay)) {
self.showExportSubscriptions = false
// Call doc picker here...
}
buttons.append(button)
}
buttons.append(.cancel { self.showImportSubscriptions = false })
return ActionSheet(title: Text("Export Subscriptions..."), message: Text("Select the account to export out of."), buttons: buttons)
}
class ViewModel: BindableObject {
let didChange = PassthroughSubject<ViewModel, Never>()