Skip to content

Commit

Permalink
use data json from firebse
Browse files Browse the repository at this point in the history
  • Loading branch information
xqsadness committed Sep 15, 2023
1 parent 286eb9d commit a4c6378
Show file tree
Hide file tree
Showing 39 changed files with 483 additions and 379 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,4 @@
uuid = "40680EE2-D096-4625-B9E1-B90CF7A46FFB"
type = "0"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "E096DF4D-BD4E-451A-B118-0A24CA842847"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "DefaultProject/View/Home/HomeView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "57"
endingLineNumber = "57"
landmarkName = "body"
landmarkType = "24">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
74 changes: 67 additions & 7 deletions DefaultProject/DEFAULT_SOURCE/CONTROLL_APP/CONSTANT.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class CONSTANT{
var DATA_SURROUNDING = [QUIZ]()
var DATA_LISTEN = [QUIZ]()
var DATA_HISTORY = [QUIZ]()
var DATA_LISTENANDREPEAT = [QUIZ]()
var DATA_LISTEN_AND_REPEAT = [QUIZ]()
var DATA_WRITING = [QUIZ]()
}

Expand Down Expand Up @@ -305,20 +305,80 @@ extension CONSTANT{
self.APP_NAVIGATION.COLOR_BACKGROUND = nav["COLOR_BACKGROUND"].stringValue
self.APP_NAVIGATION.COLOR_BUTTON_TEXT = nav["COLOR_BUTTON_TEXT"].stringValue
self.APP_NAVIGATION.COLOR_BUTTON_BACKGROUND = nav["COLOR_BUTTON_BACKGROUND"].stringValue

}

//data
func pareData(_ json: JSON, completion: @escaping ()->Void){
//DATA_COLOR
let dataColors = json["listQuestionsColor"]
let jsonColors = json["listQuestionsColor"]

var listColor: [QUIZ] = []
for (_, json) : (String, JSON) in jsonColors{
listColor.append(QUIZ(id: json["id"].stringValue, answer: json["answer"].stringValue, question: json["question"].stringValue, a: json["a"].stringValue, b: json["b"].stringValue, c: json["c"].stringValue, d: json["d"].stringValue, img: json["img"].stringValue))
}

self.DATA_COLOR = listColor

//DATA_history
let jsonHistory = json["listQuestionsHistory"]

var listHistory: [QUIZ] = []
for (_, json) : (String, JSON) in jsonHistory{
listHistory.append(QUIZ(id: json["id"].stringValue, answer: json["answer"].stringValue, question: json["question"].stringValue, a: json["a"].stringValue, b: json["b"].stringValue, c: json["c"].stringValue, d: json["d"].stringValue, img: json["img"].stringValue))
}

self.DATA_HISTORY = listHistory

//DATA_listen
let jsonListen = json["listQuestionsListen"]

var listListen: [QUIZ] = []
for (_, json) : (String, JSON) in jsonListen{
listListen.append(QUIZ(id: json["id"].stringValue, answer: json["answer"].stringValue, question: json["question"].stringValue, a: json["a"].stringValue, b: json["b"].stringValue, c: json["c"].stringValue, d: json["d"].stringValue, img: json["img"].stringValue))
}

self.DATA_LISTEN = listListen

//DATA_listen
let jsonMath = json["listQuestionsMath"]

var listMath: [QUIZ] = []
for (_, json) : (String, JSON) in jsonMath{
listMath.append(QUIZ(id: json["id"].stringValue, answer: json["answer"].stringValue, question: json["question"].stringValue, a: json["a"].stringValue, b: json["b"].stringValue, c: json["c"].stringValue, d: json["d"].stringValue, img: json["img"].stringValue))
}

self.DATA_MATH = listMath

//DATA_surrounding
let jsonSurrounding = json["listQuestionsSurrounding"]

var listSurrounding: [QUIZ] = []
for (_, json) : (String, JSON) in jsonSurrounding{
listSurrounding.append(QUIZ(id: json["id"].stringValue, answer: json["answer"].stringValue, question: json["question"].stringValue, a: json["a"].stringValue, b: json["b"].stringValue, c: json["c"].stringValue, d: json["d"].stringValue, img: json["img"].stringValue))
}

self.DATA_SURROUNDING = listSurrounding

//DATA_writing
let jsonWriting = json["listWriting"]

var listWriting: [QUIZ] = []
for (_, json) : (String, JSON) in jsonWriting{
listWriting.append(QUIZ(id: json["id"].stringValue, answer: json["answer"].stringValue, question: json["question"].stringValue))
}

self.DATA_WRITING = listWriting

//DATA_listenRepeat
let jsonRepeat = json["listListenAndRepeat"]

var list: [QUIZ] = []
for (_, json) : (String, JSON) in dataColors{
list.append(QUIZ(id: json["id"].stringValue, answer: json["answer"].stringValue, question: json["question"].stringValue, a: json["a"].stringValue, b: json["b"].stringValue, c: json["c"].stringValue, d: json["d"].stringValue, img: json["img"].stringValue))
var listListenRepeat: [QUIZ] = []
for (_, json) : (String, JSON) in jsonRepeat{
listListenRepeat.append(QUIZ(id: json["id"].stringValue, answer: json["answer"].stringValue, question: json["question"].stringValue, a: json["a"].stringValue, b: json["b"].stringValue, c: json["c"].stringValue, d: json["d"].stringValue, img: json["img"].stringValue))
}

self.DATA_COLOR = list
self.DATA_LISTEN_AND_REPEAT = listListenRepeat
}

//Load old
Expand Down
12 changes: 9 additions & 3 deletions DefaultProject/DefaultProjectApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import SwiftUI
import Firebase
import GoogleMobileAds
import CrowdinSDK

@main
struct DefaultProjectApp: App {
Expand All @@ -19,15 +20,16 @@ struct DefaultProjectApp: App {
}
}

struct RootView: View {
struct RootView: SwiftUI.View {
@StateObject var appController = APPCONTROLLER.shared
@StateObject var user = User.shared
@StateObject var coordinator = Coordinator.shared
@StateObject var alerter: Alerter = Alerter.shared
@AppStorage("FIRST_LOAD_APP") var FIRST_LOAD_APP = false
@AppStorage("USERNAME") var USERNAME: String = ""

var body: some View {
@AppStorage("Language") var language: String = "en"

var body: some SwiftUI.View {
NavigationStack(path: $coordinator.path) {
Group{
if appController.SHOW_OPEN_APPP{
Expand Down Expand Up @@ -64,6 +66,10 @@ struct RootView: View {
coordinator.build(fullScreenCover: fullScreencover)
}
.onAppear(perform: {
if USERNAME == ""{
language = "en"
CrowdinSDK.currentLocalization = language
}
if !FIRST_LOAD_APP{
let point = Point(pointColor: 0)
Point.savePoint(point: point)
Expand Down
Loading

0 comments on commit a4c6378

Please sign in to comment.