Skip to content

Commit

Permalink
added in app message
Browse files Browse the repository at this point in the history
  • Loading branch information
ronan18 committed Apr 3, 2020
1 parent 1f0976d commit b105a75
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 48 deletions.
2 changes: 2 additions & 0 deletions Arrival-iOS2/AppData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class AppData: NSObject, ObservableObject,CLLocationManagerDelegate {
@Published var trainLeaveTimeType: TrainTimeType = .now
@Published var leaveDate = Date()
@Published var arriveDate = Date()
@Published var appMessage = ""
let net = Alamofire.NetworkReachabilityManager(host: "api.arrival.city")
private let locationManager = CLLocationManager()
private var lat = 0.0
Expand Down Expand Up @@ -139,6 +140,7 @@ class AppData: NSObject, ObservableObject,CLLocationManagerDelegate {
self.daysBetweenReviewAsk = Int(self.remoteConfig["daysBetweenReviewAsk"].stringValue!)!
self.privacyPolicy = self.remoteConfig["privacyPolicyUrl"].stringValue!
self.termsOfService = self.remoteConfig["termsOfServiceUrl"].stringValue!
self.appMessage = self.remoteConfig["inAppMessage"].stringValue!
print(self.onboardingLoaded, "config onboarding loaded")


Expand Down
20 changes: 20 additions & 0 deletions Arrival-iOS2/Assets.xcassets/darkGrey.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x29",
"green" : "0x29",
"red" : "0x29"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
107 changes: 59 additions & 48 deletions Arrival-iOS2/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,52 +164,53 @@ struct HomeView: View {
}.padding().edgesIgnoringSafeArea(.bottom)
}
Spacer()
Button (action: {
self.fromStationSearch = ""
if (self.appData.fromStation.id != "loading") {
self.timeModalDisplayed = true
}

}) {
VStack(alignment: .center) {
if (self.appData.trainLeaveTimeType == .now) {
HStack {
Spacer()
Text("leave").font(.caption)
Spacer()
}
Text("now").font(.headline)
} else if (self.appData.trainLeaveTimeType == .leave) {
HStack {
Spacer()
Text("leave").font(.caption)
Spacer()
}
Text(self.formateTime(self.appData.leaveDate)).font(.headline).lineLimit(1)
} else {
HStack {
Spacer()
Text("arrive").font(.caption)
Spacer()
}
Text(self.formateTime(self.appData.arriveDate)).font(.headline).lineLimit(1)
if (false) {
Button (action: {
self.fromStationSearch = ""
if (self.appData.fromStation.id != "loading") {
self.timeModalDisplayed = true
}

}.multilineTextAlignment(.center).frame(width: geometry.size.width / 4)
}.frame(width: geometry.size.width / 4).sheet(isPresented: self.$timeModalDisplayed) {
VStack(alignment: .leading) {
HStack(alignment: .center) {
Text("Choose a time")
.font(.largeTitle)
.fontWeight(.bold)
Spacer()
Button(action: {
self.timeModalDisplayed = false
}) {
Text("Close")
}) {
VStack(alignment: .center) {
if (self.appData.trainLeaveTimeType == .now) {
HStack {
Spacer()
Text("leave").font(.caption)
Spacer()
}
Text("now").font(.headline)
} else if (self.appData.trainLeaveTimeType == .leave) {
HStack {
Spacer()
Text("leave").font(.caption)
Spacer()
}
Text(self.formateTime(self.appData.leaveDate)).font(.headline).lineLimit(1)
} else {
HStack {
Spacer()
Text("arrive").font(.caption)
Spacer()
}
Text(self.formateTime(self.appData.arriveDate)).font(.headline).lineLimit(1)
}
}


}.multilineTextAlignment(.center).frame(width: geometry.size.width / 4)
}.frame(width: geometry.size.width / 4).sheet(isPresented: self.$timeModalDisplayed) {
VStack(alignment: .leading) {
HStack(alignment: .center) {
Text("Choose a time")
.font(.largeTitle)
.fontWeight(.bold)
Spacer()
Button(action: {
self.timeModalDisplayed = false
}) {
Text("Close")
}
}

Button(action: {
self.appData.trainLeaveTimeType = .now
}) {
Expand Down Expand Up @@ -268,10 +269,11 @@ struct HomeView: View {
}



Spacer()

}.padding()

Spacer()

}.padding()
}
}
Spacer()
Button (action: {
Expand Down Expand Up @@ -346,7 +348,16 @@ struct HomeView: View {
Spacer()
}.background(Color.red)
}

if (!self.appData.appMessage.isEmpty) {
HStack {
Spacer()
Text(self.appData.appMessage)
.font(.callout)
.foregroundColor(Color.white).padding()
Spacer()

}.background(Color("darkGrey"))
}
if (self.appData.fromStation.abbr != "load" || !self.locationTimeout && self.appData.locationAcess) {

TrainView()
Expand Down

0 comments on commit b105a75

Please sign in to comment.