@@ -24,14 +24,22 @@ struct LongForm: View, QuestForm {
2424
2525 @Environment ( \. presentationMode) var presentationMode
2626
27- @State private var shouldShowAlert = false
27+ @State private var showSubmitAlert = false
2828
29- @State private var alertMessage = " "
29+ @State private var showKartaviewAlert = false
30+
31+ @State private var submitAlert = " "
32+
33+ @State private var kartaViewAlert = " "
3034
3135 @State private var isCameraPresented = false
3236 @State private var capturedImage : UIImage ?
3337
3438 @State private var isLoading = false
39+
40+ @State private var showImagePath = false
41+
42+ @State private var imagePath = " "
3543
3644 var body : some View {
3745 ZStack {
@@ -44,12 +52,6 @@ struct LongForm: View, QuestForm {
4452 Text ( " ID: \( questID ?? " 0 " ) " )
4553 . font ( . custom( " Lato-Regular " , size: 13 ) )
4654 . padding ( [ . leading] , 20 )
47- Spacer ( )
48- Button ( action: {
49- isCameraPresented = true
50- } , label: {
51- Image ( systemName: " camera " )
52- } )
5355 }
5456 . padding ( EdgeInsets ( top: 20 , leading: 20 , bottom: 10 , trailing: 20 ) )
5557 LongFormDismissButtonView {
@@ -72,15 +74,29 @@ struct LongForm: View, QuestForm {
7274 . answersToBeSubmitted [ quest. questTag] )
7375 }
7476 }
77+ Button {
78+ isCameraPresented = true
79+ } label: {
80+ Text ( " Upload a picture " )
81+ }
82+
83+
84+ if showImagePath {
85+ HStack {
86+ Text ( " Image path: " )
87+ Link ( " click here " , destination: URL ( string: imagePath) !)
88+ }
89+ }
90+
7591 VStack {
7692 Button ( action: {
7793 if !viewModel. answersToBeSubmitted. isEmpty {
7894 if let action = action {
7995 action ( viewModel. answersToBeSubmitted)
8096 }
8197 } else {
82- self . shouldShowAlert = true
83- self . alertMessage = " Please answer atleast one quest to submit "
98+ self . showSubmitAlert = true
99+ self . submitAlert = " Please answer atleast one quest to submit "
84100 }
85101
86102 } ) {
@@ -109,11 +125,11 @@ struct LongForm: View, QuestForm {
109125 . sheet ( isPresented: $isCameraPresented) {
110126 CameraView ( capturedImage: $capturedImage, isPresented: $isCameraPresented)
111127 }
112- . alert ( self . alertMessage, isPresented: $shouldShowAlert) {
113- Button ( " OK " , role: . cancel) { }
114128 }
129+ . alert ( self . submitAlert, isPresented: $showSubmitAlert) {
130+ Button ( " OK " , role: . cancel) { }
115131 }
116- if shouldShowAlert {
132+ if showKartaviewAlert {
117133 VStack {
118134 Image ( systemName: " checkmark.circle.fill " )
119135 . resizable ( )
@@ -133,7 +149,7 @@ struct LongForm: View, QuestForm {
133149 . accessibilityLabel ( " Image uploaded to Kartaview " )
134150 . onAppear {
135151 DispatchQueue . main. asyncAfter ( deadline: . now( ) + 1 ) {
136- shouldShowAlert = false // Dismiss notification box after 1 second
152+ showKartaviewAlert = false // Dismiss notification box after 1 second
137153 }
138154 }
139155 }
@@ -153,10 +169,13 @@ struct LongForm: View, QuestForm {
153169 func uploadImageToKartaView( ) {
154170 isLoading = true
155171 let kvViewModel = KartaviewViewModel ( capturedImage: capturedImage!)
156- kvViewModel. createSequence ( completion: { result in
172+ kvViewModel. createSequence ( completion: { ( path , result) in
157173 isLoading = false
158- alertMessage = result ? " Upload Successful " : " Upload Failed "
159- shouldShowAlert = true
174+ kartaViewAlert = result ? " Upload Successful " : " Upload Failed "
175+ showKartaviewAlert = true
176+ showImagePath = true
177+ imagePath = path
178+ print ( " KARTAVIEW IMAGE PATH --->>> \( path) " )
160179 } )
161180 }
162181
0 commit comments