diff --git a/trivai/Assets.xcassets/AppIcon 1.appiconset/Contents.json b/trivai/Assets.xcassets/AppIcon 1.appiconset/Contents.json index 1ec4bdc..ab64cb8 100644 --- a/trivai/Assets.xcassets/AppIcon 1.appiconset/Contents.json +++ b/trivai/Assets.xcassets/AppIcon 1.appiconset/Contents.json @@ -1,7 +1,7 @@ { "images" : [ { - "filename" : "TrivAI_logo5.png", + "filename" : "trivai_logo_3.png", "idiom" : "universal", "platform" : "ios", "size" : "1024x1024" diff --git a/trivai/Assets.xcassets/AppIcon 1.appiconset/TrivAI_logo5.png b/trivai/Assets.xcassets/AppIcon 1.appiconset/TrivAI_logo5.png deleted file mode 100644 index a0486d4..0000000 Binary files a/trivai/Assets.xcassets/AppIcon 1.appiconset/TrivAI_logo5.png and /dev/null differ diff --git a/trivai/Assets.xcassets/AppIcon 1.appiconset/trivai_logo_3.png b/trivai/Assets.xcassets/AppIcon 1.appiconset/trivai_logo_3.png new file mode 100644 index 0000000..5b6e0d9 Binary files /dev/null and b/trivai/Assets.xcassets/AppIcon 1.appiconset/trivai_logo_3.png differ diff --git a/trivai/Assets.xcassets/AppIcon.appiconset/Contents.json b/trivai/Assets.xcassets/AppIcon.appiconset/Contents.json index 1ec4bdc..ab64cb8 100644 --- a/trivai/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/trivai/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -1,7 +1,7 @@ { "images" : [ { - "filename" : "TrivAI_logo5.png", + "filename" : "trivai_logo_3.png", "idiom" : "universal", "platform" : "ios", "size" : "1024x1024" diff --git a/trivai/Assets.xcassets/AppIcon.appiconset/TrivAI_logo5.png b/trivai/Assets.xcassets/AppIcon.appiconset/TrivAI_logo5.png deleted file mode 100644 index a0486d4..0000000 Binary files a/trivai/Assets.xcassets/AppIcon.appiconset/TrivAI_logo5.png and /dev/null differ diff --git a/trivai/Assets.xcassets/AppIcon.appiconset/trivai_logo_3.png b/trivai/Assets.xcassets/AppIcon.appiconset/trivai_logo_3.png new file mode 100644 index 0000000..5b6e0d9 Binary files /dev/null and b/trivai/Assets.xcassets/AppIcon.appiconset/trivai_logo_3.png differ diff --git a/trivai/Networking/NetworkManager.swift b/trivai/Networking/NetworkManager.swift index 33d4cd8..63d0312 100644 --- a/trivai/Networking/NetworkManager.swift +++ b/trivai/Networking/NetworkManager.swift @@ -11,8 +11,7 @@ import SwiftUI class NetworkManager { - static let host = "http://100.26.175.163:5000" - static let local_host = "http://192.168.4.43:3000" + static let host = "http://127.0.0.1:5000" // Testing static func testQuestions(completion: @escaping ([Question]?, Bool, _ errorMsg: String?) -> Void) { @@ -61,7 +60,7 @@ class NetworkManager { // Create multiple choice questions based on topic static func createTopicQuestion(topic: String, num_questions: Int, completion: @escaping ([Question]?, Bool, _ errorMsg: String?) -> Void) { - let endpoint = "\(local_host)/mcq/topic/" + let endpoint = "\(host)/beta_topics_mc" let params : Parameters = [ "topic": topic, @@ -110,7 +109,7 @@ class NetworkManager { // Get topics static func getTopics(completion: @escaping ([Question]?, Bool, _ errorMsg: String?) -> Void) { - let endpoint = "\(host)/topics/" + let endpoint = "\(host)/beta_get_topics/" AF.request(endpoint, method: .post, encoding: JSONEncoding.default).validate().responseData { diff --git a/trivai/Networking/NetworkTesting.swift b/trivai/Networking/NetworkTesting.swift index 531d299..6342d79 100644 --- a/trivai/Networking/NetworkTesting.swift +++ b/trivai/Networking/NetworkTesting.swift @@ -21,10 +21,10 @@ struct NetworkTesting: View { @State var apiCall = false func call_api() { + self.quizInfo.title = user_input self.apiCall = true NetworkManager.createTopicQuestion(topic: user_input, num_questions: Int(numQuestions+0.49)) { questions, success, error in if (success) { - self.quizInfo.title = user_input self.apiCall = false DispatchQueue.main.async { self.questionListWrapper = QuestionListWrapper(questions: questions ?? []) @@ -38,12 +38,38 @@ struct NetworkTesting: View { var body: some View { VStack() { - if(self.apiCall == false){ + VStack { Text("Choose Topic") .font(.system(size:40)) - .foregroundColor(Color.black) + .foregroundColor(Color.white) .bold() - TextField("Enter Any Topic", text:$user_input) + .padding() + .padding(.bottom, 20) + .padding(.top, 10) + .background(Color("background3")) + .frame(maxWidth: .infinity) + } + .background(Color("background3")) + .frame(maxWidth: .infinity) + + + + Spacer() + VStack { + Text("\(numQuestions, specifier: "%.0f") QUESTIONS") + .font(.caption) + .fontWeight(.bold) + .foregroundColor(.gray) + Slider(value: $numQuestions, in: 1...10) + + } + .padding(.leading, 50) + .padding(.trailing, 50) + + TextField("ENTER TOPIC", text:$user_input) + .font(.system(size:25)) + .fontWeight(.bold) + .foregroundColor(.gray) .textInputAutocapitalization(.never) .disableAutocorrection(true) .frame(width: 320.0, height: 40.0) @@ -52,12 +78,13 @@ struct NetworkTesting: View { .overlay( RoundedRectangle(cornerRadius: 5) .stroke(lineWidth: 1.0) + .border(Color("background3")) ).padding() - VStack { - Text("\(numQuestions, specifier: "%.0f") questions") - Slider(value: $numQuestions, in: 1...10) - - }.padding() + + + Spacer() + + VStack { Button (action: { self.call_api() }) { @@ -69,17 +96,30 @@ struct NetworkTesting: View { .background(Color("background4")) .cornerRadius(10) .shadow(radius: 20) + .background(Color("background3")).padding(EdgeInsets(top: 30, leading: 10, bottom: 0, trailing: 10)) .padding() }.sheet(item: $questionListWrapper) { wrapper in - QuestionsView(info: quizInfo, questions: wrapper.questions) { + QuestionsView(info: Info(title: self.user_input, peopleAttended: 100, rules: ["Answer the questions carefully"]), questions: wrapper.questions) { // some action } } - } else { - Text("Loading...") + .sheet(isPresented: $apiCall) { + LoadingView() + } } + .background(Color("background3")).padding(EdgeInsets(top: 0, leading: 10, bottom: 0, trailing: 10)) + + + } } } +#if DEBUG +struct NetworkTesting_Previews: PreviewProvider { + static var previews: some View { + NetworkTesting() + } +} +#endif diff --git a/trivai/main/CertificateRow.swift b/trivai/main/CertificateRow.swift index b792ea1..346586b 100644 --- a/trivai/main/CertificateRow.swift +++ b/trivai/main/CertificateRow.swift @@ -16,7 +16,7 @@ struct CertificateRow: View { @State private var loading = false func getTopics() { - AF.request("http://192.168.4.43:3000/topics").responseJSON { response in + AF.request("http://127.0.0.1:5000/topics").responseJSON { response in print(response.result) switch response.result { case .success(let value): @@ -36,11 +36,11 @@ struct CertificateRow: View { } func makeQuestions(topic: String, num_questions: Int) { + self.quizInfo.title = topic self.loading = true NetworkManager.createTopicQuestion(topic: topic, num_questions: 3) { questions, success, error in if (success) { self.loading = false - self.quizInfo.title = topic DispatchQueue.main.async { self.questionListWrapper = QuestionListWrapper(questions: questions ?? []) } @@ -80,7 +80,7 @@ struct CertificateRow: View { .padding(.leading, 10) } } - .sheet(isPresented: $loading) { Text("Loading...") } + .sheet(isPresented: $loading) { LoadingView() } .onAppear { self.getTopics() } diff --git a/trivai/main/ContentView.swift b/trivai/main/ContentView.swift index af83d1a..d7f3596 100644 --- a/trivai/main/ContentView.swift +++ b/trivai/main/ContentView.swift @@ -101,6 +101,7 @@ struct CertificateView: View { Text(item) .font(.system(size: 25)) .fontWeight(.bold) + .textCase(.uppercase) .foregroundColor(Color.white) .padding() .offset(y: -5)//, alignment: .topLeading) diff --git a/trivai/main/LoadingView.swift b/trivai/main/LoadingView.swift new file mode 100644 index 0000000..25de05e --- /dev/null +++ b/trivai/main/LoadingView.swift @@ -0,0 +1,42 @@ +// +// LoadingView.swift +// trivai +// +// Created by Mason Bulling on 4/2/23. +// Copyright © 2023 Mithun. All rights reserved. +// + +import Foundation +import SwiftUI + +struct LoadingView: View { + @State private var isAnimating = false + + var body: some View { + ZStack { + Circle() + .stroke(Color.gray, lineWidth: 8) + .frame(width: 100, height: 100) + + Circle() + .trim(from: 0, to: 0.8) + .stroke(Color("background3"), lineWidth: 8) + .frame(width: 100, height: 100) + .rotationEffect(.degrees(isAnimating ? 360 : 0)) + .animation(Animation.linear(duration: 1).repeatForever(autoreverses: false)) + } + .onAppear { + self.isAnimating = true + } + } +} + + +struct LoadingView_Preview: View { + var body: some View { + VStack { + LoadingView() + } + } +} + diff --git a/trivai/main/TopicList.swift b/trivai/main/TopicList.swift index 98d8871..7ee5a35 100644 --- a/trivai/main/TopicList.swift +++ b/trivai/main/TopicList.swift @@ -17,7 +17,7 @@ struct TopicList: View { @State private var questionListWrapper: QuestionListWrapper? = nil func getTopics() { - AF.request("http://192.168.4.43:3000/topics").responseJSON { response in + AF.request("http://127.0.0.1:5000/topics").responseJSON { response in print(response.result) switch response.result { case .success(let value): diff --git a/trivai/quiz/CustomButton.swift b/trivai/quiz/CustomButton.swift index 60d284f..f9c1565 100644 --- a/trivai/quiz/CustomButton.swift +++ b/trivai/quiz/CustomButton.swift @@ -2,12 +2,11 @@ // CustomButton.swift // TrivAI // -// Created by Ryan Ho on 02/24/2023. +// Created by Mason Bulling on 04/02/2023. // import SwiftUI -// MARK: Reusable Custom Button (Ignores Safe Area) struct CustomButton: View{ var title: String var onClick: ()->() diff --git a/trivai/quiz/Load.swift b/trivai/quiz/Load.swift index 84e9a80..83a3b9a 100644 --- a/trivai/quiz/Load.swift +++ b/trivai/quiz/Load.swift @@ -23,6 +23,7 @@ struct Load: View { VStack { Text(info.title) //.font(.title) + .textCase(.uppercase) .fontWeight(.semibold) .scaledToFill() .font(.system(size: 42)) diff --git a/trivai/quiz/QuestionsView.swift b/trivai/quiz/QuestionsView.swift index bc2ec58..9a98673 100644 --- a/trivai/quiz/QuestionsView.swift +++ b/trivai/quiz/QuestionsView.swift @@ -32,6 +32,7 @@ struct QuestionsView: View { Text(info.title) .font(.title) + .textCase(.uppercase) .fontWeight(.semibold) .hAlign(.leading) .foregroundColor(Color.white)