@@ -19,7 +19,6 @@ struct PostCreateView: View {
19
19
@State private var tagUserYear : [ Int ] = [ 0 , 0 , 0 , 0 , 0 ]
20
20
@State private var tagUserId : [ Int ? ] = Array ( repeating: nil , count: 5 )
21
21
@State private var toast : FancyToast ? = nil
22
- @State private var boolState : Bool = false
23
22
@State private var buttonState : Bool = true
24
23
25
24
var body : some View {
@@ -346,7 +345,6 @@ struct PostCreateView: View {
346
345
buttonState: isFormValid && buttonState,
347
346
buttonOkColor: GPleAsset . Color. main. swiftUIColor
348
347
) {
349
-
350
348
print ( " ํด๋ฆญ " )
351
349
buttonState = false
352
350
toast = FancyToast ( type: . info, title: " ์
๋ก๋ ์ค... " , message: " ํด๋น ๊ฒ์๋ฌผ์ ์
๋ก๋๊ฐ ์งํ์ค์
๋๋ค. ์ ์๋ง ๊ธฐ๋ค๋ ค์ฃผ์ธ์. " )
@@ -447,15 +445,13 @@ struct PostCreateView: View {
447
445
userProfileImage: student. profileImage,
448
446
userName: student. name,
449
447
userYear: student. grade,
450
- userId: student. id,
451
- userProfileImageList: $tagUserImages [ index] ,
452
- userNameList: $tagUserName [ index] ,
453
- userYearList: $tagUserYear [ index] ,
454
- tagUserId: $tagUserId [ index]
448
+ userId: student. id
455
449
)
450
+ . padding ( . bottom, 20 )
456
451
}
457
452
}
458
453
454
+
459
455
Spacer ( )
460
456
}
461
457
. frame ( maxWidth: . infinity, maxHeight: . infinity)
@@ -470,81 +466,84 @@ struct PostCreateView: View {
470
466
. navigationBarBackButtonHidden ( true )
471
467
}
472
468
473
- private var isFormValid : Bool {
474
- return !titleTextField. isEmpty &&
475
- images [ 0 ] != nil
476
- }
477
- }
478
-
479
- @ViewBuilder
480
- func searchUserList(
481
- userProfileImage: String ,
482
- userName: String ,
483
- userYear: Int ,
484
- userId: Int ,
485
- userProfileImageList: Binding < String > ,
486
- userNameList: Binding < String > ,
487
- userYearList: Binding < Int > ,
488
- tagUserId: Binding < Int ? >
489
- ) -> some View {
490
- Button {
491
- userProfileImageList. wrappedValue = userProfileImage
492
- userNameList. wrappedValue = userName
493
- userYearList. wrappedValue = userYear
494
- tagUserId. wrappedValue = userId
495
-
496
- print ( " ์ถ๊ฐ: \( userId) " )
497
- print ( " ์ถ๊ฐ: \( userName) " )
498
- print ( " ์ถ๊ฐ: \( userYear) ํ๋
" )
499
- } label: {
500
- HStack ( spacing: 4 ) {
501
- if let url = URL ( string: userProfileImage) {
502
- AsyncImage ( url: url) { image in
503
- image
504
- . resizable ( )
505
- . scaledToFit ( )
506
- . frame ( width: 32 , height: 32 )
507
- . clipShape ( Circle ( ) )
508
- } placeholder: {
469
+ @ViewBuilder
470
+ func searchUserList(
471
+ userProfileImage: String ,
472
+ userName: String ,
473
+ userYear: Int ,
474
+ userId: Int
475
+ ) -> some View {
476
+ Button {
477
+ if let emptyIndex = tagUserName. firstIndex ( of: " " ) {
478
+ tagUserImages [ emptyIndex] = userProfileImage
479
+ tagUserName [ emptyIndex] = userName
480
+ tagUserYear [ emptyIndex] = userYear
481
+ tagUserId [ emptyIndex] = userId
482
+
483
+ print ( " ์ถ๊ฐ๋ ์ ์ ID: \( userId) " )
484
+ print ( " ์ถ๊ฐ๋ ์ ์ ์ด๋ฆ: \( userName) " )
485
+ print ( " ์ถ๊ฐ๋ ์ ์ ํ๋
: \( userYear) " )
486
+ } else {
487
+ tagUserImages [ 4 ] = userProfileImage
488
+ tagUserName [ 4 ] = userName
489
+ tagUserYear [ 4 ] = userYear
490
+ tagUserId [ 4 ] = userId
491
+ }
492
+ } label: {
493
+ HStack ( spacing: 4 ) {
494
+ if let url = URL ( string: userProfileImage) {
495
+ AsyncImage ( url: url) { image in
496
+ image
497
+ . resizable ( )
498
+ . scaledToFit ( )
499
+ . frame ( width: 32 , height: 32 )
500
+ . clipShape ( Circle ( ) )
501
+ } placeholder: {
502
+ GPleAsset . Assets. profile. swiftUIImage
503
+ . resizable ( )
504
+ . scaledToFit ( )
505
+ . frame ( width: 32 , height: 32 )
506
+ }
507
+ . padding ( . leading, 24 )
508
+ } else {
509
509
GPleAsset . Assets. profile. swiftUIImage
510
510
. resizable ( )
511
511
. scaledToFit ( )
512
512
. frame ( width: 32 , height: 32 )
513
+ . padding ( . leading, 24 )
513
514
}
514
- . padding ( . leading, 24 )
515
- } else {
516
- GPleAsset . Assets. profile. swiftUIImage
517
- . resizable ( )
518
- . scaledToFit ( )
519
- . frame ( width: 32 , height: 32 )
520
- . padding ( . leading, 24 )
521
- }
522
515
523
- Text ( userName)
524
- . font ( GPleFontFamily . Pretendard. semiBold. swiftUIFont ( size: 16 ) )
525
- . foregroundStyle ( . white)
526
- . padding ( . leading, 4 )
516
+ Text ( userName)
517
+ . font ( GPleFontFamily . Pretendard. semiBold. swiftUIFont ( size: 16 ) )
518
+ . foregroundStyle ( . white)
519
+ . padding ( . leading, 4 )
527
520
528
- Text ( " ยท \( userYear) ํ๋
" )
529
- . font ( GPleFontFamily . Pretendard. regular. swiftUIFont ( size: 14 ) )
530
- . foregroundStyle ( GPleAsset . Color. gray800. swiftUIColor)
521
+ Text ( " ยท \( userYear) ํ๋
" )
522
+ . font ( GPleFontFamily . Pretendard. regular. swiftUIFont ( size: 14 ) )
523
+ . foregroundStyle ( GPleAsset . Color. gray800. swiftUIColor)
531
524
532
- Spacer ( )
525
+ Spacer ( )
533
526
534
- HStack ( spacing: 8 ) {
535
- GPleAsset . Assets. grayUserPlus. swiftUIImage
527
+ HStack ( spacing: 8 ) {
528
+ GPleAsset . Assets. grayUserPlus. swiftUIImage
536
529
537
- Text ( " ์ถ๊ฐํ๊ธฐ " )
538
- . font ( GPleFontFamily . Pretendard. regular. swiftUIFont ( size: 14 ) )
539
- . foregroundStyle ( GPleAsset . Color. gray400. swiftUIColor)
530
+ Text ( " ์ถ๊ฐํ๊ธฐ " )
531
+ . font ( GPleFontFamily . Pretendard. regular. swiftUIFont ( size: 14 ) )
532
+ . foregroundStyle ( GPleAsset . Color. gray400. swiftUIColor)
533
+ }
534
+ . padding ( . horizontal, 12 )
535
+ . padding ( . vertical, 8 )
536
+ . background (
537
+ RoundedRectangle ( cornerRadius: 8 )
538
+ . foregroundStyle ( GPleAsset . Color. gray1000. swiftUIColor)
539
+ )
540
+ . padding ( . trailing, 20 )
540
541
}
541
- . padding ( . horizontal, 12 )
542
- . padding ( . vertical, 8 )
543
- . background (
544
- RoundedRectangle ( cornerRadius: 8 )
545
- . foregroundStyle ( GPleAsset . Color. gray1000. swiftUIColor)
546
- )
547
- . padding ( . trailing, 20 )
548
542
}
549
543
}
544
+
545
+ private var isFormValid : Bool {
546
+ return !titleTextField. isEmpty &&
547
+ images [ 0 ] != nil
548
+ }
550
549
}
0 commit comments