Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

last ditch attempt at modal #12

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Aros.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
929DC5AF2B81865B00C20C53 /* RequestManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 929DC5AE2B81865B00C20C53 /* RequestManager.swift */; };
92ED2B402B8189F800B85D6F /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 92ED2B3F2B8189F800B85D6F /* Preview Assets.xcassets */; };
92ED2B422B818E0400B85D6F /* RequestSerialization.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92ED2B412B818E0400B85D6F /* RequestSerialization.swift */; };
92ED2B462B82061A00B85D6F /* SplashModalView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92ED2B452B82061A00B85D6F /* SplashModalView.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -85,6 +86,7 @@
929DC5AE2B81865B00C20C53 /* RequestManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestManager.swift; sourceTree = "<group>"; };
92ED2B3F2B8189F800B85D6F /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
92ED2B412B818E0400B85D6F /* RequestSerialization.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestSerialization.swift; sourceTree = "<group>"; };
92ED2B452B82061A00B85D6F /* SplashModalView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplashModalView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -155,6 +157,7 @@
929DC5AE2B81865B00C20C53 /* RequestManager.swift */,
92ED2B3F2B8189F800B85D6F /* Preview Assets.xcassets */,
92ED2B412B818E0400B85D6F /* RequestSerialization.swift */,
92ED2B452B82061A00B85D6F /* SplashModalView.swift */,
);
path = Aros;
sourceTree = "<group>";
Expand Down Expand Up @@ -321,6 +324,7 @@
878655622B8078310077B123 /* ArosApp.swift in Sources */,
35D60E852B808D5D000E2D3D /* Camera.swift in Sources */,
35D60E892B808D80000E2D3D /* PhotoCollection.swift in Sources */,
92ED2B462B82061A00B85D6F /* SplashModalView.swift in Sources */,
35D60E8D2B808DA8000E2D3D /* PhotoAssetCollection.swift in Sources */,
35D60E812B808CF0000E2D3D /* DataModel.swift in Sources */,
);
Expand Down
46 changes: 28 additions & 18 deletions Aros/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ struct ContentView: View {
@State private var showModal = false
@State private var pubKeySuccess = false

init() {
notFirstTime = privateKeyExists()
print("not first time")
print(notFirstTime)
if (notFirstTime) {
navigateToNextPage = true
}
print("init")
print(navigateToNextPage)
}
// init() {
// notFirstTime = privateKeyExists()
// print("not first time")
// print(notFirstTime)
// if (notFirstTime) {
// navigateToNextPage = true
// }
// print("init")
// print(navigateToNextPage)
// }

func triggerHapticFeedback() {
let generator = UINotificationFeedbackGenerator()
Expand Down Expand Up @@ -75,6 +75,7 @@ struct ContentView: View {
RoundedRectangle(cornerRadius: 8).fill(Color.white)
)
.padding(.horizontal, 50)
.foregroundColor(.black)


Button(action: {
Expand Down Expand Up @@ -142,10 +143,10 @@ struct ContentView: View {

showSuccessMessage = true

// Wait for 1.5 seconds, then navigate
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
navigateToNextPage = true
}
// // Wait for 1.5 seconds, then navigate
// DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
// navigateToNextPage = true
// }

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate)

Expand Down Expand Up @@ -174,16 +175,25 @@ struct ContentView: View {
.buttonStyle(PlainButtonStyle())
.padding() // Add padding around the VStack content
.onAppear {
self.notFirstTime = privateKeyExists()
if self.notFirstTime {
self.navigateToNextPage = true
}
self.notFirstTime = privateKeyExists()
if self.notFirstTime {
self.navigateToNextPage = true
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity) // Expand to fill available space
.background(Color(red: 0.1, green: 0.1, blue: 0.1)) // Set the background color of the VStack
.fullScreenCover(isPresented: $navigateToNextPage) {
CameraView()
}
.sheet(isPresented: $showModal) {
// Content of the modal pop-up
if self.pubKeySuccess {
SplashModalView(showModal: $showModal, navigateToNextPage: $navigateToNextPage)
} else {
SplashModalViewFail(showModal: $showModal, navigateToNextPage: $navigateToNextPage)
}

}

}

Expand Down
69 changes: 69 additions & 0 deletions Aros/SplashModalView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
//
// SplashModalView.swift
// Aros
//
// Created by Anjan Bharadwaj on 2/18/24.
//


import SwiftUI

struct SplashModalView: View {
@Binding var showModal: Bool
@Binding var navigateToNextPage: Bool
// @Environment(\.presentationMode) var presentationMode

var body: some View {
VStack(spacing: 20) {
Text("Keys successfully generated.")
.font(.headline)
.padding()

Button("Continue to camera") {
// Action for continue button
print("Continue tapped")
// presentationMode.wrappedValue.dismiss()
showModal = false
navigateToNextPage = true
}
.padding()
.background(Color.blue)
.foregroundColor(.white)
.cornerRadius(10)
.buttonStyle(PlainButtonStyle())
}
.frame(width: 300, height: 200)
.cornerRadius(20)
.shadow(radius: 20)
}
}

struct SplashModalViewFail: View {
@Binding var showModal: Bool
@Binding var navigateToNextPage: Bool
@Environment(\.presentationMode) var presentationMode

var body: some View {
VStack(spacing: 20) {
Text("Keys were not created.")
.font(.headline)

.padding()

Button("Return") {
// Action for continue button
print("Continue tapped")
showModal = false
presentationMode.wrappedValue.dismiss()
}
.padding()
.background(Color.blue)
.foregroundColor(.white)
.cornerRadius(10)
.buttonStyle(PlainButtonStyle())
}
.frame(width: 300, height: 200)
.cornerRadius(20)
.shadow(radius: 20)
}
}