Just a couple of Combine Publishers to go.

This commit is contained in:
John Holdsworth
2019-07-09 14:43:52 +01:00
parent b8281e5e21
commit f5f4d0b3d5
12 changed files with 33 additions and 24 deletions

View File

@@ -18,7 +18,7 @@ struct CategoryRow: View {
.padding(.leading, 15) .padding(.leading, 15)
.padding(.top, 5) .padding(.top, 5)
ScrollView { ScrollView(.horizontal) {
HStack(alignment: .top, spacing: 0) { HStack(alignment: .top, spacing: 0) {
ForEach(self.items.identified(by: \.name)) { landmark in ForEach(self.items.identified(by: \.name)) { landmark in
NavigationLink( NavigationLink(

View File

@@ -42,7 +42,7 @@ struct AddCurrencyView : View {
} }
} }
} }
}.navigationBarItem(title: Text("Add Currency")) }.navigationBarTitle(Text("Add Currency"))
} }
private func select(_ currency: Currency) { private func select(_ currency: Currency) {

View File

@@ -37,6 +37,7 @@ struct ConverterView : View {
let doubleValue: Double = Double(self.$baseAmount.value) ?? 1.0 let doubleValue: Double = Double(self.$baseAmount.value) ?? 1.0
return ZStack(alignment: Alignment.bottomTrailing) { return ZStack(alignment: Alignment.bottomTrailing) {
NavigationView {
VStack(alignment: .leading){ VStack(alignment: .leading){
Text("From:").bold().color(.gray) Text("From:").bold().color(.gray)
HStack{ HStack{
@@ -69,7 +70,7 @@ struct ConverterView : View {
} }
} }
}.onAppear(perform: loadCurrencies) }.onAppear(perform: loadCurrencies)
.navigationBarItem(title: Text("Currenceis 💱")) .navigationBarTitle(Text("Currencies 💱"))
.navigationBarItems(trailing: Button(action: { self.isEditing.toggle() }) { .navigationBarItems(trailing: Button(action: { self.isEditing.toggle() }) {
if !self.isEditing { if !self.isEditing {
Text("Edit") Text("Edit")
@@ -77,9 +78,11 @@ struct ConverterView : View {
Text("Done").bold() Text("Done").bold()
} }
}) })
HStack {
Text("Last updated: \(self.lastUpdated)").color(.gray).bold() Text("Last updated: \(self.lastUpdated)").color(.gray).bold()
} Spacer()
NavigationButton(destination: AddCurrencyView().environmentObject(self.userData)) {
NavigationLink(destination: AddCurrencyView().environmentObject(self.userData)) {
Text("💰") Text("💰")
}.frame(width: 46, height: 46, alignment: .center) }.frame(width: 46, height: 46, alignment: .center)
.background( .background(
@@ -88,6 +91,9 @@ struct ConverterView : View {
.border(Color(red: 0.7, green: 0.7, blue: 0.7), width: 1 / UIScreen.main.scale, cornerRadius: 23)) .border(Color(red: 0.7, green: 0.7, blue: 0.7), width: 1 / UIScreen.main.scale, cornerRadius: 23))
.foregroundColor(.white).font(.largeTitle) .foregroundColor(.white).font(.largeTitle)
}.padding() }.padding()
}
}
}
} }
private func loadCurrencies() { private func loadCurrencies() {

View File

@@ -37,12 +37,12 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
// Use a UIHostingController as window root view controller // Use a UIHostingController as window root view controller
let window = UIWindow(frame: UIScreen.main.bounds) if let windowScene = scene as? UIWindowScene {
window.rootViewController = UIHostingController(rootView: NavigationView { let window = UIWindow(windowScene: windowScene)
ConverterView().environmentObject(UserData()) window.rootViewController = UIHostingController(rootView: ConverterView().environmentObject(UserData()))
}) self.window = window
self.window = window window.makeKeyAndVisible()
window.makeKeyAndVisible() }
} }
func sceneDidDisconnect(_ scene: UIScene) { func sceneDidDisconnect(_ scene: UIScene) {

View File

@@ -20,12 +20,12 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
// Use a UIHostingController as window root view controller // Use a UIHostingController as window root view controller
let window = UIWindow(frame: UIScreen.main.bounds) if let windowScene = scene as? UIWindowScene {
window.rootViewController = UIHostingController(rootView: NavigationView { let window = UIWindow(windowScene: windowScene)
TaskListView().environmentObject(UserData()) window.rootViewController = UIHostingController(rootView: TaskListView().environmentObject(UserData()))
}) self.window = window
self.window = window window.makeKeyAndVisible()
window.makeKeyAndVisible() }
} }
func sceneDidDisconnect(_ scene: UIScene) { func sceneDidDisconnect(_ scene: UIScene) {

View File

@@ -22,7 +22,7 @@ struct TaskItemView: View {
.tapAction(count: 1) { .tapAction(count: 1) {
self.delete() self.delete()
} }
NavigationButton(destination: TaskEditView(task: task).environmentObject(self.userData)) { NavigationLink(destination: TaskEditView(task: task).environmentObject(self.userData)) {
Text(task.title) Text(task.title)
} }
} else { } else {

View File

@@ -14,13 +14,14 @@ struct TaskListView: View {
@State var isEditing: Bool = false @State var isEditing: Bool = false
var body: some View { var body: some View {
NavigationView {
List { List {
TextField($draftTitle, placeholder: Text("Create a New Task..."), onCommit: self.createTask) TextField($draftTitle, placeholder: Text("Create a New Task..."), onCommit: self.createTask)
ForEach(self.userData.tasks) { task in ForEach(self.userData.tasks) { task in
TaskItemView(task: task, isEditing: self.$isEditing) TaskItemView(task: task, isEditing: self.$isEditing)
} }
} }
.navigationBarItem(title: Text("Tasks 👀")) .navigationBarTitle(Text("Tasks 👀"))
.navigationBarItems(trailing: Button(action: { self.isEditing.toggle() }) { .navigationBarItems(trailing: Button(action: { self.isEditing.toggle() }) {
if !self.isEditing { if !self.isEditing {
Text("Edit") Text("Edit")
@@ -28,6 +29,7 @@ struct TaskListView: View {
Text("Done").bold() Text("Done").bold()
} }
}) })
}
} }
private func createTask() { private func createTask() {

View File

@@ -18,7 +18,7 @@ struct CategoryRow: View {
.padding(.leading, 15) .padding(.leading, 15)
.padding(.top, 5) .padding(.top, 5)
ScrollView([]) { ScrollView(.horizontal) {
HStack(alignment: .top, spacing: 0) { HStack(alignment: .top, spacing: 0) {
ForEach(self.items.identified(by: \.name)) { landmark in ForEach(self.items.identified(by: \.name)) { landmark in
NavigationLink( NavigationLink(

View File

@@ -31,7 +31,7 @@ struct ProfileSummary: View {
VStack(alignment: .leading) { VStack(alignment: .leading) {
Text("Completed Badges") Text("Completed Badges")
.font(.headline) .font(.headline)
ScrollView { ScrollView(.horizontal) {
HStack { HStack {
HikeBadge(name: "First Hike") HikeBadge(name: "First Hike")

View File

@@ -18,7 +18,7 @@ struct CategoryRow: View {
.padding(.leading, 15) .padding(.leading, 15)
.padding(.top, 5) .padding(.top, 5)
ScrollView { ScrollView(.horizontal) {
HStack(alignment: .top, spacing: 0) { HStack(alignment: .top, spacing: 0) {
ForEach(self.items.identified(by: \.name)) { landmark in ForEach(self.items.identified(by: \.name)) { landmark in
NavigationLink( NavigationLink(

View File

@@ -20,7 +20,8 @@ struct LandmarkList: View {
ForEach(userData.landmarks) { landmark in ForEach(userData.landmarks) { landmark in
if !self.userData.showFavoritesOnly || landmark.isFavorite { if !self.userData.showFavoritesOnly || landmark.isFavorite {
NavigationLink( NavigationLink(
destination: LandmarkDetail(landmark: landmark)) { destination: LandmarkDetail(landmark: landmark)
.environmentObject(self.userData)) {
LandmarkRow(landmark: landmark) LandmarkRow(landmark: landmark)
} }
} }

View File

@@ -31,7 +31,7 @@ struct ProfileSummary: View {
VStack(alignment: .leading) { VStack(alignment: .leading) {
Text("Completed Badges") Text("Completed Badges")
.font(.headline) .font(.headline)
ScrollView { ScrollView(.horizontal) {
HStack { HStack {
HikeBadge(name: "First Hike") HikeBadge(name: "First Hike")