Skip to content

Commit

Permalink
Merge pull request #60 from johnchoi96/feature/intro-message
Browse files Browse the repository at this point in the history
Feature/intro message
  • Loading branch information
johnchoi96 authored Dec 29, 2023
2 parents 0485a46 + 2f1982f commit 398ef31
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 26 deletions.
4 changes: 2 additions & 2 deletions JCAlerts.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = JCAlerts/JCAlerts.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2023122901;
CURRENT_PROJECT_VERSION = 2023122902;
DEVELOPMENT_TEAM = 2JDGUK4DRH;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = JCAlerts/Info.plist;
Expand Down Expand Up @@ -689,7 +689,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = JCAlerts/JCAlerts.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2023122901;
CURRENT_PROJECT_VERSION = 2023122902;
DEVELOPMENT_TEAM = 2JDGUK4DRH;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = JCAlerts/Info.plist;
Expand Down
2 changes: 1 addition & 1 deletion JCAlerts/models/firebase/fcm/FCMTopic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

enum FCMTopic: String {
enum FCMTopic: String, CaseIterable {

case ALL = "jc-alerts-all"
case PETFINDER = "jc-alerts-petfinder"
Expand Down
6 changes: 6 additions & 0 deletions JCAlerts/services/FCMTopicService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,10 @@ class FCMTopicService {
}
UserDefaults.standard.set(topicsList, forKey: TOPIC_KEY)
}

func subscribeToAllTopic() {
FCMTopic.allCases.forEach { topic in
subscribe(toTopic: topic)
}
}
}
17 changes: 17 additions & 0 deletions JCAlerts/services/UserSettingService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class UserSettingService {

private var textViewFontSize: Int

private var firstTimeRunning: Bool

private init() {
// check if UserDefaults has username defined
if let username = userDefaults.string(forKey: "currentUsername") {
Expand All @@ -34,6 +36,21 @@ class UserSettingService {
textViewFontSize = 14
userDefaults.setValue(textViewFontSize, forKey: "textViewFontSize")
}

if let firstTime = userDefaults.string(forKey: "firstTimeRunning") {
firstTimeRunning = Bool(firstTime)!
} else {
firstTimeRunning = true
}
}

func getFirstTimeRunning() -> Bool {
return firstTimeRunning
}

func setFirstTimeRunningToFalse() {
firstTimeRunning = false
userDefaults.set("false", forKey: "firstTimeRunning")
}

func getTextViewFontSize() -> Int {
Expand Down
20 changes: 20 additions & 0 deletions JCAlerts/swiftuis/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
import SwiftUI

struct ContentView: View {
@State private var isFirstTimeRunning = UserSettingService.instance.getFirstTimeRunning()

private let WELCOME_MSG = "Welcome to JCAlerts!"
private let WELCOME_MSG_BODY = """
For the first time setup, please go to the Settings tab and configure notification subscriptions
"""

var body: some View {
TabView {
LandingPageView()
Expand All @@ -20,6 +27,19 @@ struct ContentView: View {
Label("Settings", systemImage: "gear")
}
}
.alert(WELCOME_MSG, isPresented: $isFirstTimeRunning) {
Button(role: .cancel) {
// handle action
isFirstTimeRunning = false
FCMTopicService.instance.subscribeToAllTopic()
UserSettingService.instance.setFirstTimeRunningToFalse()
} label: {
Text("OK")
}

} message: {
Text(WELCOME_MSG_BODY)
}
}
}

Expand Down
49 changes: 26 additions & 23 deletions JCAlerts/swiftuis/home/LandingPageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,38 @@ struct LandingPageView: View {

var body: some View {
NavigationView {
VStack {
ScrollView(.horizontal) {
HStack(spacing: 15) {
ForEach(cfService.trimmedNotificationPayloads) { data in
Card(payload: data)
ScrollView {
VStack {
ScrollView(.horizontal) {
HStack(spacing: 15) {
ForEach(cfService.trimmedNotificationPayloads) { data in
Card(payload: data)
}
MoreCard()
Spacer()
}
MoreCard()
Spacer()
.padding()
}
.scrollIndicators(.hidden)
.padding()
}
.scrollIndicators(.hidden)
.padding()

NavigationLink(destination: UKAlertsView()) {
Text("More...")
.foregroundStyle(Color(K.Colors.inverseTextColor, bundle: nil))
.font(.headline)
.frame(width: (UIScreen.current?.bounds.size.width)! * 0.75)
.padding()
.background(Color(K.Colors.backgroundColor, bundle: nil))
.cornerRadius(15)
}
.frame(maxWidth: .infinity, alignment: .center)
NavigationLink(destination: UKAlertsView()) {
Text("More...")
.foregroundStyle(Color(K.Colors.inverseTextColor, bundle: nil))
.font(.headline)
.frame(width: (UIScreen.current?.bounds.size.width)! * 0.75)
.padding()
.background(Color(K.Colors.backgroundColor, bundle: nil))
.cornerRadius(15)
}
.frame(maxWidth: .infinity, alignment: .center)

Spacer()
Spacer()
}
.navigationTitle("Welcome")
.navigationBarTitleDisplayMode(.large)
}
.navigationTitle("Welcome")
.navigationBarTitleDisplayMode(.large)
.scrollIndicators(.hidden)
}
}
}
Expand Down

0 comments on commit 398ef31

Please sign in to comment.