@@ -180,7 +180,7 @@ struct UploadAssetsView: View {
180
180
}
181
181
182
182
private func setFileNameMaskForPreview( fileName: String ? ) -> String {
183
-
183
+ let utilityFileSystem = NCUtilityFileSystem ( )
184
184
guard let asset = uploadAssets. assets. first? . phAsset else { return " " }
185
185
var preview : String = " "
186
186
let creationDate = asset. creationDate ?? Date ( )
@@ -200,8 +200,30 @@ struct UploadAssetsView: View {
200
200
)
201
201
202
202
let trimmedPreview = preview. trimmingCharacters ( in: . whitespacesAndNewlines)
203
+
204
+ if !( fileName? . isEmpty ?? false ) {
205
+
206
+ NCKeychain ( ) . setFileNameMask ( key: fileName ?? " " , mask: NCGlobal . shared. keyFileNameMask)
207
+ preview = CCUtility . createFileName ( asset. value ( forKey: " filename " ) as? String ,
208
+ fileDate: creationDate, fileType: asset. mediaType,
209
+ keyFileName: NCGlobal . shared. keyFileNameMask,
210
+ keyFileNameType: NCGlobal . shared. keyFileNameType,
211
+ keyFileNameOriginal: NCGlobal . shared. keyFileNameOriginal,
212
+ forcedNewFileName: false )
213
+
214
+ } else {
215
+
216
+ NCKeychain ( ) . setFileNameMask ( key: " " , mask: NCGlobal . shared. keyFileNameMask)
217
+ preview = CCUtility . createFileName ( asset. value ( forKey: " filename " ) as? String ,
218
+ fileDate: creationDate,
219
+ fileType: asset. mediaType,
220
+ keyFileName: nil ,
221
+ keyFileNameType: NCGlobal . shared. keyFileNameType,
222
+ keyFileNameOriginal: NCGlobal . shared. keyFileNameOriginal,
223
+ forcedNewFileName: false )
224
+ }
203
225
204
- return String ( format: NSLocalizedString ( " _preview_filename_ " , comment: " " ) , " MM, MMM, DD, YY, YYYY, HH, hh, mm, ss, ampm " ) + " : " + " \n \n " + ( trimmedPreview as NSString ) . deletingPathExtension
226
+ return ( !isMaintainOriginalFilename ? ( String ( format: NSLocalizedString ( " _preview_filename_ " , comment: " " ) , " MM, MMM, DD, YY, YYYY, HH, hh, mm, ss, ampm " ) + " : " + " \n \n " ) : #" \#( NSLocalizedString ( " _filename_ " , comment : " " ) ) : "# ) + preview
205
227
}
206
228
207
229
private func save( completion: @escaping ( _ metadatasNOConflict: [ tableMetadata ] , _ metadatasUploadInConflict: [ tableMetadata ] ) -> Void ) {
@@ -343,74 +365,48 @@ struct UploadAssetsView: View {
343
365
NavigationView {
344
366
ZStack ( alignment: . top) {
345
367
List {
346
- Section ( footer: Text ( NSLocalizedString ( " _modify_image_desc_ " , comment: " " ) ) ) {
347
- ScrollView ( . horizontal) {
348
- LazyHGrid ( rows: gridItems, alignment: . center, spacing: 10 ) {
349
- ForEach ( 0 ..< uploadAssets. previewStore. count, id: \. self) { index in
350
- let item = uploadAssets. previewStore [ index]
351
- Menu {
352
- Button ( action: {
353
- renameFileName = uploadAssets. previewStore [ index] . fileName
354
- renameIndex = index
355
- isPresentedAlert = true
356
- } ) {
357
- Label ( NSLocalizedString ( " _rename_ " , comment: " " ) , systemImage: " pencil " )
358
- }
359
- if item. asset. type == . photo || item. asset. type == . livePhoto {
360
- Button ( action: {
361
- presentedQuickLook ( index: index)
362
- } ) {
363
- Label ( NSLocalizedString ( " _modify_ " , comment: " " ) , systemImage: " pencil.tip.crop.circle " )
364
- }
365
- }
366
- if item. data != nil {
367
- Button ( action: {
368
- if let image = uploadAssets. previewStore [ index] . asset. fullResolutionImage? . resizeImage ( size: CGSize ( width: 300 , height: 300 ) , isAspectRation: true ) {
369
- uploadAssets. previewStore [ index] . image = image
370
- uploadAssets. previewStore [ index] . data = nil
371
- uploadAssets. previewStore [ index] . assetType = uploadAssets. previewStore [ index] . asset. type
372
- }
373
- } ) {
374
- Label ( NSLocalizedString ( " _undo_modify_ " , comment: " " ) , systemImage: " arrow.uturn.backward.circle " )
375
- }
376
- }
377
- if item. data == nil && item. asset. type == . livePhoto && item. assetType == . livePhoto {
378
- Button ( action: {
379
- uploadAssets. previewStore [ index] . assetType = . photo
380
- } ) {
381
- Label ( NSLocalizedString ( " _disable_livephoto_ " , comment: " " ) , systemImage: " livephoto.slash " )
382
- }
383
- } else if item. data == nil && item. asset. type == . livePhoto && item. assetType == . photo {
384
- Button ( action: {
385
- uploadAssets. previewStore [ index] . assetType = . livePhoto
386
- } ) {
387
- Label ( NSLocalizedString ( " _enable_livephoto_ " , comment: " " ) , systemImage: " livephoto " )
388
- }
389
- }
390
- Button ( role: . destructive, action: {
391
- deleteAsset ( index: index)
392
- } ) {
393
- Label ( NSLocalizedString ( " _remove_ " , comment: " " ) , systemImage: " trash " )
394
- }
395
- } label: {
396
- ImageAsset ( uploadAssets: uploadAssets, index: index)
397
- . alert ( NSLocalizedString ( " _rename_file_ " , comment: " " ) , isPresented: $isPresentedAlert) {
398
- TextField ( NSLocalizedString ( " _enter_filename_ " , comment: " " ) , text: $renameFileName)
399
- . autocapitalization ( . none)
400
- . autocorrectionDisabled ( )
401
- Button ( NSLocalizedString ( " _rename_ " , comment: " " ) , action: {
402
- uploadAssets. previewStore [ renameIndex] . fileName = renameFileName. trimmingCharacters ( in: . whitespacesAndNewlines)
403
- } )
404
- Button ( NSLocalizedString ( " _cancel_ " , comment: " " ) , role: . cancel, action: { } )
405
- }
406
- }
407
- }
368
+ //Save Path
369
+ Section ( header: Text ( NSLocalizedString ( " _save_path_ " , comment: " " ) . uppercased ( ) ) , footer: Text ( NSLocalizedString ( " _auto_upload_help_text_ " , comment: " " ) ) ) {
370
+ HStack {
371
+ if utilityFileSystem. getHomeServer ( urlBase: uploadAssets. userBaseUrl. urlBase, userId: uploadAssets. userBaseUrl. userId) == uploadAssets. serverUrl {
372
+ Text ( NSLocalizedString ( " _prefix_upload_path_ " , comment: " " ) )
373
+ . font ( . system( size: 15 ) )
374
+ . frame ( maxWidth: . infinity, alignment: . leading)
375
+ } else {
376
+ Text ( self . getTextServerUrl ( uploadAssets. serverUrl) )
377
+ . font ( . system( size: 15 ) )
378
+ . frame ( maxWidth: . infinity, alignment: . leading)
408
379
}
380
+
381
+ Image ( " folder " )
382
+ . renderingMode ( . template)
383
+ . resizable ( )
384
+ . scaledToFit ( )
385
+ . foregroundColor ( Color ( NCBrandColor . shared. brand) )
386
+ . frame ( width: 25 , height: 25 , alignment: . trailing)
409
387
}
388
+ . onTapGesture {
389
+ isPresentedSelect = true
390
+ }
391
+
392
+
393
+ Toggle ( isOn: $uploadAssets. isUseAutoUploadFolder, label: {
394
+ Text ( NSLocalizedString ( " _use_folder_auto_upload_ " , comment: " " ) )
395
+ . font ( . system( size: 15 ) )
396
+ } )
397
+ . toggleStyle ( SwitchToggleStyle ( tint: Color ( NCBrandColor . shared. brand) ) )
398
+
399
+ Toggle ( isOn: $uploadAssets. isUseAutoUploadSubFolder, label: {
400
+ Text ( NSLocalizedString ( " _autoupload_create_subfolder_ " , comment: " " ) )
401
+ . font ( . system( size: 15 ) )
402
+ . disabled ( !uploadAssets. isUseAutoUploadFolder)
403
+ } )
404
+ . toggleStyle ( SwitchToggleStyle ( tint: Color ( NCBrandColor . shared. brand) ) )
405
+ . disabled ( !uploadAssets. isUseAutoUploadFolder)
410
406
}
411
- . redacted ( reason : uploadAssets . previewStore . isEmpty ? . placeholder : [ ] )
412
-
413
- Section {
407
+
408
+ //File Name
409
+ Section ( header : Text ( NSLocalizedString ( " _filename_ " , comment : " " ) . uppercased ( ) ) , footer : Text ( setFileNameMaskForPreview ( fileName : fileName ) ) ) {
414
410
Toggle ( isOn: $isMaintainOriginalFilename, label: {
415
411
Text ( NSLocalizedString ( " _maintain_original_filename_ " , comment: " " ) )
416
412
. font ( . system( size: 15 ) )
@@ -423,98 +419,52 @@ struct UploadAssetsView: View {
423
419
. font ( . system( size: 15 ) )
424
420
} )
425
421
. toggleStyle ( SwitchToggleStyle ( tint: Color ( NCBrandColor . shared. brand) ) )
426
- }
427
- }
428
-
429
- Section {
430
- Toggle ( isOn: $uploadAssets. isUseAutoUploadFolder, label: {
431
- Text ( NSLocalizedString ( " _use_folder_auto_upload_ " , comment: " " ) )
432
- . font ( . system( size: 15 ) )
433
- } )
434
- . toggleStyle ( SwitchToggleStyle ( tint: Color ( NCBrandColor . shared. brand) ) )
435
-
436
- if uploadAssets. isUseAutoUploadFolder {
437
- Toggle ( isOn: $uploadAssets. isUseAutoUploadSubFolder, label: {
438
- Text ( NSLocalizedString ( " _autoupload_create_subfolder_ " , comment: " " ) )
439
- . font ( . system( size: 15 ) )
440
- } )
441
- . toggleStyle ( SwitchToggleStyle ( tint: Color ( NCBrandColor . shared. brand) ) )
442
- }
443
-
444
- if !uploadAssets. isUseAutoUploadFolder {
445
422
HStack {
446
- Label {
447
- if utilityFileSystem. getHomeServer ( urlBase: uploadAssets. userBaseUrl. urlBase, userId: uploadAssets. userBaseUrl. userId) == uploadAssets. serverUrl {
448
- Text ( " / " )
449
- . font ( . system( size: 15 ) )
450
- . frame ( maxWidth: . infinity, alignment: . trailing)
451
- } else {
452
- Text ( self . getTextServerUrl ( uploadAssets. serverUrl) )
453
- . font ( . system( size: 15 ) )
454
- . frame ( maxWidth: . infinity, alignment: . trailing)
455
- }
456
- } icon: {
457
- Image ( " folder " )
458
- . renderingMode ( . template)
459
- . resizable ( )
460
- . scaledToFit ( )
461
- . foregroundColor ( Color ( NCBrandColor . shared. brand) )
423
+ if isMaintainOriginalFilename {
424
+ Text ( getOriginalFilenameForPreview ( ) as? String ?? " " )
425
+ . font ( . system( size: 15 ) )
426
+ . frame ( maxWidth: . infinity, alignment: . leading)
427
+ . foregroundColor ( Color . gray)
428
+ } else {
429
+ TextField ( NSLocalizedString ( " _enter_filename_ " , comment: " " ) , text: $fileName)
430
+ . font ( . system( size: 15 ) )
431
+ . modifier ( TextFieldClearButton ( text: $fileName) )
432
+ . multilineTextAlignment ( . leading)
462
433
}
463
434
}
464
- . contentShape ( Rectangle ( ) )
465
- . onTapGesture {
466
- isPresentedSelect = true
467
- }
468
435
}
469
- }
470
436
471
- Section {
472
- HStack {
473
- Text ( NSLocalizedString ( " _filename_ " , comment: " " ) )
474
- if isMaintainOriginalFilename {
475
- Text ( getOriginalFilenameForPreview ( ) . deletingPathExtension)
476
- . font ( . system( size: 15 ) )
477
- . frame ( maxWidth: . infinity, alignment: . trailing)
478
- . foregroundColor ( Color . gray)
479
- } else {
480
- TextField ( NSLocalizedString ( " _enter_filename_ " , comment: " " ) , text: $fileName)
481
- . font ( . system( size: 15 ) )
482
- . modifier ( TextFieldClearButton ( text: $fileName) )
483
- . multilineTextAlignment ( . trailing)
484
- }
485
- }
486
- if !isMaintainOriginalFilename {
487
- Text ( setFileNameMaskForPreview ( fileName: fileName) )
488
- . font ( . system( size: 11 ) )
489
- . foregroundColor ( Color . gray)
490
- }
491
- }
492
- . complexModifier { view in
437
+ } . complexModifier { view in
493
438
view. listRowSeparator ( . hidden)
494
439
}
495
-
496
- Button ( NSLocalizedString ( " _save_ " , comment: " " ) ) {
497
- if uploadAssets. isUseAutoUploadFolder, uploadAssets. isUseAutoUploadSubFolder {
498
- uploadAssets. showHUD = true
499
- }
500
- uploadAssets. uploadInProgress. toggle ( )
501
- save { metadatasNOConflict, metadatasUploadInConflict in
502
- if metadatasUploadInConflict. isEmpty {
503
- uploadAssets. dismissCreateFormUploadConflict ( metadatas: metadatasNOConflict)
504
- } else {
505
- uploadAssets. metadatasNOConflict = metadatasNOConflict
506
- uploadAssets. metadatasUploadInConflict = metadatasUploadInConflict
507
- isPresentedUploadConflict = true
508
- }
509
- }
510
- }
511
- . frame ( maxWidth: . infinity)
512
- . buttonStyle ( ButtonRounded ( disabled: uploadAssets. uploadInProgress) )
513
- . listRowBackground ( Color ( UIColor . systemGroupedBackground) )
514
- . disabled ( uploadAssets. uploadInProgress)
515
440
}
441
+ . listStyle ( GroupedListStyle ( ) )
516
442
. navigationTitle ( NSLocalizedString ( " _upload_photos_videos_ " , comment: " " ) )
517
443
. navigationBarTitleDisplayMode ( . inline)
444
+ . toolbar {
445
+ ToolbarItem ( placement: . navigationBarLeading) {
446
+ Button ( NSLocalizedString ( " _cancel_ " , comment: " " ) ) {
447
+ self . uploadAssets. dismiss = true
448
+ } . foregroundColor ( Color ( NCBrandColor . shared. brand) )
449
+ }
450
+ ToolbarItem ( placement: . navigationBarTrailing) {
451
+ Button ( NSLocalizedString ( " _save_ " , comment: " " ) ) {
452
+ if uploadAssets. isUseAutoUploadFolder, uploadAssets. isUseAutoUploadSubFolder {
453
+ uploadAssets. showHUD = true
454
+ }
455
+ uploadAssets. uploadInProgress. toggle ( )
456
+ save { metadatasNOConflict, metadatasUploadInConflict in
457
+ if metadatasUploadInConflict. isEmpty {
458
+ uploadAssets. dismissCreateFormUploadConflict ( metadatas: metadatasNOConflict)
459
+ } else {
460
+ uploadAssets. metadatasNOConflict = metadatasNOConflict
461
+ uploadAssets. metadatasUploadInConflict = metadatasUploadInConflict
462
+ isPresentedUploadConflict = true
463
+ }
464
+ }
465
+ } . foregroundColor ( Color ( NCBrandColor . shared. brand) )
466
+ }
467
+ }
518
468
519
469
HUDView ( showHUD: $uploadAssets. showHUD, textLabel: NSLocalizedString ( " _wait_ " , comment: " " ) , image: " doc.badge.arrow.up " )
520
470
. offset ( y: uploadAssets. showHUD ? 5 : - 200 )
0 commit comments