Skip to content

Commit

Permalink
fix error auth, ui
Browse files Browse the repository at this point in the history
  • Loading branch information
xqsadness committed Sep 18, 2023
1 parent 87475d3 commit ae735aa
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 73 deletions.
Binary file not shown.
8 changes: 4 additions & 4 deletions DefaultProject/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import SwiftUI

struct ContentView: View {
var body: some View {
// if User.shared.userUID != ""{
// HomeView()
// } else {
if User.shared.userUID != "" || User.shared.userEmail != ""{
HomeView()
} else {
LoginDefaultView()
// }
}
}
}

Expand Down
6 changes: 5 additions & 1 deletion DefaultProject/DEFAULT_SOURCE/CONTROLL_APP/Coordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation
import SwiftUI

enum Page: String, Identifiable{
case NONE, mathView, listeningView, historyView, listenAndRepeat, speechToTextView, colorView, chooseLanguageView, writingView, surroundingObjectView, createUsernameView, homeView
case NONE, mathView, listeningView, historyView, listenAndRepeat, speechToTextView, colorView, chooseLanguageView, writingView, surroundingObjectView, createUsernameView, homeView, loginDefaultView
var id: String{
return self.rawValue
}
Expand Down Expand Up @@ -102,6 +102,10 @@ class Coordinator: ObservableObject{
HomeView()
.environmentObject(Coordinator.shared)
.navigationBarBackButtonHidden(true)
case .loginDefaultView:
LoginDefaultView()
.environmentObject(Coordinator.shared)
.navigationBarBackButtonHidden(true)
default:
EmptyView()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct LoginDefaultView: View {
.padding(.top)
.hAlign(.leading)

styledText(text: "Or continue with guest", foregroundColor: .blue, font: .regular(size: 17))
styledText(text: "Or continue with guest.", foregroundColor: .blue, font: .regular(size: 19))
.onTapGesture {
withAnimation {
coordinator.push(.createUsernameView)
Expand Down
9 changes: 8 additions & 1 deletion DefaultProject/View/ChooseLanguageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ struct ChooseLanguageView: SwiftUI.View {
Image("\(ele.code)")
.resizable()
.frame(width: 32, height: 32)
.overlay {
Circle()
.stroke(style: StrokeStyle(lineWidth: 1))
.frame(width: 32, height: 32)
.foregroundColor(.text2)
}

Text(ele.name)
.foregroundColor(ele.code == language ? .text : .background)
Expand Down Expand Up @@ -76,9 +82,10 @@ struct ChooseLanguageView: SwiftUI.View {
.contentShape(Rectangle())
.animation(.easeInOut, value: language)
.onTapGesture {
User.shared.userEmail = ""
AuthManagerViewModel.shared.logoutUser()
coordinator.popToRoot()
coordinator.push(.loginDefaultView)
// coordinator.path = NavigationPath()
}
}
}
Expand Down
32 changes: 27 additions & 5 deletions DefaultProject/View/CreateUsernameView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,23 @@ struct CreateUsernameView: View {

var body: some View {
VStack{
HStack{
Button {
coordinator.pop()
} label: {
Image(systemName: "chevron.left")
.imageScale(.large)
.foregroundColor(Color.text)
Text("Back".cw_localized)
.font(.bold(size: 20))
.foregroundColor(Color.text)
}
.hAlign(.leading)

Spacer()
}
.padding(.horizontal)

VStack{
Text("Quiz kid app")
.font(.bold(size: 22))
Expand Down Expand Up @@ -59,24 +76,29 @@ struct CreateUsernameView: View {
.frame(height: 50)
.cornerRadius(6)
.background(Color.blue)
.cornerRadius(6)
.contentShape(Rectangle())
.onTapGesture {
User.shared.userEmail = name
if User.shared.userEmail != "" {
coordinator.push(.homeView)
if name.isEmpty || name.count < 2{
LocalNotification.shared.message("Name must be >= 2 characters", .warning)
}else{
User.shared.userEmail = name
if User.shared.userEmail != "" {
coordinator.push(.homeView)
}
}
}
.disabled(name.isEmpty || name.count < 2)
}
}
.padding()
.background(Color.text)
.cornerRadius(6)
.padding(.horizontal)
}
.vAlign(.center)
}
.hAlign(.center)
.vAlign(.center)
.vAlign(.top)
.background(Color.accentColor)
}
}
12 changes: 9 additions & 3 deletions DefaultProject/View/Home/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,15 @@ struct HomeView: View {

SectionHistoryView()

SectionListenAndRPView()

SectionWritingView()
LazyVGrid(columns: [
GridItem(.flexible()),
GridItem(.flexible()),
], spacing: 5) {
SectionListenAndRPView()

SectionWritingView()
}
.padding(.top,5)
}
.zIndex(1)
}
Expand Down
56 changes: 28 additions & 28 deletions DefaultProject/View/Home/SectionListenAndRPView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,45 @@ struct SectionListenAndRPView: View {
@ObservedResults(Point.self) var point

var body: some View {
HStack(spacing: 0) {
VStack(spacing: 0) {
LottieView(name: "animation_human2", loopMode: .loop)
.frame(width: 80)
.frame(width: 100, height: 60)

VStack(spacing: 5) {
Text("Listen And Repeat".cw_localized)
.font(.bold(size: 16))
.foregroundColor(Color.background)
.hAlign(.leading)
Text("\(CONSTANT.SHARED.DATA_LISTEN_AND_REPEAT.count) \("questions".cw_localized)")
.font(.bold(size: 14))
.foregroundColor(Color.text)
.hAlign(.leading)
}

Spacer()

VStack{
ZStack {
Image("Ellipse")
.resizable()
.frame(width: 52, height: 52)
.overlay {
Circle()
.trim(from: 0, to: CGFloat(point.first?.pointListenAndRepeat ?? 0) / CGFloat(CONSTANT.SHARED.DATA_LISTEN_AND_REPEAT.count))
.stroke(Color.text, style: StrokeStyle(lineWidth: 5, lineCap: .round))
.rotationEffect(.degrees(-90))
}

Text("\(String(format: "%.0f", CGFloat(point.first?.pointListenAndRepeat ?? 0) / CGFloat(CONSTANT.SHARED.DATA_LISTEN_AND_REPEAT.count) * 100 ))%")
.font(.bold(size: 12))
HStack{
Text("\(CONSTANT.SHARED.DATA_LISTEN_AND_REPEAT.count) \("\nquestions".cw_localized)")
.font(.bold(size: 14))
.foregroundColor(Color.text)
.hAlign(.center)

VStack{
ZStack {
Image("Ellipse")
.resizable()
.frame(width: 52, height: 52)
.overlay {
Circle()
.trim(from: 0, to: CGFloat(point.first?.pointListenAndRepeat ?? 0) / CGFloat(CONSTANT.SHARED.DATA_LISTEN_AND_REPEAT.count))
.stroke(Color.text, style: StrokeStyle(lineWidth: 5, lineCap: .round))
.rotationEffect(.degrees(-90))
}

Text("\(String(format: "%.0f", CGFloat(point.first?.pointListenAndRepeat ?? 0) / CGFloat(CONSTANT.SHARED.DATA_LISTEN_AND_REPEAT.count) * 100 ))%")
.font(.bold(size: 12))
.foregroundColor(Color.text)
}
.padding()
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottomTrailing)
.padding()
}

}
.frame(maxWidth: .infinity)
.frame(height: 80)
.padding()
.frame(height: 155)
.background(Color(hex: "#e9d579"))
.cornerRadius(12)
.onTapGesture {
Expand Down
60 changes: 30 additions & 30 deletions DefaultProject/View/Home/SectionWritingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,47 +14,47 @@ struct SectionWritingView: View {
@ObservedResults(Point.self) var point

var body: some View {
HStack(spacing: 0) {
VStack(spacing: 0) {
Image("pngegg")
.resizable()
.frame(width: 60, height: 60)
.padding(.leading)

VStack(spacing: 5) {
Text("Writing".cw_localized)
.font(.bold(size: 16))
.foregroundColor(Color.background)
.hAlign(.leading)
Text("\(CONSTANT.SHARED.DATA_WRITING.count) \("questions".cw_localized)")
.font(.bold(size: 14))
.foregroundColor(Color.text)
.hAlign(.leading)
}

Spacer()

VStack{
ZStack {
Image("Ellipse")
.resizable()
.frame(width: 52, height: 52)
.overlay {
Circle()
.trim(from: 0, to: CGFloat(point.first?.pointWriting ?? 0) / CGFloat(CONSTANT.SHARED.DATA_WRITING.count))
.stroke(Color.text, style: StrokeStyle(lineWidth: 5, lineCap: .round))
.rotationEffect(.degrees(-90))
}

Text("\(String(format: "%.0f", CGFloat(point.first?.pointWriting ?? 0) / CGFloat(CONSTANT.SHARED.DATA_WRITING.count) * 100 ))%")
.font(.bold(size: 12))
.hAlign(.center)

HStack{
Text("\(CONSTANT.SHARED.DATA_WRITING.count) \("\nquestions".cw_localized)")
.font(.bold(size: 14))
.foregroundColor(Color.text)
.hAlign(.center)

VStack{
ZStack {
Image("Ellipse")
.resizable()
.frame(width: 52, height: 52)
.overlay {
Circle()
.trim(from: 0, to: CGFloat(point.first?.pointWriting ?? 0) / CGFloat(CONSTANT.SHARED.DATA_WRITING.count))
.stroke(Color.text, style: StrokeStyle(lineWidth: 5, lineCap: .round))
.rotationEffect(.degrees(-90))
}

Text("\(String(format: "%.0f", CGFloat(point.first?.pointWriting ?? 0) / CGFloat(CONSTANT.SHARED.DATA_WRITING.count) * 100 ))%")
.font(.bold(size: 12))
.foregroundColor(Color.text)
}
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottomTrailing)
.padding()
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottomTrailing)
.padding()
}
}
}
.frame(maxWidth: .infinity)
.frame(height: 80)
.padding()
.frame(height: 155)
.background(Color(hex: "#e64d33").opacity(0.3))
.cornerRadius(12)
.onTapGesture {
Expand Down

0 comments on commit ae735aa

Please sign in to comment.