Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3e0f70f
commit 902304c
Showing
21 changed files
with
449 additions
and
282 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// SettingsAccountLabelView.swift | ||
// NetNewsWire-iOS | ||
// | ||
// Created by Maurice Parker on 6/11/19. | ||
// Copyright © 2019 Ranchero Software. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct SettingsAccountLabelView : View { | ||
let accountImage: String | ||
let accountLabel: String | ||
|
||
var body: some View { | ||
HStack { | ||
Spacer() | ||
HStack { | ||
Image(accountImage) | ||
.resizable() | ||
.aspectRatio(1, contentMode: .fit) | ||
.frame(height: 32) | ||
Text(verbatim: accountLabel).font(.title) | ||
|
||
} | ||
.layoutPriority(1) | ||
Spacer() | ||
} | ||
.foregroundColor(.primary) | ||
} | ||
} | ||
|
||
#if DEBUG | ||
struct SettingsAccountLabelView_Previews : PreviewProvider { | ||
static var previews: some View { | ||
SettingsAccountLabelView(accountImage: "accountLocal", accountLabel: "On My Device") | ||
.previewLayout(.fixed(width: 300, height: 44)) | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// SettingsAddAccountView.swift | ||
// NetNewsWire-iOS | ||
// | ||
// Created by Maurice Parker on 6/11/19. | ||
// Copyright © 2019 Ranchero Software. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct SettingsAddAccountView : View { | ||
var body: some View { | ||
List { | ||
PresentationButton(SettingsAccountLabelView(accountImage: "accountLocal", accountLabel: "On My Device"), | ||
destination: SettingsLocalAccountView(name: "")) | ||
PresentationButton(SettingsAccountLabelView(accountImage: "accountFeedbin", accountLabel: "Feedbin"), | ||
destination: SettingsFeedbinAccountView(email: "", password: "")) | ||
} | ||
.listStyle(.grouped) | ||
.navigationBarTitle(Text("Add Account"), displayMode: .inline) | ||
} | ||
} | ||
|
||
#if DEBUG | ||
struct AddAccountView_Previews : PreviewProvider { | ||
static var previews: some View { | ||
SettingsAddAccountView() | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// | ||
// SettingsFeedbinAccountView.swift | ||
// NetNewsWire-iOS | ||
// | ||
// Created by Maurice Parker on 6/11/19. | ||
// Copyright © 2019 Ranchero Software. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct SettingsFeedbinAccountView : View { | ||
@State var email: String | ||
@State var password: String | ||
|
||
var body: some View { | ||
NavigationView { | ||
List { | ||
Section(header: | ||
SettingsAccountLabelView(accountImage: "accountFeedbin", accountLabel: "Feedbin").padding() | ||
) { | ||
HStack { | ||
Spacer() | ||
TextField($email, placeholder: Text("Email")) | ||
Spacer() | ||
} | ||
HStack { | ||
Spacer() | ||
SecureField($password, placeholder: Text("Password")) | ||
Spacer() | ||
} | ||
} | ||
Section { | ||
HStack { | ||
Spacer() | ||
Button(action: {}) { | ||
Text("Add Account") | ||
} | ||
Spacer() | ||
} | ||
} | ||
} | ||
.listStyle(.grouped) | ||
.navigationBarTitle(Text(""), displayMode: .inline) | ||
} | ||
} | ||
|
||
} | ||
|
||
#if DEBUG | ||
struct SettingsFeedbinAccountView_Previews : PreviewProvider { | ||
static var previews: some View { | ||
SettingsFeedbinAccountView(email: "", password: "") | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// | ||
// SettingsLocalAccountView.swift | ||
// NetNewsWire-iOS | ||
// | ||
// Created by Maurice Parker on 6/11/19. | ||
// Copyright © 2019 Ranchero Software. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import Account | ||
|
||
struct SettingsLocalAccountView : View { | ||
@State var name: String | ||
|
||
var body: some View { | ||
NavigationView { | ||
List { | ||
Section(header: | ||
SettingsAccountLabelView(accountImage: "accountLocal", accountLabel: "On My Device").padding() | ||
) { | ||
HStack { | ||
Spacer() | ||
TextField($name, placeholder: Text("Name (Optional)")) | ||
Spacer() | ||
} | ||
} | ||
Section { | ||
HStack { | ||
Spacer() | ||
Button(action: { self.addAccount() }) { | ||
Text("Add Account") | ||
} | ||
Spacer() | ||
} | ||
} | ||
} | ||
.listStyle(.grouped) | ||
.navigationBarTitle(Text(""), displayMode: .inline) | ||
} | ||
} | ||
|
||
func addAccount() { | ||
let account = AccountManager.shared.createAccount(type: .onMyMac) | ||
account.name = name | ||
} | ||
} | ||
|
||
#if DEBUG | ||
struct SettingsLocalAccountView_Previews : PreviewProvider { | ||
static var previews: some View { | ||
SettingsLocalAccountView(name: "") | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// | ||
// SettingsView.swift | ||
// NetNewsWire-iOS | ||
// | ||
// Created by Maurice Parker on 6/11/19. | ||
// Copyright © 2019 Ranchero Software. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import Account | ||
|
||
struct SettingsView : View { | ||
@ObjectBinding var viewModel: SettingsViewModel | ||
|
||
var body: some View { | ||
NavigationView { | ||
List { | ||
|
||
Section(header: Text("ACCOUNTS")) { | ||
ForEach(viewModel.accounts.identified(by: \.self)) { account in | ||
Text(verbatim: account.nameForDisplay) | ||
} | ||
NavigationButton(destination: SettingsAddAccountView(), isDetail: false) { | ||
Text("Add Account") | ||
} | ||
} | ||
|
||
Section(header: Text("ABOUT")) { | ||
|
||
Text("About NetNewsWire") | ||
|
||
Button(action: { | ||
UIApplication.shared.open(URL(string: "https://ranchero.com/netnewswire/")!, options: [:]) | ||
}) { | ||
Text("Website") | ||
} | ||
|
||
Button(action: { | ||
UIApplication.shared.open(URL(string: "https://github.com/brentsimmons/NetNewsWire")!, options: [:]) | ||
}) { | ||
Text("Github Repository") | ||
} | ||
|
||
Button(action: { | ||
UIApplication.shared.open(URL(string: "https://github.com/brentsimmons/NetNewsWire/issues")!, options: [:]) | ||
}) { | ||
Text("Bug Tracker") | ||
} | ||
|
||
Button(action: { | ||
UIApplication.shared.open(URL(string: "https://github.com/brentsimmons/NetNewsWire/tree/master/Technotes")!, options: [:]) | ||
}) { | ||
Text("Technotes") | ||
} | ||
|
||
Text("Add NetNewsWire News Feed") | ||
|
||
} | ||
.foregroundColor(.primary) | ||
|
||
Section(header: Text("TIMELINE")) { | ||
Toggle(isOn: $viewModel.sortOldestToNewest) { | ||
Text("Sort Oldest to Newest") | ||
} | ||
Stepper(value: $viewModel.timelineNumberOfLines, in: 2...6) { | ||
Text("Number of Text Lines: \(viewModel.timelineNumberOfLines)") | ||
} | ||
} | ||
|
||
Section(header: Text("DATABASE")) { | ||
Picker(selection: $viewModel.refreshInterval, label: Text("Refresh Interval")) { | ||
ForEach(RefreshInterval.allCases.identified(by: \.self)) { interval in | ||
Text(interval.description()).tag(interval) | ||
} | ||
} | ||
Text("Import Subscriptions...") | ||
Text("Export Subscriptions...") | ||
} | ||
|
||
} | ||
.listStyle(.grouped) | ||
.navigationBarTitle(Text("Settings"), displayMode: .inline) | ||
|
||
} | ||
} | ||
} | ||
|
||
#if DEBUG | ||
struct SettingsView_Previews : PreviewProvider { | ||
static var previews: some View { | ||
SettingsView(viewModel: SettingsViewModel()) | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// | ||
// SettingsViewModel.swift | ||
// NetNewsWire-iOS | ||
// | ||
// Created by Maurice Parker on 6/11/19. | ||
// Copyright © 2019 Ranchero Software. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import SwiftUI | ||
import Combine | ||
import Account | ||
|
||
class SettingsViewModel: BindableObject { | ||
|
||
let didChange = PassthroughSubject<SettingsViewModel, Never>() | ||
|
||
init() { | ||
NotificationCenter.default.addObserver(self, selector: #selector(accountsDidChange(_:)), name: .AccountsDidChange, object: nil) | ||
} | ||
|
||
var accounts: [Account] { | ||
get { | ||
return AccountManager.shared.accounts | ||
} | ||
set { | ||
} | ||
} | ||
|
||
var sortOldestToNewest: Bool { | ||
get { | ||
return AppDefaults.timelineSortDirection == .orderedDescending | ||
} | ||
set { | ||
if newValue == true { | ||
AppDefaults.timelineSortDirection = .orderedDescending | ||
} else { | ||
AppDefaults.timelineSortDirection = .orderedAscending | ||
} | ||
didChange.send(self) | ||
} | ||
} | ||
|
||
var timelineNumberOfLines: Int { | ||
get { | ||
return AppDefaults.timelineNumberOfLines | ||
} | ||
set { | ||
AppDefaults.timelineNumberOfLines = newValue | ||
didChange.send(self) | ||
} | ||
} | ||
|
||
var refreshInterval: RefreshInterval { | ||
get { | ||
return AppDefaults.refreshInterval | ||
} | ||
set { | ||
AppDefaults.refreshInterval = newValue | ||
didChange.send(self) | ||
} | ||
} | ||
|
||
@objc func accountsDidChange(_ notification: Notification) { | ||
didChange.send(self) | ||
} | ||
|
||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.