mirror of
https://github.com/ivanvorobei/SwiftUI.git
synced 2026-04-19 07:19:53 +02:00
Just a couple of Combine Publishers to go.
This commit is contained in:
@@ -18,7 +18,7 @@ struct CategoryRow: View {
|
||||
.padding(.leading, 15)
|
||||
.padding(.top, 5)
|
||||
|
||||
ScrollView {
|
||||
ScrollView(.horizontal) {
|
||||
HStack(alignment: .top, spacing: 0) {
|
||||
ForEach(self.items.identified(by: \.name)) { landmark in
|
||||
NavigationLink(
|
||||
|
||||
@@ -42,7 +42,7 @@ struct AddCurrencyView : View {
|
||||
}
|
||||
}
|
||||
}
|
||||
}.navigationBarItem(title: Text("Add Currency"))
|
||||
}.navigationBarTitle(Text("Add Currency"))
|
||||
}
|
||||
|
||||
private func select(_ currency: Currency) {
|
||||
|
||||
@@ -37,6 +37,7 @@ struct ConverterView : View {
|
||||
let doubleValue: Double = Double(self.$baseAmount.value) ?? 1.0
|
||||
|
||||
return ZStack(alignment: Alignment.bottomTrailing) {
|
||||
NavigationView {
|
||||
VStack(alignment: .leading){
|
||||
Text("From:").bold().color(.gray)
|
||||
HStack{
|
||||
@@ -69,7 +70,7 @@ struct ConverterView : View {
|
||||
}
|
||||
}
|
||||
}.onAppear(perform: loadCurrencies)
|
||||
.navigationBarItem(title: Text("Currenceis 💱"))
|
||||
.navigationBarTitle(Text("Currencies 💱"))
|
||||
.navigationBarItems(trailing: Button(action: { self.isEditing.toggle() }) {
|
||||
if !self.isEditing {
|
||||
Text("Edit")
|
||||
@@ -77,9 +78,11 @@ struct ConverterView : View {
|
||||
Text("Done").bold()
|
||||
}
|
||||
})
|
||||
HStack {
|
||||
Text("Last updated: \(self.lastUpdated)").color(.gray).bold()
|
||||
}
|
||||
NavigationButton(destination: AddCurrencyView().environmentObject(self.userData)) {
|
||||
Spacer()
|
||||
|
||||
NavigationLink(destination: AddCurrencyView().environmentObject(self.userData)) {
|
||||
Text("💰")
|
||||
}.frame(width: 46, height: 46, alignment: .center)
|
||||
.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))
|
||||
.foregroundColor(.white).font(.largeTitle)
|
||||
}.padding()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func loadCurrencies() {
|
||||
|
||||
@@ -37,12 +37,12 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
|
||||
|
||||
// Use a UIHostingController as window root view controller
|
||||
let window = UIWindow(frame: UIScreen.main.bounds)
|
||||
window.rootViewController = UIHostingController(rootView: NavigationView {
|
||||
ConverterView().environmentObject(UserData())
|
||||
})
|
||||
self.window = window
|
||||
window.makeKeyAndVisible()
|
||||
if let windowScene = scene as? UIWindowScene {
|
||||
let window = UIWindow(windowScene: windowScene)
|
||||
window.rootViewController = UIHostingController(rootView: ConverterView().environmentObject(UserData()))
|
||||
self.window = window
|
||||
window.makeKeyAndVisible()
|
||||
}
|
||||
}
|
||||
|
||||
func sceneDidDisconnect(_ scene: UIScene) {
|
||||
|
||||
@@ -20,12 +20,12 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
|
||||
|
||||
// Use a UIHostingController as window root view controller
|
||||
let window = UIWindow(frame: UIScreen.main.bounds)
|
||||
window.rootViewController = UIHostingController(rootView: NavigationView {
|
||||
TaskListView().environmentObject(UserData())
|
||||
})
|
||||
self.window = window
|
||||
window.makeKeyAndVisible()
|
||||
if let windowScene = scene as? UIWindowScene {
|
||||
let window = UIWindow(windowScene: windowScene)
|
||||
window.rootViewController = UIHostingController(rootView: TaskListView().environmentObject(UserData()))
|
||||
self.window = window
|
||||
window.makeKeyAndVisible()
|
||||
}
|
||||
}
|
||||
|
||||
func sceneDidDisconnect(_ scene: UIScene) {
|
||||
|
||||
@@ -22,7 +22,7 @@ struct TaskItemView: View {
|
||||
.tapAction(count: 1) {
|
||||
self.delete()
|
||||
}
|
||||
NavigationButton(destination: TaskEditView(task: task).environmentObject(self.userData)) {
|
||||
NavigationLink(destination: TaskEditView(task: task).environmentObject(self.userData)) {
|
||||
Text(task.title)
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -14,13 +14,14 @@ struct TaskListView: View {
|
||||
@State var isEditing: Bool = false
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
List {
|
||||
TextField($draftTitle, placeholder: Text("Create a New Task..."), onCommit: self.createTask)
|
||||
ForEach(self.userData.tasks) { task in
|
||||
TaskItemView(task: task, isEditing: self.$isEditing)
|
||||
}
|
||||
}
|
||||
.navigationBarItem(title: Text("Tasks 👀"))
|
||||
.navigationBarTitle(Text("Tasks 👀"))
|
||||
.navigationBarItems(trailing: Button(action: { self.isEditing.toggle() }) {
|
||||
if !self.isEditing {
|
||||
Text("Edit")
|
||||
@@ -28,6 +29,7 @@ struct TaskListView: View {
|
||||
Text("Done").bold()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private func createTask() {
|
||||
|
||||
@@ -18,7 +18,7 @@ struct CategoryRow: View {
|
||||
.padding(.leading, 15)
|
||||
.padding(.top, 5)
|
||||
|
||||
ScrollView([]) {
|
||||
ScrollView(.horizontal) {
|
||||
HStack(alignment: .top, spacing: 0) {
|
||||
ForEach(self.items.identified(by: \.name)) { landmark in
|
||||
NavigationLink(
|
||||
|
||||
@@ -31,7 +31,7 @@ struct ProfileSummary: View {
|
||||
VStack(alignment: .leading) {
|
||||
Text("Completed Badges")
|
||||
.font(.headline)
|
||||
ScrollView {
|
||||
ScrollView(.horizontal) {
|
||||
HStack {
|
||||
HikeBadge(name: "First Hike")
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ struct CategoryRow: View {
|
||||
.padding(.leading, 15)
|
||||
.padding(.top, 5)
|
||||
|
||||
ScrollView {
|
||||
ScrollView(.horizontal) {
|
||||
HStack(alignment: .top, spacing: 0) {
|
||||
ForEach(self.items.identified(by: \.name)) { landmark in
|
||||
NavigationLink(
|
||||
|
||||
@@ -20,7 +20,8 @@ struct LandmarkList: View {
|
||||
ForEach(userData.landmarks) { landmark in
|
||||
if !self.userData.showFavoritesOnly || landmark.isFavorite {
|
||||
NavigationLink(
|
||||
destination: LandmarkDetail(landmark: landmark)) {
|
||||
destination: LandmarkDetail(landmark: landmark)
|
||||
.environmentObject(self.userData)) {
|
||||
LandmarkRow(landmark: landmark)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ struct ProfileSummary: View {
|
||||
VStack(alignment: .leading) {
|
||||
Text("Completed Badges")
|
||||
.font(.headline)
|
||||
ScrollView {
|
||||
ScrollView(.horizontal) {
|
||||
HStack {
|
||||
HikeBadge(name: "First Hike")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user