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

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

View File

@@ -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() {

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).
// 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) {