@@ -90,42 +90,7 @@ struct CreateClipView: View {
9090 }
9191
9292 if let clipCode {
93- GroupBox {
94- VStack ( spacing : 8 ) {
95- Label ( " Your code " , systemImage : " tag " )
96- . font ( . caption )
97- . foregroundStyle ( . secondary )
98- . frame ( maxWidth : . infinity , alignment : . leading )
99- Text ( clipCode )
100- . font ( . system ( . title , design : . monospaced , weight : . semibold ) )
101- . frame ( maxWidth : . infinity , alignment : . center )
102- . textSelection ( . enabled )
103- . contentTransition ( . numericText ( ) )
104- }
105- }
106- . contextMenu {
107- Button {
108- UIPasteboard . general . string = clipCode
109- } label : {
110- Label ( " Copy " , systemImage : " doc.on.doc " )
111- }
112- Button {
113- shouldShowQrCodeSheet = true
114- } label : {
115- Label ( " Show QR code " , systemImage : " qrcode " )
116- }
117- Button {
118- let url = URL ( string : " https://interclip.app/ \( clipCode ) " ) !
119- let activity = UIActivityViewController ( activityItems : [ url ] , applicationActivities : nil )
120- if let scene = UIApplication . shared . connectedScenes . first as? UIWindowScene ,
121- let window = scene . windows . first ( where : { $0 . isKeyWindow } ) {
122- window . rootViewController ? . present ( activity , animated : true )
123- }
124- } label : {
125- Label ( " Share " , systemImage : " square.and.arrow.up " )
126- }
127- }
128- . transition ( . move ( edge : . bottom ) . combined ( with : . opacity ) )
93+ ClipCodeBox ( code : clipCode , onShowQRCode : { shouldShowQrCodeSheet = true } )
12994 }
13095
13196 Spacer ( )
@@ -191,6 +156,52 @@ struct CreateClipView: View {
191156 }
192157}
193158
159+ // MARK: - Clip Code Box
160+
161+ private struct ClipCodeBox : View {
162+ let code : String
163+ var onShowQRCode : ( ( ) -> Void ) ? = nil
164+
165+ var body : some View {
166+ GroupBox {
167+ VStack ( spacing : 2 ) {
168+ Text ( " interclip.app/ " )
169+ . font ( . system ( . caption , design : . monospaced ) )
170+ . foregroundStyle ( . secondary )
171+ . frame ( maxWidth : . infinity , alignment : . center )
172+ Text ( code )
173+ . font ( . system ( . title , design : . monospaced , weight : . semibold ) )
174+ . frame ( maxWidth : . infinity , alignment : . center )
175+ . textSelection ( . enabled )
176+ . contentTransition ( . numericText ( ) )
177+ }
178+ }
179+ . contextMenu {
180+ Button {
181+ UIPasteboard . general . string = code
182+ } label : {
183+ Label ( " Copy " , systemImage : " doc.on.doc " )
184+ }
185+ if let onShowQRCode {
186+ Button ( action : onShowQRCode ) {
187+ Label ( " Show QR code " , systemImage : " qrcode " )
188+ }
189+ }
190+ Button {
191+ let url = URL ( string : " https://interclip.app/ \( code ) " ) !
192+ let activity = UIActivityViewController ( activityItems : [ url ] , applicationActivities : nil )
193+ if let scene = UIApplication . shared . connectedScenes . first as? UIWindowScene ,
194+ let window = scene . windows . first ( where : { $0 . isKeyWindow } ) {
195+ window . rootViewController ? . present ( activity , animated : true )
196+ }
197+ } label : {
198+ Label ( " Share " , systemImage : " square.and.arrow.up " )
199+ }
200+ }
201+ . transition ( . move ( edge : . bottom ) . combined ( with : . opacity ) )
202+ }
203+ }
204+
194205// MARK: - QR Sheet
195206
196207private struct QRCodeSheet : View {
@@ -417,7 +428,7 @@ struct UploadFileView: View {
417428 }
418429
419430 if let clipCode {
420- clipCodeBox ( code : clipCode )
431+ ClipCodeBox ( code : clipCode , onShowQRCode : { shouldShowQrCodeSheet = true } )
421432 Button {
422433 clearAll ( )
423434 } label : {
@@ -560,43 +571,6 @@ struct UploadFileView: View {
560571 . padding ( . vertical , 8 )
561572 }
562573
563- // MARK: Result
564-
565- private func clipCodeBox ( code : String ) -> some View {
566- GroupBox {
567- VStack ( spacing : 8 ) {
568- Label ( " Your code " , systemImage : " tag " )
569- . font ( . caption )
570- . foregroundStyle ( . secondary )
571- . frame ( maxWidth : . infinity , alignment : . leading )
572- Text ( code )
573- . font ( . system ( . title , design : . monospaced , weight : . semibold ) )
574- . frame ( maxWidth : . infinity , alignment : . center )
575- . textSelection ( . enabled )
576- . contentTransition ( . numericText ( ) )
577- }
578- }
579- . contextMenu {
580- Button { UIPasteboard . general . string = code } label : {
581- Label ( " Copy " , systemImage : " doc.on.doc " )
582- }
583- Button { shouldShowQrCodeSheet = true } label : {
584- Label ( " Show QR code " , systemImage : " qrcode " )
585- }
586- Button {
587- let url = URL ( string : " https://interclip.app/ \( code ) " ) !
588- let activity = UIActivityViewController ( activityItems : [ url ] , applicationActivities : nil )
589- if let scene = UIApplication . shared . connectedScenes . first as? UIWindowScene ,
590- let window = scene . windows . first ( where : { $0 . isKeyWindow } ) {
591- window . rootViewController ? . present ( activity , animated : true )
592- }
593- } label : {
594- Label ( " Share " , systemImage : " square.and.arrow.up " )
595- }
596- }
597- . transition ( . move ( edge : . bottom ) . combined ( with : . opacity ) )
598- }
599-
600574 // MARK: Computed
601575
602576 private var uploadButtonLabel : String {
0 commit comments