From 3b1fb0c624784f9e222122022764a53868a85c87 Mon Sep 17 00:00:00 2001 From: boyeon Date: Mon, 8 Jan 2024 23:44:04 +0900 Subject: [PATCH 001/101] =?UTF-8?q?[Fix/#31]=20Literals=20-=20=ED=8F=AC?= =?UTF-8?q?=EC=9D=B8=ED=8A=B8=20=EC=95=84=EC=9D=B4=EC=BD=98=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Global/Literals/Literal/Image.swift | 2 +- .../first_active.imageset/first_active.svg | 4 --- .../first_default.imageset/first_default.svg | 4 --- .../Contents.json | 2 +- .../ios_badge_ic_disabled.svg | 3 +++ .../Contents.json | 2 +- .../ios_badge_ic_normal.svg | 3 +++ .../Contents.json | 2 +- .../ios_journey_ic.svg | 10 ++++++++ .../ios_point.imageset/Contents.json | 23 ------------------ .../ios_point.imageset/ios_point.png | Bin 791 -> 0 bytes .../ios_point.imageset/ios_point@2x.png | Bin 1412 -> 0 bytes .../ios_point.imageset/ios_point@3x.png | Bin 2052 -> 0 bytes .../Contents.json | 2 +- .../ios_point_ic.imageset/ios_point_ic.svg | 10 ++++++++ .../Contents.json | 2 +- .../ios_store_ic.imageset/ios_store_ic.svg | 11 +++++++++ .../second_active.imageset/second_active.svg | 4 --- .../second_default.svg | 4 --- .../third_active.imageset/third_active.svg | 4 --- .../third_default.imageset/Contents.json | 15 ------------ .../third_default.imageset/third_default.svg | 4 --- 22 files changed, 43 insertions(+), 68 deletions(-) delete mode 100644 HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/first_active.imageset/first_active.svg delete mode 100644 HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/first_default.imageset/first_default.svg rename HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/{second_active.imageset => ios_badge_ic_disabled.imageset}/Contents.json (80%) create mode 100644 HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_badge_ic_disabled.imageset/ios_badge_ic_disabled.svg rename HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/{first_default.imageset => ios_badge_ic_normal.imageset}/Contents.json (80%) create mode 100644 HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_badge_ic_normal.imageset/ios_badge_ic_normal.svg rename HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/{second_default.imageset => ios_journey_ic.imageset}/Contents.json (82%) create mode 100644 HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_journey_ic.imageset/ios_journey_ic.svg delete mode 100644 HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_point.imageset/Contents.json delete mode 100644 HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_point.imageset/ios_point.png delete mode 100644 HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_point.imageset/ios_point@2x.png delete mode 100644 HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_point.imageset/ios_point@3x.png rename HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/{first_active.imageset => ios_point_ic.imageset}/Contents.json (83%) create mode 100644 HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_point_ic.imageset/ios_point_ic.svg rename HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/{third_active.imageset => ios_store_ic.imageset}/Contents.json (83%) create mode 100644 HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_store_ic.imageset/ios_store_ic.svg delete mode 100644 HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/second_active.imageset/second_active.svg delete mode 100644 HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/second_default.imageset/second_default.svg delete mode 100644 HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/third_active.imageset/third_active.svg delete mode 100644 HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/third_default.imageset/Contents.json delete mode 100644 HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/third_default.imageset/third_default.svg diff --git a/HMH_iOS/HMH_iOS/Global/Literals/Literal/Image.swift b/HMH_iOS/HMH_iOS/Global/Literals/Literal/Image.swift index 877d8f9..123b28e 100644 --- a/HMH_iOS/HMH_iOS/Global/Literals/Literal/Image.swift +++ b/HMH_iOS/HMH_iOS/Global/Literals/Literal/Image.swift @@ -10,7 +10,7 @@ import UIKit enum ImageLiterals { enum NavigationBar { static var icArrowLeft: UIImage { .load(named: "ic_back")} - static var icPoint: UIImage { .load(named: "ios_point")} + static var icPoint: UIImage { .load(named: "ios_point_ic")} } enum TabBar { diff --git a/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/first_active.imageset/first_active.svg b/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/first_active.imageset/first_active.svg deleted file mode 100644 index 1bbe3a8..0000000 --- a/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/first_active.imageset/first_active.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/first_default.imageset/first_default.svg b/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/first_default.imageset/first_default.svg deleted file mode 100644 index e650e73..0000000 --- a/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/first_default.imageset/first_default.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/second_active.imageset/Contents.json b/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_badge_ic_disabled.imageset/Contents.json similarity index 80% rename from HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/second_active.imageset/Contents.json rename to HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_badge_ic_disabled.imageset/Contents.json index e3937c1..e30b405 100644 --- a/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/second_active.imageset/Contents.json +++ b/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_badge_ic_disabled.imageset/Contents.json @@ -1,7 +1,7 @@ { "images" : [ { - "filename" : "second_active.svg", + "filename" : "ios_badge_ic_disabled.svg", "idiom" : "universal" } ], diff --git a/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_badge_ic_disabled.imageset/ios_badge_ic_disabled.svg b/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_badge_ic_disabled.imageset/ios_badge_ic_disabled.svg new file mode 100644 index 0000000..ec9bc05 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_badge_ic_disabled.imageset/ios_badge_ic_disabled.svg @@ -0,0 +1,3 @@ + + + diff --git a/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/first_default.imageset/Contents.json b/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_badge_ic_normal.imageset/Contents.json similarity index 80% rename from HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/first_default.imageset/Contents.json rename to HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_badge_ic_normal.imageset/Contents.json index edc1a52..395b95f 100644 --- a/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/first_default.imageset/Contents.json +++ b/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_badge_ic_normal.imageset/Contents.json @@ -1,7 +1,7 @@ { "images" : [ { - "filename" : "first_default.svg", + "filename" : "ios_badge_ic_normal.svg", "idiom" : "universal" } ], diff --git a/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_badge_ic_normal.imageset/ios_badge_ic_normal.svg b/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_badge_ic_normal.imageset/ios_badge_ic_normal.svg new file mode 100644 index 0000000..761dc52 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_badge_ic_normal.imageset/ios_badge_ic_normal.svg @@ -0,0 +1,3 @@ + + + diff --git a/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/second_default.imageset/Contents.json b/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_journey_ic.imageset/Contents.json similarity index 82% rename from HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/second_default.imageset/Contents.json rename to HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_journey_ic.imageset/Contents.json index b01ada3..8fb8563 100644 --- a/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/second_default.imageset/Contents.json +++ b/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_journey_ic.imageset/Contents.json @@ -1,7 +1,7 @@ { "images" : [ { - "filename" : "second_default.svg", + "filename" : "ios_journey_ic.svg", "idiom" : "universal" } ], diff --git a/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_journey_ic.imageset/ios_journey_ic.svg b/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_journey_ic.imageset/ios_journey_ic.svg new file mode 100644 index 0000000..6456e9c --- /dev/null +++ b/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_journey_ic.imageset/ios_journey_ic.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_point.imageset/Contents.json b/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_point.imageset/Contents.json deleted file mode 100644 index f78062d..0000000 --- a/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_point.imageset/Contents.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "images" : [ - { - "filename" : "ios_point.png", - "idiom" : "universal", - "scale" : "1x" - }, - { - "filename" : "ios_point@2x.png", - "idiom" : "universal", - "scale" : "2x" - }, - { - "filename" : "ios_point@3x.png", - "idiom" : "universal", - "scale" : "3x" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_point.imageset/ios_point.png b/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_point.imageset/ios_point.png deleted file mode 100644 index da9d0cd3014739b99ccd23c7eaedc4c00985fd95..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 791 zcmV+y1L*vTP)X1^@s6D=Y3@00009a7bBm000XU z000XU0RWnu7ytkO0drDELIAGL9O(c600d`2O+f$vv5yP7{=Cx9bUE5iC8Z>(ckx&R7I*zX)GZ&(l zK-splf+%_mU@-&tMK{{Qh`CbVzn)ZJtk&PaktLFVmzZD_I|>WrC|qFux+bf@6FYSB z5IkF%gC+39<+^pwXQM(shp@@(LP@U>41&v#B+tuOsoP1Ku3ImWWYToA#Cb9{1fPSS z;M>nqK@`0iWB9~p5X;*S4r}{CFg$Nk48R0Ro@4roI0#-oKyK@?TT>pl0Dmu>l>O!~ zI>?(5hMDUe(}Pu^F!@aiV%JgjlH`1zACZZ>oUnqBu;GCoRn{*S!bydf_4$#KM3_PZ zWziWFaMt8$XjweQg=g54FN8@+-`a*3qm=>D8w7%?T3P$|U>Gj1&O{lWY-54rTXttw zS~OEx-DC)z8B{5)DOE>g6kT#rtvkz25_H~21I4v^DX{vU>jbiC)=^2!vNn}1h7@eg zR1TY!NG05K-vCZnK96fs@W6{p2gr$rC!aYsuFRnSQko{b2)QO|q=&*u$9pD0ihkxP zDCkiL_)_$=CQR0|2h{w$Yw!SzC5!YK&{k@7g~g(We(?`Ilz&;FeyukN*9&;+U&YvTTGu~{1K^mu=<%*-Ax^`PJ1ZBK-ctv~Bx!rI9|42{ VH=ZG|k%a&N002ovPDHLkV1frCUjqOD diff --git a/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_point.imageset/ios_point@2x.png b/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_point.imageset/ios_point@2x.png deleted file mode 100644 index 4379e9647935ab76f143d2a52234f7b78659bb43..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1412 zcmV-~1$+95P)C%|U z3;-%52!H@Y?R)#*qfHaQ;17Tq3&ZbqGanLuO>+TQSdPACUO3_?p7$kYXQ;v$J#9?LPnI(_nB0)H?qN!a$v(D(w6d z8n7@@5Jsz$qo>ZW?oU`Zb;~2ePp*b$!>NEG{{q%gXGoHxAtq#qB?JIv|Xu=Z;UmoiYRX5jCLWGQhE5RTgV>z4OkUR9tUJ0 z2PGWX=Uj#xI_l^4Qc7B#VFP{Llbd8$5CI%P91Qk>W)$C-5CwJ(#{Hx|3}|ZxOru|~ zVgfDcQDENsbZ0WaA*jBe3`KX%OCmcojy^7(-yb0g6rpzHP1~au0$fT<>AE|Z%DC(> z1Ihb-Q?`N#7)HNA)GSEUhFRcZ#UxTF&$Uuocfp~p>P#Q~2GO&C-oAjIE$|ECPBUN# z(%2>@L~x9LgIHT2E}yi|;sp3kMu$3>S17B;uY#5l?*us2C*5y?SEh zj&%F`K>~r08_Ow_;P*;)5KIaTu5H;-atot@-^T9xq(G$!^D<7H>S7!v1o^_VZmNB# zNP%9o=eyY)uLLa{U-ANJ_fIAi_-v?n0sg2U8WV4iXLhgrAKC{@hlUKi@fM=&5p7L% zd6~!^P6zGIzF;XtBRLPKYlxU9WupA99_eK=@#F&*K%xh)K2*vj>wcy4O0jL+=(^vm zo`Vz1tf1LF{N>lk zFIPVn?8#-3SnlxX1aq<=xi`p6RdO|j6JsDV-pf<(RB(J=y;^`ux3ek*?5vFs(nRfb3Lc zmmk0j!pB!g?p6Cv|9)_x!iRzL24%%5u{?ZA^HP8?aECP_#BARCUSoMH&;S*gD}zg6 zR0toxlBc|YRuBoL$n5xkJBa^33DFvkgxcIPX_SXG?&`7v5ehRp$`;4oGyexo_%AHH S#&dE20000bVmP)f6yUr-@tC5k5l`XUhjv0Zf^cg(ou~i$ViQPhuaD4G{iV%+BG5w$wBixzraHY zjiAkUiTi6XW}LS5=^%Meec>k1El@9@87iD|2Te$dCg||+^^sC=3emboE6@oZOq=Qk z{9z=R=|k3W5O+1)3DG&ZxHzB0TogsnVDK8J6e+;q+anPQO>l9V+qqjI>z&=vti@(5I7xr!$EbV~6PR(UivX*4$JWj2D+xy@T_#6@8~6(pC!1VhhXPf@7;+WQJMvs$=fsET=Uj6@d50F)NqBkw_A) zD@UvU6l;T|Mwj3us3225hK%5TZ`b86GDA;EiK0TxQCTfry#R#584pwozs*6@6 z=$=-`(te$qwBraWhe25Aq{I_M1OdoeftG4g;t>6ls}F0F3C>fWfgxE2%AemQj<+R@R6buYAKbU7eK+hBDT;8-vgK6x8>9}2t5 z`cpy{Cf{U5&|1iZWp^oos7{RP2twsJM+7N{=of*D#iE5JK`Q3`uy(3)oZKTT=F$y; zbGayC=TMBp+I1@DUBDey4I;>_l8ewezX7N>5x$$Nopi*cHG-`H4(OC(MX+@cIUmQ6 z2|j|NU}8nvBq=XB1Rp`szRUJVYD|vv8Hu2(>BTl|o}?tnaXn+@k)V4C4Z$SsLxdiS z2Ng+B>^fyyed)UHU%1mDLP7#e(7iZ-R!Aap#6fys-|52W(A9>Lr3_+ zv0k*fPD{M^ecy5Nj#db4#aueV6^;!WM2iG9x3UJ#OpfM+337%W`*lhEh(To1V|nlG z&*Yd;GZWMqgA+-CFbVA;K{~yOfRg@bg8UKw$LZL}fkZrni1e4D%72##ke+2GXT_6t zW-q!;q=<9t0mN!zFz+v(Q*{OStHPG!YG%p2MHpMB$6{x6$uX>{Du+ zB$<9WQ=An{RMa%%XBgRAP@>|Yf@MiiSW;j4%JSAbbFFhqQ;RdH4Q@3cDiA*1^EivV zwpjHg^~s{WikNDYchaeu)d7^I9&i%$a>-+&#B}Xm6$B<02&VSZm9W(Jd(?+`dXv{9 z+__lh6?9lgldH!l_x3H#?bOmbPIR*Ks$X@e0v`%QOdaGhlK&b(e(t!qnQAS#EA-Rj;>4FNXXGc6?7;ueX1-sh3t_ z!EZ%UTK#8F)AuMnzt^2`L=>r(&lkrbg{LJ+!j9oVa(q=J?&>)!LF`?V*m?8}dCK#h zB56e-dwe8an0nx9;fzTe3sHm=jY}GkF{9fBTH)ismvA8D4J83Vozfe9^FSvt?JeV` z;Purx1b^uvEE5t$5D#D&PLjU$coRf5`=~*9nkbkc9?UR~B;Cch4Wjtnj+d;2BixO+ z99k4X0E-p6ew$B16!b?(CMjQR;rI1lHv5u{P7@u*dh*c(5qQ2|HjT%CDWB7|hWNmr zx$bZs9PHPne3A)i=$JNtWwa4N3k0m&b^&MT=S0V{7Dyt9kU^SSf|i=Msf*)ef);4- za(_!8T{B0c@bMHfAR9poY>%jRzV?uvpaqzyBWV8 + + + + + + + + + diff --git a/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/third_active.imageset/Contents.json b/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_store_ic.imageset/Contents.json similarity index 83% rename from HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/third_active.imageset/Contents.json rename to HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_store_ic.imageset/Contents.json index 5d038d7..de8a262 100644 --- a/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/third_active.imageset/Contents.json +++ b/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_store_ic.imageset/Contents.json @@ -1,7 +1,7 @@ { "images" : [ { - "filename" : "third_active.svg", + "filename" : "ios_store_ic.svg", "idiom" : "universal" } ], diff --git a/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_store_ic.imageset/ios_store_ic.svg b/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_store_ic.imageset/ios_store_ic.svg new file mode 100644 index 0000000..a2b510a --- /dev/null +++ b/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/ios_store_ic.imageset/ios_store_ic.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/second_active.imageset/second_active.svg b/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/second_active.imageset/second_active.svg deleted file mode 100644 index d06df25..0000000 --- a/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/second_active.imageset/second_active.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/second_default.imageset/second_default.svg b/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/second_default.imageset/second_default.svg deleted file mode 100644 index 4712d28..0000000 --- a/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/second_default.imageset/second_default.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/third_active.imageset/third_active.svg b/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/third_active.imageset/third_active.svg deleted file mode 100644 index 07e95f0..0000000 --- a/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/third_active.imageset/third_active.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/third_default.imageset/Contents.json b/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/third_default.imageset/Contents.json deleted file mode 100644 index 12fa298..0000000 --- a/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/third_default.imageset/Contents.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "images" : [ - { - "filename" : "third_default.svg", - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - }, - "properties" : { - "preserves-vector-representation" : true - } -} diff --git a/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/third_default.imageset/third_default.svg b/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/third_default.imageset/third_default.svg deleted file mode 100644 index a4f0884..0000000 --- a/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/third_default.imageset/third_default.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - From 63022f7a617dba0d414504436c98db6ada063394 Mon Sep 17 00:00:00 2001 From: boyeon Date: Tue, 9 Jan 2024 00:07:47 +0900 Subject: [PATCH 002/101] =?UTF-8?q?[Feat/#31]=20MyPage=20-=20CollectionVie?= =?UTF-8?q?w=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyPage/Views/MyPageView.swift | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 HMH_iOS/HMH_iOS/Presentation/MyPage/Views/MyPageView.swift diff --git a/HMH_iOS/HMH_iOS/Presentation/MyPage/Views/MyPageView.swift b/HMH_iOS/HMH_iOS/Presentation/MyPage/Views/MyPageView.swift new file mode 100644 index 0000000..222c0c2 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Presentation/MyPage/Views/MyPageView.swift @@ -0,0 +1,43 @@ +// +// MyPageView.swift +// HMH_iOS +// +// Created by 김보연 on 1/8/24. +// + +import UIKit + +import SnapKit +import Then + +final class MyPageView: UIView { + lazy var myPageCollectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()).then { + $0.backgroundColor = .gray8 + } + + override init(frame: CGRect) { + super.init(frame: frame) + + setUI() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + func setUI() { + setHierarchy() + setConstraints() + } + + func setHierarchy() { + self.addSubviews(myPageCollectionView) + + } + + func setConstraints() { + myPageCollectionView.snp.makeConstraints { + $0.edges.equalToSuperview() + } + } +} From 9710d4271dbdf647941f454812f16bc2ef20906c Mon Sep 17 00:00:00 2001 From: boyeon Date: Tue, 9 Jan 2024 00:08:22 +0900 Subject: [PATCH 003/101] =?UTF-8?q?[Feat/#31]=20MyPage=20-=20=EB=84=A4?= =?UTF-8?q?=EB=B9=84=EB=B0=94=20=EB=B0=8F=20myPageView=20=EC=97=B0?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyPageViewController.swift | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/MyPage/ViewControllers/MyPageViewController.swift b/HMH_iOS/HMH_iOS/Presentation/MyPage/ViewControllers/MyPageViewController.swift index 339b44f..71c80ea 100644 --- a/HMH_iOS/HMH_iOS/Presentation/MyPage/ViewControllers/MyPageViewController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/MyPage/ViewControllers/MyPageViewController.swift @@ -8,9 +8,31 @@ import UIKit final class MyPageViewController: UIViewController { + private let navigationBar = HMHNavigationBar(leftItem: .normal, isBackButton: false, isTitleLabel: true, isPointImage: false, isBackGroundGray: true, titleText: "마이페이지") + private let myPageView = MyPageView() + + override func loadView() { + self.view = myPageView + } override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = .systemYellow + setUI() + } + + private func setUI() { + setHierarchy() + setConstraints() + + } + + private func setHierarchy() { + view.addSubviews(navigationBar) + } + + private func setConstraints() { + navigationBar.snp.makeConstraints { + $0.top.leading.trailing.equalToSuperview() + } } } From 5b15c3327308bed79cbc47e69190a1b5710321b7 Mon Sep 17 00:00:00 2001 From: boyeon Date: Tue, 9 Jan 2024 00:31:34 +0900 Subject: [PATCH 004/101] =?UTF-8?q?[Fix/#31]=20Resource=20-=20Font=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS/Global/Resources/Font.swift | 81 ++++++++++--------- .../MyPage/Cells/UserPointHeaderView.swift | 12 +++ 2 files changed, 54 insertions(+), 39 deletions(-) create mode 100644 HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/UserPointHeaderView.swift diff --git a/HMH_iOS/HMH_iOS/Global/Resources/Font.swift b/HMH_iOS/HMH_iOS/Global/Resources/Font.swift index 1a6cb4d..24d2940 100644 --- a/HMH_iOS/HMH_iOS/Global/Resources/Font.swift +++ b/HMH_iOS/HMH_iOS/Global/Resources/Font.swift @@ -8,43 +8,46 @@ import UIKit extension UIFont { - class var iosTitle1Semibold32: UIFont { - return UIFont(name: "Pretendard-SemiBold", size: 32.0)! - } - class var iosTitle1Semibold22: UIFont { - return UIFont(name: "Pretendard-SemiBold", size: 22.0)! - } - class var iosText1Medium22: UIFont { - return UIFont(name: "Pretendard-Medium", size: 22.0)! - } - class var iosTitle2Semibold20: UIFont { - return UIFont(name: "Pretendard-SemiBold", size: 20.0)! - } - class var iosText2Medium20: UIFont { - return UIFont(name: "Pretendard-Medium", size: 20.0)! - } - class var iosText3Semibold18: UIFont { - return UIFont(name: "Pretendard-SemiBold", size: 18.0)! - } - class var iosText4Semibold16: UIFont { - return UIFont(name: "Pretendard-SemiBold", size: 16.0)! - } - class var iosText5Medium16: UIFont { - return UIFont(name: "Pretendard-Medium", size: 16.0)! - } - class var iosText6Medium14: UIFont { - return UIFont(name: "Pretendard-Medium", size: 14.0)! - } - class var iosDetail1Regular14: UIFont { - return UIFont(name: "Pretendard-Regular", size: 14.0)! - } - class var iosDetail2Semibold13: UIFont { - return UIFont(name: "Pretendard-SemiBold", size: 13.0)! - } - class var iosDetail3Semibold12: UIFont { - return UIFont(name: "Pretendard-SemiBold", size: 12.0)! - } - class var iosDetail4Medium12: UIFont { - return UIFont(name: "Pretendard-Medium", size: 12.0)! - } + class var iosTitle1Semibold32: UIFont { + return UIFont(name: "Pretendard-SemiBold", size: 32.0)! + } + class var iosTitle2Semibold24: UIFont { + return UIFont(name: "Pretendard-SemiBold", size: 24.0)! + } + class var iosTitle3Semibold22: UIFont { + return UIFont(name: "Pretendard-SemiBold", size: 22.0)! + } + class var iosTitle4Semibold20: UIFont { + return UIFont(name: "Pretendard-SemiBold", size: 20.0)! + } + class var iosText1Medium22: UIFont { + return UIFont(name: "Pretendard-Medium", size: 22.0)! + } + class var iosText2Medium20: UIFont { + return UIFont(name: "Pretendard-Medium", size: 20.0)! + } + class var iosText3Semibold18: UIFont { + return UIFont(name: "Pretendard-SemiBold", size: 18.0)! + } + class var iosText4Semibold16: UIFont { + return UIFont(name: "Pretendard-SemiBold", size: 16.0)! + } + class var iosText5Medium16: UIFont { + return UIFont(name: "Pretendard-Medium", size: 16.0)! + } + class var iosText6Medium14: UIFont { + return UIFont(name: "Pretendard-Medium", size: 14.0)! + } + class var iosDetail1Regular14: UIFont { + return UIFont(name: "Pretendard-Regular", size: 14.0)! + } + class var iosDetail2Semibold13: UIFont { + return UIFont(name: "Pretendard-SemiBold", size: 13.0)! + } + class var iosDetail3Semibold12: UIFont { + return UIFont(name: "Pretendard-SemiBold", size: 12.0)! + } + class var iosDetail4Medium12: UIFont { + return UIFont(name: "Pretendard-Medium", size: 12.0)! + } } diff --git a/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/UserPointHeaderView.swift b/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/UserPointHeaderView.swift new file mode 100644 index 0000000..3a13865 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/UserPointHeaderView.swift @@ -0,0 +1,12 @@ +// +// UserPointHeaderView.swift +// HMH_iOS +// +// Created by 김보연 on 1/9/24. +// + +import UIKit + +class UserPointHeaderView: UICollectionReusableView { + +} From f2de1588d7f8a487dcd3f6d3450dde5ef9092877 Mon Sep 17 00:00:00 2001 From: boyeon Date: Tue, 9 Jan 2024 02:15:10 +0900 Subject: [PATCH 005/101] =?UTF-8?q?[Add/#31]=20Literals=20-=20myPage=20str?= =?UTF-8?q?ing=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HMH_iOS/Global/Literals/String/String.swift | 12 ++++++++++++ .../chevron_right.imageset/Contents.json | 15 +++++++++++++++ .../chevron_right.imageset/chevron_right.svg | 3 +++ 3 files changed, 30 insertions(+) create mode 100644 HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/chevron_right.imageset/Contents.json create mode 100644 HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/chevron_right.imageset/chevron_right.svg diff --git a/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift b/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift index c51a281..9f07ff9 100644 --- a/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift +++ b/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift @@ -30,6 +30,18 @@ enum StringLiteral { static var backgroundViewId = "GrayBackground" } } + + enum myPage { + static var journey = "지금까지의 여정" + static var store = "상점" + + static var TOS = "이용약관" + static var privacyPolicy = "개인정보처리방침" + + static var logout = "로그아웃" + static var quit = "회원탈퇴" + } + enum AlertButton { static let confirm = "확인" static let cancel = "취소" diff --git a/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/chevron_right.imageset/Contents.json b/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/chevron_right.imageset/Contents.json new file mode 100644 index 0000000..45dd49b --- /dev/null +++ b/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/chevron_right.imageset/Contents.json @@ -0,0 +1,15 @@ +{ + "images" : [ + { + "filename" : "chevron_right.svg", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "preserves-vector-representation" : true + } +} diff --git a/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/chevron_right.imageset/chevron_right.svg b/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/chevron_right.imageset/chevron_right.svg new file mode 100644 index 0000000..f2beee8 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Global/Resources/Assets.xcassets/chevron_right.imageset/chevron_right.svg @@ -0,0 +1,3 @@ + + + From 3587c179243b9bc675004feb23416274bf18b554 Mon Sep 17 00:00:00 2001 From: boyeon Date: Tue, 9 Jan 2024 02:15:55 +0900 Subject: [PATCH 006/101] =?UTF-8?q?[Add/#31]=20Literals=20-=20myPage=20Ima?= =?UTF-8?q?ge=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS/Global/Literals/Literal/Image.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/HMH_iOS/HMH_iOS/Global/Literals/Literal/Image.swift b/HMH_iOS/HMH_iOS/Global/Literals/Literal/Image.swift index 123b28e..581aed0 100644 --- a/HMH_iOS/HMH_iOS/Global/Literals/Literal/Image.swift +++ b/HMH_iOS/HMH_iOS/Global/Literals/Literal/Image.swift @@ -21,5 +21,12 @@ enum ImageLiterals { static var icMyPage: UIImage { .load(named: "mypageDisabled") } static var icMyPageSelected: UIImage { .load(named: "mypageEnabled") } } + + enum myPage { + static var icBadge: UIImage { .load(named: "ios_badge_ic_disabled")} + static var icJourney: UIImage { .load(named: "ios_journey_ic")} + static var icStore: UIImage { .load(named: "ios_store_ic")} + static var icArrowRight: UIImage { .load(named: "chevron_right")} + } } From 386c1549fa80cac0f3fac9a72afaf9cf45b6886a Mon Sep 17 00:00:00 2001 From: boyeon Date: Tue, 9 Jan 2024 02:53:32 +0900 Subject: [PATCH 007/101] =?UTF-8?q?[Feat/#31]=20MyPageCell=20-=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=ED=95=84=20=EB=A0=88=EC=9D=B4=EC=95=84=EC=9B=83=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyPage/Cells/UserPointHeaderView.swift | 59 ++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/UserPointHeaderView.swift b/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/UserPointHeaderView.swift index 3a13865..58099b6 100644 --- a/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/UserPointHeaderView.swift +++ b/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/UserPointHeaderView.swift @@ -7,6 +7,63 @@ import UIKit -class UserPointHeaderView: UICollectionReusableView { +import SnapKit +import Then + +final class UserPointHeaderView: UICollectionReusableView { + + static let identifier = "UserPointHeaderView" + + private let userStackView = UIStackView().then { + $0.axis = .horizontal + $0.spacing = 15 + $0.alignment = .center + } + + private let userprofilView = UIView().then { + $0.backgroundColor = .gray6 + $0.makeCornerRound(radius: 27) + } + + private let userLabel = UILabel().then { + $0.font = .iosTitle4Semibold20 + $0.text = "여민서" + $0.textColor = .whiteText + } + + override init(frame: CGRect) { + super.init(frame: frame) + setUI() + configureView() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + private func setUI() { + setHierarchy() + setConstraints() + } + + func setHierarchy() { + self.addSubviews(userStackView) + userStackView.addArrangeSubViews([userprofilView, userLabel]) + + } + + func setConstraints() { + userStackView.snp.makeConstraints { + $0.top.equalToSuperview().inset(11.adjustedHeight) + $0.leading.equalToSuperview().inset(20.adjustedHeight) + } + userprofilView.snp.makeConstraints { + $0.size.equalTo(54) + } + } + + private func configureView() { + self.backgroundColor = .background + } } From c05d044a67dfbaf46697a82d26dcd3b5539ea729 Mon Sep 17 00:00:00 2001 From: boyeon Date: Tue, 9 Jan 2024 03:03:33 +0900 Subject: [PATCH 008/101] =?UTF-8?q?[Feat/#31]=20MyPageCell=20-=20cell=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Cells/MypageCollectionViewCell.swift | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/MypageCollectionViewCell.swift diff --git a/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/MypageCollectionViewCell.swift b/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/MypageCollectionViewCell.swift new file mode 100644 index 0000000..1192d6b --- /dev/null +++ b/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/MypageCollectionViewCell.swift @@ -0,0 +1,80 @@ +// +// MypageCollectionViewCell.swift +// HMH_iOS +// +// Created by 김보연 on 1/9/24. +// + +import UIKit + +import SnapKit +import Then + +final class MypageCollectionViewCell: UICollectionViewCell { + + static let identifier = "MypageCollectionViewCell" + + private let imageAndLabelStackView = UIStackView().then { + $0.axis = .horizontal + $0.spacing = 15 + $0.alignment = .center + } + + private let myPageCellIconImageView = UIImageView() + private let myPageCellTitleLabel = UILabel().then { + $0.font = .iosText5Medium16 + $0.textAlignment = .left + } + + private let myPageCellNextPageImageView = UIImageView().then { + $0.image = ImageLiterals.myPage.icArrowRight + } + + override init(frame: CGRect) { + super.init(frame: frame) + setUI() + configureView() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + private func setUI() { + setHierarchy() + setConstraints() + } + + private func setHierarchy() { + self.addSubviews(imageAndLabelStackView, myPageCellNextPageImageView) + imageAndLabelStackView.addArrangeSubViews([myPageCellIconImageView, myPageCellTitleLabel]) + } + + private func setConstraints() { + imageAndLabelStackView.snp.makeConstraints { + $0.centerY.equalToSuperview() + $0.leading.equalToSuperview().inset(20) + } + + myPageCellNextPageImageView.snp.makeConstraints { + $0.centerY.equalToSuperview() + $0.trailing.equalToSuperview().inset(20) + } + } + + func configureCell(iconImage: UIImage?, labelText: String, labelColor: UIColor) { + if let iconImage = iconImage { + myPageCellIconImageView.image = iconImage + myPageCellIconImageView.isHidden = false + } else { + myPageCellIconImageView.isHidden = true + } + + myPageCellTitleLabel.text = labelText + myPageCellTitleLabel.textColor = labelColor + } + + private func configureView() { + self.backgroundColor = .background + } +} From 3018a0865d7d756cd29c636c700ff7a81134400e Mon Sep 17 00:00:00 2001 From: boyeon Date: Tue, 9 Jan 2024 03:37:32 +0900 Subject: [PATCH 009/101] =?UTF-8?q?[Add/#31]=20Literals=20-=20myPage=20str?= =?UTF-8?q?ing=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS/Global/Literals/String/String.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift b/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift index 9f07ff9..e6bf471 100644 --- a/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift +++ b/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift @@ -32,6 +32,9 @@ enum StringLiteral { } enum myPage { + static var point = "보유 포인트" + static var badge = "배지 컬랙션" + static var journey = "지금까지의 여정" static var store = "상점" From 7ec56261681a589e25cd7551fa20a207da3cd8bb Mon Sep 17 00:00:00 2001 From: boyeon Date: Tue, 9 Jan 2024 03:38:50 +0900 Subject: [PATCH 010/101] =?UTF-8?q?[Feat/#31]=20MyPageViewController=20-?= =?UTF-8?q?=20myPageViewController=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewControllers/MyPageViewController.swift | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/MyPage/ViewControllers/MyPageViewController.swift b/HMH_iOS/HMH_iOS/Presentation/MyPage/ViewControllers/MyPageViewController.swift index 71c80ea..5c8acfb 100644 --- a/HMH_iOS/HMH_iOS/Presentation/MyPage/ViewControllers/MyPageViewController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/MyPage/ViewControllers/MyPageViewController.swift @@ -8,16 +8,13 @@ import UIKit final class MyPageViewController: UIViewController { - private let navigationBar = HMHNavigationBar(leftItem: .normal, isBackButton: false, isTitleLabel: true, isPointImage: false, isBackGroundGray: true, titleText: "마이페이지") + private let navigationBar = HMHNavigationBar(leftItem: .normal, isBackButton: false, isTitleLabel: true, isPointImage: false, isBackGroundGray: false, titleText: "마이페이지") private let myPageView = MyPageView() - - override func loadView() { - self.view = myPageView - } override func viewDidLoad() { super.viewDidLoad() setUI() + configureView() } private func setUI() { @@ -27,12 +24,21 @@ final class MyPageViewController: UIViewController { } private func setHierarchy() { - view.addSubviews(navigationBar) + view.addSubviews(navigationBar, myPageView) } private func setConstraints() { navigationBar.snp.makeConstraints { $0.top.leading.trailing.equalToSuperview() } + + myPageView.snp.makeConstraints { + $0.top.equalTo(navigationBar.snp.bottom) + $0.bottom.horizontalEdges.equalToSuperview() + } + } + + private func configureView() { + view.backgroundColor = .gray8 } } From 66cd8ffa8ed5d375c3fffca866cc250911c78360 Mon Sep 17 00:00:00 2001 From: boyeon Date: Tue, 9 Jan 2024 17:25:00 +0900 Subject: [PATCH 011/101] =?UTF-8?q?[Feat/#31]=20MyPageCell=20-=20=EB=B0=B0?= =?UTF-8?q?=EC=A7=80=20=EC=BB=AC=EB=A0=89=EC=85=98=20=EB=A0=88=EC=9D=B4?= =?UTF-8?q?=EC=95=84=EC=9B=83=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyPage/Cells/UserPointHeaderView.swift | 59 +++++++- .../MyPage/Views/MyPointButton.swift | 136 ++++++++++++++++++ 2 files changed, 193 insertions(+), 2 deletions(-) create mode 100644 HMH_iOS/HMH_iOS/Presentation/MyPage/Views/MyPointButton.swift diff --git a/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/UserPointHeaderView.swift b/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/UserPointHeaderView.swift index 58099b6..a483db4 100644 --- a/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/UserPointHeaderView.swift +++ b/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/UserPointHeaderView.swift @@ -31,6 +31,35 @@ final class UserPointHeaderView: UICollectionReusableView { $0.textColor = .whiteText } + private let pointBadgeView = UIView().then { + $0.backgroundColor = .gray6 + $0.makeCornerRound(radius: 7.adjusted) + } + + private let lineView = UIView().then { + $0.backgroundColor = .gray4 + } + + private let myPointButton = MyPointButton() +// private let myBadgeButton = MyBadgeButton() + + private let myBadgeButtonStackView = UIStackView().then { + $0.alignment = .center + $0.axis = .vertical + $0.spacing = 8 + } + + private let badgeLabel = UILabel().then { + $0.font = .iosText6Medium14 + $0.text = StringLiteral.myPage.badge + $0.textColor = .gray2 + } + + private let badgeImageView = UIImageView().then { + $0.image = ImageLiterals.myPage.icBadge + $0.contentMode = .scaleAspectFit + } + override init(frame: CGRect) { super.init(frame: frame) setUI() @@ -47,8 +76,10 @@ final class UserPointHeaderView: UICollectionReusableView { } func setHierarchy() { - self.addSubviews(userStackView) + self.addSubviews(userStackView, pointBadgeView) userStackView.addArrangeSubViews([userprofilView, userLabel]) + pointBadgeView.addSubviews(myPointButton, lineView, myBadgeButtonStackView) + myBadgeButtonStackView.addArrangeSubViews([badgeLabel, badgeImageView]) } @@ -59,8 +90,32 @@ final class UserPointHeaderView: UICollectionReusableView { } userprofilView.snp.makeConstraints { - $0.size.equalTo(54) + $0.size.equalTo(54.adjusted) + } + + pointBadgeView.snp.makeConstraints { + $0.top.equalTo(userStackView.snp.bottom).offset(25.adjusted) + $0.bottom.equalToSuperview().inset(21.adjusted) + $0.horizontalEdges.equalToSuperview().inset(20.adjustedWidth) + } + + myPointButton.snp.makeConstraints { + $0.centerY.equalToSuperview() + $0.leading.equalToSuperview().inset(12.adjusted) } + + lineView.snp.makeConstraints { + $0.center.equalToSuperview() + $0.width.equalTo(1.adjusted) + $0.height.equalTo(57.adjusted) + } + + myBadgeButtonStackView.snp.makeConstraints { + $0.centerY.equalToSuperview() + $0.width.equalTo(145.adjusted) + $0.trailing.equalToSuperview().offset(-12.adjusted) + } + } private func configureView() { diff --git a/HMH_iOS/HMH_iOS/Presentation/MyPage/Views/MyPointButton.swift b/HMH_iOS/HMH_iOS/Presentation/MyPage/Views/MyPointButton.swift new file mode 100644 index 0000000..7a9b37b --- /dev/null +++ b/HMH_iOS/HMH_iOS/Presentation/MyPage/Views/MyPointButton.swift @@ -0,0 +1,136 @@ +// +// MyPageProfilButton.swift +// HMH_iOS +// +// Created by 김보연 on 1/9/24. +// + +import UIKit + +import SnapKit +import Then + +final class MyPageProfilButton: UIView { + private let profilButtonStackView = UIStackView().then { + $0.alignment = .center + $0.axis = .vertical + } + + private let profilLabel = UILabel().then { + $0.font = .iosText6Medium14 + } + + private let pointStackView = UIStackView().then { + $0.axis = .horizontal + $0.spacing = 15 + $0.alignment = .center + } + + private let pointLabel = UILabel().then { + $0.font = .iosTitle4Semibold20 + $0.textColor = .gray2 + $0.text = "P" + } + + private let myPointLabel = UILabel().then { + $0.font = .iosTitle4Semibold20 + $0.textColor = .whiteText + $0.text = "0" + } + + private let mybadgeImageView = UIImageView().then { + $0.image = .iosBadgeIcDisabled + } + + init(buttonType: MyPageProfilButtonType, labelText: String, labelColor: UIColor) { + super.init(frame: .zero) + self.profilButtonType = buttonType + profilLabel.text = labelText + profilLabel.textColor = labelColor + + configureButton() + addTarget() + setUI() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + private func setUI() { + setHierarchy() + setConstraints() + } + + private func setHierarchy() { + self.addSubview(profilButtonStackView) + profilButtonStackView.addArrangeSubViews([]) + } + + private func setConstraints() { + self.snp.makeConstraints { + $0.height.equalTo(62.adjusted) + } + + buttonContentLabel.snp.makeConstraints { + $0.center.equalToSuperview() + } + } + + private func addTarget() { + self.addTarget(self, action: #selector(onboardingButtonTapped), for: .touchUpInside) + } + + private func configureButton() { + self.makeCornerRound(radius: 6.adjustedHeight) + self.layer.cornerCurve = .continuous + + switch profilButtonType { + case .pointButton: + self.isEnabled = true + self.backgroundColor = .gray6 + buttonContentLabel.textColor = .whiteText + + case .badgeButton: + self.isEnabled = false + self.backgroundColor = .gray7 + buttonContentLabel.textColor = .gray4 + } + } + + private func updateStyle() { + if isChecked { + backgroundColor = .bluePurpleButton + makeBorder(width: 1.5, color: .bluePurpleLine) + } else { + backgroundColor = .gray6 + layer.borderColor = UIColor.clear.cgColor + } + } + + private func setChecked(_ checked: Bool) { + isChecked = checked + updateStyle() + } + + @objc private func onboardingButtonTapped() { + switch selectButtonType { + case .solitary: + guard !isChecked else { return } + + superview?.subviews.forEach { subview in + if let button = subview as? HMHSelectButton, button != self { + button.setChecked(false) + } + } + + setChecked(true) + + case .multiple: + setChecked(!isChecked) + + case .disabled: + return + } + } +} From 340455395a4de79e387b1a71ade590fafb31c1e4 Mon Sep 17 00:00:00 2001 From: boyeon Date: Tue, 9 Jan 2024 17:31:28 +0900 Subject: [PATCH 012/101] =?UTF-8?q?[Feat/#31]=20MyPageCell=20-=20=EB=82=B4?= =?UTF-8?q?=20=ED=8F=AC=EC=9D=B8=ED=8A=B8=20=EB=A0=88=EC=9D=B4=EC=95=84?= =?UTF-8?q?=EC=9B=83=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyPage/Cells/UserPointHeaderView.swift | 39 ++++- .../MyPage/Views/MyPointButton.swift | 136 ------------------ 2 files changed, 35 insertions(+), 140 deletions(-) delete mode 100644 HMH_iOS/HMH_iOS/Presentation/MyPage/Views/MyPointButton.swift diff --git a/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/UserPointHeaderView.swift b/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/UserPointHeaderView.swift index a483db4..39d9669 100644 --- a/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/UserPointHeaderView.swift +++ b/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/UserPointHeaderView.swift @@ -40,9 +40,37 @@ final class UserPointHeaderView: UICollectionReusableView { $0.backgroundColor = .gray4 } - private let myPointButton = MyPointButton() -// private let myBadgeButton = MyBadgeButton() + private let myPointButtonStackView = UIStackView().then { + $0.alignment = .center + $0.spacing = 9 + $0.axis = .vertical + } + + private let myPointLabel = UILabel().then { + $0.font = .iosText6Medium14 + $0.text = StringLiteral.myPage.point + $0.textColor = .whiteText + } + private let pointStackView = UIStackView().then { + $0.axis = .horizontal + $0.spacing = 15 + $0.alignment = .center + } + + private let pointLabel = UILabel().then { + $0.font = .iosTitle4Semibold20 + $0.textColor = .gray2 + $0.text = "P" + } + + private let countPointLabel = UILabel().then { + $0.font = .iosTitle4Semibold20 + $0.textColor = .whiteText + $0.textAlignment = .right + $0.text = "0" + } + private let myBadgeButtonStackView = UIStackView().then { $0.alignment = .center $0.axis = .vertical @@ -78,7 +106,9 @@ final class UserPointHeaderView: UICollectionReusableView { func setHierarchy() { self.addSubviews(userStackView, pointBadgeView) userStackView.addArrangeSubViews([userprofilView, userLabel]) - pointBadgeView.addSubviews(myPointButton, lineView, myBadgeButtonStackView) + pointBadgeView.addSubviews(myPointButtonStackView, lineView, myBadgeButtonStackView) + myPointButtonStackView.addArrangeSubViews([myPointLabel, pointStackView]) + pointStackView.addArrangeSubViews([countPointLabel, pointLabel]) myBadgeButtonStackView.addArrangeSubViews([badgeLabel, badgeImageView]) } @@ -99,8 +129,9 @@ final class UserPointHeaderView: UICollectionReusableView { $0.horizontalEdges.equalToSuperview().inset(20.adjustedWidth) } - myPointButton.snp.makeConstraints { + myPointButtonStackView.snp.makeConstraints { $0.centerY.equalToSuperview() + $0.width.equalTo(142.adjusted) $0.leading.equalToSuperview().inset(12.adjusted) } diff --git a/HMH_iOS/HMH_iOS/Presentation/MyPage/Views/MyPointButton.swift b/HMH_iOS/HMH_iOS/Presentation/MyPage/Views/MyPointButton.swift deleted file mode 100644 index 7a9b37b..0000000 --- a/HMH_iOS/HMH_iOS/Presentation/MyPage/Views/MyPointButton.swift +++ /dev/null @@ -1,136 +0,0 @@ -// -// MyPageProfilButton.swift -// HMH_iOS -// -// Created by 김보연 on 1/9/24. -// - -import UIKit - -import SnapKit -import Then - -final class MyPageProfilButton: UIView { - private let profilButtonStackView = UIStackView().then { - $0.alignment = .center - $0.axis = .vertical - } - - private let profilLabel = UILabel().then { - $0.font = .iosText6Medium14 - } - - private let pointStackView = UIStackView().then { - $0.axis = .horizontal - $0.spacing = 15 - $0.alignment = .center - } - - private let pointLabel = UILabel().then { - $0.font = .iosTitle4Semibold20 - $0.textColor = .gray2 - $0.text = "P" - } - - private let myPointLabel = UILabel().then { - $0.font = .iosTitle4Semibold20 - $0.textColor = .whiteText - $0.text = "0" - } - - private let mybadgeImageView = UIImageView().then { - $0.image = .iosBadgeIcDisabled - } - - init(buttonType: MyPageProfilButtonType, labelText: String, labelColor: UIColor) { - super.init(frame: .zero) - self.profilButtonType = buttonType - profilLabel.text = labelText - profilLabel.textColor = labelColor - - configureButton() - addTarget() - setUI() - } - - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - private func setUI() { - setHierarchy() - setConstraints() - } - - private func setHierarchy() { - self.addSubview(profilButtonStackView) - profilButtonStackView.addArrangeSubViews([]) - } - - private func setConstraints() { - self.snp.makeConstraints { - $0.height.equalTo(62.adjusted) - } - - buttonContentLabel.snp.makeConstraints { - $0.center.equalToSuperview() - } - } - - private func addTarget() { - self.addTarget(self, action: #selector(onboardingButtonTapped), for: .touchUpInside) - } - - private func configureButton() { - self.makeCornerRound(radius: 6.adjustedHeight) - self.layer.cornerCurve = .continuous - - switch profilButtonType { - case .pointButton: - self.isEnabled = true - self.backgroundColor = .gray6 - buttonContentLabel.textColor = .whiteText - - case .badgeButton: - self.isEnabled = false - self.backgroundColor = .gray7 - buttonContentLabel.textColor = .gray4 - } - } - - private func updateStyle() { - if isChecked { - backgroundColor = .bluePurpleButton - makeBorder(width: 1.5, color: .bluePurpleLine) - } else { - backgroundColor = .gray6 - layer.borderColor = UIColor.clear.cgColor - } - } - - private func setChecked(_ checked: Bool) { - isChecked = checked - updateStyle() - } - - @objc private func onboardingButtonTapped() { - switch selectButtonType { - case .solitary: - guard !isChecked else { return } - - superview?.subviews.forEach { subview in - if let button = subview as? HMHSelectButton, button != self { - button.setChecked(false) - } - } - - setChecked(true) - - case .multiple: - setChecked(!isChecked) - - case .disabled: - return - } - } -} From b128a3b90840aba82010198137fa6c53e7242629 Mon Sep 17 00:00:00 2001 From: boyeon Date: Tue, 9 Jan 2024 18:54:44 +0900 Subject: [PATCH 013/101] =?UTF-8?q?[Feat/#31]=20MyPageCell=20-=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=95=84=EC=9B=83=20=EB=B0=8F=20=ED=9A=8C=EC=9B=90?= =?UTF-8?q?=ED=83=88=ED=87=B4=20=ED=91=B8=ED=84=B0=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Cells/LogoutAndQuitFooterView.swift | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/LogoutAndQuitFooterView.swift diff --git a/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/LogoutAndQuitFooterView.swift b/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/LogoutAndQuitFooterView.swift new file mode 100644 index 0000000..7c80a68 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/LogoutAndQuitFooterView.swift @@ -0,0 +1,74 @@ +// +// LogoutAndQuitFooterView.swift +// HMH_iOS +// +// Created by 김보연 on 1/9/24. +// + +import UIKit + +import SnapKit +import Then + +final class LogoutAndQuitFooterView: UICollectionReusableView { + + static let identifier = "LogoutAndQuitFooterView" + + private let logoutQuitStackView = UIStackView().then { + $0.alignment = .center + $0.spacing = 19 + $0.axis = .horizontal + } + + private let logoutButton = UIButton().then { + $0.setTitle(StringLiteral.myPage.logout, for: .normal) + $0.setTitleColor(.gray3, for: .normal) + $0.titleLabel?.font = .iosText6Medium14 + } + + private let lineView = UIView().then { + $0.backgroundColor = .gray3 + } + + private let quitButton = UIButton().then { + $0.setTitle(StringLiteral.myPage.quit, for: .normal) + $0.titleLabel?.font = .iosText6Medium14 + $0.setTitleColor(.gray3, for: .normal) + } + + override init(frame: CGRect) { + super.init(frame: frame) + setUI() + configureView() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + private func setUI() { + setHierarchy() + setConstraints() + } + + private func setHierarchy() { + self.addSubview(logoutQuitStackView) + logoutQuitStackView.addArrangeSubViews([logoutButton, lineView, quitButton]) + } + + private func setConstraints() { + logoutQuitStackView.snp.makeConstraints { + $0.top.equalToSuperview().inset(35.adjusted) + $0.centerX.equalToSuperview() + } + + lineView.snp.makeConstraints { + $0.height.equalTo(16.adjusted) + $0.width.equalTo(1) + } + } + + private func configureView() { + self.backgroundColor = .background + } +} From f1cc5787074d33bcd8d44a58f1c2d884d170a723 Mon Sep 17 00:00:00 2001 From: boyeon Date: Tue, 9 Jan 2024 18:55:37 +0900 Subject: [PATCH 014/101] =?UTF-8?q?[Delete/#31]=20MyPage=20-=20=EB=B0=B0?= =?UTF-8?q?=EA=B2=BD=EC=83=89=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyPage/ViewControllers/MyPageViewController.swift | 5 ----- 1 file changed, 5 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/MyPage/ViewControllers/MyPageViewController.swift b/HMH_iOS/HMH_iOS/Presentation/MyPage/ViewControllers/MyPageViewController.swift index 5c8acfb..0c8656d 100644 --- a/HMH_iOS/HMH_iOS/Presentation/MyPage/ViewControllers/MyPageViewController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/MyPage/ViewControllers/MyPageViewController.swift @@ -14,7 +14,6 @@ final class MyPageViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() setUI() - configureView() } private func setUI() { @@ -37,8 +36,4 @@ final class MyPageViewController: UIViewController { $0.bottom.horizontalEdges.equalToSuperview() } } - - private func configureView() { - view.backgroundColor = .gray8 - } } From a0e9123092d318c0f5ab51e02064dc7a875a5fcb Mon Sep 17 00:00:00 2001 From: boyeon Date: Tue, 9 Jan 2024 18:56:26 +0900 Subject: [PATCH 015/101] [Add/#31] MyPage - Add footer to collectionView --- .../MyPage/Views/MyPageView.swift | 133 +++++++++++++++++- 1 file changed, 128 insertions(+), 5 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/MyPage/Views/MyPageView.swift b/HMH_iOS/HMH_iOS/Presentation/MyPage/Views/MyPageView.swift index 222c0c2..cb33901 100644 --- a/HMH_iOS/HMH_iOS/Presentation/MyPage/Views/MyPageView.swift +++ b/HMH_iOS/HMH_iOS/Presentation/MyPage/Views/MyPageView.swift @@ -17,27 +17,150 @@ final class MyPageView: UIView { override init(frame: CGRect) { super.init(frame: frame) - setUI() + setRegister() + configreCollectionView() } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } - func setUI() { + private func setUI() { setHierarchy() setConstraints() } - func setHierarchy() { + private func setHierarchy() { self.addSubviews(myPageCollectionView) - } - func setConstraints() { + private func setConstraints() { myPageCollectionView.snp.makeConstraints { $0.edges.equalToSuperview() } } + + private func setRegister() { + myPageCollectionView.register(UserPointHeaderView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: UserPointHeaderView.identifier) + myPageCollectionView.register(MypageCollectionViewCell.self, forCellWithReuseIdentifier: MypageCollectionViewCell.identifier) + myPageCollectionView.register(LogoutAndQuitFooterView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionFooter, withReuseIdentifier: LogoutAndQuitFooterView.identifier) + } + + private func configreCollectionView() { + myPageCollectionView.delegate = self + myPageCollectionView.dataSource = self + } +} + + +extension MyPageView: UICollectionViewDelegate {} + +extension MyPageView: UICollectionViewDataSource { + func numberOfSections(in collectionView: UICollectionView) -> Int { + return 2 + } + + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + switch section { + case 0: + return 2 + case 1: + return 2 + default: + return 0 + } + } + + func collectionView(_ listCollectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + guard let item = myPageCollectionView.dequeueReusableCell(withReuseIdentifier: MypageCollectionViewCell.identifier, for: indexPath) as? MypageCollectionViewCell else { + return UICollectionViewCell() + } + + switch indexPath.section { + case 0: + if indexPath.item == 0 { + item.configureCell(iconImage: ImageLiterals.myPage.icJourney, labelText: StringLiteral.myPage.journey, labelColor: .gray5) + } else if indexPath.item == 1 { + item.configureCell(iconImage: ImageLiterals.myPage.icStore, labelText: StringLiteral.myPage.store, labelColor: .gray5) + } + return item + + case 1: + if indexPath.item == 0 { + item.configureCell(iconImage: nil, labelText: StringLiteral.myPage.TOS, labelColor: .whiteText) + } else if indexPath.item == 1 { + item.configureCell(iconImage: nil, labelText: StringLiteral.myPage.privacyPolicy, labelColor: .whiteText) + } + return item + + default: + return UICollectionViewCell() + } + } +} + +extension MyPageView: UICollectionViewDelegateFlowLayout { + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + switch indexPath.section { + default: + let itemWidthOrHeight: CGFloat = 60 + return CGSize(width: collectionView.frame.width.adjustedWidth, height: itemWidthOrHeight.adjustedHeight) + } + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { + let sectionInsets = UIEdgeInsets.zero + switch section { + case 0: + return UIEdgeInsets(top: 0, left: 0, bottom: 10, right: 0) + case 1: + return UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) + default: + break + } + return sectionInsets + } + + func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { + switch indexPath.section { + case 0: + if kind == UICollectionView.elementKindSectionHeader { + guard let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: UserPointHeaderView.identifier, for: indexPath) as? UserPointHeaderView else { + return UICollectionReusableView() + } + return headerView + } + case 1: + if kind == UICollectionView.elementKindSectionFooter { + guard let footerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: LogoutAndQuitFooterView.identifier, for: indexPath) as? LogoutAndQuitFooterView else { + return UICollectionReusableView() + } + return footerView + } + default: + return UICollectionReusableView() + } + return UICollectionReusableView() + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize { + if section == 0 { + return .init(width: UIScreen.main.bounds.width, height: 205.adjusted) + } else { + return .zero + } + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize { + if section == 1 { + return .init(width: UIScreen.main.bounds.width, height: 96.adjusted) + } else { + return .zero + } + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { + return 1 + } } From 70c868c4d9afb65ea2e2dcc9ca2d06dee558b06d Mon Sep 17 00:00:00 2001 From: boyeon Date: Tue, 9 Jan 2024 19:44:53 +0900 Subject: [PATCH 016/101] =?UTF-8?q?[Add/#31]=20Literals=20-=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20literal=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS/Global/Literals/String/String.swift | 2 ++ .../Presentation/MyPage/Cells/InfoHeaderView.swift | 12 ++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/InfoHeaderView.swift diff --git a/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift b/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift index e6bf471..ce92977 100644 --- a/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift +++ b/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift @@ -41,6 +41,8 @@ enum StringLiteral { static var TOS = "이용약관" static var privacyPolicy = "개인정보처리방침" + static var info = "정보" + static var logout = "로그아웃" static var quit = "회원탈퇴" } diff --git a/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/InfoHeaderView.swift b/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/InfoHeaderView.swift new file mode 100644 index 0000000..b562fa1 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/InfoHeaderView.swift @@ -0,0 +1,12 @@ +// +// InfoHeaderView.swift +// HMH_iOS +// +// Created by 김보연 on 1/9/24. +// + +import UIKit + +class InfoHeaderView: UICollectionReusableView { + +} From 77c69afbacdc75e7f78be64763cf4dd26cab337d Mon Sep 17 00:00:00 2001 From: boyeon Date: Tue, 9 Jan 2024 19:45:19 +0900 Subject: [PATCH 017/101] =?UTF-8?q?[Feat/#31]=20MyPageCell=20-=20infoHeade?= =?UTF-8?q?rView=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyPage/Cells/InfoHeaderView.swift | 44 ++++++++++++++++++- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/InfoHeaderView.swift b/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/InfoHeaderView.swift index b562fa1..af83285 100644 --- a/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/InfoHeaderView.swift +++ b/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/InfoHeaderView.swift @@ -7,6 +7,46 @@ import UIKit -class InfoHeaderView: UICollectionReusableView { - +import SnapKit +import Then + +final class InfoHeaderView: UICollectionReusableView { + + static let identifier = "InfoHeaderView" + + private let infoLabel = UILabel().then { + $0.font = .iosText4Semibold16 + $0.textColor = .gray2 + $0.text = StringLiteral.myPage.info + } + + override init(frame: CGRect) { + super.init(frame: frame) + setUI() + configureView() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + private func setUI() { + setHierarchy() + setConstraints() + } + + private func setHierarchy() { + self.addSubview(infoLabel) + } + + private func setConstraints() { + infoLabel.snp.makeConstraints { + $0.bottom.equalToSuperview().offset(-11.adjusted) + $0.leading.equalToSuperview().inset(20) + } + } + + private func configureView() { + self.backgroundColor = .background + } } From f5961f1e845126e809b80a6897c953ec413d44e9 Mon Sep 17 00:00:00 2001 From: boyeon Date: Tue, 9 Jan 2024 19:45:48 +0900 Subject: [PATCH 018/101] =?UTF-8?q?[Chore/#31]=20MyPageCell=20-=20?= =?UTF-8?q?=ED=8F=AC=EC=9D=B8=ED=8A=B8=20=EA=B0=84=EA=B2=A9=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HMH_iOS/Presentation/MyPage/Cells/UserPointHeaderView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/UserPointHeaderView.swift b/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/UserPointHeaderView.swift index 39d9669..1938460 100644 --- a/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/UserPointHeaderView.swift +++ b/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/UserPointHeaderView.swift @@ -54,7 +54,7 @@ final class UserPointHeaderView: UICollectionReusableView { private let pointStackView = UIStackView().then { $0.axis = .horizontal - $0.spacing = 15 + $0.spacing = 7 $0.alignment = .center } From 2c078a777976d8f4a475f9fb6f53a1522608491d Mon Sep 17 00:00:00 2001 From: boyeon Date: Tue, 9 Jan 2024 19:46:24 +0900 Subject: [PATCH 019/101] [Add/#31] MyPage - Add header to collectionView --- .../Presentation/MyPage/Views/MyPageView.swift | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/MyPage/Views/MyPageView.swift b/HMH_iOS/HMH_iOS/Presentation/MyPage/Views/MyPageView.swift index cb33901..7922b16 100644 --- a/HMH_iOS/HMH_iOS/Presentation/MyPage/Views/MyPageView.swift +++ b/HMH_iOS/HMH_iOS/Presentation/MyPage/Views/MyPageView.swift @@ -44,6 +44,7 @@ final class MyPageView: UIView { private func setRegister() { myPageCollectionView.register(UserPointHeaderView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: UserPointHeaderView.identifier) myPageCollectionView.register(MypageCollectionViewCell.self, forCellWithReuseIdentifier: MypageCollectionViewCell.identifier) + myPageCollectionView.register(InfoHeaderView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: InfoHeaderView.identifier) myPageCollectionView.register(LogoutAndQuitFooterView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionFooter, withReuseIdentifier: LogoutAndQuitFooterView.identifier) } @@ -132,7 +133,14 @@ extension MyPageView: UICollectionViewDelegateFlowLayout { return headerView } case 1: - if kind == UICollectionView.elementKindSectionFooter { + if kind == UICollectionView.elementKindSectionHeader { + guard let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: InfoHeaderView.identifier, for: indexPath) as? InfoHeaderView else { + return UICollectionReusableView() + } + return headerView + } + + else if kind == UICollectionView.elementKindSectionFooter { guard let footerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: LogoutAndQuitFooterView.identifier, for: indexPath) as? LogoutAndQuitFooterView else { return UICollectionReusableView() } @@ -147,6 +155,8 @@ extension MyPageView: UICollectionViewDelegateFlowLayout { func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize { if section == 0 { return .init(width: UIScreen.main.bounds.width, height: 205.adjusted) + } else if section == 1 { + return .init(width: UIScreen.main.bounds.width, height: 66.adjusted) } else { return .zero } From 8d333072eb6a73b877dc548ae84a61411054ed59 Mon Sep 17 00:00:00 2001 From: boyeon Date: Tue, 9 Jan 2024 20:43:58 +0900 Subject: [PATCH 020/101] =?UTF-8?q?[Feat/#31]=20MyPageModel=20-=20UserMode?= =?UTF-8?q?l=20=EA=B5=AC=EC=B6=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Presentation/MyPage/Models/UserModel.swift | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 HMH_iOS/HMH_iOS/Presentation/MyPage/Models/UserModel.swift diff --git a/HMH_iOS/HMH_iOS/Presentation/MyPage/Models/UserModel.swift b/HMH_iOS/HMH_iOS/Presentation/MyPage/Models/UserModel.swift new file mode 100644 index 0000000..231fd0f --- /dev/null +++ b/HMH_iOS/HMH_iOS/Presentation/MyPage/Models/UserModel.swift @@ -0,0 +1,13 @@ +// +// UserModel.swift +// HMH_iOS +// +// Created by 김보연 on 1/9/24. +// + +import Foundation + +struct UserModel { + let userName: String + let point: Int +} From e14dab43f8964135a8b517136084b4ed715ed945 Mon Sep 17 00:00:00 2001 From: boyeon Date: Tue, 9 Jan 2024 22:06:05 +0900 Subject: [PATCH 021/101] =?UTF-8?q?[Feat/#31]=20MyPageModel=20-=20?= =?UTF-8?q?=EB=8D=94=EB=AF=B8=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EA=B5=AC?= =?UTF-8?q?=EC=B6=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS/Presentation/MyPage/Models/UserModel.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/HMH_iOS/HMH_iOS/Presentation/MyPage/Models/UserModel.swift b/HMH_iOS/HMH_iOS/Presentation/MyPage/Models/UserModel.swift index 231fd0f..f565761 100644 --- a/HMH_iOS/HMH_iOS/Presentation/MyPage/Models/UserModel.swift +++ b/HMH_iOS/HMH_iOS/Presentation/MyPage/Models/UserModel.swift @@ -11,3 +11,9 @@ struct UserModel { let userName: String let point: Int } + +extension UserModel { + static func dummy() -> UserModel { + return UserModel(userName: "여민서", point: 3000) + } +} From 976d3d6d4fc6e9910cf8c971b2b51854b5025db0 Mon Sep 17 00:00:00 2001 From: boyeon Date: Tue, 9 Jan 2024 22:18:22 +0900 Subject: [PATCH 022/101] =?UTF-8?q?[Feat/#31]=20MyPageCell=20-=20=EB=8D=94?= =?UTF-8?q?=EB=AF=B8=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyPage/Cells/UserPointHeaderView.swift | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/UserPointHeaderView.swift b/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/UserPointHeaderView.swift index 1938460..0de0e2b 100644 --- a/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/UserPointHeaderView.swift +++ b/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/UserPointHeaderView.swift @@ -27,7 +27,6 @@ final class UserPointHeaderView: UICollectionReusableView { private let userLabel = UILabel().then { $0.font = .iosTitle4Semibold20 - $0.text = "여민서" $0.textColor = .whiteText } @@ -68,9 +67,8 @@ final class UserPointHeaderView: UICollectionReusableView { $0.font = .iosTitle4Semibold20 $0.textColor = .whiteText $0.textAlignment = .right - $0.text = "0" } - + private let myBadgeButtonStackView = UIStackView().then { $0.alignment = .center $0.axis = .vertical @@ -153,3 +151,13 @@ final class UserPointHeaderView: UICollectionReusableView { self.backgroundColor = .background } } + +extension UserPointHeaderView { + func bindData(model: UserModel) { + let numberFormatter: NumberFormatter = NumberFormatter() + numberFormatter.numberStyle = .decimal + let userPoint: String = numberFormatter.string(for: model.point) ?? "0" + self.userLabel.text = model.userName + self.countPointLabel.text = "\(userPoint)" + } +} From 85f44b3b0fc187d9b237662d6b6c80b3c5fee8fb Mon Sep 17 00:00:00 2001 From: boyeon Date: Tue, 9 Jan 2024 22:19:22 +0900 Subject: [PATCH 023/101] =?UTF-8?q?[Feat/#31]=20MyPage=20-=20=ED=97=A4?= =?UTF-8?q?=EB=8D=94=20=EB=8D=94=EB=AF=B8=EB=8D=B0=EC=9D=B4=ED=84=B0=20?= =?UTF-8?q?=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS/Presentation/MyPage/Views/MyPageView.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/MyPage/Views/MyPageView.swift b/HMH_iOS/HMH_iOS/Presentation/MyPage/Views/MyPageView.swift index 7922b16..07b6cef 100644 --- a/HMH_iOS/HMH_iOS/Presentation/MyPage/Views/MyPageView.swift +++ b/HMH_iOS/HMH_iOS/Presentation/MyPage/Views/MyPageView.swift @@ -54,7 +54,6 @@ final class MyPageView: UIView { } } - extension MyPageView: UICollectionViewDelegate {} extension MyPageView: UICollectionViewDataSource { @@ -105,7 +104,7 @@ extension MyPageView: UICollectionViewDelegateFlowLayout { func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { switch indexPath.section { default: - let itemWidthOrHeight: CGFloat = 60 + let itemWidthOrHeight: CGFloat = 58 return CGSize(width: collectionView.frame.width.adjustedWidth, height: itemWidthOrHeight.adjustedHeight) } } @@ -130,6 +129,7 @@ extension MyPageView: UICollectionViewDelegateFlowLayout { guard let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: UserPointHeaderView.identifier, for: indexPath) as? UserPointHeaderView else { return UICollectionReusableView() } + headerView.bindData(model: UserModel.dummy()) return headerView } case 1: From 6a436275d3cdfaa56eafe5c5082c896e70002bc2 Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Tue, 9 Jan 2024 21:38:39 +0900 Subject: [PATCH 024/101] =?UTF-8?q?[Add/#40]=20Splash=20-=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj | 40 ++++++++++++++++++ .../HMH_iOS/Application/SceneDelegate.swift | 41 ++++++++++++++++--- .../SplashViewController.swift | 16 ++++++++ 3 files changed, 91 insertions(+), 6 deletions(-) create mode 100644 HMH_iOS/HMH_iOS/Presentation/Splash/ViewControllers/SplashViewController.swift diff --git a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj index a744c84..7e06b2e 100644 --- a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj +++ b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj @@ -32,6 +32,8 @@ 0BA193B92B4D4097007E3F9C /* SignInModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BA193B82B4D4097007E3F9C /* SignInModel.swift */; }; 0BC0EBD22B493B6B003EF5D4 /* OnboardingProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BC0EBD12B493B6B003EF5D4 /* OnboardingProgressView.swift */; }; 0BC0EBD42B494459003EF5D4 /* OnboardingSwipeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BC0EBD32B494459003EF5D4 /* OnboardingSwipeView.swift */; }; + 0BD98DB92B4D671600E35188 /* SplashViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BD98DB82B4D671600E35188 /* SplashViewController.swift */; }; + 0BD98DBE2B4D6AB700E35188 /* LoginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BD98DBD2B4D6AB700E35188 /* LoginViewController.swift */; }; 17314F7F2B485E150089A551 /* CustomAlertButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17314F7E2B485E150089A551 /* CustomAlertButton.swift */; }; 17314F832B486BEC0089A551 /* AlertViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17314F822B486BEC0089A551 /* AlertViewController.swift */; }; 17314F852B497FDE0089A551 /* HMHLogoutAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17314F842B497FDE0089A551 /* HMHLogoutAlert.swift */; }; @@ -171,6 +173,8 @@ 0BA193B82B4D4097007E3F9C /* SignInModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignInModel.swift; sourceTree = ""; }; 0BC0EBD12B493B6B003EF5D4 /* OnboardingProgressView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingProgressView.swift; sourceTree = ""; }; 0BC0EBD32B494459003EF5D4 /* OnboardingSwipeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingSwipeView.swift; sourceTree = ""; }; + 0BD98DB82B4D671600E35188 /* SplashViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplashViewController.swift; sourceTree = ""; }; + 0BD98DBD2B4D6AB700E35188 /* LoginViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginViewController.swift; sourceTree = ""; }; 17314F7E2B485E150089A551 /* CustomAlertButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomAlertButton.swift; sourceTree = ""; }; 17314F822B486BEC0089A551 /* AlertViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertViewController.swift; sourceTree = ""; }; 17314F842B497FDE0089A551 /* HMHLogoutAlert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HMHLogoutAlert.swift; sourceTree = ""; }; @@ -362,6 +366,8 @@ 0B67CCE72B369BE300582D54 /* Presentation */ = { isa = PBXGroup; children = ( + 0BD98DBA2B4D6A5A00E35188 /* Login */, + 0BD98DB72B4D670200E35188 /* Splash */, 3666C8842B47110800564874 /* CreateChallenge */, 174AF4842B447AB500450D07 /* MyPage */, 174AF4832B447A7A00450D07 /* Challenge */, @@ -568,6 +574,38 @@ path = Models; sourceTree = ""; }; + 0BD98DB72B4D670200E35188 /* Splash */ = { + isa = PBXGroup; + children = ( + 0BD98DBB2B4D6A6D00E35188 /* ViewControllers */, + ); + path = Splash; + sourceTree = ""; + }; + 0BD98DBA2B4D6A5A00E35188 /* Login */ = { + isa = PBXGroup; + children = ( + 0BD98DBC2B4D6A8800E35188 /* ViewControllers */, + ); + path = Login; + sourceTree = ""; + }; + 0BD98DBB2B4D6A6D00E35188 /* ViewControllers */ = { + isa = PBXGroup; + children = ( + 0BD98DB82B4D671600E35188 /* SplashViewController.swift */, + ); + path = ViewControllers; + sourceTree = ""; + }; + 0BD98DBC2B4D6A8800E35188 /* ViewControllers */ = { + isa = PBXGroup; + children = ( + 0BD98DBD2B4D6AB700E35188 /* LoginViewController.swift */, + ); + path = ViewControllers; + sourceTree = ""; + }; 17314F7D2B485DCF0089A551 /* CustomAlert */ = { isa = PBXGroup; children = ( @@ -958,6 +996,8 @@ 36A3D9BE2B409BCC007EA272 /* Color.swift in Sources */, 0B8A89B52B369F0100688BA6 /* B.swift in Sources */, 174AF49C2B447D0700450D07 /* ChallengeViewController.swift in Sources */, + 0BD98DB92B4D671600E35188 /* SplashViewController.swift in Sources */, + 0BD98DBE2B4D6AB700E35188 /* LoginViewController.swift in Sources */, 17314F892B49A8B60089A551 /* AlertDelegate.swift in Sources */, 0B78174E2B4BD96D0078E925 /* OnboardingBaseViewControllers.swift in Sources */, 0B8A89B12B369E4C00688BA6 /* HomeView.swift in Sources */, diff --git a/HMH_iOS/HMH_iOS/Application/SceneDelegate.swift b/HMH_iOS/HMH_iOS/Application/SceneDelegate.swift index 5ff73d9..629882e 100644 --- a/HMH_iOS/HMH_iOS/Application/SceneDelegate.swift +++ b/HMH_iOS/HMH_iOS/Application/SceneDelegate.swift @@ -13,12 +13,41 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { - guard let windowScene = (scene as? UIWindowScene) else { return } - window = UIWindow(windowScene: windowScene) - window?.rootViewController = UINavigationController(rootViewController: TabBarController()) - if let navigationController = window?.rootViewController as? UINavigationController { - navigationController.isNavigationBarHidden = true + guard let windowScene = (scene as? UIWindowScene) else { return } + + let window = UIWindow(windowScene: windowScene) + self.window = window + + let splashViewController = SplashViewController() + window.rootViewController = splashViewController + window.makeKeyAndVisible() + + DispatchQueue.main.asyncAfter(deadline: .now() + 2) { + DispatchQueue.main.async{ + showLoginViewController() } - window?.makeKeyAndVisible() } + + func showTabBarViewController() { + let tabBarViewController = TabBarController() + navigateTo(viewController: tabBarViewController) + } + + func showLoginViewController() { + let loginViewController = LoginViewController() + navigateTo(viewController: loginViewController) + } + + func navigateTo(viewController: UIViewController) { + DispatchQueue.main.async { + if let navigationController = self.window?.rootViewController as? UINavigationController { + navigationController.pushViewController(viewController, animated: true) + } else { + let navigationController = UINavigationController(rootViewController: viewController) + self.window?.rootViewController = navigationController + self.window?.makeKeyAndVisible() + } + } + } + } } diff --git a/HMH_iOS/HMH_iOS/Presentation/Splash/ViewControllers/SplashViewController.swift b/HMH_iOS/HMH_iOS/Presentation/Splash/ViewControllers/SplashViewController.swift new file mode 100644 index 0000000..c0839d4 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Presentation/Splash/ViewControllers/SplashViewController.swift @@ -0,0 +1,16 @@ +// +// SplashViewController.swift +// HMH_iOS +// +// Created by Seonwoo Kim on 1/9/24. +// + +import UIKit + +final class SplashViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + view.backgroundColor = .systemYellow + } +} From 4ef8695fdd5c1c775e2ffaec2777eeefe6fc37be Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Tue, 9 Jan 2024 21:39:17 +0900 Subject: [PATCH 025/101] =?UTF-8?q?[Add/#40]=20Login=20-=20LoginViewContro?= =?UTF-8?q?ller=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewControllers/LoginViewController.swift | 136 ++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift diff --git a/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift b/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift new file mode 100644 index 0000000..2774df5 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift @@ -0,0 +1,136 @@ +// +// LoginViewController.swift +// HMH_iOS +// +// Created by Seonwoo Kim on 1/9/24. +// + +import UIKit + +import SnapKit +import Then +import AuthenticationServices + +final class LoginViewController: UIViewController { + let authorizationButton = ASAuthorizationAppleIDButton(authorizationButtonType: .signIn, authorizationButtonStyle: .white) + let swipeView = OnboardingSwipeView() + + func setAppleLoginButton() { + authorizationButton.addTarget(self, action: #selector(handleAuthorizationAppleIDButtonPress), for: .touchUpInside) + self.view.addSubview(authorizationButton) + + authorizationButton.translatesAutoresizingMaskIntoConstraints = false + } + + @objc + func handleAuthorizationAppleIDButtonPress() { + let appleIDProvider = ASAuthorizationAppleIDProvider() + let request = appleIDProvider.createRequest() + request.requestedScopes = [.fullName, .email] + //사용자의 이름과 이메일에 대한 인증요청 + let authorizationController = ASAuthorizationController(authorizationRequests: [request]) + authorizationController.delegate = self + authorizationController.presentationContextProvider = self + authorizationController.performRequests() + } + + override func viewDidLoad() { + super.viewDidLoad() + setUI() + } + + private func setUI() { + setHierarchy() + setConstraints() + } + + private func setHierarchy() { + view.addSubviews(authorizationButton, swipeView) + } + + private func setConstraints() { + authorizationButton.snp.makeConstraints { + $0.width.equalTo(336) + $0.height.equalTo(54) + $0.centerX.equalToSuperview() + $0.bottom.equalTo(view.safeAreaLayoutGuide).offset(-21.adjusted) + } + + swipeView.snp.makeConstraints { + $0.top.equalToSuperview().offset(108.adjusted) + $0.leading.trailing.equalToSuperview() + $0.height.equalTo(480) + } + } +} + + +extension LoginViewController: ASAuthorizationControllerDelegate, ASAuthorizationControllerPresentationContextProviding{ + func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor { + return self.view.window! + } + + func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) { + //로그인 성공 + switch authorization.credential { + case let appleIDCredential as ASAuthorizationAppleIDCredential: + // You can create an account in your system. + let userIdentifier = appleIDCredential.user + let fullName = appleIDCredential.fullName + let email = appleIDCredential.email + + UserDefaults.standard.set(userIdentifier, forKey: "userIdentifier") + + if let authorizationCode = appleIDCredential.authorizationCode, + let identityToken = appleIDCredential.identityToken, + let authCodeString = String(data: authorizationCode, encoding: .utf8), + let identifyTokenString = String(data: identityToken, encoding: .utf8) { + print("authorizationCode: \(authorizationCode)") + print("identityToken: \(identityToken)") + print("authCodeString: \(authCodeString)") + print("identifyTokenString: \(identifyTokenString)") + print("🚨", appleIDCredential) + if let bundleID = Bundle.main.bundleIdentifier { + UserDefaults.standard.removePersistentDomain(forName: bundleID) + } +// saveToUserDefaults("authorizationCode",keyValue: authorizationCode) +// saveToUserDefaults("identityToken",keyValue: identityToken) +// saveToUserDefaults(authCodeString,keyValue:"authCodeString") +// saveToUserDefaults(identifyTokenString,keyValue:"identifyTokenString") +// saveToUserDefaults("cool",keyValue:"userIdentifier") + + } + + print("useridentifier: \(userIdentifier)") + + + + //Move to MainPage + //let validVC = SignValidViewController() + //validVC.modalPresentationStyle = .fullScreen + //present(validVC, animated: true, completion: nil) + + case let passwordCredential as ASPasswordCredential: + // Sign in using an existing iCloud Keychain credential. + let username = passwordCredential.user + let password = passwordCredential.password + + print("username: \(username)") + print("password: \(password)") + + default: + break + } + } + + func saveToUserDefaults(_ content: String, keyValue: String) { + // Save the userId to UserDefaults + UserDefaults.standard.set(content, forKey: keyValue) + } + + + func authorizationController(controller: ASAuthorizationController, didCompleteWithError error: Error) { + // 로그인 실패(유저의 취소도 포함) + print("login failed - \(error.localizedDescription)") + } +} From 19dafd558fa6d8f1d5892ea23f457bf401d02479 Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Tue, 9 Jan 2024 23:18:51 +0900 Subject: [PATCH 026/101] =?UTF-8?q?[Fix/#40]=20Onboarding=20-=20swipeView?= =?UTF-8?q?=20=EB=A0=88=EC=9D=B4=EC=95=84=EC=9B=83=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Onboarding/Views/OnboardingSwipeView.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/Onboarding/Views/OnboardingSwipeView.swift b/HMH_iOS/HMH_iOS/Presentation/Onboarding/Views/OnboardingSwipeView.swift index ecd400f..e9b43de 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Onboarding/Views/OnboardingSwipeView.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Onboarding/Views/OnboardingSwipeView.swift @@ -59,7 +59,7 @@ final class OnboardingSwipeView: UIView { private func setConstraints() { scrollView.snp.makeConstraints { - $0.width.equalToSuperview() + $0.width.equalTo(UIScreen.main.bounds.width) $0.height.equalTo(380.adjustedHeight) } @@ -81,8 +81,8 @@ final class OnboardingSwipeView: UIView { pageView.snp.makeConstraints { $0.top.equalTo(scrollView.snp.top) - $0.size.equalToSuperview() - $0.leading.equalTo(scrollView.snp.leading).offset(375.adjusted * CGFloat(i)) + $0.size.equalTo(scrollView) + $0.leading.equalTo(scrollView.snp.leading).offset(375.adjustedWidth * CGFloat(i)) } } } @@ -98,14 +98,14 @@ final class OnboardingSwipeView: UIView { @objc private func nextPage() { currentPage = (currentPage + 1) % 3 - scrollView.setContentOffset(CGPoint(x: (scrollView.frame.width.adjusted * CGFloat(currentPage)), y: 0), animated: true) + scrollView.setContentOffset(CGPoint(x: (UIScreen.main.bounds.width * CGFloat(currentPage)), y: 0), animated: true) pageControl.currentPage = currentPage } } extension OnboardingSwipeView: UIScrollViewDelegate { func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { - currentPage = Int(scrollView.contentOffset.x.adjusted / scrollView.frame.width.adjusted) + currentPage = Int(scrollView.contentOffset.x.adjustedWidth / UIScreen.main.bounds.width) pageControl.currentPage = currentPage } } From 1d33f4330d07b8205865ba5474c04fc18acc5db2 Mon Sep 17 00:00:00 2001 From: boyeon Date: Wed, 10 Jan 2024 00:05:14 +0900 Subject: [PATCH 027/101] =?UTF-8?q?[Feat/#31]=20MyPageCell=20-=20=EB=B9=88?= =?UTF-8?q?=20=EA=B3=B5=EA=B0=84=20=EC=85=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Cells/StoreCollectionViewCell.swift | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/StoreCollectionViewCell.swift diff --git a/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/StoreCollectionViewCell.swift b/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/StoreCollectionViewCell.swift new file mode 100644 index 0000000..88b7b14 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/StoreCollectionViewCell.swift @@ -0,0 +1,25 @@ +// +// StoreCollectionViewCell.swift +// HMH_iOS +// +// Created by 김보연 on 1/9/24. +// + +import UIKit + +import SnapKit +import Then + +final class StoreCollectionViewCell: UICollectionViewCell { + + static let identifier = "StoreCollectionViewCell" + + override init(frame: CGRect) { + super.init(frame: frame) + self.backgroundColor = .background + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} From 3758e9289b52c43d1cbf5b41bd33aaccac82f916 Mon Sep 17 00:00:00 2001 From: boyeon Date: Wed, 10 Jan 2024 00:06:06 +0900 Subject: [PATCH 028/101] =?UTF-8?q?[Chore/#31]=20MyPage=20-=20=EC=A0=84?= =?UTF-8?q?=EC=B2=B4=20=EB=A0=88=EC=9D=B4=EC=95=84=EC=9B=83=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyPage/Cells/InfoHeaderView.swift | 2 +- .../Cells/MypageCollectionViewCell.swift | 6 +-- .../MyPage/Cells/UserPointHeaderView.swift | 10 ++--- .../MyPage/Views/MyPageView.swift | 42 ++++++++++--------- 4 files changed, 31 insertions(+), 29 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/InfoHeaderView.swift b/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/InfoHeaderView.swift index af83285..72af1bc 100644 --- a/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/InfoHeaderView.swift +++ b/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/InfoHeaderView.swift @@ -41,7 +41,7 @@ final class InfoHeaderView: UICollectionReusableView { private func setConstraints() { infoLabel.snp.makeConstraints { - $0.bottom.equalToSuperview().offset(-11.adjusted) + $0.bottom.equalToSuperview().inset(13.adjusted) $0.leading.equalToSuperview().inset(20) } } diff --git a/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/MypageCollectionViewCell.swift b/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/MypageCollectionViewCell.swift index 1192d6b..3dc1faa 100644 --- a/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/MypageCollectionViewCell.swift +++ b/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/MypageCollectionViewCell.swift @@ -16,7 +16,7 @@ final class MypageCollectionViewCell: UICollectionViewCell { private let imageAndLabelStackView = UIStackView().then { $0.axis = .horizontal - $0.spacing = 15 + $0.spacing = 15.adjusted $0.alignment = .center } @@ -53,12 +53,12 @@ final class MypageCollectionViewCell: UICollectionViewCell { private func setConstraints() { imageAndLabelStackView.snp.makeConstraints { $0.centerY.equalToSuperview() - $0.leading.equalToSuperview().inset(20) + $0.leading.equalToSuperview().inset(20.adjusted) } myPageCellNextPageImageView.snp.makeConstraints { $0.centerY.equalToSuperview() - $0.trailing.equalToSuperview().inset(20) + $0.trailing.equalToSuperview().inset(20.adjusted) } } diff --git a/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/UserPointHeaderView.swift b/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/UserPointHeaderView.swift index 0de0e2b..f6683a1 100644 --- a/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/UserPointHeaderView.swift +++ b/HMH_iOS/HMH_iOS/Presentation/MyPage/Cells/UserPointHeaderView.swift @@ -16,7 +16,7 @@ final class UserPointHeaderView: UICollectionReusableView { private let userStackView = UIStackView().then { $0.axis = .horizontal - $0.spacing = 15 + $0.spacing = 15.adjusted $0.alignment = .center } @@ -41,7 +41,7 @@ final class UserPointHeaderView: UICollectionReusableView { private let myPointButtonStackView = UIStackView().then { $0.alignment = .center - $0.spacing = 9 + $0.spacing = 8.adjusted $0.axis = .vertical } @@ -72,7 +72,7 @@ final class UserPointHeaderView: UICollectionReusableView { private let myBadgeButtonStackView = UIStackView().then { $0.alignment = .center $0.axis = .vertical - $0.spacing = 8 + $0.spacing = 8.adjusted } private let badgeLabel = UILabel().then { @@ -123,7 +123,7 @@ final class UserPointHeaderView: UICollectionReusableView { pointBadgeView.snp.makeConstraints { $0.top.equalTo(userStackView.snp.bottom).offset(25.adjusted) - $0.bottom.equalToSuperview().inset(21.adjusted) + $0.bottom.equalToSuperview().inset(22.adjusted) $0.horizontalEdges.equalToSuperview().inset(20.adjustedWidth) } @@ -135,7 +135,7 @@ final class UserPointHeaderView: UICollectionReusableView { lineView.snp.makeConstraints { $0.center.equalToSuperview() - $0.width.equalTo(1.adjusted) + $0.width.equalTo(1) $0.height.equalTo(57.adjusted) } diff --git a/HMH_iOS/HMH_iOS/Presentation/MyPage/Views/MyPageView.swift b/HMH_iOS/HMH_iOS/Presentation/MyPage/Views/MyPageView.swift index 07b6cef..5f30797 100644 --- a/HMH_iOS/HMH_iOS/Presentation/MyPage/Views/MyPageView.swift +++ b/HMH_iOS/HMH_iOS/Presentation/MyPage/Views/MyPageView.swift @@ -44,11 +44,13 @@ final class MyPageView: UIView { private func setRegister() { myPageCollectionView.register(UserPointHeaderView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: UserPointHeaderView.identifier) myPageCollectionView.register(MypageCollectionViewCell.self, forCellWithReuseIdentifier: MypageCollectionViewCell.identifier) + myPageCollectionView.register(StoreCollectionViewCell.self, forCellWithReuseIdentifier: StoreCollectionViewCell.identifier) myPageCollectionView.register(InfoHeaderView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: InfoHeaderView.identifier) myPageCollectionView.register(LogoutAndQuitFooterView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionFooter, withReuseIdentifier: LogoutAndQuitFooterView.identifier) } private func configreCollectionView() { + myPageCollectionView.showsVerticalScrollIndicator = false myPageCollectionView.delegate = self myPageCollectionView.dataSource = self } @@ -58,7 +60,7 @@ extension MyPageView: UICollectionViewDelegate {} extension MyPageView: UICollectionViewDataSource { func numberOfSections(in collectionView: UICollectionView) -> Int { - return 2 + return 3 } func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { @@ -66,6 +68,8 @@ extension MyPageView: UICollectionViewDataSource { case 0: return 2 case 1: + return 1 + case 2: return 2 default: return 0 @@ -85,15 +89,16 @@ extension MyPageView: UICollectionViewDataSource { item.configureCell(iconImage: ImageLiterals.myPage.icStore, labelText: StringLiteral.myPage.store, labelColor: .gray5) } return item - case 1: + guard let item = myPageCollectionView.dequeueReusableCell(withReuseIdentifier: StoreCollectionViewCell.identifier, for: indexPath) as? StoreCollectionViewCell else {return UICollectionViewCell()} + return item + case 2: if indexPath.item == 0 { item.configureCell(iconImage: nil, labelText: StringLiteral.myPage.TOS, labelColor: .whiteText) } else if indexPath.item == 1 { item.configureCell(iconImage: nil, labelText: StringLiteral.myPage.privacyPolicy, labelColor: .whiteText) } return item - default: return UICollectionViewCell() } @@ -103,23 +108,22 @@ extension MyPageView: UICollectionViewDataSource { extension MyPageView: UICollectionViewDelegateFlowLayout { func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { switch indexPath.section { + case 1: + let itemWidthOrHeight: CGFloat = 8 + return CGSize(width: collectionView.frame.width, height: itemWidthOrHeight.adjusted) default: - let itemWidthOrHeight: CGFloat = 58 - return CGSize(width: collectionView.frame.width.adjustedWidth, height: itemWidthOrHeight.adjustedHeight) + let itemWidthOrHeight: CGFloat = 60 + return CGSize(width: collectionView.frame.width, height: itemWidthOrHeight.adjusted) } } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { - let sectionInsets = UIEdgeInsets.zero switch section { - case 0: - return UIEdgeInsets(top: 0, left: 0, bottom: 10, right: 0) case 1: - return UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) + return UIEdgeInsets(top: 0, left: 0, bottom: 10.adjusted, right: 0) default: - break + return UIEdgeInsets.zero } - return sectionInsets } func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { @@ -132,15 +136,13 @@ extension MyPageView: UICollectionViewDelegateFlowLayout { headerView.bindData(model: UserModel.dummy()) return headerView } - case 1: + case 2: if kind == UICollectionView.elementKindSectionHeader { guard let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: InfoHeaderView.identifier, for: indexPath) as? InfoHeaderView else { return UICollectionReusableView() } return headerView - } - - else if kind == UICollectionView.elementKindSectionFooter { + } else if kind == UICollectionView.elementKindSectionFooter { guard let footerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: LogoutAndQuitFooterView.identifier, for: indexPath) as? LogoutAndQuitFooterView else { return UICollectionReusableView() } @@ -154,17 +156,17 @@ extension MyPageView: UICollectionViewDelegateFlowLayout { func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize { if section == 0 { - return .init(width: UIScreen.main.bounds.width, height: 205.adjusted) - } else if section == 1 { - return .init(width: UIScreen.main.bounds.width, height: 66.adjusted) + return .init(width: UIScreen.main.bounds.width, height: 198.adjusted) + } else if section == 2 { + return .init(width: UIScreen.main.bounds.width, height: 64.adjusted) } else { return .zero } } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize { - if section == 1 { - return .init(width: UIScreen.main.bounds.width, height: 96.adjusted) + if section == 2 { + return .init(width: UIScreen.main.bounds.width, height: 87.adjusted) } else { return .zero } From 2a52faa560ead4166c96dd1c622e2cd45934e3f1 Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Wed, 10 Jan 2024 00:23:35 +0900 Subject: [PATCH 029/101] =?UTF-8?q?[Fix/#40]=20Login=20-=20=EC=95=A0?= =?UTF-8?q?=ED=94=8C=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EA=B4=80=EB=A0=A8=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=20=EB=A1=9C=EC=A7=81=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewControllers/LoginViewController.swift | 93 +------------------ 1 file changed, 5 insertions(+), 88 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift b/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift index 2774df5..da57696 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift @@ -15,25 +15,6 @@ final class LoginViewController: UIViewController { let authorizationButton = ASAuthorizationAppleIDButton(authorizationButtonType: .signIn, authorizationButtonStyle: .white) let swipeView = OnboardingSwipeView() - func setAppleLoginButton() { - authorizationButton.addTarget(self, action: #selector(handleAuthorizationAppleIDButtonPress), for: .touchUpInside) - self.view.addSubview(authorizationButton) - - authorizationButton.translatesAutoresizingMaskIntoConstraints = false - } - - @objc - func handleAuthorizationAppleIDButtonPress() { - let appleIDProvider = ASAuthorizationAppleIDProvider() - let request = appleIDProvider.createRequest() - request.requestedScopes = [.fullName, .email] - //사용자의 이름과 이메일에 대한 인증요청 - let authorizationController = ASAuthorizationController(authorizationRequests: [request]) - authorizationController.delegate = self - authorizationController.presentationContextProvider = self - authorizationController.performRequests() - } - override func viewDidLoad() { super.viewDidLoad() setUI() @@ -62,75 +43,11 @@ final class LoginViewController: UIViewController { $0.height.equalTo(480) } } -} - - -extension LoginViewController: ASAuthorizationControllerDelegate, ASAuthorizationControllerPresentationContextProviding{ - func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor { - return self.view.window! - } - - func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) { - //로그인 성공 - switch authorization.credential { - case let appleIDCredential as ASAuthorizationAppleIDCredential: - // You can create an account in your system. - let userIdentifier = appleIDCredential.user - let fullName = appleIDCredential.fullName - let email = appleIDCredential.email - - UserDefaults.standard.set(userIdentifier, forKey: "userIdentifier") - - if let authorizationCode = appleIDCredential.authorizationCode, - let identityToken = appleIDCredential.identityToken, - let authCodeString = String(data: authorizationCode, encoding: .utf8), - let identifyTokenString = String(data: identityToken, encoding: .utf8) { - print("authorizationCode: \(authorizationCode)") - print("identityToken: \(identityToken)") - print("authCodeString: \(authCodeString)") - print("identifyTokenString: \(identifyTokenString)") - print("🚨", appleIDCredential) - if let bundleID = Bundle.main.bundleIdentifier { - UserDefaults.standard.removePersistentDomain(forName: bundleID) - } -// saveToUserDefaults("authorizationCode",keyValue: authorizationCode) -// saveToUserDefaults("identityToken",keyValue: identityToken) -// saveToUserDefaults(authCodeString,keyValue:"authCodeString") -// saveToUserDefaults(identifyTokenString,keyValue:"identifyTokenString") -// saveToUserDefaults("cool",keyValue:"userIdentifier") - - } - - print("useridentifier: \(userIdentifier)") - - - - //Move to MainPage - //let validVC = SignValidViewController() - //validVC.modalPresentationStyle = .fullScreen - //present(validVC, animated: true, completion: nil) - - case let passwordCredential as ASPasswordCredential: - // Sign in using an existing iCloud Keychain credential. - let username = passwordCredential.user - let password = passwordCredential.password - - print("username: \(username)") - print("password: \(password)") - - default: - break - } - } - - func saveToUserDefaults(_ content: String, keyValue: String) { - // Save the userId to UserDefaults - UserDefaults.standard.set(content, forKey: keyValue) - } - - func authorizationController(controller: ASAuthorizationController, didCompleteWithError error: Error) { - // 로그인 실패(유저의 취소도 포함) - print("login failed - \(error.localizedDescription)") + private func setAppleLoginButton() { + self.view.addSubview(authorizationButton) + authorizationButton.translatesAutoresizingMaskIntoConstraints = false } } + + From 3226cb65062f88c555152d8a67eab0e8dd0ad5e5 Mon Sep 17 00:00:00 2001 From: boyeon Date: Wed, 10 Jan 2024 00:31:42 +0900 Subject: [PATCH 030/101] =?UTF-8?q?[Add/#31]=20=ED=95=84=EC=9A=94=ED=95=9C?= =?UTF-8?q?=20=ED=8C=8C=EC=9D=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj index ca0313d..363811c 100644 --- a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj +++ b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj @@ -30,6 +30,13 @@ 17314F852B497FDE0089A551 /* HMHLogoutAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17314F842B497FDE0089A551 /* HMHLogoutAlert.swift */; }; 17314F872B49853C0089A551 /* HMHQuitAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17314F862B49853C0089A551 /* HMHQuitAlert.swift */; }; 17314F892B49A8B60089A551 /* AlertDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17314F882B49A8B60089A551 /* AlertDelegate.swift */; }; + 17314F972B4C42130089A551 /* MyPageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17314F962B4C42130089A551 /* MyPageView.swift */; }; + 17314F9B2B4C485B0089A551 /* UserPointHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17314F9A2B4C485B0089A551 /* UserPointHeaderView.swift */; }; + 17314F9D2B4C554D0089A551 /* MypageCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17314F9C2B4C554D0089A551 /* MypageCollectionViewCell.swift */; }; + 17314FAF2B4D3E1C0089A551 /* LogoutAndQuitFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17314FAE2B4D3E1C0089A551 /* LogoutAndQuitFooterView.swift */; }; + 17314FB12B4D50380089A551 /* InfoHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17314FB02B4D50380089A551 /* InfoHeaderView.swift */; }; + 17314FB32B4D68950089A551 /* UserModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17314FB22B4D68950089A551 /* UserModel.swift */; }; + 17314FB72B4D93D30089A551 /* StoreCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17314FB62B4D93D30089A551 /* StoreCollectionViewCell.swift */; }; 174AF48E2B447B1F00450D07 /* MyPageCells.swift in Sources */ = {isa = PBXBuildFile; fileRef = 174AF48D2B447B1F00450D07 /* MyPageCells.swift */; }; 174AF4902B447B3C00450D07 /* MyPageModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 174AF48F2B447B3C00450D07 /* MyPageModels.swift */; }; 174AF4922B447B4600450D07 /* MyPageViews.swift in Sources */ = {isa = PBXBuildFile; fileRef = 174AF4912B447B4600450D07 /* MyPageViews.swift */; }; @@ -162,6 +169,13 @@ 17314F842B497FDE0089A551 /* HMHLogoutAlert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HMHLogoutAlert.swift; sourceTree = ""; }; 17314F862B49853C0089A551 /* HMHQuitAlert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HMHQuitAlert.swift; sourceTree = ""; }; 17314F882B49A8B60089A551 /* AlertDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertDelegate.swift; sourceTree = ""; }; + 17314F962B4C42130089A551 /* MyPageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageView.swift; sourceTree = ""; }; + 17314F9A2B4C485B0089A551 /* UserPointHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserPointHeaderView.swift; sourceTree = ""; }; + 17314F9C2B4C554D0089A551 /* MypageCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MypageCollectionViewCell.swift; sourceTree = ""; }; + 17314FAE2B4D3E1C0089A551 /* LogoutAndQuitFooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogoutAndQuitFooterView.swift; sourceTree = ""; }; + 17314FB02B4D50380089A551 /* InfoHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoHeaderView.swift; sourceTree = ""; }; + 17314FB22B4D68950089A551 /* UserModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserModel.swift; sourceTree = ""; }; + 17314FB62B4D93D30089A551 /* StoreCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoreCollectionViewCell.swift; sourceTree = ""; }; 174AF48D2B447B1F00450D07 /* MyPageCells.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageCells.swift; sourceTree = ""; }; 174AF48F2B447B3C00450D07 /* MyPageModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageModels.swift; sourceTree = ""; }; 174AF4912B447B4600450D07 /* MyPageViews.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageViews.swift; sourceTree = ""; }; @@ -621,6 +635,7 @@ isa = PBXGroup; children = ( 174AF4912B447B4600450D07 /* MyPageViews.swift */, + 17314F962B4C42130089A551 /* MyPageView.swift */, ); path = Views; sourceTree = ""; @@ -629,6 +644,7 @@ isa = PBXGroup; children = ( 174AF48F2B447B3C00450D07 /* MyPageModels.swift */, + 17314FB22B4D68950089A551 /* UserModel.swift */, ); path = Models; sourceTree = ""; @@ -637,6 +653,11 @@ isa = PBXGroup; children = ( 174AF48D2B447B1F00450D07 /* MyPageCells.swift */, + 17314F9A2B4C485B0089A551 /* UserPointHeaderView.swift */, + 17314F9C2B4C554D0089A551 /* MypageCollectionViewCell.swift */, + 17314FAE2B4D3E1C0089A551 /* LogoutAndQuitFooterView.swift */, + 17314FB02B4D50380089A551 /* InfoHeaderView.swift */, + 17314FB62B4D93D30089A551 /* StoreCollectionViewCell.swift */, ); path = Cells; sourceTree = ""; @@ -885,6 +906,7 @@ 3666C89F2B485C8F00564874 /* DateCollectionViewCell.swift in Sources */, 3666C87A2B45F4F900564874 /* SelectedBlocker.swift in Sources */, 0BC0EBD42B494459003EF5D4 /* OnboardingSwipeView.swift in Sources */, + 17314F9B2B4C485B0089A551 /* UserPointHeaderView.swift in Sources */, 36A3D9C02B409CBD007EA272 /* Font.swift in Sources */, 174AF4902B447B3C00450D07 /* MyPageModels.swift in Sources */, 174AF4982B447CF100450D07 /* ChanllengeModels.swift in Sources */, @@ -904,11 +926,15 @@ 3666C8A32B4861A200564874 /* AppListCollectionViewCell.swift in Sources */, 0B8A89AD2B369E3B00688BA6 /* HomeCell.swift in Sources */, 3666C8882B47110800564874 /* SpecificTimePickerView.swift in Sources */, + 17314FB72B4D93D30089A551 /* StoreCollectionViewCell.swift in Sources */, 174AF4922B447B4600450D07 /* MyPageViews.swift in Sources */, 36A3D9BE2B409BCC007EA272 /* Color.swift in Sources */, + 17314FB12B4D50380089A551 /* InfoHeaderView.swift in Sources */, 0B8A89B52B369F0100688BA6 /* B.swift in Sources */, 174AF49C2B447D0700450D07 /* ChallengeViewController.swift in Sources */, + 17314FB32B4D68950089A551 /* UserModel.swift in Sources */, 17314F892B49A8B60089A551 /* AlertDelegate.swift in Sources */, + 17314FAF2B4D3E1C0089A551 /* LogoutAndQuitFooterView.swift in Sources */, 0B8A89B12B369E4C00688BA6 /* HomeView.swift in Sources */, 36A3D9B62B3EBBF7007EA272 /* Adjust+.swift in Sources */, 36A3D9BC2B3EBD2D007EA272 /* UIScreen+.swift in Sources */, @@ -916,7 +942,9 @@ 36A3D9B42B3EBBED007EA272 /* UIStackView+.swift in Sources */, 174AF4962B447CE700450D07 /* ChanllengeCells.swift in Sources */, 17314F832B486BEC0089A551 /* AlertViewController.swift in Sources */, + 17314F9D2B4C554D0089A551 /* MypageCollectionViewCell.swift in Sources */, 0B8A89B32B369EF700688BA6 /* A.swift in Sources */, + 17314F972B4C42130089A551 /* MyPageView.swift in Sources */, 0BC0EBD22B493B6B003EF5D4 /* OnboardingProgressView.swift in Sources */, 17314F7F2B485E150089A551 /* CustomAlertButton.swift in Sources */, 36A3D9BA2B3EBC65007EA272 /* UIButton+.swift in Sources */, From 6cbfcf9b8825b6db5439eeec49d3c28285849d33 Mon Sep 17 00:00:00 2001 From: boyeon Date: Wed, 10 Jan 2024 03:07:18 +0900 Subject: [PATCH 031/101] =?UTF-8?q?[Fix]=20=EC=98=A4=EB=A5=98=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS/Global/Literals/Literal/Image.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Global/Literals/Literal/Image.swift b/HMH_iOS/HMH_iOS/Global/Literals/Literal/Image.swift index 1fcf9e0..b07fe16 100644 --- a/HMH_iOS/HMH_iOS/Global/Literals/Literal/Image.swift +++ b/HMH_iOS/HMH_iOS/Global/Literals/Literal/Image.swift @@ -27,9 +27,9 @@ enum ImageLiterals { static var icJourney: UIImage { .load(named: "ios_journey_ic")} static var icStore: UIImage { .load(named: "ios_store_ic")} static var icArrowRight: UIImage { .load(named: "chevron_right")} - + } + enum Challenge { static var icPlus: UIImage { .load(named: "Minus_XL") } } } - From aa2551e1147474c64c3a21bdddf327e4964331fe Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Wed, 10 Jan 2024 00:41:16 +0900 Subject: [PATCH 032/101] =?UTF-8?q?[Add/#42]=20CreateChallenge=20-=20?= =?UTF-8?q?=EC=B1=8C=EB=A6=B0=EC=A7=80=20=EC=83=9D=EC=84=B1=20=EB=B7=B0?= =?UTF-8?q?=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj | 24 +++++++ .../Global/Literals/String/String.swift | 9 +++ .../ViewControllers/AppChoiceController.swift | 8 +++ .../ApprovePermisionController.swift | 71 +++++++++++++++++++ .../SelectPeriodController.swift | 70 ++++++++++++++++++ .../SelectTotalTimeController.swift | 70 ++++++++++++++++++ .../ProblemSurveyViewController.swift | 2 +- 7 files changed, 253 insertions(+), 1 deletion(-) create mode 100644 HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/AppChoiceController.swift create mode 100644 HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/ApprovePermisionController.swift create mode 100644 HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/SelectPeriodController.swift create mode 100644 HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/SelectTotalTimeController.swift diff --git a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj index 6af0e32..be6a11c 100644 --- a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj +++ b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj @@ -7,6 +7,10 @@ objects = { /* Begin PBXBuildFile section */ + 0B000CE92B4D9D6E00AEC582 /* SelectPeriodController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B000CE82B4D9D6E00AEC582 /* SelectPeriodController.swift */; }; + 0B000CEB2B4D9D9100AEC582 /* SelectTotalTimeController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B000CEA2B4D9D9100AEC582 /* SelectTotalTimeController.swift */; }; + 0B000CED2B4D9DA800AEC582 /* ApprovePermisionController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B000CEC2B4D9DA800AEC582 /* ApprovePermisionController.swift */; }; + 0B000CEF2B4D9DBF00AEC582 /* AppChoiceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B000CEE2B4D9DBF00AEC582 /* AppChoiceController.swift */; }; 0B0035402B43D64D00DA140C /* HMHNavigationBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B00353F2B43D64D00DA140C /* HMHNavigationBar.swift */; }; 0B2C2D3B2B443BE90023CCFA /* Image.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B2C2D3A2B443BE90023CCFA /* Image.swift */; }; 0B2C2D412B4572240023CCFA /* HMHSelectButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B2C2D402B4572240023CCFA /* HMHSelectButton.swift */; }; @@ -153,6 +157,10 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 0B000CE82B4D9D6E00AEC582 /* SelectPeriodController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectPeriodController.swift; sourceTree = ""; }; + 0B000CEA2B4D9D9100AEC582 /* SelectTotalTimeController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectTotalTimeController.swift; sourceTree = ""; }; + 0B000CEC2B4D9DA800AEC582 /* ApprovePermisionController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApprovePermisionController.swift; sourceTree = ""; }; + 0B000CEE2B4D9DBF00AEC582 /* AppChoiceController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppChoiceController.swift; sourceTree = ""; }; 0B00353F2B43D64D00DA140C /* HMHNavigationBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HMHNavigationBar.swift; sourceTree = ""; }; 0B2C2D3A2B443BE90023CCFA /* Image.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Image.swift; sourceTree = ""; }; 0B2C2D402B4572240023CCFA /* HMHSelectButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HMHSelectButton.swift; sourceTree = ""; }; @@ -289,6 +297,17 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 0B000CE72B4D9D4E00AEC582 /* ViewControllers */ = { + isa = PBXGroup; + children = ( + 0B000CE82B4D9D6E00AEC582 /* SelectPeriodController.swift */, + 0B000CEA2B4D9D9100AEC582 /* SelectTotalTimeController.swift */, + 0B000CEC2B4D9DA800AEC582 /* ApprovePermisionController.swift */, + 0B000CEE2B4D9DBF00AEC582 /* AppChoiceController.swift */, + ); + path = ViewControllers; + sourceTree = ""; + }; 0B2C2D3C2B4559AE0023CCFA /* Onboarding */ = { isa = PBXGroup; children = ( @@ -796,6 +815,7 @@ 3666C8842B47110800564874 /* CreateChallenge */ = { isa = PBXGroup; children = ( + 0B000CE72B4D9D4E00AEC582 /* ViewControllers */, 3666C8852B47110800564874 /* Views */, ); path = CreateChallenge; @@ -985,6 +1005,7 @@ 36E05FE42B487911005B633E /* GrayBackgroundView.swift in Sources */, 0B50F9CF2B369813000C5046 /* HomeViewController.swift in Sources */, 0B2C2D412B4572240023CCFA /* HMHSelectButton.swift in Sources */, + 0B000CEF2B4D9DBF00AEC582 /* AppChoiceController.swift in Sources */, 0B8A89BC2B369F2D00688BA6 /* UIView+.swift in Sources */, 0B8A89AF2B369E4300688BA6 /* HomeModel.swift in Sources */, 3666C89F2B485C8F00564874 /* DateCollectionViewCell.swift in Sources */, @@ -1003,9 +1024,12 @@ 0B7817522B4BE0280078E925 /* ProgressBarManager.swift in Sources */, 0B8A89C42B369FA000688BA6 /* F.swift in Sources */, 3666C8892B47110800564874 /* TotalTimePickerView.swift in Sources */, + 0B000CE92B4D9D6E00AEC582 /* SelectPeriodController.swift in Sources */, 174AF49A2B447CFB00450D07 /* ChanllengeViews.swift in Sources */, + 0B000CEB2B4D9D9100AEC582 /* SelectTotalTimeController.swift in Sources */, 17314F872B49853C0089A551 /* HMHQuitAlert.swift in Sources */, 0BA193B62B4D08B7007E3F9C /* ProblemSurveyViewController.swift in Sources */, + 0B000CED2B4D9DA800AEC582 /* ApprovePermisionController.swift in Sources */, 0B8A89B72B369F1100688BA6 /* C.swift in Sources */, 0B2C2D3B2B443BE90023CCFA /* Image.swift in Sources */, 17314F852B497FDE0089A551 /* HMHLogoutAlert.swift in Sources */, diff --git a/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift b/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift index cc09bc6..9ebb914 100644 --- a/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift +++ b/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift @@ -75,10 +75,12 @@ enum StringLiteral { enum OnboardigMain { static let timeSurvey = "하루 평균 휴대폰을\n얼마나 사용하나요?" static let problemSurvey = "휴대폰을 사용할 때\n어떤 문제를 겪고 있나요?" + static let selectPeriod = "챌린지 기간을 선택해 주세요" } enum OnboardigSub { static let problemSurvey = "해당 문항은 최대 2개까지 선택할 수 있어요" + static let selectPeriod = "첫 챌린지로 가볍게 도전하기 좋은 7일을 추천해요" } enum TimeSurveySelect { @@ -94,4 +96,11 @@ enum StringLiteral { static let thirdSelect = "특정 앱에 수시로 접속하게 돼요" static let fourthSelect = "중독을 탈출하려고 노력해도 잘 안 돼요" } + + enum PeriodSelect { + static let firstSelect = "7일" + static let secondSelect = "14일" + static let thirdSelect = "20일" + static let fourthSelect = "30일" + } } diff --git a/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/AppChoiceController.swift b/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/AppChoiceController.swift new file mode 100644 index 0000000..1665fff --- /dev/null +++ b/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/AppChoiceController.swift @@ -0,0 +1,8 @@ +// +// AppChoiceController.swift +// HMH_iOS +// +// Created by Seonwoo Kim on 1/10/24. +// + +import Foundation diff --git a/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/ApprovePermisionController.swift b/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/ApprovePermisionController.swift new file mode 100644 index 0000000..ec86398 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/ApprovePermisionController.swift @@ -0,0 +1,71 @@ +// +// ApprovePermisionController.swift +// HMH_iOS +// +// Created by Seonwoo Kim on 1/10/24. +// + +import UIKit + +import SnapKit +import Then + +final class ApprovePermisionController: OnboardingBaseViewController { + private let surveyView = SurveyView(buttonType: .solitary) + + override func viewDidLoad() { + super.viewDidLoad() + setUI() + configureSurveyView() + setDelegate() + setTimeSurvey() + } + + override func viewDidAppear(_ animated: Bool) { + setUI() + } + + private func setUI(){ + setHierarchy() + setConstraints() + } + + private func setHierarchy() { + view.addSubview(surveyView) + } + + private func setConstraints() { + surveyView.snp.makeConstraints { + $0.top.equalTo(mainTitleLabel.snp.bottom).offset(94.adjustedHeight) + $0.leading.trailing.equalTo(progressBar) + } + } + + private func setDelegate() { + self.delegate = self + } + + private func setTimeSurvey() { + view.backgroundColor = .background + step = 5 + } + + private func configureSurveyView() { + nextButtonText = StringLiteral.OnboardingButton.next + nextButton.setButtonText(buttonTitle: nextButtonText) + mainTitleText = StringLiteral.OnboardigMain.selectPeriod + subTitleText = StringLiteral.OnboardigSub.selectPeriod + surveyView.firstButton.setButtonText(buttonTitle: StringLiteral.PeriodSelect.firstSelect) + surveyView.secondButton.setButtonText(buttonTitle: StringLiteral.PeriodSelect.secondSelect) + surveyView.thirdButton.setButtonText(buttonTitle: StringLiteral.PeriodSelect.thirdSelect) + surveyView.fourthButton.setButtonText(buttonTitle: StringLiteral.PeriodSelect.fourthSelect) + } +} + +extension ApprovePermisionController: NextViewPushDelegate { + func didTapButton() { + let nextViewController = SelectTotalTimeController() + self.navigationController?.pushViewController(nextViewController, animated: false) + } +} + diff --git a/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/SelectPeriodController.swift b/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/SelectPeriodController.swift new file mode 100644 index 0000000..c11515f --- /dev/null +++ b/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/SelectPeriodController.swift @@ -0,0 +1,70 @@ +// +// SelectPeriodController.swift +// HMH_iOS +// +// Created by Seonwoo Kim on 1/10/24. +// + +import UIKit + +import SnapKit +import Then + +final class SelectPeriodController: OnboardingBaseViewController { + private let surveyView = SurveyView(buttonType: .solitary) + + override func viewDidLoad() { + super.viewDidLoad() + setUI() + configureSurveyView() + setDelegate() + setTimeSurvey() + } + + override func viewDidAppear(_ animated: Bool) { + setUI() + } + + private func setUI(){ + setHierarchy() + setConstraints() + } + + private func setHierarchy() { + view.addSubview(surveyView) + } + + private func setConstraints() { + surveyView.snp.makeConstraints { + $0.top.equalTo(mainTitleLabel.snp.bottom).offset(94.adjustedHeight) + $0.leading.trailing.equalTo(progressBar) + } + } + + private func setDelegate() { + self.delegate = self + } + + private func setTimeSurvey() { + view.backgroundColor = .background + step = 3 + } + + private func configureSurveyView() { + nextButtonText = StringLiteral.OnboardingButton.next + nextButton.setButtonText(buttonTitle: nextButtonText) + mainTitleText = StringLiteral.OnboardigMain.selectPeriod + subTitleText = StringLiteral.OnboardigSub.selectPeriod + surveyView.firstButton.setButtonText(buttonTitle: StringLiteral.PeriodSelect.firstSelect) + surveyView.secondButton.setButtonText(buttonTitle: StringLiteral.PeriodSelect.secondSelect) + surveyView.thirdButton.setButtonText(buttonTitle: StringLiteral.PeriodSelect.thirdSelect) + surveyView.fourthButton.setButtonText(buttonTitle: StringLiteral.PeriodSelect.fourthSelect) + } +} + +extension SelectPeriodController: NextViewPushDelegate { + func didTapButton() { + let nextViewController = SelectTotalTimeController() + self.navigationController?.pushViewController(nextViewController, animated: false) + } +} diff --git a/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/SelectTotalTimeController.swift b/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/SelectTotalTimeController.swift new file mode 100644 index 0000000..be84e1e --- /dev/null +++ b/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/SelectTotalTimeController.swift @@ -0,0 +1,70 @@ +// +// SelectTotalTimeController.swift +// HMH_iOS +// +// Created by Seonwoo Kim on 1/10/24. +// + +import UIKit + +import SnapKit +import Then + +final class SelectTotalTimeController: OnboardingBaseViewController { + private let surveyView = SurveyView(buttonType: .solitary) + + override func viewDidLoad() { + super.viewDidLoad() + setUI() + configureSurveyView() + setDelegate() + setTimeSurvey() + } + + override func viewDidAppear(_ animated: Bool) { + setUI() + } + + private func setUI(){ + setHierarchy() + setConstraints() + } + + private func setHierarchy() { + view.addSubview(surveyView) + } + + private func setConstraints() { + surveyView.snp.makeConstraints { + $0.top.equalTo(mainTitleLabel.snp.bottom).offset(94.adjustedHeight) + $0.leading.trailing.equalTo(progressBar) + } + } + + private func setDelegate() { + self.delegate = self + } + + private func setTimeSurvey() { + view.backgroundColor = .background + step = 4 + } + + private func configureSurveyView() { + nextButtonText = StringLiteral.OnboardingButton.next + nextButton.setButtonText(buttonTitle: nextButtonText) + mainTitleText = StringLiteral.OnboardigMain.selectPeriod + subTitleText = StringLiteral.OnboardigSub.selectPeriod + surveyView.firstButton.setButtonText(buttonTitle: StringLiteral.PeriodSelect.firstSelect) + surveyView.secondButton.setButtonText(buttonTitle: StringLiteral.PeriodSelect.secondSelect) + surveyView.thirdButton.setButtonText(buttonTitle: StringLiteral.PeriodSelect.thirdSelect) + surveyView.fourthButton.setButtonText(buttonTitle: StringLiteral.PeriodSelect.fourthSelect) + } +} + +extension SelectTotalTimeController: NextViewPushDelegate { + func didTapButton() { + let nextViewController = ApprovePermisionController() + self.navigationController?.pushViewController(nextViewController, animated: false) + } +} diff --git a/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/ProblemSurveyViewController.swift b/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/ProblemSurveyViewController.swift index f31df04..16ef9db 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/ProblemSurveyViewController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/ProblemSurveyViewController.swift @@ -64,7 +64,7 @@ final class ProblemSurveyViewController: OnboardingBaseViewController { extension ProblemSurveyViewController: NextViewPushDelegate { func didTapButton() { - let nextViewController = TimeSurveyViewController() + let nextViewController = SelectPeriodController() self.navigationController?.pushViewController(nextViewController, animated: false) } } From 9892a9e6b353de0691cdc5e4bc4eb3734779a80c Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Wed, 10 Jan 2024 01:30:51 +0900 Subject: [PATCH 033/101] =?UTF-8?q?[Fix/#42]=20CreateChallenge=20-=20?= =?UTF-8?q?=EC=BB=A4=EC=8A=A4=ED=85=80=20=EB=B2=84=ED=8A=BC=20=ED=8C=8C?= =?UTF-8?q?=EB=9D=BC=EB=AF=B8=ED=84=B0=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj | 4 ++ .../HMH_iOS/Global/Extension/UILabel+.swift | 20 +++++++++ .../Global/Literals/String/String.swift | 6 +++ .../AppSelectViewController.swift | 45 +++++++++++++++++++ .../ApprovePermisionController.swift | 34 ++------------ .../SelectPeriodController.swift | 2 +- .../SelectTotalTimeController.swift | 15 +++---- .../OnboardingBaseViewControllers.swift | 5 ++- .../ProblemSurveyViewController.swift | 3 +- .../TimeSurveyViewController.swift | 2 +- .../Onboarding/Views/SurveyView.swift | 28 +++++++----- 11 files changed, 106 insertions(+), 58 deletions(-) create mode 100644 HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/AppSelectViewController.swift diff --git a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj index be6a11c..ceea8b3 100644 --- a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj +++ b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj @@ -11,6 +11,7 @@ 0B000CEB2B4D9D9100AEC582 /* SelectTotalTimeController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B000CEA2B4D9D9100AEC582 /* SelectTotalTimeController.swift */; }; 0B000CED2B4D9DA800AEC582 /* ApprovePermisionController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B000CEC2B4D9DA800AEC582 /* ApprovePermisionController.swift */; }; 0B000CEF2B4D9DBF00AEC582 /* AppChoiceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B000CEE2B4D9DBF00AEC582 /* AppChoiceController.swift */; }; + 0B000CF12B4DA30F00AEC582 /* AppSelectViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B000CF02B4DA30F00AEC582 /* AppSelectViewController.swift */; }; 0B0035402B43D64D00DA140C /* HMHNavigationBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B00353F2B43D64D00DA140C /* HMHNavigationBar.swift */; }; 0B2C2D3B2B443BE90023CCFA /* Image.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B2C2D3A2B443BE90023CCFA /* Image.swift */; }; 0B2C2D412B4572240023CCFA /* HMHSelectButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B2C2D402B4572240023CCFA /* HMHSelectButton.swift */; }; @@ -161,6 +162,7 @@ 0B000CEA2B4D9D9100AEC582 /* SelectTotalTimeController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectTotalTimeController.swift; sourceTree = ""; }; 0B000CEC2B4D9DA800AEC582 /* ApprovePermisionController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApprovePermisionController.swift; sourceTree = ""; }; 0B000CEE2B4D9DBF00AEC582 /* AppChoiceController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppChoiceController.swift; sourceTree = ""; }; + 0B000CF02B4DA30F00AEC582 /* AppSelectViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppSelectViewController.swift; sourceTree = ""; }; 0B00353F2B43D64D00DA140C /* HMHNavigationBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HMHNavigationBar.swift; sourceTree = ""; }; 0B2C2D3A2B443BE90023CCFA /* Image.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Image.swift; sourceTree = ""; }; 0B2C2D402B4572240023CCFA /* HMHSelectButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HMHSelectButton.swift; sourceTree = ""; }; @@ -304,6 +306,7 @@ 0B000CEA2B4D9D9100AEC582 /* SelectTotalTimeController.swift */, 0B000CEC2B4D9DA800AEC582 /* ApprovePermisionController.swift */, 0B000CEE2B4D9DBF00AEC582 /* AppChoiceController.swift */, + 0B000CF02B4DA30F00AEC582 /* AppSelectViewController.swift */, ); path = ViewControllers; sourceTree = ""; @@ -1065,6 +1068,7 @@ 0BC0EBD22B493B6B003EF5D4 /* OnboardingProgressView.swift in Sources */, 364C4E732B4BF27C0015729C /* AppAddCollectionReusableView.swift in Sources */, 17314F7F2B485E150089A551 /* CustomAlertButton.swift in Sources */, + 0B000CF12B4DA30F00AEC582 /* AppSelectViewController.swift in Sources */, 36A3D9BA2B3EBC65007EA272 /* UIButton+.swift in Sources */, 3666C88F2B471C5800564874 /* TabBarController.swift in Sources */, 36E05FE62B48825A005B633E /* AppCollectionReusableView.swift in Sources */, diff --git a/HMH_iOS/HMH_iOS/Global/Extension/UILabel+.swift b/HMH_iOS/HMH_iOS/Global/Extension/UILabel+.swift index c74ee8e..31d8316 100644 --- a/HMH_iOS/HMH_iOS/Global/Extension/UILabel+.swift +++ b/HMH_iOS/HMH_iOS/Global/Extension/UILabel+.swift @@ -34,4 +34,24 @@ extension UILabel { self.numberOfLines = 2 } } + + func setTextWithLineHeightLeft(text: String?, lineHeight: CGFloat) { + if let text = text { + let style = NSMutableParagraphStyle() + style.maximumLineHeight = lineHeight + style.minimumLineHeight = lineHeight + + let attributes: [NSAttributedString.Key: Any] = [ + .paragraphStyle: style, + .baselineOffset: (lineHeight - font.lineHeight) * 0.26 + ] + + let attrString = NSAttributedString(string: text, + attributes: attributes) + self.attributedText = attrString + self.textAlignment = .left + self.numberOfLines = 2 + } + } + } diff --git a/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift b/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift index 9ebb914..9f2bd7f 100644 --- a/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift +++ b/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift @@ -76,11 +76,17 @@ enum StringLiteral { static let timeSurvey = "하루 평균 휴대폰을\n얼마나 사용하나요?" static let problemSurvey = "휴대폰을 사용할 때\n어떤 문제를 겪고 있나요?" static let selectPeriod = "챌린지 기간을 선택해 주세요" + static let selectTotalTime = "총 목표 이용 시간을\n설정해 주세요" + static let approvePermision = "스크린타임 권한 허용이 필요해요" + static let appSelect = "중독에서 탈출하고 싶은\n앱을 선택해 주세요" } enum OnboardigSub { static let problemSurvey = "해당 문항은 최대 2개까지 선택할 수 있어요" static let selectPeriod = "첫 챌린지로 가볍게 도전하기 좋은 7일을 추천해요" + static let selectTotalTime = "목표 이용 시간은 최대 6시간까지 설정할 수 있어요" + static let approvePermision = "언제든지 설정에서 스크린타임 권한을\n변경할 수 있어요" + static let appSelect = "목표 이용 시간이 지나면 앱이 잠겨요\n선택하고 싶은 앱은 언제든지 추가할 수 있어요" } enum TimeSurveySelect { diff --git a/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/AppSelectViewController.swift b/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/AppSelectViewController.swift new file mode 100644 index 0000000..7e3e85e --- /dev/null +++ b/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/AppSelectViewController.swift @@ -0,0 +1,45 @@ +// +// AppSelectViewController.swift +// HMH_iOS +// +// Created by Seonwoo Kim on 1/10/24. +// + +import UIKit + +import SnapKit +import Then + +final class AppSelectViewController: OnboardingBaseViewController { + override func viewDidLoad() { + super.viewDidLoad() + configureSurveyView() + setDelegate() + setTimeSurvey() + } + + private func setDelegate() { + self.delegate = self + } + + private func setTimeSurvey() { + view.backgroundColor = .background + step = 5 + } + + private func configureSurveyView() { + nextButtonText = StringLiteral.OnboardingButton.permission + nextButton.setButtonText(buttonTitle: nextButtonText) + mainTitleText = StringLiteral.OnboardigMain.appSelect + subTitleText = StringLiteral.OnboardigSub.appSelect + } +} + +extension AppSelectViewController: NextViewPushDelegate { + func didTapButton() { + let nextViewController = AppSelectViewController() + self.navigationController?.pushViewController(nextViewController, animated: false) + } +} + + diff --git a/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/ApprovePermisionController.swift b/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/ApprovePermisionController.swift index ec86398..96b3745 100644 --- a/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/ApprovePermisionController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/ApprovePermisionController.swift @@ -11,35 +11,13 @@ import SnapKit import Then final class ApprovePermisionController: OnboardingBaseViewController { - private let surveyView = SurveyView(buttonType: .solitary) - override func viewDidLoad() { super.viewDidLoad() - setUI() configureSurveyView() setDelegate() setTimeSurvey() } - override func viewDidAppear(_ animated: Bool) { - setUI() - } - - private func setUI(){ - setHierarchy() - setConstraints() - } - - private func setHierarchy() { - view.addSubview(surveyView) - } - - private func setConstraints() { - surveyView.snp.makeConstraints { - $0.top.equalTo(mainTitleLabel.snp.bottom).offset(94.adjustedHeight) - $0.leading.trailing.equalTo(progressBar) - } - } private func setDelegate() { self.delegate = self @@ -51,20 +29,16 @@ final class ApprovePermisionController: OnboardingBaseViewController { } private func configureSurveyView() { - nextButtonText = StringLiteral.OnboardingButton.next + nextButtonText = StringLiteral.OnboardingButton.permission nextButton.setButtonText(buttonTitle: nextButtonText) - mainTitleText = StringLiteral.OnboardigMain.selectPeriod - subTitleText = StringLiteral.OnboardigSub.selectPeriod - surveyView.firstButton.setButtonText(buttonTitle: StringLiteral.PeriodSelect.firstSelect) - surveyView.secondButton.setButtonText(buttonTitle: StringLiteral.PeriodSelect.secondSelect) - surveyView.thirdButton.setButtonText(buttonTitle: StringLiteral.PeriodSelect.thirdSelect) - surveyView.fourthButton.setButtonText(buttonTitle: StringLiteral.PeriodSelect.fourthSelect) + mainTitleText = StringLiteral.OnboardigMain.approvePermision + subTitleText = StringLiteral.OnboardigSub.approvePermision } } extension ApprovePermisionController: NextViewPushDelegate { func didTapButton() { - let nextViewController = SelectTotalTimeController() + let nextViewController = AppSelectViewController() self.navigationController?.pushViewController(nextViewController, animated: false) } } diff --git a/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/SelectPeriodController.swift b/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/SelectPeriodController.swift index c11515f..e78088b 100644 --- a/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/SelectPeriodController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/SelectPeriodController.swift @@ -11,7 +11,7 @@ import SnapKit import Then final class SelectPeriodController: OnboardingBaseViewController { - private let surveyView = SurveyView(buttonType: .solitary) + private let surveyView = SurveyView(firstButtonType: .solitary, secondButtonType: .solitary, thirdButtonType: .disabled, fourthButtonType: .disabled) override func viewDidLoad() { super.viewDidLoad() diff --git a/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/SelectTotalTimeController.swift b/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/SelectTotalTimeController.swift index be84e1e..ec38715 100644 --- a/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/SelectTotalTimeController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/SelectTotalTimeController.swift @@ -11,8 +11,7 @@ import SnapKit import Then final class SelectTotalTimeController: OnboardingBaseViewController { - private let surveyView = SurveyView(buttonType: .solitary) - + private let pickerView = TotalTimePickerView() override func viewDidLoad() { super.viewDidLoad() setUI() @@ -31,11 +30,11 @@ final class SelectTotalTimeController: OnboardingBaseViewController { } private func setHierarchy() { - view.addSubview(surveyView) + view.addSubview(pickerView) } private func setConstraints() { - surveyView.snp.makeConstraints { + pickerView.snp.makeConstraints { $0.top.equalTo(mainTitleLabel.snp.bottom).offset(94.adjustedHeight) $0.leading.trailing.equalTo(progressBar) } @@ -53,12 +52,8 @@ final class SelectTotalTimeController: OnboardingBaseViewController { private func configureSurveyView() { nextButtonText = StringLiteral.OnboardingButton.next nextButton.setButtonText(buttonTitle: nextButtonText) - mainTitleText = StringLiteral.OnboardigMain.selectPeriod - subTitleText = StringLiteral.OnboardigSub.selectPeriod - surveyView.firstButton.setButtonText(buttonTitle: StringLiteral.PeriodSelect.firstSelect) - surveyView.secondButton.setButtonText(buttonTitle: StringLiteral.PeriodSelect.secondSelect) - surveyView.thirdButton.setButtonText(buttonTitle: StringLiteral.PeriodSelect.thirdSelect) - surveyView.fourthButton.setButtonText(buttonTitle: StringLiteral.PeriodSelect.fourthSelect) + mainTitleText = StringLiteral.OnboardigMain.selectTotalTime + subTitleText = StringLiteral.OnboardigSub.selectTotalTime } } diff --git a/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/OnboardingBaseViewControllers.swift b/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/OnboardingBaseViewControllers.swift index be95177..5b1c6c7 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/OnboardingBaseViewControllers.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/OnboardingBaseViewControllers.swift @@ -21,12 +21,13 @@ class OnboardingBaseViewController: UIViewController { $0.textColor = .whiteText $0.font = .iosTitle1Semibold22 $0.text = StringLiteral.OnboardingButton.next - $0.numberOfLines = 2 + $0.setTextWithLineHeightLeft(text: $0.text, lineHeight: 33) } private let subTitleLabel = UILabel().then { $0.textColor = .gray2 $0.font = .iosText6Medium14 $0.text = StringLiteral.OnboardingButton.next + $0.setTextWithLineHeightLeft(text: $0.text, lineHeight: 21) } var nextButtonText: String = StringLiteral.OnboardingButton.next var mainTitleText: String = "" @@ -87,7 +88,7 @@ class OnboardingBaseViewController: UIViewController { } subTitleLabel.snp.makeConstraints { - $0.top.equalTo(mainTitleLabel.snp.bottom).offset(4.adjusted) + $0.top.equalTo(mainTitleLabel.snp.bottom).offset(7.adjusted) $0.leading.equalTo(progressBar) } diff --git a/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/ProblemSurveyViewController.swift b/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/ProblemSurveyViewController.swift index 16ef9db..eb50dbe 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/ProblemSurveyViewController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/ProblemSurveyViewController.swift @@ -11,8 +11,7 @@ import SnapKit import Then final class ProblemSurveyViewController: OnboardingBaseViewController { - private let surveyView = SurveyView(buttonType: .multiple) - + private let surveyView = SurveyView(firstButtonType: .multiple, secondButtonType: .multiple, thirdButtonType: .multiple, fourthButtonType: .multiple) override func viewDidLoad() { super.viewDidLoad() setDelegate() diff --git a/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/TimeSurveyViewController.swift b/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/TimeSurveyViewController.swift index e7b2963..588efb6 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/TimeSurveyViewController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/TimeSurveyViewController.swift @@ -11,7 +11,7 @@ import SnapKit import Then final class TimeSurveyViewController: OnboardingBaseViewController { - private let surveyView = SurveyView(buttonType: .solitary) + private let surveyView = SurveyView(firstButtonType: .solitary, secondButtonType: .solitary, thirdButtonType: .solitary, fourthButtonType: .solitary) override func viewDidLoad() { super.viewDidLoad() diff --git a/HMH_iOS/HMH_iOS/Presentation/Onboarding/Views/SurveyView.swift b/HMH_iOS/HMH_iOS/Presentation/Onboarding/Views/SurveyView.swift index c854925..fc3e4c6 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Onboarding/Views/SurveyView.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Onboarding/Views/SurveyView.swift @@ -20,17 +20,25 @@ final class SurveyView: UIView { var secondButtonText: String = "" var thirdButtonText: String = "" var fourthButtonText: String = "" - var buttonType: HMHSelectButton.HMHSelectButtonType = .solitary + var firstButtonType: HMHSelectButton.HMHSelectButtonType = .solitary + var secondButtonType: HMHSelectButton.HMHSelectButtonType = .solitary + var thirdButtonType: HMHSelectButton.HMHSelectButtonType = .solitary + var fourthButtonType: HMHSelectButton.HMHSelectButtonType = .solitary - lazy var firstButton = HMHSelectButton(buttonType: buttonType) - lazy var secondButton = HMHSelectButton(buttonType: buttonType) - lazy var thirdButton = HMHSelectButton(buttonType: buttonType) - lazy var fourthButton = HMHSelectButton(buttonType: buttonType) + lazy var firstButton = HMHSelectButton(buttonType: firstButtonType) + lazy var secondButton = HMHSelectButton(buttonType: secondButtonType) + lazy var thirdButton = HMHSelectButton(buttonType: thirdButtonType) + lazy var fourthButton = HMHSelectButton(buttonType: fourthButtonType) - - init(buttonType: HMHSelectButton.HMHSelectButtonType) { + init(firstButtonType: HMHSelectButton.HMHSelectButtonType, + secondButtonType: HMHSelectButton.HMHSelectButtonType, + thirdButtonType: HMHSelectButton.HMHSelectButtonType, + fourthButtonType: HMHSelectButton.HMHSelectButtonType) { super.init(frame: .zero) - self.buttonType = buttonType + self.firstButtonType = firstButtonType + self.secondButtonType = secondButtonType + self.thirdButtonType = thirdButtonType + self.fourthButtonType = fourthButtonType setAddTarget() setUI() @@ -62,8 +70,4 @@ final class SurveyView: UIView { private func setAddTarget() { } - - func setButtonType(buttonType: HMHSelectButton.HMHSelectButtonType) { - self.buttonType = buttonType - } } From e6472dd62ca1f2159c22ea4819bf0c6e52fffaa7 Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Wed, 10 Jan 2024 06:09:31 +0900 Subject: [PATCH 034/101] =?UTF-8?q?[Feat/#42]=20Onboarding=20-=20=EB=B2=84?= =?UTF-8?q?=ED=8A=BC=20=ED=99=9C=EC=84=B1=ED=99=94=20=EA=B4=80=EB=A0=A8=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Common/UIComponets/HMHSelectButton.swift | 23 ++++++++++++++++++- .../OnboardingBaseViewControllers.swift | 15 +++++++++--- .../ProblemSurveyViewController.swift | 11 +++++++++ .../TimeSurveyViewController.swift | 12 ++++++++++ .../Onboarding/Views/OnboardingButton.swift | 2 +- 5 files changed, 58 insertions(+), 5 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/Common/UIComponets/HMHSelectButton.swift b/HMH_iOS/HMH_iOS/Presentation/Common/UIComponets/HMHSelectButton.swift index b9685f0..725ef38 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Common/UIComponets/HMHSelectButton.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Common/UIComponets/HMHSelectButton.swift @@ -4,6 +4,9 @@ // // Created by Seonwoo Kim on 1/3/24. // +protocol HMHSelectButtonDelegate: AnyObject { + func updateAvailability(isEnabled: Bool) +} import UIKit @@ -11,6 +14,8 @@ import SnapKit import Then final class HMHSelectButton: UIButton { + weak var delegate: HMHSelectButtonDelegate? + @frozen enum HMHSelectButtonType { case solitary @@ -105,14 +110,15 @@ final class HMHSelectButton: UIButton { } setChecked(true) + setAvailability() case .multiple: let selectedCount = (superview?.subviews.compactMap { ($0 as? HMHSelectButton)?.isChecked } ?? []).filter { $0 }.count if selectedCount < 2 || isChecked { setChecked(!isChecked) + setAvailability() } - case .disabled: return } @@ -121,4 +127,19 @@ final class HMHSelectButton: UIButton { func setButtonText(buttonTitle: String) { buttonContentLabel.text = buttonTitle } + + func setAvailability() { + if (superview?.subviews.compactMap { ($0 as? HMHSelectButton)?.isChecked } ?? []).filter { $0 }.count == 0 { + updateAvailability(status: false) + } else { + updateAvailability(status: true) + } + + } + + @objc + func updateAvailability(status: Bool) { + self.delegate?.updateAvailability(isEnabled: status) + print("tap") + } } diff --git a/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/OnboardingBaseViewControllers.swift b/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/OnboardingBaseViewControllers.swift index 5b1c6c7..cd9e067 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/OnboardingBaseViewControllers.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/OnboardingBaseViewControllers.swift @@ -16,7 +16,6 @@ protocol NextViewPushDelegate: AnyObject { class OnboardingBaseViewController: UIViewController { weak var delegate: NextViewPushDelegate? - let mainTitleLabel = UILabel().then { $0.textColor = .whiteText $0.font = .iosTitle1Semibold22 @@ -32,13 +31,13 @@ class OnboardingBaseViewController: UIViewController { var nextButtonText: String = StringLiteral.OnboardingButton.next var mainTitleText: String = "" var subTitleText: String = "" - let navigationBar = HMHNavigationBar(leftItem: .normal, + let navigationBar = HMHNavigationBar(leftItem: .normal, isBackButton: true, isTitleLabel: false, isPointImage: false, isBackGroundGray: false) let progressBar = ProgressBarManager.shared.progressBarView - lazy var nextButton = OnboardingButton(buttonStatus: .enabled) + lazy var nextButton = OnboardingButton(buttonStatus: .disabled) var step = 0 override func viewWillAppear(_ animated: Bool) { @@ -102,6 +101,16 @@ class OnboardingBaseViewController: UIViewController { func onTapButton() { self.delegate?.didTapButton() } + + func updateNextButtonStatus(buttonStatus: Bool) { + if buttonStatus { + self.nextButton.backgroundColor = .bluePurpleButton + self.nextButton.isEnabled = true + } else { + self.nextButton.backgroundColor = .gray4 + self.nextButton.isEnabled = false + } + } } diff --git a/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/ProblemSurveyViewController.swift b/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/ProblemSurveyViewController.swift index eb50dbe..a82e76c 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/ProblemSurveyViewController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/ProblemSurveyViewController.swift @@ -58,6 +58,11 @@ final class ProblemSurveyViewController: OnboardingBaseViewController { surveyView.secondButton.setButtonText(buttonTitle: StringLiteral.ProblemSurveySelect.secondSelect) surveyView.thirdButton.setButtonText(buttonTitle: StringLiteral.ProblemSurveySelect.thirdSelect) surveyView.fourthButton.setButtonText(buttonTitle: StringLiteral.ProblemSurveySelect.fourthSelect) + + surveyView.firstButton.delegate = self + surveyView.secondButton.delegate = self + surveyView.thirdButton.delegate = self + surveyView.fourthButton.delegate = self } } @@ -68,3 +73,9 @@ extension ProblemSurveyViewController: NextViewPushDelegate { } } +extension ProblemSurveyViewController: HMHSelectButtonDelegate { + func updateAvailability(isEnabled: Bool) { + print("taptap") + updateNextButtonStatus(buttonStatus: isEnabled) + } +} diff --git a/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/TimeSurveyViewController.swift b/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/TimeSurveyViewController.swift index 588efb6..32e8bd7 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/TimeSurveyViewController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/TimeSurveyViewController.swift @@ -58,6 +58,11 @@ final class TimeSurveyViewController: OnboardingBaseViewController { surveyView.secondButton.setButtonText(buttonTitle: StringLiteral.TimeSurveySelect.secondSelect) surveyView.thirdButton.setButtonText(buttonTitle: StringLiteral.TimeSurveySelect.thirdSelect) surveyView.fourthButton.setButtonText(buttonTitle: StringLiteral.TimeSurveySelect.fourthSelect) + + surveyView.firstButton.delegate = self + surveyView.secondButton.delegate = self + surveyView.thirdButton.delegate = self + surveyView.fourthButton.delegate = self } } @@ -67,3 +72,10 @@ extension TimeSurveyViewController: NextViewPushDelegate { self.navigationController?.pushViewController(nextViewController, animated: false) } } + +extension TimeSurveyViewController: HMHSelectButtonDelegate { + func updateAvailability(isEnabled: Bool) { + print("taptap") + updateNextButtonStatus(buttonStatus: isEnabled) + } +} diff --git a/HMH_iOS/HMH_iOS/Presentation/Onboarding/Views/OnboardingButton.swift b/HMH_iOS/HMH_iOS/Presentation/Onboarding/Views/OnboardingButton.swift index 3f0ddd1..cf443ae 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Onboarding/Views/OnboardingButton.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Onboarding/Views/OnboardingButton.swift @@ -17,7 +17,7 @@ final class OnboardingButton: UIButton { case disabled } - private var type: OnboardingButtonType = .disabled + var type: OnboardingButtonType = .disabled private let buttonTitleLabel = UILabel().then { $0.textColor = .whiteText From e1783b8595b76e17cbc6abd0b1d96b44946ce4fe Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Wed, 10 Jan 2024 16:20:40 +0900 Subject: [PATCH 035/101] =?UTF-8?q?[Feat/#42]=20PickerView=20-=20=EB=B2=84?= =?UTF-8?q?=ED=8A=BC=20=ED=99=9C=EC=84=B1=ED=99=94=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewControllers/SelectTotalTimeController.swift | 8 ++++++++ .../CreateChallenge/Views/TotalTimePickerView.swift | 9 ++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/SelectTotalTimeController.swift b/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/SelectTotalTimeController.swift index ec38715..db3a35d 100644 --- a/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/SelectTotalTimeController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/SelectTotalTimeController.swift @@ -42,6 +42,7 @@ final class SelectTotalTimeController: OnboardingBaseViewController { private func setDelegate() { self.delegate = self + pickerView.totalTimePickerDelegate = self } private func setTimeSurvey() { @@ -63,3 +64,10 @@ extension SelectTotalTimeController: NextViewPushDelegate { self.navigationController?.pushViewController(nextViewController, animated: false) } } + +extension SelectTotalTimeController: TotalTimePickerDelegate { + func updateAvailability() { + nextButton.updateStatus(isEnabled: true) + } +} + diff --git a/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/Views/TotalTimePickerView.swift b/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/Views/TotalTimePickerView.swift index 2d54704..a07ccd1 100644 --- a/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/Views/TotalTimePickerView.swift +++ b/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/Views/TotalTimePickerView.swift @@ -10,7 +10,13 @@ import UIKit import SnapKit import Then +protocol TotalTimePickerDelegate: AnyObject { + func updateAvailability() +} + final class TotalTimePickerView: UIPickerView { + weak var totalTimePickerDelegate: TotalTimePickerDelegate? + private let hours: [String] = ["1", "2", "3", "4", "5", "6"] private let titleLabel = UILabel().then { @@ -43,7 +49,7 @@ final class TotalTimePickerView: UIPickerView { private func setConstraints() { titleLabel.snp.makeConstraints { $0.centerY.equalToSuperview() - $0.trailing.equalToSuperview().inset(124.adjusted) + $0.trailing.equalToSuperview().inset(110.adjusted) } } @@ -68,6 +74,7 @@ extension TotalTimePickerView: UIPickerViewDelegate { func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { self.reloadComponent(component) + self.totalTimePickerDelegate?.updateAvailability() } func pickerView(_ pickerView: UIPickerView, attributedTitleForRow row: Int, forComponent component: Int) -> NSAttributedString? { From 8d5ebc87f0da8ca41c99d8c38072cff1e38f24f2 Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Wed, 10 Jan 2024 16:21:29 +0900 Subject: [PATCH 036/101] =?UTF-8?q?[Delete/#42]=20CreateChallenge=20-=20?= =?UTF-8?q?=EB=B6=88=ED=95=84=EC=9A=94=ED=95=9C=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj | 4 ---- .../ViewControllers/AppChoiceController.swift | 8 -------- 2 files changed, 12 deletions(-) delete mode 100644 HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/AppChoiceController.swift diff --git a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj index ceea8b3..168e9f4 100644 --- a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj +++ b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj @@ -10,7 +10,6 @@ 0B000CE92B4D9D6E00AEC582 /* SelectPeriodController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B000CE82B4D9D6E00AEC582 /* SelectPeriodController.swift */; }; 0B000CEB2B4D9D9100AEC582 /* SelectTotalTimeController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B000CEA2B4D9D9100AEC582 /* SelectTotalTimeController.swift */; }; 0B000CED2B4D9DA800AEC582 /* ApprovePermisionController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B000CEC2B4D9DA800AEC582 /* ApprovePermisionController.swift */; }; - 0B000CEF2B4D9DBF00AEC582 /* AppChoiceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B000CEE2B4D9DBF00AEC582 /* AppChoiceController.swift */; }; 0B000CF12B4DA30F00AEC582 /* AppSelectViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B000CF02B4DA30F00AEC582 /* AppSelectViewController.swift */; }; 0B0035402B43D64D00DA140C /* HMHNavigationBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B00353F2B43D64D00DA140C /* HMHNavigationBar.swift */; }; 0B2C2D3B2B443BE90023CCFA /* Image.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B2C2D3A2B443BE90023CCFA /* Image.swift */; }; @@ -161,7 +160,6 @@ 0B000CE82B4D9D6E00AEC582 /* SelectPeriodController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectPeriodController.swift; sourceTree = ""; }; 0B000CEA2B4D9D9100AEC582 /* SelectTotalTimeController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectTotalTimeController.swift; sourceTree = ""; }; 0B000CEC2B4D9DA800AEC582 /* ApprovePermisionController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApprovePermisionController.swift; sourceTree = ""; }; - 0B000CEE2B4D9DBF00AEC582 /* AppChoiceController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppChoiceController.swift; sourceTree = ""; }; 0B000CF02B4DA30F00AEC582 /* AppSelectViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppSelectViewController.swift; sourceTree = ""; }; 0B00353F2B43D64D00DA140C /* HMHNavigationBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HMHNavigationBar.swift; sourceTree = ""; }; 0B2C2D3A2B443BE90023CCFA /* Image.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Image.swift; sourceTree = ""; }; @@ -305,7 +303,6 @@ 0B000CE82B4D9D6E00AEC582 /* SelectPeriodController.swift */, 0B000CEA2B4D9D9100AEC582 /* SelectTotalTimeController.swift */, 0B000CEC2B4D9DA800AEC582 /* ApprovePermisionController.swift */, - 0B000CEE2B4D9DBF00AEC582 /* AppChoiceController.swift */, 0B000CF02B4DA30F00AEC582 /* AppSelectViewController.swift */, ); path = ViewControllers; @@ -1008,7 +1005,6 @@ 36E05FE42B487911005B633E /* GrayBackgroundView.swift in Sources */, 0B50F9CF2B369813000C5046 /* HomeViewController.swift in Sources */, 0B2C2D412B4572240023CCFA /* HMHSelectButton.swift in Sources */, - 0B000CEF2B4D9DBF00AEC582 /* AppChoiceController.swift in Sources */, 0B8A89BC2B369F2D00688BA6 /* UIView+.swift in Sources */, 0B8A89AF2B369E4300688BA6 /* HomeModel.swift in Sources */, 3666C89F2B485C8F00564874 /* DateCollectionViewCell.swift in Sources */, diff --git a/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/AppChoiceController.swift b/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/AppChoiceController.swift deleted file mode 100644 index 1665fff..0000000 --- a/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/AppChoiceController.swift +++ /dev/null @@ -1,8 +0,0 @@ -// -// AppChoiceController.swift -// HMH_iOS -// -// Created by Seonwoo Kim on 1/10/24. -// - -import Foundation From f54708bcd1c62c9bc5fb9f2876c9338bb5460e78 Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Wed, 10 Jan 2024 16:30:31 +0900 Subject: [PATCH 037/101] =?UTF-8?q?[Chore/#42]=20CreateChallenge=20-=20?= =?UTF-8?q?=EC=9E=90=EC=9E=98=ED=95=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Common/UIComponets/HMHSelectButton.swift | 10 ++++------ .../ViewControllers/SelectPeriodController.swift | 11 +++++++++++ .../OnboardingBaseViewControllers.swift | 12 +----------- .../ProblemSurveyViewController.swift | 9 ++++++--- .../ViewControllers/TimeSurveyViewController.swift | 3 +-- .../Onboarding/Views/OnboardingButton.swift | 10 ++++++++++ 6 files changed, 33 insertions(+), 22 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/Common/UIComponets/HMHSelectButton.swift b/HMH_iOS/HMH_iOS/Presentation/Common/UIComponets/HMHSelectButton.swift index 725ef38..f31028d 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Common/UIComponets/HMHSelectButton.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Common/UIComponets/HMHSelectButton.swift @@ -4,15 +4,16 @@ // // Created by Seonwoo Kim on 1/3/24. // -protocol HMHSelectButtonDelegate: AnyObject { - func updateAvailability(isEnabled: Bool) -} import UIKit import SnapKit import Then +protocol HMHSelectButtonDelegate: AnyObject { + func updateAvailability(isEnabled: Bool) +} + final class HMHSelectButton: UIButton { weak var delegate: HMHSelectButtonDelegate? @@ -134,12 +135,9 @@ final class HMHSelectButton: UIButton { } else { updateAvailability(status: true) } - } - @objc func updateAvailability(status: Bool) { self.delegate?.updateAvailability(isEnabled: status) - print("tap") } } diff --git a/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/SelectPeriodController.swift b/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/SelectPeriodController.swift index e78088b..7b47f5f 100644 --- a/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/SelectPeriodController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/SelectPeriodController.swift @@ -59,6 +59,11 @@ final class SelectPeriodController: OnboardingBaseViewController { surveyView.secondButton.setButtonText(buttonTitle: StringLiteral.PeriodSelect.secondSelect) surveyView.thirdButton.setButtonText(buttonTitle: StringLiteral.PeriodSelect.thirdSelect) surveyView.fourthButton.setButtonText(buttonTitle: StringLiteral.PeriodSelect.fourthSelect) + + surveyView.firstButton.delegate = self + surveyView.secondButton.delegate = self + surveyView.thirdButton.delegate = self + surveyView.fourthButton.delegate = self } } @@ -68,3 +73,9 @@ extension SelectPeriodController: NextViewPushDelegate { self.navigationController?.pushViewController(nextViewController, animated: false) } } + +extension SelectPeriodController: HMHSelectButtonDelegate { + func updateAvailability(isEnabled: Bool) { + nextButton.updateStatus(isEnabled: isEnabled) + } +} diff --git a/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/OnboardingBaseViewControllers.swift b/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/OnboardingBaseViewControllers.swift index cd9e067..28ced65 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/OnboardingBaseViewControllers.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/OnboardingBaseViewControllers.swift @@ -18,7 +18,7 @@ class OnboardingBaseViewController: UIViewController { weak var delegate: NextViewPushDelegate? let mainTitleLabel = UILabel().then { $0.textColor = .whiteText - $0.font = .iosTitle1Semibold22 + $0.font = .iosTitle3Semibold22 $0.text = StringLiteral.OnboardingButton.next $0.setTextWithLineHeightLeft(text: $0.text, lineHeight: 33) } @@ -101,16 +101,6 @@ class OnboardingBaseViewController: UIViewController { func onTapButton() { self.delegate?.didTapButton() } - - func updateNextButtonStatus(buttonStatus: Bool) { - if buttonStatus { - self.nextButton.backgroundColor = .bluePurpleButton - self.nextButton.isEnabled = true - } else { - self.nextButton.backgroundColor = .gray4 - self.nextButton.isEnabled = false - } - } } diff --git a/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/ProblemSurveyViewController.swift b/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/ProblemSurveyViewController.swift index a82e76c..8b52e3d 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/ProblemSurveyViewController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/ProblemSurveyViewController.swift @@ -11,7 +11,11 @@ import SnapKit import Then final class ProblemSurveyViewController: OnboardingBaseViewController { - private let surveyView = SurveyView(firstButtonType: .multiple, secondButtonType: .multiple, thirdButtonType: .multiple, fourthButtonType: .multiple) + private let surveyView = SurveyView(firstButtonType: .multiple, + secondButtonType: .multiple, + thirdButtonType: .multiple, + fourthButtonType: .multiple) + override func viewDidLoad() { super.viewDidLoad() setDelegate() @@ -75,7 +79,6 @@ extension ProblemSurveyViewController: NextViewPushDelegate { extension ProblemSurveyViewController: HMHSelectButtonDelegate { func updateAvailability(isEnabled: Bool) { - print("taptap") - updateNextButtonStatus(buttonStatus: isEnabled) + nextButton.updateStatus(isEnabled: isEnabled) } } diff --git a/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/TimeSurveyViewController.swift b/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/TimeSurveyViewController.swift index 32e8bd7..759bbcb 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/TimeSurveyViewController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/TimeSurveyViewController.swift @@ -75,7 +75,6 @@ extension TimeSurveyViewController: NextViewPushDelegate { extension TimeSurveyViewController: HMHSelectButtonDelegate { func updateAvailability(isEnabled: Bool) { - print("taptap") - updateNextButtonStatus(buttonStatus: isEnabled) + nextButton.updateStatus(isEnabled: isEnabled) } } diff --git a/HMH_iOS/HMH_iOS/Presentation/Onboarding/Views/OnboardingButton.swift b/HMH_iOS/HMH_iOS/Presentation/Onboarding/Views/OnboardingButton.swift index cf443ae..3898af4 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Onboarding/Views/OnboardingButton.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Onboarding/Views/OnboardingButton.swift @@ -73,5 +73,15 @@ final class OnboardingButton: UIButton { func setButtonText(buttonTitle: String) { buttonTitleLabel.text = buttonTitle } + + func updateStatus(isEnabled: Bool) { + if isEnabled { + self.isEnabled = true + self.backgroundColor = .bluePurpleButton + } else { + self.isEnabled = false + self.backgroundColor = .gray5 + } + } } From db07ad4b1a33bb44e2edaf7b6f82036f5cf693b3 Mon Sep 17 00:00:00 2001 From: Zoe <68178395+Zoe0929@users.noreply.github.com> Date: Thu, 11 Jan 2024 00:01:02 +0900 Subject: [PATCH 038/101] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 51cea08..590220a 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ 챌린지와 특정 앱 스크린타임 제한 기능을 이용해 건강한 디지털 습관을 형성해주는 서비스입니다. ## 🍎 HMH-iOS Team +![아요햄](https://github.com/Team-HMH/HMH-iOS/assets/68178395/3a51e265-723b-48a1-b91a-baed208f73e4) + | 👑 이지희 | 김선우 | 김보연 | | :--------: | :--------: | :--------: | | | | | From 1255bf2255919d543301e42bb9be860235fa6259 Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Thu, 11 Jan 2024 00:37:09 +0900 Subject: [PATCH 039/101] =?UTF-8?q?[Add/#49]=20Onboarding=20-=20SignInComp?= =?UTF-8?q?leteViewController=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj | 4 + .../SignInCompleteViewController.swift | 89 +++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/SignInCompleteViewController.swift diff --git a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj index 168e9f4..6fc1f6e 100644 --- a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj +++ b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj @@ -38,6 +38,7 @@ 0BC0EBD42B494459003EF5D4 /* OnboardingSwipeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BC0EBD32B494459003EF5D4 /* OnboardingSwipeView.swift */; }; 0BD98DB92B4D671600E35188 /* SplashViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BD98DB82B4D671600E35188 /* SplashViewController.swift */; }; 0BD98DBE2B4D6AB700E35188 /* LoginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BD98DBD2B4D6AB700E35188 /* LoginViewController.swift */; }; + 0BFD2FB42B4EE71900C6327F /* SignInCompleteViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BFD2FB32B4EE71900C6327F /* SignInCompleteViewController.swift */; }; 17314F7F2B485E150089A551 /* CustomAlertButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17314F7E2B485E150089A551 /* CustomAlertButton.swift */; }; 17314F832B486BEC0089A551 /* AlertViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17314F822B486BEC0089A551 /* AlertViewController.swift */; }; 17314F852B497FDE0089A551 /* HMHLogoutAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17314F842B497FDE0089A551 /* HMHLogoutAlert.swift */; }; @@ -190,6 +191,7 @@ 0BC0EBD32B494459003EF5D4 /* OnboardingSwipeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingSwipeView.swift; sourceTree = ""; }; 0BD98DB82B4D671600E35188 /* SplashViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplashViewController.swift; sourceTree = ""; }; 0BD98DBD2B4D6AB700E35188 /* LoginViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginViewController.swift; sourceTree = ""; }; + 0BFD2FB32B4EE71900C6327F /* SignInCompleteViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignInCompleteViewController.swift; sourceTree = ""; }; 17314F7E2B485E150089A551 /* CustomAlertButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomAlertButton.swift; sourceTree = ""; }; 17314F822B486BEC0089A551 /* AlertViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertViewController.swift; sourceTree = ""; }; 17314F842B497FDE0089A551 /* HMHLogoutAlert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HMHLogoutAlert.swift; sourceTree = ""; }; @@ -417,6 +419,7 @@ 0B78174D2B4BD96D0078E925 /* OnboardingBaseViewControllers.swift */, 0BA193B32B4D089C007E3F9C /* TimeSurveyViewController.swift */, 0BA193B52B4D08B7007E3F9C /* ProblemSurveyViewController.swift */, + 0BFD2FB32B4EE71900C6327F /* SignInCompleteViewController.swift */, ); path = ViewControllers; sourceTree = ""; @@ -1050,6 +1053,7 @@ 17314FAF2B4D3E1C0089A551 /* LogoutAndQuitFooterView.swift in Sources */, 0B78174E2B4BD96D0078E925 /* OnboardingBaseViewControllers.swift in Sources */, 0B8A89B12B369E4C00688BA6 /* HomeView.swift in Sources */, + 0BFD2FB42B4EE71900C6327F /* SignInCompleteViewController.swift in Sources */, 36A3D9B62B3EBBF7007EA272 /* Adjust+.swift in Sources */, 36A3D9BC2B3EBD2D007EA272 /* UIScreen+.swift in Sources */, 0B7817502B4BD9F10078E925 /* OnboardingButton.swift in Sources */, diff --git a/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/SignInCompleteViewController.swift b/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/SignInCompleteViewController.swift new file mode 100644 index 0000000..6daf4af --- /dev/null +++ b/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/SignInCompleteViewController.swift @@ -0,0 +1,89 @@ +// +// SignInSuccessViewController.swift +// HMH_iOS +// +// Created by Seonwoo Kim on 1/10/24. +// + +import UIKit + +import SnapKit +import Then + +final class SignInCompleteViewController: OnboardingBaseViewController { + private let SignInMainLabel = UILabel().then { + $0.textColor = .whiteText + $0.font = .iosTitle3Semibold22 + $0.text = StringLiteral.OnboardigMain.signInComplete + } + private let SignInSubLabel = UILabel().then { + $0.textColor = .gray2 + $0.font = .iosText6Medium14 + $0.text = StringLiteral.OnboardigSub.signInComplete + $0.setTextWithLineHeight(text: $0.text, lineHeight: 21) + } + + private let SignInImageView = UIImageView().then { + $0.image = ImageLiterals.myPage.icBadge + $0.contentMode = .scaleAspectFit + } + + override func viewDidLoad() { + super.viewDidLoad() + configureBaseView() + setDelegate() + setUI() + } + + private func setUI() { + setHierarchy() + setConstraints() + } + + private func setHierarchy() { + view.addSubviews(SignInMainLabel,SignInSubLabel,SignInImageView) + } + + private func setConstraints() { + SignInImageView.snp.makeConstraints { + $0.top.equalTo(navigationBar.snp.bottom).offset(126.adjustedHeight) + $0.size.equalTo(150.adjusted) + $0.centerX.equalToSuperview() + } + + SignInMainLabel.snp.makeConstraints { + $0.centerX.equalToSuperview() + $0.top.equalTo(SignInImageView.snp.bottom).offset(27.adjustedHeight) + } + + SignInSubLabel.snp.makeConstraints { + $0.centerX.equalToSuperview() + $0.top.equalTo(SignInMainLabel.snp.bottom).offset(8.adjustedHeight) + } + } + + private func setDelegate() { + self.delegate = self + } + + private func configureBaseView() { + view.backgroundColor = .background + progressBar.isHidden = true + nextButton.setButtonText(buttonTitle: StringLiteral.OnboardingButton.confirm) + nextButton.updateStatus(isEnabled: true) + } +} + +extension SignInCompleteViewController: NextViewPushDelegate { + func didTapButton() { + let nextViewController = TabBarController() + let navigationController = UINavigationController(rootViewController: nextViewController) + let sceneDelegate = UIApplication.shared.connectedScenes.first?.delegate as? SceneDelegate + guard let delegate = sceneDelegate else { + return + } + delegate.window?.rootViewController = navigationController + } +} + + From 9859c56d1166f2d59fb9f99b742046940bd564e2 Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Thu, 11 Jan 2024 00:37:53 +0900 Subject: [PATCH 040/101] =?UTF-8?q?[Feat/#49]=20String=20-=20SignInComplet?= =?UTF-8?q?e=20string=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS/Global/Literals/String/String.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift b/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift index 9f2bd7f..ff7ccba 100644 --- a/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift +++ b/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift @@ -79,6 +79,7 @@ enum StringLiteral { static let selectTotalTime = "총 목표 이용 시간을\n설정해 주세요" static let approvePermision = "스크린타임 권한 허용이 필요해요" static let appSelect = "중독에서 탈출하고 싶은\n앱을 선택해 주세요" + static let signInComplete = "회원가입 완료" } enum OnboardigSub { @@ -87,6 +88,7 @@ enum StringLiteral { static let selectTotalTime = "목표 이용 시간은 최대 6시간까지 설정할 수 있어요" static let approvePermision = "언제든지 설정에서 스크린타임 권한을\n변경할 수 있어요" static let appSelect = "목표 이용 시간이 지나면 앱이 잠겨요\n선택하고 싶은 앱은 언제든지 추가할 수 있어요" + static let signInComplete = "이제 하면함에서 블랙홀 탈출을 위한\n여정을 시작해 볼까요?" } enum TimeSurveySelect { From 90b6bdad8d20a9b15c383ec731ed9b5cc52b7a91 Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Thu, 11 Jan 2024 03:19:45 +0900 Subject: [PATCH 041/101] =?UTF-8?q?[Fix/#49]=20SignIn=20-=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=EB=A6=AC=EB=B7=B0=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SignInCompleteViewController.swift | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/SignInCompleteViewController.swift b/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/SignInCompleteViewController.swift index 6daf4af..44cb594 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/SignInCompleteViewController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/SignInCompleteViewController.swift @@ -11,19 +11,20 @@ import SnapKit import Then final class SignInCompleteViewController: OnboardingBaseViewController { - private let SignInMainLabel = UILabel().then { + + private let signInMainLabel = UILabel().then { $0.textColor = .whiteText $0.font = .iosTitle3Semibold22 $0.text = StringLiteral.OnboardigMain.signInComplete } - private let SignInSubLabel = UILabel().then { + private let signInSubLabel = UILabel().then { $0.textColor = .gray2 $0.font = .iosText6Medium14 $0.text = StringLiteral.OnboardigSub.signInComplete $0.setTextWithLineHeight(text: $0.text, lineHeight: 21) } - private let SignInImageView = UIImageView().then { + private let signInImageView = UIImageView().then { $0.image = ImageLiterals.myPage.icBadge $0.contentMode = .scaleAspectFit } @@ -41,24 +42,24 @@ final class SignInCompleteViewController: OnboardingBaseViewController { } private func setHierarchy() { - view.addSubviews(SignInMainLabel,SignInSubLabel,SignInImageView) + view.addSubviews(signInMainLabel,signInSubLabel,signInImageView) } private func setConstraints() { - SignInImageView.snp.makeConstraints { + signInImageView.snp.makeConstraints { $0.top.equalTo(navigationBar.snp.bottom).offset(126.adjustedHeight) $0.size.equalTo(150.adjusted) $0.centerX.equalToSuperview() } - SignInMainLabel.snp.makeConstraints { + signInMainLabel.snp.makeConstraints { $0.centerX.equalToSuperview() - $0.top.equalTo(SignInImageView.snp.bottom).offset(27.adjustedHeight) + $0.top.equalTo(signInImageView.snp.bottom).offset(27.adjustedHeight) } - SignInSubLabel.snp.makeConstraints { + signInSubLabel.snp.makeConstraints { $0.centerX.equalToSuperview() - $0.top.equalTo(SignInMainLabel.snp.bottom).offset(8.adjustedHeight) + $0.top.equalTo(signInMainLabel.snp.bottom).offset(8.adjustedHeight) } } From d901e1093c5027f842c85ff7b70855e7a618e73f Mon Sep 17 00:00:00 2001 From: Zoe Date: Thu, 11 Jan 2024 03:54:27 +0900 Subject: [PATCH 042/101] [Feat/#51] Challenge - Delete Button Add target --- .../AppCollectionReusableView.swift | 2 +- .../Challenge/Views/ChallengeView.swift | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/Challenge/Cells/HeaderFooterView/AppCollectionReusableView.swift b/HMH_iOS/HMH_iOS/Presentation/Challenge/Cells/HeaderFooterView/AppCollectionReusableView.swift index e3197a7..4500d3a 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Challenge/Cells/HeaderFooterView/AppCollectionReusableView.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Challenge/Cells/HeaderFooterView/AppCollectionReusableView.swift @@ -21,7 +21,7 @@ final class AppCollectionReusableView: UICollectionReusableView { $0.setTextWithLineHeight(text: $0.text, lineHeight: 24) } - private let deleteButton = UIButton().then { + let deleteButton = UIButton().then { $0.setTitle(StringLiteral.Challenge.AppList.appListHeaderButtonText, for: .normal) $0.titleLabel?.font = .iosText4Semibold16 diff --git a/HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift b/HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift index 450c64b..7f5dd69 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift @@ -14,7 +14,7 @@ final class ChallengeView: UIView { private let goalTime: Int = 3 private var days: Int = 7 - private let appList: [AppModel] = [AppModel(appIcon: "", appName: "Instagram", appUseTime: "1시간 20분"), + private var appList: [AppModel] = [AppModel(appIcon: "", appName: "Instagram", appUseTime: "1시간 20분"), AppModel(appIcon: "", appName: "Youtube", appUseTime: "1시간")] lazy var challengeCollectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()).then { @@ -30,7 +30,6 @@ final class ChallengeView: UIView { setRegister() configureView() configreCollectionView() - addTarget() } required init?(coder: NSCoder) { @@ -77,7 +76,10 @@ final class ChallengeView: UIView { challengeCollectionView.dataSource = self } - func addTarget() {} + @objc private func deleteButtonTapped() { + + } +} } extension ChallengeView: UICollectionViewDataSource { @@ -124,9 +126,12 @@ extension ChallengeView: UICollectionViewDataSource { else { return UICollectionReusableView() } return header } else if kind == StringLiteral.Challenge.Idetifier.appListHeaderViewId { - guard let header = collectionView.dequeueReusableSupplementaryView(ofKind: StringLiteral.Challenge.Idetifier.appListHeaderViewId, withReuseIdentifier: AppCollectionReusableView.identifier, for: indexPath) as? AppCollectionReusableView + if let header = collectionView.dequeueReusableSupplementaryView(ofKind: StringLiteral.Challenge.Idetifier.appListHeaderViewId, withReuseIdentifier: AppCollectionReusableView.identifier, for: indexPath) as? AppCollectionReusableView { + header.deleteButton.addTarget(self, action: #selector(deleteButtonTapped), for: .touchUpInside) + return header + } else { return UICollectionReusableView() } - return header + } else if kind == StringLiteral.Challenge.Idetifier.appAddFooterViewID { guard let footer = collectionView.dequeueReusableSupplementaryView(ofKind: StringLiteral.Challenge.Idetifier.appAddFooterViewID, withReuseIdentifier: AppAddCollectionReusableView.identifier, for: indexPath) as? AppAddCollectionReusableView else { return UICollectionReusableView() } From 323b85196530146412769d17b12413d67d2b33d7 Mon Sep 17 00:00:00 2001 From: Zoe Date: Thu, 11 Jan 2024 04:05:12 +0900 Subject: [PATCH 043/101] =?UTF-8?q?[Chore/#51]=20=EC=97=90=EB=9F=AC=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift b/HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift index 7f5dd69..fc2e110 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift @@ -80,7 +80,6 @@ final class ChallengeView: UIView { } } -} extension ChallengeView: UICollectionViewDataSource { From 879b0e33f2fb835695153b9ed667de067c24b14b Mon Sep 17 00:00:00 2001 From: boyeon Date: Thu, 11 Jan 2024 05:48:07 +0900 Subject: [PATCH 044/101] =?UTF-8?q?[Add/#44]=20Literals=20-=20home=20?= =?UTF-8?q?=EB=A6=AC=ED=84=B0=EB=9F=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS/Global/Literals/String/String.swift | 6 ++++++ .../Home/Cells/AppUsingProgressViewCell.swift | 12 ++++++++++++ .../Presentation/Home/Cells/BlackHoleImageCell.swift | 12 ++++++++++++ .../Presentation/Home/Cells/MyGoalTimeCell.swift | 12 ++++++++++++ .../Presentation/Home/Models/AppUsingTimeModel.swift | 8 ++++++++ .../Presentation/Home/Views/HMHHomeView.swift | 8 ++++++++ .../Presentation/Home/Views/MyGoalTimeView.swift | 8 ++++++++ 7 files changed, 66 insertions(+) create mode 100644 HMH_iOS/HMH_iOS/Presentation/Home/Cells/AppUsingProgressViewCell.swift create mode 100644 HMH_iOS/HMH_iOS/Presentation/Home/Cells/BlackHoleImageCell.swift create mode 100644 HMH_iOS/HMH_iOS/Presentation/Home/Cells/MyGoalTimeCell.swift create mode 100644 HMH_iOS/HMH_iOS/Presentation/Home/Models/AppUsingTimeModel.swift create mode 100644 HMH_iOS/HMH_iOS/Presentation/Home/Views/HMHHomeView.swift create mode 100644 HMH_iOS/HMH_iOS/Presentation/Home/Views/MyGoalTimeView.swift diff --git a/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift b/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift index cc09bc6..f05441f 100644 --- a/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift +++ b/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift @@ -14,6 +14,12 @@ enum StringLiteral { static var myPageTitle = "마이페이지" } + enum Home { + static var blackHoleState = "블랙홀에 빠지지 않고\n우주를 유지해 보아요" + + static var totalGoalUsingTime = "총 목표 이용 시간" + } + enum Challenge { static var NavigationBarTitle = "나의 챌린지" enum Date { diff --git a/HMH_iOS/HMH_iOS/Presentation/Home/Cells/AppUsingProgressViewCell.swift b/HMH_iOS/HMH_iOS/Presentation/Home/Cells/AppUsingProgressViewCell.swift new file mode 100644 index 0000000..df3a4f7 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Presentation/Home/Cells/AppUsingProgressViewCell.swift @@ -0,0 +1,12 @@ +// +// AppUsingProgressViewCell.swift +// HMH_iOS +// +// Created by 김보연 on 1/11/24. +// + +import UIKit + +class AppUsingProgressViewCell: UICollectionViewCell { + +} diff --git a/HMH_iOS/HMH_iOS/Presentation/Home/Cells/BlackHoleImageCell.swift b/HMH_iOS/HMH_iOS/Presentation/Home/Cells/BlackHoleImageCell.swift new file mode 100644 index 0000000..9951d36 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Presentation/Home/Cells/BlackHoleImageCell.swift @@ -0,0 +1,12 @@ +// +// BlackHoleImageCell.swift +// HMH_iOS +// +// Created by 김보연 on 1/11/24. +// + +import UIKit + +class BlackHoleImageCell: UICollectionViewCell { + +} diff --git a/HMH_iOS/HMH_iOS/Presentation/Home/Cells/MyGoalTimeCell.swift b/HMH_iOS/HMH_iOS/Presentation/Home/Cells/MyGoalTimeCell.swift new file mode 100644 index 0000000..48411ac --- /dev/null +++ b/HMH_iOS/HMH_iOS/Presentation/Home/Cells/MyGoalTimeCell.swift @@ -0,0 +1,12 @@ +// +// MyGoalTimeCell.swift +// HMH_iOS +// +// Created by 김보연 on 1/11/24. +// + +import UIKit + +class MyGoalTimeCell: UICollectionViewCell { + +} diff --git a/HMH_iOS/HMH_iOS/Presentation/Home/Models/AppUsingTimeModel.swift b/HMH_iOS/HMH_iOS/Presentation/Home/Models/AppUsingTimeModel.swift new file mode 100644 index 0000000..f00966c --- /dev/null +++ b/HMH_iOS/HMH_iOS/Presentation/Home/Models/AppUsingTimeModel.swift @@ -0,0 +1,8 @@ +// +// AppUsingTimeModel.swift +// HMH_iOS +// +// Created by 김보연 on 1/10/24. +// + +import Foundation diff --git a/HMH_iOS/HMH_iOS/Presentation/Home/Views/HMHHomeView.swift b/HMH_iOS/HMH_iOS/Presentation/Home/Views/HMHHomeView.swift new file mode 100644 index 0000000..ecc1c87 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Presentation/Home/Views/HMHHomeView.swift @@ -0,0 +1,8 @@ +// +// HMHHomeView.swift +// HMH_iOS +// +// Created by 김보연 on 1/10/24. +// + +import Foundation diff --git a/HMH_iOS/HMH_iOS/Presentation/Home/Views/MyGoalTimeView.swift b/HMH_iOS/HMH_iOS/Presentation/Home/Views/MyGoalTimeView.swift new file mode 100644 index 0000000..8a973fd --- /dev/null +++ b/HMH_iOS/HMH_iOS/Presentation/Home/Views/MyGoalTimeView.swift @@ -0,0 +1,8 @@ +// +// MyGoalTime.swift +// HMH_iOS +// +// Created by 김보연 on 1/10/24. +// + +import Foundation From 6716043fb2dd8ca77183c66f2c0c468fa4bc58f9 Mon Sep 17 00:00:00 2001 From: boyeon Date: Thu, 11 Jan 2024 05:50:08 +0900 Subject: [PATCH 045/101] =?UTF-8?q?[Feat/#44]=20HomeCell=20-=20=EA=B0=9C?= =?UTF-8?q?=EB=B3=84=EC=95=B1=20=ED=94=84=EB=A1=9C=EA=B7=B8=EB=9E=98?= =?UTF-8?q?=EC=8A=A4=20=EB=B7=B0=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Home/Cells/AppUsingProgressViewCell.swift | 157 +++++++++++++++++- 1 file changed, 156 insertions(+), 1 deletion(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/Home/Cells/AppUsingProgressViewCell.swift b/HMH_iOS/HMH_iOS/Presentation/Home/Cells/AppUsingProgressViewCell.swift index df3a4f7..6b4b737 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Home/Cells/AppUsingProgressViewCell.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Home/Cells/AppUsingProgressViewCell.swift @@ -7,6 +7,161 @@ import UIKit -class AppUsingProgressViewCell: UICollectionViewCell { +import SnapKit +import Then + +final class AppUsingProgressViewCell: UICollectionViewCell { + + static let identifier = "AppUsingProgressViewCell" + + private let appStackView = UIStackView().then { + $0.axis = .horizontal + $0.spacing = 9 + $0.alignment = .center + } + private let appIconImageView = UIImageView().then { + $0.backgroundColor = .whiteBtn + $0.makeCornerRound(radius: 6.adjusted) + } + private let appLabelStackView = UIStackView().then { + $0.axis = .vertical + $0.spacing = 5 + $0.alignment = .leading + } + private let appNameLabel = UILabel().then { + $0.font = .iosDetail3Semibold12 + $0.textColor = .gray1 + $0.textAlignment = .left + } + private var appGoalTimeLabel = UILabel().then { + $0.font = .iosDetail2Semibold13 + $0.textColor = .whiteText + $0.textAlignment = .left + } + private let remainedTimeStackView = UIStackView().then { + $0.axis = .horizontal + $0.spacing = 5 + $0.alignment = .center + } + private let appRemainedTimeLabel = UILabel().then { + $0.font = .iosText4Semibold16 + $0.textColor = .whiteText + $0.textAlignment = .right + } + private let remainedTimeUnitLabel = UILabel().then { + $0.font = .iosText6Medium14 + $0.textColor = .gray2 + $0.textAlignment = .center + $0.text = "남음" + } + lazy var appProgressBar = UIProgressView().then { + $0.trackTintColor = .gray7 + $0.progressTintColor = .bluePurpleOpacity70 + $0.makeCornerRound(radius: 6.adjusted) + } + + override init(frame: CGRect) { + super.init(frame: frame) + setUI() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + private func setUI() { + setHierarchy() + setConstraints() + } + + private func setHierarchy() { + self.addSubview(appProgressBar) + appProgressBar.addSubviews(appStackView, remainedTimeStackView) + appStackView.addArrangeSubViews([appIconImageView, appLabelStackView]) + appLabelStackView.addArrangeSubViews([appNameLabel, appGoalTimeLabel]) + remainedTimeStackView.addArrangeSubViews([appRemainedTimeLabel, remainedTimeUnitLabel]) + } + + private func setConstraints() { + appProgressBar.snp.makeConstraints { + $0.height.equalTo(75.adjusted) + $0.horizontalEdges.equalToSuperview().inset(20) + } + + appStackView.snp.makeConstraints { + $0.leading.equalToSuperview().inset(18.adjusted) + $0.centerY.equalToSuperview() + } + + appIconImageView.snp.makeConstraints { + $0.size.equalTo(40) + } + + remainedTimeStackView.snp.makeConstraints { + $0.trailing.equalToSuperview().inset(19.adjusted) + $0.centerY.equalToSuperview() + } + } + + func bindData(data: AppUsingTimeModel) { + self.appGoalTimeLabel.text = "\(HourOrMinuteConvert(data: data))시간" + self.appRemainedTimeLabel.text = "\(finalTimeConvert(data: data))분" + self.appNameLabel.text = data.usingAppName + self.appIconImageView.image = data.usingAppIcon + updateProgressBar(data: data) + HourOrMinuteConvert(data: data) + finalTimeConvert(data: data) + + appProgressBar.setProgress(0, animated: false) + DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) { + let progress = Float(data.usedTime) / Float(data.appGoalTime) + self.appProgressBar.setProgress(progress, animated: true) + } + } + + func convertMillisecondsToHoursAndMinutes(milliseconds: Int) -> (hours: Int, minutes: Int) { + let totalMinutes = milliseconds / (1000 * 60) + let hours = totalMinutes / 60 + let remainingMinutes = totalMinutes % 60 + return (hours, remainingMinutes) + } + + func updateProgressBar(data: AppUsingTimeModel) { + if data.appGoalTime != 0 { + let progress = Float(data.usedTime) / Float(data.appGoalTime) + appProgressBar.progress = progress + } else { + appProgressBar.progress = 0.0 + } + + if data.usedTime >= data.appGoalTime { + appProgressBar.progress = 1 + } + } + + func HourOrMinuteConvert(data: AppUsingTimeModel) { + let convertedGoalTime = convertMillisecondsToHoursAndMinutes(milliseconds: data.appGoalTime) + if convertedGoalTime.hours == 0 { + self.appGoalTimeLabel.text = "\(convertedGoalTime.minutes)분" + } else if convertedGoalTime.minutes == 0 { + self.appGoalTimeLabel.text = "\(convertedGoalTime.hours)시간" + } else { + self.appGoalTimeLabel.text = "\(convertedGoalTime.hours)시간 \(convertedGoalTime.minutes)분" + } + } + func finalTimeConvert(data: AppUsingTimeModel) { + let appRemainedTime = max(0, Int(data.appGoalTime) - Int(data.usedTime)) + let convertedTime = convertMillisecondsToHoursAndMinutes(milliseconds: appRemainedTime) + + if convertedTime.hours == 0 { + appRemainedTimeLabel.text = "\(convertedTime.minutes)분" + } else { + appRemainedTimeLabel.text = "\(convertedTime.hours)시간 \(convertedTime.minutes)분" + } + + if data.usedTime >= data.appGoalTime { + appRemainedTimeLabel.text = "남은 시간 없음" + } + } } From 89a8561546ac36c7f1b8d4a2dca22ed86893dad2 Mon Sep 17 00:00:00 2001 From: boyeon Date: Thu, 11 Jan 2024 05:50:42 +0900 Subject: [PATCH 046/101] =?UTF-8?q?[Feat/#44]=20HomeCell=20-=20=EC=A0=84?= =?UTF-8?q?=EC=B2=B4=20=EB=AA=A9=ED=91=9C=20=EC=8B=9C=EA=B0=84=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EB=9E=98=EC=8A=A4=EB=B0=94=20=EB=B7=B0=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Home/Cells/MyGoalTimeCell.swift | 127 +++++++++++++++++- 1 file changed, 126 insertions(+), 1 deletion(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/Home/Cells/MyGoalTimeCell.swift b/HMH_iOS/HMH_iOS/Presentation/Home/Cells/MyGoalTimeCell.swift index 48411ac..fbc5c88 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Home/Cells/MyGoalTimeCell.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Home/Cells/MyGoalTimeCell.swift @@ -7,6 +7,131 @@ import UIKit -class MyGoalTimeCell: UICollectionViewCell { +import SnapKit +import Then + +final class MyGoalTimeCell: UICollectionViewCell { + + static let identifier = "MyGoalTimeCell" + + private let totalGoalTimeLabel = UILabel().then { + $0.font = .iosDetail4Medium12 + $0.text = StringLiteral.Home.totalGoalUsingTime + $0.textColor = .gray1 + } + private let goalTimeLabel = UILabel().then { + $0.font = .iosTitle2Semibold24 + $0.text = "3시간" + $0.textColor = .whiteText + } + private let usableLabel = UILabel().then { + $0.font = .iosDetail3Semibold12 + $0.textColor = .whiteText + } + private let remainTimeLabel = UILabel().then { + $0.font = .iosDetail4Medium12 + $0.text = "남음" + $0.textColor = .gray1 + } + lazy var totalProgressBar = UIProgressView().then { + $0.trackTintColor = .gray3 + $0.progressTintColor = .whiteText + } + + override init(frame: CGRect) { + super.init(frame: frame) + setUI() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + private func setUI() { + setHierarchy() + setConstraints() + } + + private func setHierarchy() { + self.addSubviews(totalGoalTimeLabel, goalTimeLabel, usableLabel, remainTimeLabel, totalProgressBar) + } + + private func setConstraints() { + totalGoalTimeLabel.snp.makeConstraints { + $0.top.equalToSuperview() + $0.leading.equalToSuperview().inset(20) + } + + goalTimeLabel.snp.makeConstraints { + $0.top.equalTo(totalGoalTimeLabel.snp.bottom).offset(10) + $0.leading.equalToSuperview().inset(20) + } + + usableLabel.snp.makeConstraints { + $0.top.equalToSuperview().inset(38) + $0.trailing.equalTo(remainTimeLabel.snp.leading).offset(-5) + } + + remainTimeLabel.snp.makeConstraints { + $0.top.equalToSuperview().inset(38) + $0.trailing.equalToSuperview().inset(20) + } + + totalProgressBar.snp.makeConstraints { + $0.height.equalTo(6) + $0.top.equalTo(remainTimeLabel.snp.bottom).offset(17) + $0.leading.trailing.equalToSuperview().inset(20) + } + } + var totalTime: Int = 21600000 + + func bindData(data: [AppUsingTimeModel]) { + self.usableLabel.text = "\(convertMillisecondsToHoursAndMinutes(milliseconds: calculateTotalUsageTime(data: data)))분" + finalTimeConvert(data: data) + updateTotalUsageTime(data: data) + + totalProgressBar.setProgress(0, animated: false) + DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { + let progress = Float(self.calculateTotalUsageTime(data: data)) / Float(self.totalTime) + self.totalProgressBar.setProgress(progress, animated: true) + } + } + + func calculateTotalUsageTime(data: [AppUsingTimeModel]) -> Int { + return data.reduce(0) { $0 + Int($1.usedTime) } + } + + func convertMillisecondsToHoursAndMinutes(milliseconds: Int) -> (hours: Int, minutes: Int) { + let totalMinutes = milliseconds / (1000 * 60) + let hours = totalMinutes / 60 + let remainingMinutes = totalMinutes % 60 + return (hours, remainingMinutes) + } + + func updateTotalUsageTime(data: [AppUsingTimeModel]) { + let totalProgress = Float(calculateTotalUsageTime(data: data)) / Float(totalTime) + DispatchQueue.main.async { + self.totalProgressBar.progress = totalProgress + if self.calculateTotalUsageTime(data: data) >= self.totalTime { + self.totalProgressBar.progress = 1 + } + } + } + + func finalTimeConvert(data: [AppUsingTimeModel]) { + let finalTime = max(0, Int(totalTime) - Int(calculateTotalUsageTime(data: data))) + let convertedTime = convertMillisecondsToHoursAndMinutes(milliseconds: finalTime) + + if convertedTime.hours == 0 && convertedTime.minutes == 0 { + usableLabel.text = "남은 시간 없음" + } else if convertedTime.hours == 0 { + usableLabel.text = "\(convertedTime.minutes)분" + } else if convertedTime.minutes == 0 { + usableLabel.text = "\(convertedTime.hours)시간" + } else { + usableLabel.text = "\(convertedTime.hours)시간 \(convertedTime.minutes)분" + } + } } + From 2c76f9b5e554fb2e51d95f41f859e2a0f6436195 Mon Sep 17 00:00:00 2001 From: boyeon Date: Thu, 11 Jan 2024 05:51:09 +0900 Subject: [PATCH 047/101] =?UTF-8?q?[Feat/#44]=20HomeModel=20-=20=EC=8B=9C?= =?UTF-8?q?=EA=B0=84=20=EB=8D=94=EB=AF=B8=EB=8D=B0=EC=9D=B4=ED=84=B0=20?= =?UTF-8?q?=EA=B5=AC=EC=B6=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Home/Models/AppUsingTimeModel.swift | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/Home/Models/AppUsingTimeModel.swift b/HMH_iOS/HMH_iOS/Presentation/Home/Models/AppUsingTimeModel.swift index f00966c..e627b15 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Home/Models/AppUsingTimeModel.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Home/Models/AppUsingTimeModel.swift @@ -5,4 +5,37 @@ // Created by 김보연 on 1/10/24. // -import Foundation +import UIKit + +struct AppUsingTimeModel { + + let appGoalTime: Int + let usingAppIcon: UIImage + let usingAppName: String + let usedTime: Int + + init(appGoalTime: Int, usingAppIcon: UIImage, usingAppName: String, usedTime: Int) { + self.appGoalTime = appGoalTime + self.usingAppIcon = usingAppIcon + self.usingAppName = usingAppName + self.usedTime = usedTime + } +} + +var appUsingTimeModel: [AppUsingTimeModel] = [ + + .init(appGoalTime: 7200000, + usingAppIcon: ImageLiterals.TabBar.icHomeSelected, + usingAppName: "Instagram", + usedTime: 3200000), + + .init(appGoalTime: 2700000, + usingAppIcon: ImageLiterals.TabBar.icChallengeSelected, + usingAppName: "melon", + usedTime: 1500000), + + .init(appGoalTime: 9000000, + usingAppIcon: ImageLiterals.TabBar.icMyPageSelected, + usingAppName: "Netflix", + usedTime: 7900000), +] From c9a4d156e58d8b82257d914aedb0f214a29e89a6 Mon Sep 17 00:00:00 2001 From: boyeon Date: Thu, 11 Jan 2024 05:52:03 +0900 Subject: [PATCH 048/101] =?UTF-8?q?[Feat/#44]=20HomeCell=20-=20=EB=B8=94?= =?UTF-8?q?=EB=9E=99=ED=99=80=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=85=80=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Home/Cells/BlackHoleImageCell.swift | 47 ++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/Home/Cells/BlackHoleImageCell.swift b/HMH_iOS/HMH_iOS/Presentation/Home/Cells/BlackHoleImageCell.swift index 9951d36..d12d2ca 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Home/Cells/BlackHoleImageCell.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Home/Cells/BlackHoleImageCell.swift @@ -7,6 +7,51 @@ import UIKit -class BlackHoleImageCell: UICollectionViewCell { +import SnapKit +import Then + +final class BlackHoleImageCell: UICollectionViewCell { + + static let identifier = "BlackHoleImageCell" + + private let blackHoleImageView = UIImageView().then { + $0.image = ImageLiterals.TabBar.icHome + $0.alpha = 0.1 + } + private let homeBlackHoleStateLabel = UILabel().then { + $0.font = .iosTitle3Semibold22 + $0.textColor = .whiteText + $0.setTextWithLineHeight(text: StringLiteral.Home.blackHoleState, lineHeight: 33) + $0.numberOfLines = 2 + } + + override init(frame: CGRect) { + super.init(frame: frame) + setUI() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + private func setUI() { + setHierarchy() + setConstraints() + } + + private func setHierarchy() { + self.addSubviews(blackHoleImageView, homeBlackHoleStateLabel) + } + private func setConstraints() { + blackHoleImageView.snp.makeConstraints { + $0.top.horizontalEdges.equalToSuperview() + $0.height.equalTo(blackHoleImageView.snp.width) + } + + homeBlackHoleStateLabel.snp.makeConstraints { + $0.top.equalToSuperview().inset(23.adjusted) + $0.leading.equalToSuperview().inset(21.adjusted) + } + } } From 157b101bc70810d98f41e8ee90abd2ac49d7f717 Mon Sep 17 00:00:00 2001 From: boyeon Date: Thu, 11 Jan 2024 05:53:16 +0900 Subject: [PATCH 049/101] =?UTF-8?q?[Feat/#44]=20HomeView=20-=20=ED=99=88?= =?UTF-8?q?=20=EC=BB=AC=EB=9E=99=EC=85=98=20=EB=B7=B0=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewControllers/HomeViewController.swift | 28 +++- .../Presentation/Home/Views/HMHHomeView.swift | 121 +++++++++++++++++- .../Home/Views/MyGoalTimeView.swift | 8 -- 3 files changed, 145 insertions(+), 12 deletions(-) delete mode 100644 HMH_iOS/HMH_iOS/Presentation/Home/Views/MyGoalTimeView.swift diff --git a/HMH_iOS/HMH_iOS/Presentation/Home/ViewControllers/HomeViewController.swift b/HMH_iOS/HMH_iOS/Presentation/Home/ViewControllers/HomeViewController.swift index 550efc2..1a08238 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Home/ViewControllers/HomeViewController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Home/ViewControllers/HomeViewController.swift @@ -8,12 +8,34 @@ import UIKit final class HomeViewController: UIViewController { + private let navigationBar = HMHNavigationBar(leftItem: .logo, isBackButton: false, isTitleLabel: false, isPointImage: false, isBackGroundGray: false, titleText: "") + private let homeView = HMHHomeView() override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = .cyan + setUI() + } + + private func setUI() { + setHierarchy() + setConstraints() + + } + + private func setHierarchy() { + view.addSubviews(navigationBar, homeView) + } + + private func setConstraints() { + navigationBar.snp.makeConstraints { + $0.top.leading.trailing.equalToSuperview() + } + + homeView.snp.makeConstraints { + $0.top.equalTo(navigationBar.snp.bottom) + $0.bottom.horizontalEdges.equalToSuperview() + } } - - } + diff --git a/HMH_iOS/HMH_iOS/Presentation/Home/Views/HMHHomeView.swift b/HMH_iOS/HMH_iOS/Presentation/Home/Views/HMHHomeView.swift index ecc1c87..a20a763 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Home/Views/HMHHomeView.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Home/Views/HMHHomeView.swift @@ -5,4 +5,123 @@ // Created by 김보연 on 1/10/24. // -import Foundation +import UIKit + +import SnapKit +import Then + +final class HMHHomeView: UIView { + private let homeCollectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()).then { + $0.backgroundColor = .clear + } + + override init(frame: CGRect) { + super.init(frame: frame) + setUI() + configureView() + setRegister() + configreCollectionView() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + private func setUI() { + setHierarchy() + setConstraints() + } + + private func setHierarchy() { + self.addSubview(homeCollectionView) + } + + private func setConstraints() { + homeCollectionView.snp.makeConstraints { + $0.edges.equalToSuperview() + } + } + + private func configureView() { + self.backgroundColor = .background + } + + private func setRegister() { + homeCollectionView.register(BlackHoleImageCell.self, forCellWithReuseIdentifier: BlackHoleImageCell.identifier) + homeCollectionView.register(MyGoalTimeCell.self, forCellWithReuseIdentifier: MyGoalTimeCell.identifier) + homeCollectionView.register(AppUsingProgressViewCell.self, forCellWithReuseIdentifier: AppUsingProgressViewCell.identifier) + } + + private func configreCollectionView() { + homeCollectionView.showsVerticalScrollIndicator = false + homeCollectionView.delegate = self + homeCollectionView.dataSource = self + } +} + +extension HMHHomeView: UICollectionViewDelegate {} + +extension HMHHomeView: UICollectionViewDataSource { + func numberOfSections(in collectionView: UICollectionView) -> Int { + return 3 + } + + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + switch section { + case 0: + return 1 + case 1: + return 1 + case 2: + return appUsingTimeModel.count + default: + return 1 + } + } + + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + switch indexPath.section { + case 0: + guard let item = homeCollectionView.dequeueReusableCell(withReuseIdentifier: BlackHoleImageCell.identifier, for: indexPath) as? BlackHoleImageCell else { return UICollectionViewCell() } + return item + + case 1: + guard let item = homeCollectionView.dequeueReusableCell(withReuseIdentifier: MyGoalTimeCell.identifier, for: indexPath) as? MyGoalTimeCell else { return UICollectionViewCell() } + item.bindData(data: appUsingTimeModel) + return item + + case 2: + guard let item = homeCollectionView.dequeueReusableCell(withReuseIdentifier: AppUsingProgressViewCell.identifier, for: indexPath) as? AppUsingProgressViewCell else { return UICollectionViewCell() } + item.bindData(data: appUsingTimeModel[indexPath.row]) + return item + default: + return UICollectionViewCell() + } + } +} + +extension HMHHomeView: UICollectionViewDelegateFlowLayout { + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + switch indexPath.section { + case 0: + return CGSize(width: collectionView.frame.width, height: collectionView.frame.width) + case 1: + let itemWidthOrHeight: CGFloat = 90 + return CGSize(width: collectionView.frame.width, height: itemWidthOrHeight.adjusted) + case 2: + let itemWidthOrHeight: CGFloat = 80 + return CGSize(width: collectionView.frame.width, height: itemWidthOrHeight.adjusted) + default: + return CGSize(width: collectionView.frame.width, height: collectionView.frame.height) + } + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { + switch section { + case 1: + return UIEdgeInsets(top: -25.adjusted, left: 0, bottom: 16.adjusted, right: 0) + default: + return UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) + } + } +} diff --git a/HMH_iOS/HMH_iOS/Presentation/Home/Views/MyGoalTimeView.swift b/HMH_iOS/HMH_iOS/Presentation/Home/Views/MyGoalTimeView.swift deleted file mode 100644 index 8a973fd..0000000 --- a/HMH_iOS/HMH_iOS/Presentation/Home/Views/MyGoalTimeView.swift +++ /dev/null @@ -1,8 +0,0 @@ -// -// MyGoalTime.swift -// HMH_iOS -// -// Created by 김보연 on 1/10/24. -// - -import Foundation From e006bf08ccfc34b4bb39ad4a883b6e6234c41bb1 Mon Sep 17 00:00:00 2001 From: boyeon Date: Thu, 11 Jan 2024 05:54:39 +0900 Subject: [PATCH 050/101] =?UTF-8?q?[Chore/#44]=20=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=ED=8C=8C=EC=9D=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj index 0ea2714..d6e81e8 100644 --- a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj +++ b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj @@ -52,6 +52,11 @@ 174AF4982B447CF100450D07 /* ChanllengeModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 174AF4972B447CF100450D07 /* ChanllengeModels.swift */; }; 174AF49A2B447CFB00450D07 /* ChanllengeViews.swift in Sources */ = {isa = PBXBuildFile; fileRef = 174AF4992B447CFB00450D07 /* ChanllengeViews.swift */; }; 174AF49C2B447D0700450D07 /* ChallengeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 174AF49B2B447D0700450D07 /* ChallengeViewController.swift */; }; + 17CF9FBD2B4DC757000DD09C /* HMHHomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17CF9FBC2B4DC757000DD09C /* HMHHomeView.swift */; }; + 17CF9FC12B4DE2B6000DD09C /* AppUsingTimeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17CF9FC02B4DE2B6000DD09C /* AppUsingTimeModel.swift */; }; + 17CF9FC92B4EE964000DD09C /* AppUsingProgressViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17CF9FC82B4EE964000DD09C /* AppUsingProgressViewCell.swift */; }; + 17CF9FCF2B4F1A91000DD09C /* MyGoalTimeCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17CF9FCE2B4F1A91000DD09C /* MyGoalTimeCell.swift */; }; + 17CF9FD12B4F31C0000DD09C /* BlackHoleImageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17CF9FD02B4F31C0000DD09C /* BlackHoleImageCell.swift */; }; 364C4E712B4BC9780015729C /* AppAddButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 364C4E702B4BC9780015729C /* AppAddButtonView.swift */; }; 364C4E732B4BF27C0015729C /* AppAddCollectionReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 364C4E722B4BF27C0015729C /* AppAddCollectionReusableView.swift */; }; 3666C84D2B45F41300564874 /* HMHAppSelectButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3666C84C2B45F41300564874 /* HMHAppSelectButtonView.swift */; }; @@ -198,6 +203,11 @@ 174AF4972B447CF100450D07 /* ChanllengeModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChanllengeModels.swift; sourceTree = ""; }; 174AF4992B447CFB00450D07 /* ChanllengeViews.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChanllengeViews.swift; sourceTree = ""; }; 174AF49B2B447D0700450D07 /* ChallengeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeViewController.swift; sourceTree = ""; }; + 17CF9FBC2B4DC757000DD09C /* HMHHomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HMHHomeView.swift; sourceTree = ""; }; + 17CF9FC02B4DE2B6000DD09C /* AppUsingTimeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppUsingTimeModel.swift; sourceTree = ""; }; + 17CF9FC82B4EE964000DD09C /* AppUsingProgressViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppUsingProgressViewCell.swift; sourceTree = ""; }; + 17CF9FCE2B4F1A91000DD09C /* MyGoalTimeCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyGoalTimeCell.swift; sourceTree = ""; }; + 17CF9FD02B4F31C0000DD09C /* BlackHoleImageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlackHoleImageCell.swift; sourceTree = ""; }; 364C4E702B4BC9780015729C /* AppAddButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppAddButtonView.swift; sourceTree = ""; }; 364C4E722B4BF27C0015729C /* AppAddCollectionReusableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppAddCollectionReusableView.swift; sourceTree = ""; }; 3666C84C2B45F41300564874 /* HMHAppSelectButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HMHAppSelectButtonView.swift; sourceTree = ""; }; @@ -554,6 +564,7 @@ isa = PBXGroup; children = ( 0B8A89B02B369E4C00688BA6 /* HomeView.swift */, + 17CF9FBC2B4DC757000DD09C /* HMHHomeView.swift */, ); path = Views; sourceTree = ""; @@ -562,6 +573,7 @@ isa = PBXGroup; children = ( 0B8A89AE2B369E4300688BA6 /* HomeModel.swift */, + 17CF9FC02B4DE2B6000DD09C /* AppUsingTimeModel.swift */, ); path = Models; sourceTree = ""; @@ -570,6 +582,9 @@ isa = PBXGroup; children = ( 0B8A89AC2B369E3B00688BA6 /* HomeCell.swift */, + 17CF9FC82B4EE964000DD09C /* AppUsingProgressViewCell.swift */, + 17CF9FCE2B4F1A91000DD09C /* MyGoalTimeCell.swift */, + 17CF9FD02B4F31C0000DD09C /* BlackHoleImageCell.swift */, ); path = Cells; sourceTree = ""; @@ -956,6 +971,7 @@ 36A3D9C02B409CBD007EA272 /* Font.swift in Sources */, 174AF4902B447B3C00450D07 /* MyPageModels.swift in Sources */, 174AF4982B447CF100450D07 /* ChanllengeModels.swift in Sources */, + 17CF9FBD2B4DC757000DD09C /* HMHHomeView.swift in Sources */, 174AF48E2B447B1F00450D07 /* MyPageCells.swift in Sources */, 3666C8A52B48644A00564874 /* AppModel.swift in Sources */, 174AF4942B447B5500450D07 /* MyPageViewController.swift in Sources */, @@ -966,12 +982,14 @@ 0B8A89C42B369FA000688BA6 /* F.swift in Sources */, 3666C8892B47110800564874 /* TotalTimePickerView.swift in Sources */, 174AF49A2B447CFB00450D07 /* ChanllengeViews.swift in Sources */, + 17CF9FC92B4EE964000DD09C /* AppUsingProgressViewCell.swift in Sources */, 17314F872B49853C0089A551 /* HMHQuitAlert.swift in Sources */, 0BA193B62B4D08B7007E3F9C /* ProblemSurveyViewController.swift in Sources */, 0B8A89B72B369F1100688BA6 /* C.swift in Sources */, 0B2C2D3B2B443BE90023CCFA /* Image.swift in Sources */, 17314F852B497FDE0089A551 /* HMHLogoutAlert.swift in Sources */, 3666C84D2B45F41300564874 /* HMHAppSelectButtonView.swift in Sources */, + 17CF9FC12B4DE2B6000DD09C /* AppUsingTimeModel.swift in Sources */, 3666C8A32B4861A200564874 /* AppListCollectionViewCell.swift in Sources */, 0BA193B92B4D4097007E3F9C /* SignInModel.swift in Sources */, 0B8A89AD2B369E3B00688BA6 /* HomeCell.swift in Sources */, @@ -992,6 +1010,7 @@ 0B7817502B4BD9F10078E925 /* OnboardingButton.swift in Sources */, 0B50F9CD2B369813000C5046 /* SceneDelegate.swift in Sources */, 36A3D9B42B3EBBED007EA272 /* UIStackView+.swift in Sources */, + 17CF9FD12B4F31C0000DD09C /* BlackHoleImageCell.swift in Sources */, 364C4E712B4BC9780015729C /* AppAddButtonView.swift in Sources */, 174AF4962B447CE700450D07 /* ChanllengeCells.swift in Sources */, 17314F832B486BEC0089A551 /* AlertViewController.swift in Sources */, @@ -1005,6 +1024,7 @@ 3666C88F2B471C5800564874 /* TabBarController.swift in Sources */, 36E05FE62B48825A005B633E /* AppCollectionReusableView.swift in Sources */, 3666C88B2B471B0D00564874 /* String.swift in Sources */, + 17CF9FCF2B4F1A91000DD09C /* MyGoalTimeCell.swift in Sources */, 3666C89B2B48516500564874 /* ChallengeView.swift in Sources */, 3666C88D2B471B1D00564874 /* UIImage+.swift in Sources */, 3666C87C2B45F50F00564874 /* BlockingApplicationModel.swift in Sources */, From 1967ebd6ad8c78f114e523a128ac2d07ec492a36 Mon Sep 17 00:00:00 2001 From: Zoe Date: Thu, 11 Jan 2024 05:18:45 +0900 Subject: [PATCH 051/101] =?UTF-8?q?[Feat/#51]=20Challenge=20-=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20=EB=AA=A8=EB=93=9C=20UI=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Global/Literals/String/String.swift | 3 +- .../Cells/AppListCollectionViewCell.swift | 14 +++++++++ .../AppCollectionReusableView.swift | 29 +++++++++++++++---- .../Challenge/Views/ChallengeView.swift | 20 ++++++++++++- 4 files changed, 58 insertions(+), 8 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift b/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift index ff7ccba..af95360 100644 --- a/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift +++ b/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift @@ -22,7 +22,8 @@ enum StringLiteral { } enum AppList { static var appListHeaderTitle = "앱 잠금" - static var appListHeaderButtonText = "삭제" + static var appListDeleteHeaderButtonText = "삭제" + static var appListCancelHeaderButtonText = "취소" } enum Idetifier { static var titleHeaderViewId = "TitleSectionHeader" diff --git a/HMH_iOS/HMH_iOS/Presentation/Challenge/Cells/AppListCollectionViewCell.swift b/HMH_iOS/HMH_iOS/Presentation/Challenge/Cells/AppListCollectionViewCell.swift index 02f02c2..2c01b07 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Challenge/Cells/AppListCollectionViewCell.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Challenge/Cells/AppListCollectionViewCell.swift @@ -13,6 +13,15 @@ import Then final class AppListCollectionViewCell: UICollectionViewCell { static let identifer = "AppListCollectionViewCell" + var isSelectedCell = false { + didSet { + if isSelectedCell { + contentView.makeBorder(width: 1.3, color: .gray5) + } else { + contentView.makeBorder(width: 0, color: .clear) + } + } + } private let appImageView = UIImageView().then { $0.backgroundColor = .blue @@ -40,6 +49,11 @@ final class AppListCollectionViewCell: UICollectionViewCell { fatalError("init(coder:) has not been implemented") } + override func prepareForReuse() { + super.prepareForReuse() + self.makeBorder(width: 0, color: .gray5) + } + override func layoutSubviews() { super.layoutSubviews() } diff --git a/HMH_iOS/HMH_iOS/Presentation/Challenge/Cells/HeaderFooterView/AppCollectionReusableView.swift b/HMH_iOS/HMH_iOS/Presentation/Challenge/Cells/HeaderFooterView/AppCollectionReusableView.swift index 4500d3a..4244792 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Challenge/Cells/HeaderFooterView/AppCollectionReusableView.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Challenge/Cells/HeaderFooterView/AppCollectionReusableView.swift @@ -14,6 +14,12 @@ final class AppCollectionReusableView: UICollectionReusableView { static let identifier = "AppCollectionReusableView" + var isDeleteMode = false { + didSet { + configureButton() + } + } + private let titleLabel = UILabel().then { $0.text = StringLiteral.Challenge.AppList.appListHeaderTitle $0.font = .iosText5Medium16 @@ -21,15 +27,11 @@ final class AppCollectionReusableView: UICollectionReusableView { $0.setTextWithLineHeight(text: $0.text, lineHeight: 24) } - let deleteButton = UIButton().then { - $0.setTitle(StringLiteral.Challenge.AppList.appListHeaderButtonText, - for: .normal) - $0.titleLabel?.font = .iosText4Semibold16 - $0.setTitleColor(.bluePurpleText, for: .normal) - } + let deleteButton = UIButton() override init(frame: CGRect) { super.init(frame: frame) + configureButton() setUI() } @@ -56,4 +58,19 @@ final class AppCollectionReusableView: UICollectionReusableView { $0.centerY.equalTo(titleLabel.snp.centerY) } } + + private func configureButton() { + if isDeleteMode{ + deleteButton.setTitle(StringLiteral.Challenge.AppList.appListCancelHeaderButtonText, + for: .normal) + deleteButton.titleLabel?.font = .iosText4Semibold16 + deleteButton.setTitleColor(.gray4, for: .normal) + } else { + deleteButton.setTitle(StringLiteral.Challenge.AppList.appListDeleteHeaderButtonText, + for: .normal) + deleteButton.titleLabel?.font = .iosText4Semibold16 + deleteButton.setTitleColor(.bluePurpleText, for: .normal) + } + } + } diff --git a/HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift b/HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift index fc2e110..de91919 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift @@ -16,6 +16,11 @@ final class ChallengeView: UIView { private var days: Int = 7 private var appList: [AppModel] = [AppModel(appIcon: "", appName: "Instagram", appUseTime: "1시간 20분"), AppModel(appIcon: "", appName: "Youtube", appUseTime: "1시간")] + private var isDeleteMode: Bool = false { + didSet { + challengeCollectionView.reloadData() + } + } lazy var challengeCollectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()).then { $0.backgroundColor = .background @@ -77,7 +82,9 @@ final class ChallengeView: UIView { } @objc private func deleteButtonTapped() { - + isDeleteMode.toggle() + print(isDeleteMode) + challengeCollectionView.reloadData() } } @@ -112,6 +119,16 @@ extension ChallengeView: UICollectionViewDataSource { as? AppListCollectionViewCell else { return UICollectionViewCell() } + if isDeleteMode { + if indexPath.item == 0 { + cell.isSelectedCell = true + } + else { + cell.isSelectedCell = false + } + } else { + cell.isSelectedCell = false + } cell.configureCell(appName: appList[indexPath.item].appName, appTime: appList[indexPath.item].appUseTime) return cell default: @@ -127,6 +144,7 @@ extension ChallengeView: UICollectionViewDataSource { } else if kind == StringLiteral.Challenge.Idetifier.appListHeaderViewId { if let header = collectionView.dequeueReusableSupplementaryView(ofKind: StringLiteral.Challenge.Idetifier.appListHeaderViewId, withReuseIdentifier: AppCollectionReusableView.identifier, for: indexPath) as? AppCollectionReusableView { header.deleteButton.addTarget(self, action: #selector(deleteButtonTapped), for: .touchUpInside) + header.isDeleteMode = isDeleteMode return header } else { return UICollectionReusableView() } From e05e5681601c03997f77550dd1eabd9588279990 Mon Sep 17 00:00:00 2001 From: Zoe Date: Thu, 11 Jan 2024 06:49:00 +0900 Subject: [PATCH 052/101] =?UTF-8?q?[Feat/#51]=20Challenge=20-=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20=EB=AA=A8=EB=93=9C=20=EC=85=80=20=EC=84=A0=ED=83=9D?= =?UTF-8?q?=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChallengeViewController.swift | 33 +++++++++++++++++++ .../Challenge/Views/ChallengeView.swift | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/Challenge/ViewControllers/ChallengeViewController.swift b/HMH_iOS/HMH_iOS/Presentation/Challenge/ViewControllers/ChallengeViewController.swift index dea96cf..647fca0 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Challenge/ViewControllers/ChallengeViewController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Challenge/ViewControllers/ChallengeViewController.swift @@ -19,6 +19,7 @@ final class ChallengeViewController: UIViewController { isBackGroundGray: true, titleText: StringLiteral.Challenge.NavigationBarTitle) private let challengeView = ChallengeView() + private var selectedIndex = IndexPath() override func loadView() { self.view = challengeView @@ -27,6 +28,7 @@ final class ChallengeViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() setUI() + setDelegate() } private func setUI(){ @@ -44,4 +46,35 @@ final class ChallengeViewController: UIViewController { } } + private func setDelegate() { + challengeView.challengeCollectionView.delegate = self + } + +} + +extension ChallengeViewController: UICollectionViewDelegate { + func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool { + if let selectedIndexPath = collectionView.indexPathsForSelectedItems?.first { + if selectedIndexPath == indexPath { + return false + } + } + return true + } + + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + if selectedIndex == [] { + selectedIndex = [1,0] + } + if challengeView.isDeleteMode { + if let previousSelectedCell = collectionView.cellForItem(at: selectedIndex) as? AppListCollectionViewCell { + previousSelectedCell.isSelectedCell = false + } + if let currentSelectedCell = collectionView.cellForItem(at: indexPath) as? AppListCollectionViewCell { + currentSelectedCell.isSelectedCell = true + self.selectedIndex = indexPath + } + + } + } } diff --git a/HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift b/HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift index de91919..e11206e 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift @@ -16,7 +16,7 @@ final class ChallengeView: UIView { private var days: Int = 7 private var appList: [AppModel] = [AppModel(appIcon: "", appName: "Instagram", appUseTime: "1시간 20분"), AppModel(appIcon: "", appName: "Youtube", appUseTime: "1시간")] - private var isDeleteMode: Bool = false { + var isDeleteMode: Bool = false { didSet { challengeCollectionView.reloadData() } From 232d540978f2e985dc7c9a4b70f46555d6d38747 Mon Sep 17 00:00:00 2001 From: Zoe Date: Thu, 11 Jan 2024 06:52:14 +0900 Subject: [PATCH 053/101] =?UTF-8?q?[Chore/#51]=20Challenge=20-=20=ED=95=84?= =?UTF-8?q?=EC=9A=94=EC=97=86=EB=8A=94=20=EC=BD=94=EB=93=9C=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift b/HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift index e11206e..4e4ab61 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift @@ -83,7 +83,6 @@ final class ChallengeView: UIView { @objc private func deleteButtonTapped() { isDeleteMode.toggle() - print(isDeleteMode) challengeCollectionView.reloadData() } } From 0a919ce0523de12452cf61fe66677b5009b49a93 Mon Sep 17 00:00:00 2001 From: Zoe Date: Thu, 11 Jan 2024 07:07:20 +0900 Subject: [PATCH 054/101] [Chore/#51] Code convention --- HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift b/HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift index 4e4ab61..1acd2a3 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift @@ -147,7 +147,6 @@ extension ChallengeView: UICollectionViewDataSource { return header } else { return UICollectionReusableView() } - } else if kind == StringLiteral.Challenge.Idetifier.appAddFooterViewID { guard let footer = collectionView.dequeueReusableSupplementaryView(ofKind: StringLiteral.Challenge.Idetifier.appAddFooterViewID, withReuseIdentifier: AppAddCollectionReusableView.identifier, for: indexPath) as? AppAddCollectionReusableView else { return UICollectionReusableView() } From 1dbc788a0cfb1ccd6323ef7f523b96a2213a97b9 Mon Sep 17 00:00:00 2001 From: Zoe Date: Thu, 11 Jan 2024 07:23:17 +0900 Subject: [PATCH 055/101] [Set/#53] BaseURL Setting --- HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj | 14 +++++++++++ HMH_iOS/HMH_iOS/Info.plist | 2 ++ HMH_iOS/HMH_iOS/Network/Config.swift | 30 +++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 HMH_iOS/HMH_iOS/Network/Config.swift diff --git a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj index 6fc1f6e..81feaea 100644 --- a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj +++ b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj @@ -59,6 +59,7 @@ 174AF4982B447CF100450D07 /* ChanllengeModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 174AF4972B447CF100450D07 /* ChanllengeModels.swift */; }; 174AF49A2B447CFB00450D07 /* ChanllengeViews.swift in Sources */ = {isa = PBXBuildFile; fileRef = 174AF4992B447CFB00450D07 /* ChanllengeViews.swift */; }; 174AF49C2B447D0700450D07 /* ChallengeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 174AF49B2B447D0700450D07 /* ChallengeViewController.swift */; }; + 364923652B4F4FB800BF7ACA /* Config.swift in Sources */ = {isa = PBXBuildFile; fileRef = 364923642B4F4FB800BF7ACA /* Config.swift */; }; 364C4E712B4BC9780015729C /* AppAddButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 364C4E702B4BC9780015729C /* AppAddButtonView.swift */; }; 364C4E732B4BF27C0015729C /* AppAddCollectionReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 364C4E722B4BF27C0015729C /* AppAddCollectionReusableView.swift */; }; 3666C84D2B45F41300564874 /* HMHAppSelectButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3666C84C2B45F41300564874 /* HMHAppSelectButtonView.swift */; }; @@ -212,6 +213,8 @@ 174AF4972B447CF100450D07 /* ChanllengeModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChanllengeModels.swift; sourceTree = ""; }; 174AF4992B447CFB00450D07 /* ChanllengeViews.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChanllengeViews.swift; sourceTree = ""; }; 174AF49B2B447D0700450D07 /* ChallengeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeViewController.swift; sourceTree = ""; }; + 364923612B4F4E7D00BF7ACA /* Config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = ""; }; + 364923642B4F4FB800BF7ACA /* Config.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Config.swift; sourceTree = ""; }; 364C4E702B4BC9780015729C /* AppAddButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppAddButtonView.swift; sourceTree = ""; }; 364C4E722B4BF27C0015729C /* AppAddCollectionReusableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppAddCollectionReusableView.swift; sourceTree = ""; }; 3666C84C2B45F41300564874 /* HMHAppSelectButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HMHAppSelectButtonView.swift; sourceTree = ""; }; @@ -356,6 +359,7 @@ 0B50F9C92B369813000C5046 /* HMH_iOS */ = { isa = PBXGroup; children = ( + 364923612B4F4E7D00BF7ACA /* Config.xcconfig */, 3666C8772B45F4C600564874 /* HMH_iOS.entitlements */, 0B50F9D82B369815000C5046 /* Info.plist */, 0B67CCE32B369BB400582D54 /* Application */, @@ -394,6 +398,7 @@ 0B8A89A22B369DB600688BA6 /* Base */, 0B8A89A32B369DBE00688BA6 /* DataModel */, 0B8A89A42B369DCA00688BA6 /* Service */, + 364923642B4F4FB800BF7ACA /* Config.swift */, ); path = Network; sourceTree = ""; @@ -1066,6 +1071,7 @@ 0B8A89B32B369EF700688BA6 /* A.swift in Sources */, 17314F972B4C42130089A551 /* MyPageView.swift in Sources */, 0BC0EBD22B493B6B003EF5D4 /* OnboardingProgressView.swift in Sources */, + 364923652B4F4FB800BF7ACA /* Config.swift in Sources */, 364C4E732B4BF27C0015729C /* AppAddCollectionReusableView.swift in Sources */, 17314F7F2B485E150089A551 /* CustomAlertButton.swift in Sources */, 0B000CF12B4DA30F00AEC582 /* AppSelectViewController.swift in Sources */, @@ -1128,6 +1134,7 @@ /* Begin XCBuildConfiguration section */ 0B50F9D92B369815000C5046 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 364923612B4F4E7D00BF7ACA /* Config.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; @@ -1191,6 +1198,7 @@ }; 0B50F9DA2B369815000C5046 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 364923612B4F4E7D00BF7ACA /* Config.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; @@ -1247,6 +1255,7 @@ }; 0B50F9DC2B369815000C5046 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 364923612B4F4E7D00BF7ACA /* Config.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; @@ -1278,6 +1287,7 @@ }; 0B50F9DD2B369815000C5046 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 364923612B4F4E7D00BF7ACA /* Config.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; @@ -1309,6 +1319,7 @@ }; 3666C85F2B45F47600564874 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 364923612B4F4E7D00BF7ACA /* Config.xcconfig */; buildSettings = { CODE_SIGN_ENTITLEMENTS = DeviceMonitor/DeviceMonitor.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; @@ -1337,6 +1348,7 @@ }; 3666C8602B45F47600564874 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 364923612B4F4E7D00BF7ACA /* Config.xcconfig */; buildSettings = { CODE_SIGN_ENTITLEMENTS = DeviceMonitor/DeviceMonitor.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; @@ -1365,6 +1377,7 @@ }; 3666C8742B45F4B200564874 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 364923612B4F4E7D00BF7ACA /* Config.xcconfig */; buildSettings = { CODE_SIGN_ENTITLEMENTS = DeviceReport/DeviceReport.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; @@ -1393,6 +1406,7 @@ }; 3666C8752B45F4B200564874 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 364923612B4F4E7D00BF7ACA /* Config.xcconfig */; buildSettings = { CODE_SIGN_ENTITLEMENTS = DeviceReport/DeviceReport.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; diff --git a/HMH_iOS/HMH_iOS/Info.plist b/HMH_iOS/HMH_iOS/Info.plist index 54a3c5e..1c20cb8 100644 --- a/HMH_iOS/HMH_iOS/Info.plist +++ b/HMH_iOS/HMH_iOS/Info.plist @@ -2,6 +2,8 @@ + BASE_URL + $(BASE_URL) UIAppFonts Pretendard-Black.otf diff --git a/HMH_iOS/HMH_iOS/Network/Config.swift b/HMH_iOS/HMH_iOS/Network/Config.swift new file mode 100644 index 0000000..bc6ca62 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Network/Config.swift @@ -0,0 +1,30 @@ +// +// Config.swift +// HMH_iOS +// +// Created by 지희의 MAC on 1/11/24. +// + +import Foundation + +enum Config { + enum Keys { + enum Plist { + static let baseURL = "BASE_URL" + } + } + + private static let infoDictionary: [String: Any] = { + guard let dict = Bundle.main.infoDictionary else { + fatalError("plist cannot found.") + } + return dict + }() + + static let baseURL: String = { + guard let key = Config.infoDictionary[Keys.Plist.baseURL] as? String else { + fatalError("Base URL is not set in plist for this configuration.") + } + return key + }() +} From 43c99358a3d61cfad899fc076da2b6e42cb34c5c Mon Sep 17 00:00:00 2001 From: Zoe Date: Thu, 11 Jan 2024 07:37:06 +0900 Subject: [PATCH 056/101] [Add/#53] Add Package - Moya --- HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj | 22 +++++++++++++++ .../xcshareddata/swiftpm/Package.resolved | 27 +++++++++++++++++++ HMH_iOS/HMH_iOS/Network/Base/A.swift | 8 ------ 3 files changed, 49 insertions(+), 8 deletions(-) delete mode 100644 HMH_iOS/HMH_iOS/Network/Base/A.swift diff --git a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj index 81feaea..5f02026 100644 --- a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj +++ b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj @@ -60,6 +60,12 @@ 174AF49A2B447CFB00450D07 /* ChanllengeViews.swift in Sources */ = {isa = PBXBuildFile; fileRef = 174AF4992B447CFB00450D07 /* ChanllengeViews.swift */; }; 174AF49C2B447D0700450D07 /* ChallengeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 174AF49B2B447D0700450D07 /* ChallengeViewController.swift */; }; 364923652B4F4FB800BF7ACA /* Config.swift in Sources */ = {isa = PBXBuildFile; fileRef = 364923642B4F4FB800BF7ACA /* Config.swift */; }; + 364923682B4F513600BF7ACA /* BaseTargetType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 364923672B4F513600BF7ACA /* BaseTargetType.swift */; }; + 3649236A2B4F514A00BF7ACA /* Moya in Frameworks */ = {isa = PBXBuildFile; productRef = 364923692B4F514A00BF7ACA /* Moya */; }; + 3649236C2B4F517900BF7ACA /* NetworkError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3649236B2B4F517900BF7ACA /* NetworkError.swift */; }; + 3649236E2B4F519E00BF7ACA /* StatusCode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3649236D2B4F519E00BF7ACA /* StatusCode.swift */; }; + 364923702B4F524D00BF7ACA /* MoyaLoggerPlugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3649236F2B4F524D00BF7ACA /* MoyaLoggerPlugin.swift */; }; + 364923722B4F527200BF7ACA /* NetworkResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 364923712B4F527200BF7ACA /* NetworkResult.swift */; }; 364C4E712B4BC9780015729C /* AppAddButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 364C4E702B4BC9780015729C /* AppAddButtonView.swift */; }; 364C4E732B4BF27C0015729C /* AppAddCollectionReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 364C4E722B4BF27C0015729C /* AppAddCollectionReusableView.swift */; }; 3666C84D2B45F41300564874 /* HMHAppSelectButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3666C84C2B45F41300564874 /* HMHAppSelectButtonView.swift */; }; @@ -275,6 +281,7 @@ 36A3D8AC2B3AB5A1007EA272 /* KakaoSDKShare in Frameworks */, 36A3D8992B3AB58A007EA272 /* Then in Frameworks */, 36A3D8AE2B3AB5A1007EA272 /* KakaoSDKTalk in Frameworks */, + 3649236A2B4F514A00BF7ACA /* Moya in Frameworks */, 36A3D8B22B3AB5A1007EA272 /* KakaoSDKUser in Frameworks */, 36A3D8A02B3AB5A1007EA272 /* KakaoSDKCert in Frameworks */, 36A3D8B02B3AB5A1007EA272 /* KakaoSDKTemplate in Frameworks */, @@ -884,6 +891,7 @@ 36A3D8AD2B3AB5A1007EA272 /* KakaoSDKTalk */, 36A3D8AF2B3AB5A1007EA272 /* KakaoSDKTemplate */, 36A3D8B12B3AB5A1007EA272 /* KakaoSDKUser */, + 364923692B4F514A00BF7ACA /* Moya */, ); productName = HMH_iOS; productReference = 0B50F9C72B369813000C5046 /* HMH_iOS.app */; @@ -957,6 +965,7 @@ 36A3D8922B3AB57B007EA272 /* XCRemoteSwiftPackageReference "SnapKit" */, 36A3D8972B3AB58A007EA272 /* XCRemoteSwiftPackageReference "Then" */, 36A3D89A2B3AB5A1007EA272 /* XCRemoteSwiftPackageReference "kakao-ios-sdk" */, + 364923662B4F510E00BF7ACA /* XCRemoteSwiftPackageReference "Moya" */, ); productRefGroup = 0B50F9C82B369813000C5046 /* Products */; projectDirPath = ""; @@ -1475,6 +1484,14 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ + 364923662B4F510E00BF7ACA /* XCRemoteSwiftPackageReference "Moya" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/Moya/Moya"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 15.0.3; + }; + }; 36A3D8922B3AB57B007EA272 /* XCRemoteSwiftPackageReference "SnapKit" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/SnapKit/SnapKit.git"; @@ -1502,6 +1519,11 @@ /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ + 364923692B4F514A00BF7ACA /* Moya */ = { + isa = XCSwiftPackageProductDependency; + package = 364923662B4F510E00BF7ACA /* XCRemoteSwiftPackageReference "Moya" */; + productName = Moya; + }; 36A3D8932B3AB57B007EA272 /* SnapKit */ = { isa = XCSwiftPackageProductDependency; package = 36A3D8922B3AB57B007EA272 /* XCRemoteSwiftPackageReference "SnapKit" */; diff --git a/HMH_iOS/HMH_iOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/HMH_iOS/HMH_iOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 1e8b4ba..5ed1b91 100644 --- a/HMH_iOS/HMH_iOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/HMH_iOS/HMH_iOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -18,6 +18,33 @@ "version" : "2.20.0" } }, + { + "identity" : "moya", + "kind" : "remoteSourceControl", + "location" : "https://github.com/Moya/Moya", + "state" : { + "revision" : "c263811c1f3dbf002be9bd83107f7cdc38992b26", + "version" : "15.0.3" + } + }, + { + "identity" : "reactiveswift", + "kind" : "remoteSourceControl", + "location" : "https://github.com/ReactiveCocoa/ReactiveSwift.git", + "state" : { + "revision" : "c43bae3dac73fdd3cb906bd5a1914686ca71ed3c", + "version" : "6.7.0" + } + }, + { + "identity" : "rxswift", + "kind" : "remoteSourceControl", + "location" : "https://github.com/ReactiveX/RxSwift.git", + "state" : { + "revision" : "9dcaa4b333db437b0fbfaf453fad29069044a8b4", + "version" : "6.6.0" + } + }, { "identity" : "snapkit", "kind" : "remoteSourceControl", diff --git a/HMH_iOS/HMH_iOS/Network/Base/A.swift b/HMH_iOS/HMH_iOS/Network/Base/A.swift deleted file mode 100644 index 832e293..0000000 --- a/HMH_iOS/HMH_iOS/Network/Base/A.swift +++ /dev/null @@ -1,8 +0,0 @@ -// -// A.swift -// HMH_iOS -// -// Created by Seonwoo Kim on 12/23/23. -// - -import Foundation From 940bf9db8c7ebe4d2d04babfcff065e8e8913ff5 Mon Sep 17 00:00:00 2001 From: Zoe Date: Thu, 11 Jan 2024 07:37:38 +0900 Subject: [PATCH 057/101] =?UTF-8?q?[Set/#53]=20=EB=84=A4=ED=8A=B8=EC=9B=8C?= =?UTF-8?q?=ED=81=AC=20=EA=B8=B0=EB=B3=B8=20=EC=84=B8=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj | 19 +++-- .../HMH_iOS/Network/Base/BaseTargetType.swift | 32 +++++++++ .../Network/Base/MoyaLoggerPlugin.swift | 71 +++++++++++++++++++ .../HMH_iOS/Network/Base/NetworkError.swift | 15 ++++ .../HMH_iOS/Network/Base/NetworkResult.swift | 16 +++++ HMH_iOS/HMH_iOS/Network/Base/StatusCode.swift | 48 +++++++++++++ 6 files changed, 197 insertions(+), 4 deletions(-) create mode 100644 HMH_iOS/HMH_iOS/Network/Base/BaseTargetType.swift create mode 100644 HMH_iOS/HMH_iOS/Network/Base/MoyaLoggerPlugin.swift create mode 100644 HMH_iOS/HMH_iOS/Network/Base/NetworkError.swift create mode 100644 HMH_iOS/HMH_iOS/Network/Base/NetworkResult.swift create mode 100644 HMH_iOS/HMH_iOS/Network/Base/StatusCode.swift diff --git a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj index 5f02026..57f0b33 100644 --- a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj +++ b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj @@ -25,7 +25,6 @@ 0B8A89AD2B369E3B00688BA6 /* HomeCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B8A89AC2B369E3B00688BA6 /* HomeCell.swift */; }; 0B8A89AF2B369E4300688BA6 /* HomeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B8A89AE2B369E4300688BA6 /* HomeModel.swift */; }; 0B8A89B12B369E4C00688BA6 /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B8A89B02B369E4C00688BA6 /* HomeView.swift */; }; - 0B8A89B32B369EF700688BA6 /* A.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B8A89B22B369EF700688BA6 /* A.swift */; }; 0B8A89B52B369F0100688BA6 /* B.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B8A89B42B369F0100688BA6 /* B.swift */; }; 0B8A89B72B369F1100688BA6 /* C.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B8A89B62B369F1100688BA6 /* C.swift */; }; 0B8A89BC2B369F2D00688BA6 /* UIView+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B8A89BB2B369F2D00688BA6 /* UIView+.swift */; }; @@ -185,7 +184,6 @@ 0B8A89AC2B369E3B00688BA6 /* HomeCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeCell.swift; sourceTree = ""; }; 0B8A89AE2B369E4300688BA6 /* HomeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeModel.swift; sourceTree = ""; }; 0B8A89B02B369E4C00688BA6 /* HomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = ""; }; - 0B8A89B22B369EF700688BA6 /* A.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = A.swift; sourceTree = ""; }; 0B8A89B42B369F0100688BA6 /* B.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = B.swift; sourceTree = ""; }; 0B8A89B62B369F1100688BA6 /* C.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = C.swift; sourceTree = ""; }; 0B8A89BB2B369F2D00688BA6 /* UIView+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+.swift"; sourceTree = ""; }; @@ -221,6 +219,11 @@ 174AF49B2B447D0700450D07 /* ChallengeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeViewController.swift; sourceTree = ""; }; 364923612B4F4E7D00BF7ACA /* Config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = ""; }; 364923642B4F4FB800BF7ACA /* Config.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Config.swift; sourceTree = ""; }; + 364923672B4F513600BF7ACA /* BaseTargetType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseTargetType.swift; sourceTree = ""; }; + 3649236B2B4F517900BF7ACA /* NetworkError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkError.swift; sourceTree = ""; }; + 3649236D2B4F519E00BF7ACA /* StatusCode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusCode.swift; sourceTree = ""; }; + 3649236F2B4F524D00BF7ACA /* MoyaLoggerPlugin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoyaLoggerPlugin.swift; sourceTree = ""; }; + 364923712B4F527200BF7ACA /* NetworkResult.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkResult.swift; sourceTree = ""; }; 364C4E702B4BC9780015729C /* AppAddButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppAddButtonView.swift; sourceTree = ""; }; 364C4E722B4BF27C0015729C /* AppAddCollectionReusableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppAddCollectionReusableView.swift; sourceTree = ""; }; 3666C84C2B45F41300564874 /* HMHAppSelectButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HMHAppSelectButtonView.swift; sourceTree = ""; }; @@ -530,7 +533,11 @@ 0B8A89A22B369DB600688BA6 /* Base */ = { isa = PBXGroup; children = ( - 0B8A89B22B369EF700688BA6 /* A.swift */, + 364923672B4F513600BF7ACA /* BaseTargetType.swift */, + 3649236D2B4F519E00BF7ACA /* StatusCode.swift */, + 3649236B2B4F517900BF7ACA /* NetworkError.swift */, + 3649236F2B4F524D00BF7ACA /* MoyaLoggerPlugin.swift */, + 364923712B4F527200BF7ACA /* NetworkResult.swift */, ); path = Base; sourceTree = ""; @@ -1028,6 +1035,7 @@ 3666C87A2B45F4F900564874 /* SelectedBlocker.swift in Sources */, 0BC0EBD42B494459003EF5D4 /* OnboardingSwipeView.swift in Sources */, 17314F9B2B4C485B0089A551 /* UserPointHeaderView.swift in Sources */, + 364923702B4F524D00BF7ACA /* MoyaLoggerPlugin.swift in Sources */, 36A3D9C02B409CBD007EA272 /* Font.swift in Sources */, 174AF4902B447B3C00450D07 /* MyPageModels.swift in Sources */, 174AF4982B447CF100450D07 /* ChanllengeModels.swift in Sources */, @@ -1071,17 +1079,19 @@ 36A3D9B62B3EBBF7007EA272 /* Adjust+.swift in Sources */, 36A3D9BC2B3EBD2D007EA272 /* UIScreen+.swift in Sources */, 0B7817502B4BD9F10078E925 /* OnboardingButton.swift in Sources */, + 364923722B4F527200BF7ACA /* NetworkResult.swift in Sources */, 0B50F9CD2B369813000C5046 /* SceneDelegate.swift in Sources */, 36A3D9B42B3EBBED007EA272 /* UIStackView+.swift in Sources */, 364C4E712B4BC9780015729C /* AppAddButtonView.swift in Sources */, + 3649236E2B4F519E00BF7ACA /* StatusCode.swift in Sources */, 174AF4962B447CE700450D07 /* ChanllengeCells.swift in Sources */, 17314F832B486BEC0089A551 /* AlertViewController.swift in Sources */, 17314F9D2B4C554D0089A551 /* MypageCollectionViewCell.swift in Sources */, - 0B8A89B32B369EF700688BA6 /* A.swift in Sources */, 17314F972B4C42130089A551 /* MyPageView.swift in Sources */, 0BC0EBD22B493B6B003EF5D4 /* OnboardingProgressView.swift in Sources */, 364923652B4F4FB800BF7ACA /* Config.swift in Sources */, 364C4E732B4BF27C0015729C /* AppAddCollectionReusableView.swift in Sources */, + 3649236C2B4F517900BF7ACA /* NetworkError.swift in Sources */, 17314F7F2B485E150089A551 /* CustomAlertButton.swift in Sources */, 0B000CF12B4DA30F00AEC582 /* AppSelectViewController.swift in Sources */, 36A3D9BA2B3EBC65007EA272 /* UIButton+.swift in Sources */, @@ -1089,6 +1099,7 @@ 36E05FE62B48825A005B633E /* AppCollectionReusableView.swift in Sources */, 3666C88B2B471B0D00564874 /* String.swift in Sources */, 3666C89B2B48516500564874 /* ChallengeView.swift in Sources */, + 364923682B4F513600BF7ACA /* BaseTargetType.swift in Sources */, 3666C88D2B471B1D00564874 /* UIImage+.swift in Sources */, 3666C87C2B45F50F00564874 /* BlockingApplicationModel.swift in Sources */, 0B0035402B43D64D00DA140C /* HMHNavigationBar.swift in Sources */, diff --git a/HMH_iOS/HMH_iOS/Network/Base/BaseTargetType.swift b/HMH_iOS/HMH_iOS/Network/Base/BaseTargetType.swift new file mode 100644 index 0000000..82314d6 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Network/Base/BaseTargetType.swift @@ -0,0 +1,32 @@ +// +// BaseTargetType.swift +// HMH_iOS +// +// Created by 지희의 MAC on 1/11/24. +// + +import Foundation +import Moya + +protocol BaseTargetType: TargetType {} + +extension BaseTargetType { + var baseURL: URL { + return URL(string: Config.baseURL)! + } + + var headers: [String: String]? { + return [ + "Content-Type": "application/json", + "Authorization": "Bearer " + ] + } + + var sampleData: Data { + return Data() + } + + var validationType: ValidationType { + return .successCodes + } +} diff --git a/HMH_iOS/HMH_iOS/Network/Base/MoyaLoggerPlugin.swift b/HMH_iOS/HMH_iOS/Network/Base/MoyaLoggerPlugin.swift new file mode 100644 index 0000000..e5e0500 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Network/Base/MoyaLoggerPlugin.swift @@ -0,0 +1,71 @@ +// +// MoyaLoggerPlugin.swift +// HMH_iOS +// +// Created by 지희의 MAC on 1/11/24. +// + +import Foundation + +import Foundation +import Moya + +final class MoyaLoggingPlugin: PluginType { + // Request를 보낼 때 호출 + func willSend(_ request: RequestType, target: TargetType) { + guard let httpRequest = request.request else { + print("--> 유효하지 않은 요청") + return + } + let url = httpRequest.description + let method = httpRequest.httpMethod ?? "unknown method" + var log = "----------------------------------------------------\n\n[\(method)] \(url)\n\n----------------------------------------------------\n" + log.append("API: \(target)\n") + if let headers = httpRequest.allHTTPHeaderFields, !headers.isEmpty { + log.append("header: \(headers)\n") + } + if let body = httpRequest.httpBody, let bodyString = String(bytes: body, encoding: String.Encoding.utf8) { + log.append("\(bodyString)\n") + } + log.append("------------------- END \(method) --------------------------") + print(log) + } + // Response가 왔을 때 + func didReceive(_ result: Result, target: TargetType) { + switch result { + case let .success(response): + onSuceed(response, target: target, isFromError: false) + case let .failure(error): + onFail(error, target: target) + } + } + + func onSuceed(_ response: Response, target: TargetType, isFromError: Bool) { + let request = response.request + let url = request?.url?.absoluteString ?? "nil" + let statusCode = response.statusCode + var log = "------------------- 네트워크 통신 성공 -------------------" + log.append("\n[\(statusCode)] \(url)\n----------------------------------------------------\n") + log.append("API: \(target)\n") + response.response?.allHeaderFields.forEach { + log.append("\($0): \($1)\n") + } + if let reString = String(bytes: response.data, encoding: String.Encoding.utf8) { + log.append("\(reString)\n") + } + log.append("------------------- END HTTP (\(response.data.count)-byte body) -------------------") + print(log) + } + + func onFail(_ error: MoyaError, target: TargetType) { + if let response = error.response { + onSuceed(response, target: target, isFromError: true) + return + } + var log = "네트워크 오류" + log.append("<-- \(error.errorCode) \(target)\n") + log.append("\(error.failureReason ?? error.errorDescription ?? "unknown error")\n") + log.append("<-- END HTTP") + print(log) + } +} diff --git a/HMH_iOS/HMH_iOS/Network/Base/NetworkError.swift b/HMH_iOS/HMH_iOS/Network/Base/NetworkError.swift new file mode 100644 index 0000000..20a941b --- /dev/null +++ b/HMH_iOS/HMH_iOS/Network/Base/NetworkError.swift @@ -0,0 +1,15 @@ +// +// NetworkError.swift +// HMH_iOS +// +// Created by 지희의 MAC on 1/11/24. +// + +import Foundation + +enum NetworkError: Error { + case httpError(ErrorResponse) + case decodedError + case networkFail + case error(Error?) +} diff --git a/HMH_iOS/HMH_iOS/Network/Base/NetworkResult.swift b/HMH_iOS/HMH_iOS/Network/Base/NetworkResult.swift new file mode 100644 index 0000000..59bfb61 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Network/Base/NetworkResult.swift @@ -0,0 +1,16 @@ +// +// NetworkResult.swift +// HMH_iOS +// +// Created by 지희의 MAC on 1/11/24. +// + +import Foundation + +enum NetworkResult { + case success(T) // 서버 통신 성공했을 때, + case requestErr(T) // 요청 에러 발생했을 때, + case pathErr // 경로 에러 발생했을 때, + case serverErr // 서버의 내부적 에러가 발생했을 때, + case networkFail // 네트워크 연결 실패했을 때 +} diff --git a/HMH_iOS/HMH_iOS/Network/Base/StatusCode.swift b/HMH_iOS/HMH_iOS/Network/Base/StatusCode.swift new file mode 100644 index 0000000..9382776 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Network/Base/StatusCode.swift @@ -0,0 +1,48 @@ +// +// StatusCode.swift +// HMH_iOS +// +// Created by 지희의 MAC on 1/11/24. +// + +import Foundation + +enum StatusCase: String, Decodable { + case okay = "OK" + case created = "CREATED" + case accepted = "ACCEPTED" + case noContent = "NO_CONTENT" + case badRequest = "BAD_REQUEST" + case unAuthorized = "UNAUTHORIZED" + case forbidden = "FORBIDDEN" + case notFound = "NOT_FOUND" + case methodNotAllowed = "METHOD_NOT_ALLOWED" + case notAcceptable = "NOT_ACCEPTABLE" + case conflict = "CONFLICT" + case unsupportedMediaType = "UNSUPPORTED_MEDIA_TYPE" + case internalSever = "INTERNAL_SERVER" + case badGateway = "BAD_GATEWAY" + case serviceUnavailable = "SERVICE_UNAVAILABLE" + case notDefined = "NOT_DEFINED_CLIENT_ERROR" + + // swiftlint: disable cyclomatic_complexity + init(_ statusCode: Int) { + switch statusCode { + case 200: self = .okay + case 201: self = .created + case 202: self = .noContent + case 204: self = .noContent + case 400: self = .badRequest + case 401: self = .unAuthorized + case 404: self = .notFound + case 405: self = .methodNotAllowed + case 406: self = .notAcceptable + case 409: self = .conflict + case 415: self = .unsupportedMediaType + case 500: self = .internalSever + case 502: self = .badRequest + case 503: self = .serviceUnavailable + default: self = .notDefined + } + } +} From 6364f5fd99b1cd4449825cbc7624f81f0b4174f4 Mon Sep 17 00:00:00 2001 From: Zoe Date: Thu, 11 Jan 2024 07:45:40 +0900 Subject: [PATCH 058/101] [Add/#54] Add Package - Lottie --- HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj | 17 +++++++++++++++++ .../xcshareddata/swiftpm/Package.resolved | 9 +++++++++ 2 files changed, 26 insertions(+) diff --git a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj index 6fc1f6e..6ecffac 100644 --- a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj +++ b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj @@ -59,6 +59,7 @@ 174AF4982B447CF100450D07 /* ChanllengeModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 174AF4972B447CF100450D07 /* ChanllengeModels.swift */; }; 174AF49A2B447CFB00450D07 /* ChanllengeViews.swift in Sources */ = {isa = PBXBuildFile; fileRef = 174AF4992B447CFB00450D07 /* ChanllengeViews.swift */; }; 174AF49C2B447D0700450D07 /* ChallengeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 174AF49B2B447D0700450D07 /* ChallengeViewController.swift */; }; + 364923752B4F555F00BF7ACA /* Lottie in Frameworks */ = {isa = PBXBuildFile; productRef = 364923742B4F555F00BF7ACA /* Lottie */; }; 364C4E712B4BC9780015729C /* AppAddButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 364C4E702B4BC9780015729C /* AppAddButtonView.swift */; }; 364C4E732B4BF27C0015729C /* AppAddCollectionReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 364C4E722B4BF27C0015729C /* AppAddCollectionReusableView.swift */; }; 3666C84D2B45F41300564874 /* HMHAppSelectButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3666C84C2B45F41300564874 /* HMHAppSelectButtonView.swift */; }; @@ -269,6 +270,7 @@ 36A3D8A62B3AB5A1007EA272 /* KakaoSDKFriend in Frameworks */, 36A3D89C2B3AB5A1007EA272 /* KakaoSDK in Frameworks */, 36A3D8AA2B3AB5A1007EA272 /* KakaoSDKNavi in Frameworks */, + 364923752B4F555F00BF7ACA /* Lottie in Frameworks */, 36A3D8AC2B3AB5A1007EA272 /* KakaoSDKShare in Frameworks */, 36A3D8992B3AB58A007EA272 /* Then in Frameworks */, 36A3D8AE2B3AB5A1007EA272 /* KakaoSDKTalk in Frameworks */, @@ -879,6 +881,7 @@ 36A3D8AD2B3AB5A1007EA272 /* KakaoSDKTalk */, 36A3D8AF2B3AB5A1007EA272 /* KakaoSDKTemplate */, 36A3D8B12B3AB5A1007EA272 /* KakaoSDKUser */, + 364923742B4F555F00BF7ACA /* Lottie */, ); productName = HMH_iOS; productReference = 0B50F9C72B369813000C5046 /* HMH_iOS.app */; @@ -952,6 +955,7 @@ 36A3D8922B3AB57B007EA272 /* XCRemoteSwiftPackageReference "SnapKit" */, 36A3D8972B3AB58A007EA272 /* XCRemoteSwiftPackageReference "Then" */, 36A3D89A2B3AB5A1007EA272 /* XCRemoteSwiftPackageReference "kakao-ios-sdk" */, + 364923732B4F555F00BF7ACA /* XCRemoteSwiftPackageReference "lottie-spm" */, ); productRefGroup = 0B50F9C82B369813000C5046 /* Products */; projectDirPath = ""; @@ -1461,6 +1465,14 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ + 364923732B4F555F00BF7ACA /* XCRemoteSwiftPackageReference "lottie-spm" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/airbnb/lottie-spm.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 4.3.4; + }; + }; 36A3D8922B3AB57B007EA272 /* XCRemoteSwiftPackageReference "SnapKit" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/SnapKit/SnapKit.git"; @@ -1488,6 +1500,11 @@ /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ + 364923742B4F555F00BF7ACA /* Lottie */ = { + isa = XCSwiftPackageProductDependency; + package = 364923732B4F555F00BF7ACA /* XCRemoteSwiftPackageReference "lottie-spm" */; + productName = Lottie; + }; 36A3D8932B3AB57B007EA272 /* SnapKit */ = { isa = XCSwiftPackageProductDependency; package = 36A3D8922B3AB57B007EA272 /* XCRemoteSwiftPackageReference "SnapKit" */; diff --git a/HMH_iOS/HMH_iOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/HMH_iOS/HMH_iOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 1e8b4ba..b65eb67 100644 --- a/HMH_iOS/HMH_iOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/HMH_iOS/HMH_iOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -18,6 +18,15 @@ "version" : "2.20.0" } }, + { + "identity" : "lottie-spm", + "kind" : "remoteSourceControl", + "location" : "https://github.com/airbnb/lottie-spm.git", + "state" : { + "revision" : "96790253c1a82223bd43da651121abfd7e96d0f3", + "version" : "4.3.4" + } + }, { "identity" : "snapkit", "kind" : "remoteSourceControl", From 484c539cfbc8232361f282a4cd2a7124a415f21f Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Thu, 11 Jan 2024 17:41:52 +0900 Subject: [PATCH 059/101] =?UTF-8?q?[Feat/#46]=20=EC=95=A0=ED=94=8C?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=ED=83=80=EA=B2=9F=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS/HMH_iOS.entitlements | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/HMH_iOS/HMH_iOS/HMH_iOS.entitlements b/HMH_iOS/HMH_iOS/HMH_iOS.entitlements index e048c21..92f5bd8 100644 --- a/HMH_iOS/HMH_iOS/HMH_iOS.entitlements +++ b/HMH_iOS/HMH_iOS/HMH_iOS.entitlements @@ -2,6 +2,10 @@ + com.apple.developer.applesignin + + Default + com.apple.developer.family-controls From 754f0dc1bfc445be0c6fa05025ffbaf1b62da8ba Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Thu, 11 Jan 2024 17:42:33 +0900 Subject: [PATCH 060/101] =?UTF-8?q?[Feat/#46]=20Login=20-=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=20=EB=B7=B0=20=EC=BB=A8=ED=8A=B8=EB=A1=A4?= =?UTF-8?q?=EB=9F=AC=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewControllers/LoginViewController.swift | 96 ++++++++++++++++++- 1 file changed, 91 insertions(+), 5 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift b/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift index da57696..42a26ce 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift @@ -13,10 +13,33 @@ import AuthenticationServices final class LoginViewController: UIViewController { let authorizationButton = ASAuthorizationAppleIDButton(authorizationButtonType: .signIn, authorizationButtonStyle: .white) + func setAppleLoginButton() { + authorizationButton.addTarget(self, action: #selector(handleAuthorizationAppleIDButtonPress), for: .touchUpInside) + self.view.addSubview(authorizationButton) + authorizationButton.translatesAutoresizingMaskIntoConstraints = false + } + + @objc + func handleAuthorizationAppleIDButtonPress() { + let appleIDProvider = ASAuthorizationAppleIDProvider() + let request = appleIDProvider.createRequest() + request.requestedScopes = [.fullName, .email] + print(request, "👍") + let authorizationController = ASAuthorizationController(authorizationRequests: [request]) + authorizationController.delegate = self + authorizationController.presentationContextProvider = self + authorizationController.performRequests() + } + + @objc func appleButtonTaped() { + print("tap") + } + let swipeView = OnboardingSwipeView() override func viewDidLoad() { super.viewDidLoad() + setAppleLoginButton() setUI() } @@ -43,11 +66,74 @@ final class LoginViewController: UIViewController { $0.height.equalTo(480) } } - - private func setAppleLoginButton() { - self.view.addSubview(authorizationButton) - authorizationButton.translatesAutoresizingMaskIntoConstraints = false - } } +extension LoginViewController: ASAuthorizationControllerDelegate, ASAuthorizationControllerPresentationContextProviding{ + func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor { + return self.view.window! + } + + func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) { + //로그인 성공 + switch authorization.credential { + case let appleIDCredential as ASAuthorizationAppleIDCredential: + // You can create an account in your system. + let userIdentifier = appleIDCredential.user + let fullName = appleIDCredential.fullName + let email = appleIDCredential.email + + UserDefaults.standard.set(userIdentifier, forKey: "userIdentifier") + if let authorizationCode = appleIDCredential.authorizationCode, + let identityToken = appleIDCredential.identityToken, + let authCodeString = String(data: authorizationCode, encoding: .utf8), + let identifyTokenString = String(data: identityToken, encoding: .utf8) { + print("authorizationCode: \(authorizationCode)") + print("identityToken: \(identityToken)") + print("authCodeString: \(authCodeString)") + print("identifyTokenString: \(identifyTokenString)") + print("🚨", appleIDCredential) + if let bundleID = Bundle.main.bundleIdentifier { + UserDefaults.standard.removePersistentDomain(forName: bundleID) + } + // saveToUserDefaults("authorizationCode",keyValue: authorizationCode) + // saveToUserDefaults("identityToken",keyValue: identityToken) + // saveToUserDefaults(authCodeString,keyValue:"authCodeString") + // saveToUserDefaults(identifyTokenString,keyValue:"identifyTokenString") + // saveToUserDefaults("cool",keyValue:"userIdentifier") + + } + + print("useridentifier: \(userIdentifier)") + + + + //Move to MainPage + //let validVC = SignValidViewController() + //validVC.modalPresentationStyle = .fullScreen + //present(validVC, animated: true, completion: nil) + + case let passwordCredential as ASPasswordCredential: + // Sign in using an existing iCloud Keychain credential. + let username = passwordCredential.user + let password = passwordCredential.password + + print("username: \(username)") + print("password: \(password)") + + default: + break + } + } + + func saveToUserDefaults(_ content: String, keyValue: String) { + // Save the userId to UserDefaults + UserDefaults.standard.set(content, forKey: keyValue) + } + + + func authorizationController(controller: ASAuthorizationController, didCompleteWithError error: Error) { + // 로그인 실패(유저의 취소도 포함) + print("login failed - \(error.localizedDescription)") + } +} From e64b7f907865538f5571639364771ca6eb84033d Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Thu, 11 Jan 2024 17:43:11 +0900 Subject: [PATCH 061/101] =?UTF-8?q?[Fix/#46]=20SignModel=20-=20=EC=A3=BC?= =?UTF-8?q?=EC=84=9D=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Onboarding/Models/SignInModel.swift | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/Onboarding/Models/SignInModel.swift b/HMH_iOS/HMH_iOS/Presentation/Onboarding/Models/SignInModel.swift index 05871b7..d5d1095 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Onboarding/Models/SignInModel.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Onboarding/Models/SignInModel.swift @@ -5,26 +5,26 @@ // Created by Seonwoo Kim on 1/9/24. // -import Foundation - -struct SignInModel { - let socialPlatform: String - let onboarding: Onboarding - let challenge: Challenge -} - -struct Onboarding { - let averageUseTime: String - let problem: [String] -} - -struct Challenge { - let period: Int - let goalTime: Int - let apps: [Apps] -} - -struct Apps { - let appCode: String - let goalTime: Int -} +//import Foundation +// +//struct SignInModel { +// let socialPlatform: String +// let onboarding: Onboarding +// let challenge: Challenge +//} +// +//struct Onboarding { +// let averageUseTime: String +// let problem: [String] +//} +// +//struct Challenge { +// let period: Int +// let goalTime: Int +// let apps: [Apps] +//} +// +//struct Apps { +// let appCode: String +// let goalTime: Int +//} From 7fb78410597a8dd4bcd448ed6fc009cec9ce7ffc Mon Sep 17 00:00:00 2001 From: boyeon Date: Thu, 11 Jan 2024 18:48:57 +0900 Subject: [PATCH 062/101] =?UTF-8?q?[Feat/#44]=20HomeViewCell=20-=20?= =?UTF-8?q?=ED=94=84=EB=A1=9C=EA=B7=B8=EB=9E=98=EC=8A=A4=EB=B0=94=20?= =?UTF-8?q?=EB=9D=BC=EC=9A=B4=EB=93=9C=20=EA=B0=92=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Presentation/Home/Cells/AppUsingProgressViewCell.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/Home/Cells/AppUsingProgressViewCell.swift b/HMH_iOS/HMH_iOS/Presentation/Home/Cells/AppUsingProgressViewCell.swift index 6b4b737..01c00fe 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Home/Cells/AppUsingProgressViewCell.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Home/Cells/AppUsingProgressViewCell.swift @@ -57,7 +57,11 @@ final class AppUsingProgressViewCell: UICollectionViewCell { lazy var appProgressBar = UIProgressView().then { $0.trackTintColor = .gray7 $0.progressTintColor = .bluePurpleOpacity70 - $0.makeCornerRound(radius: 6.adjusted) + $0.clipsToBounds = true + $0.progressViewStyle = .bar + $0.layer.cornerRadius = 6.adjusted + $0.layer.sublayers![1].masksToBounds = true + $0.layer.sublayers![1].cornerRadius = 6.adjusted } override init(frame: CGRect) { From 73a9fdf90f217004f0475bd4d790a41bf3029afe Mon Sep 17 00:00:00 2001 From: Zoe Date: Fri, 12 Jan 2024 02:50:26 +0900 Subject: [PATCH 063/101] [Set/#53] Network - NetworkSetting --- HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj | 88 ++++++++++++++----- .../Network/Base/AuthInterceptor.swift | 25 ++++++ HMH_iOS/HMH_iOS/Network/Base/BaseModel.swift | 15 ++++ .../HMH_iOS/Network/Base/BaseTargetType.swift | 24 +++-- .../HMH_iOS/Network/Base/NetworkError.swift | 15 ---- .../Network/Base/NetworkProvider.swift | 40 +++++++++ .../HMH_iOS/Network/Base/NetworkResult.swift | 16 ---- HMH_iOS/HMH_iOS/Network/Base/StatusCode.swift | 48 ---------- .../CreateChallengeRequestDTO.swift | 12 +++ HMH_iOS/HMH_iOS/Network/DataModel/B.swift | 8 -- .../Network/Foundation/APIConstants.swift | 27 ++++++ .../Network/{ => Foundation}/Config.swift | 0 .../MoyaLoggerPlugin.swift | 14 +-- .../Network/Foundation/NetworkHelper.swift | 38 ++++++++ .../Network/Foundation/NetworkRequest.swift | 36 ++++++++ .../Network/Foundation/NetworkResult.swift | 68 ++++++++++++++ .../Network/Foundation/ResponseData.swift | 49 +++++++++++ .../Network/Router/ChallengeRouter.swift | 38 ++++++++ HMH_iOS/HMH_iOS/Network/Service/C.swift | 8 -- .../HMH_iOS/Network/Service/Providers.swift | 24 +++++ .../Network/Service/WeatherTarget.swift | 79 +++++++++++++++++ .../SplashViewController.swift | 12 ++- 22 files changed, 550 insertions(+), 134 deletions(-) create mode 100644 HMH_iOS/HMH_iOS/Network/Base/AuthInterceptor.swift create mode 100644 HMH_iOS/HMH_iOS/Network/Base/BaseModel.swift delete mode 100644 HMH_iOS/HMH_iOS/Network/Base/NetworkError.swift create mode 100644 HMH_iOS/HMH_iOS/Network/Base/NetworkProvider.swift delete mode 100644 HMH_iOS/HMH_iOS/Network/Base/NetworkResult.swift delete mode 100644 HMH_iOS/HMH_iOS/Network/Base/StatusCode.swift create mode 100644 HMH_iOS/HMH_iOS/Network/DTO/ChallengeModel/CreateChallengeRequestDTO.swift delete mode 100644 HMH_iOS/HMH_iOS/Network/DataModel/B.swift create mode 100644 HMH_iOS/HMH_iOS/Network/Foundation/APIConstants.swift rename HMH_iOS/HMH_iOS/Network/{ => Foundation}/Config.swift (100%) rename HMH_iOS/HMH_iOS/Network/{Base => Foundation}/MoyaLoggerPlugin.swift (78%) create mode 100644 HMH_iOS/HMH_iOS/Network/Foundation/NetworkHelper.swift create mode 100644 HMH_iOS/HMH_iOS/Network/Foundation/NetworkRequest.swift create mode 100644 HMH_iOS/HMH_iOS/Network/Foundation/NetworkResult.swift create mode 100644 HMH_iOS/HMH_iOS/Network/Foundation/ResponseData.swift create mode 100644 HMH_iOS/HMH_iOS/Network/Router/ChallengeRouter.swift delete mode 100644 HMH_iOS/HMH_iOS/Network/Service/C.swift create mode 100644 HMH_iOS/HMH_iOS/Network/Service/Providers.swift create mode 100644 HMH_iOS/HMH_iOS/Network/Service/WeatherTarget.swift diff --git a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj index 57f0b33..0b0e21e 100644 --- a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj +++ b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj @@ -25,8 +25,6 @@ 0B8A89AD2B369E3B00688BA6 /* HomeCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B8A89AC2B369E3B00688BA6 /* HomeCell.swift */; }; 0B8A89AF2B369E4300688BA6 /* HomeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B8A89AE2B369E4300688BA6 /* HomeModel.swift */; }; 0B8A89B12B369E4C00688BA6 /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B8A89B02B369E4C00688BA6 /* HomeView.swift */; }; - 0B8A89B52B369F0100688BA6 /* B.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B8A89B42B369F0100688BA6 /* B.swift */; }; - 0B8A89B72B369F1100688BA6 /* C.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B8A89B62B369F1100688BA6 /* C.swift */; }; 0B8A89BC2B369F2D00688BA6 /* UIView+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B8A89BB2B369F2D00688BA6 /* UIView+.swift */; }; 0B8A89C42B369FA000688BA6 /* F.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B8A89C32B369FA000688BA6 /* F.swift */; }; 0BA193B22B4CE908007E3F9C /* SurveyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BA193B12B4CE908007E3F9C /* SurveyView.swift */; }; @@ -61,10 +59,17 @@ 364923652B4F4FB800BF7ACA /* Config.swift in Sources */ = {isa = PBXBuildFile; fileRef = 364923642B4F4FB800BF7ACA /* Config.swift */; }; 364923682B4F513600BF7ACA /* BaseTargetType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 364923672B4F513600BF7ACA /* BaseTargetType.swift */; }; 3649236A2B4F514A00BF7ACA /* Moya in Frameworks */ = {isa = PBXBuildFile; productRef = 364923692B4F514A00BF7ACA /* Moya */; }; - 3649236C2B4F517900BF7ACA /* NetworkError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3649236B2B4F517900BF7ACA /* NetworkError.swift */; }; - 3649236E2B4F519E00BF7ACA /* StatusCode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3649236D2B4F519E00BF7ACA /* StatusCode.swift */; }; 364923702B4F524D00BF7ACA /* MoyaLoggerPlugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3649236F2B4F524D00BF7ACA /* MoyaLoggerPlugin.swift */; }; 364923722B4F527200BF7ACA /* NetworkResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 364923712B4F527200BF7ACA /* NetworkResult.swift */; }; + 364923792B4FC8E800BF7ACA /* BaseModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 364923782B4FC8E800BF7ACA /* BaseModel.swift */; }; + 3649237D2B4FC9CD00BF7ACA /* NetworkRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3649237C2B4FC9CD00BF7ACA /* NetworkRequest.swift */; }; + 364923822B4FD68000BF7ACA /* APIConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 364923812B4FD68000BF7ACA /* APIConstants.swift */; }; + 364923862B4FDCBD00BF7ACA /* NetworkProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 364923852B4FDCBD00BF7ACA /* NetworkProvider.swift */; }; + 364923932B50397100BF7ACA /* NetworkHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 364923922B50397100BF7ACA /* NetworkHelper.swift */; }; + 364923992B505A3A00BF7ACA /* AuthInterceptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 364923982B505A3A00BF7ACA /* AuthInterceptor.swift */; }; + 3649239B2B505B2600BF7ACA /* Providers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3649239A2B505B2600BF7ACA /* Providers.swift */; }; + 3649239D2B505CED00BF7ACA /* ChallengeRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3649239C2B505CED00BF7ACA /* ChallengeRouter.swift */; }; + 364923A02B505F2000BF7ACA /* CreateChallengeRequestDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3649239F2B505F2000BF7ACA /* CreateChallengeRequestDTO.swift */; }; 364C4E712B4BC9780015729C /* AppAddButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 364C4E702B4BC9780015729C /* AppAddButtonView.swift */; }; 364C4E732B4BF27C0015729C /* AppAddCollectionReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 364C4E722B4BF27C0015729C /* AppAddCollectionReusableView.swift */; }; 3666C84D2B45F41300564874 /* HMHAppSelectButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3666C84C2B45F41300564874 /* HMHAppSelectButtonView.swift */; }; @@ -184,8 +189,6 @@ 0B8A89AC2B369E3B00688BA6 /* HomeCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeCell.swift; sourceTree = ""; }; 0B8A89AE2B369E4300688BA6 /* HomeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeModel.swift; sourceTree = ""; }; 0B8A89B02B369E4C00688BA6 /* HomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = ""; }; - 0B8A89B42B369F0100688BA6 /* B.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = B.swift; sourceTree = ""; }; - 0B8A89B62B369F1100688BA6 /* C.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = C.swift; sourceTree = ""; }; 0B8A89BB2B369F2D00688BA6 /* UIView+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+.swift"; sourceTree = ""; }; 0B8A89C32B369FA000688BA6 /* F.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = F.swift; sourceTree = ""; }; 0BA193B12B4CE908007E3F9C /* SurveyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SurveyView.swift; sourceTree = ""; }; @@ -220,10 +223,17 @@ 364923612B4F4E7D00BF7ACA /* Config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = ""; }; 364923642B4F4FB800BF7ACA /* Config.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Config.swift; sourceTree = ""; }; 364923672B4F513600BF7ACA /* BaseTargetType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseTargetType.swift; sourceTree = ""; }; - 3649236B2B4F517900BF7ACA /* NetworkError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkError.swift; sourceTree = ""; }; - 3649236D2B4F519E00BF7ACA /* StatusCode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusCode.swift; sourceTree = ""; }; 3649236F2B4F524D00BF7ACA /* MoyaLoggerPlugin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoyaLoggerPlugin.swift; sourceTree = ""; }; 364923712B4F527200BF7ACA /* NetworkResult.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkResult.swift; sourceTree = ""; }; + 364923782B4FC8E800BF7ACA /* BaseModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseModel.swift; sourceTree = ""; }; + 3649237C2B4FC9CD00BF7ACA /* NetworkRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkRequest.swift; sourceTree = ""; }; + 364923812B4FD68000BF7ACA /* APIConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIConstants.swift; sourceTree = ""; }; + 364923852B4FDCBD00BF7ACA /* NetworkProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkProvider.swift; sourceTree = ""; }; + 364923922B50397100BF7ACA /* NetworkHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkHelper.swift; sourceTree = ""; }; + 364923982B505A3A00BF7ACA /* AuthInterceptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthInterceptor.swift; sourceTree = ""; }; + 3649239A2B505B2600BF7ACA /* Providers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Providers.swift; sourceTree = ""; }; + 3649239C2B505CED00BF7ACA /* ChallengeRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeRouter.swift; sourceTree = ""; }; + 3649239F2B505F2000BF7ACA /* CreateChallengeRequestDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateChallengeRequestDTO.swift; sourceTree = ""; }; 364C4E702B4BC9780015729C /* AppAddButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppAddButtonView.swift; sourceTree = ""; }; 364C4E722B4BF27C0015729C /* AppAddCollectionReusableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppAddCollectionReusableView.swift; sourceTree = ""; }; 3666C84C2B45F41300564874 /* HMHAppSelectButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HMHAppSelectButtonView.swift; sourceTree = ""; }; @@ -406,9 +416,10 @@ isa = PBXGroup; children = ( 0B8A89A22B369DB600688BA6 /* Base */, - 0B8A89A32B369DBE00688BA6 /* DataModel */, + 364923962B50547F00BF7ACA /* Foundation */, + 364923972B5054AE00BF7ACA /* Router */, + 0B8A89A32B369DBE00688BA6 /* DTO */, 0B8A89A42B369DCA00688BA6 /* Service */, - 364923642B4F4FB800BF7ACA /* Config.swift */, ); path = Network; sourceTree = ""; @@ -533,27 +544,26 @@ 0B8A89A22B369DB600688BA6 /* Base */ = { isa = PBXGroup; children = ( + 364923982B505A3A00BF7ACA /* AuthInterceptor.swift */, + 364923852B4FDCBD00BF7ACA /* NetworkProvider.swift */, 364923672B4F513600BF7ACA /* BaseTargetType.swift */, - 3649236D2B4F519E00BF7ACA /* StatusCode.swift */, - 3649236B2B4F517900BF7ACA /* NetworkError.swift */, - 3649236F2B4F524D00BF7ACA /* MoyaLoggerPlugin.swift */, - 364923712B4F527200BF7ACA /* NetworkResult.swift */, + 364923782B4FC8E800BF7ACA /* BaseModel.swift */, ); path = Base; sourceTree = ""; }; - 0B8A89A32B369DBE00688BA6 /* DataModel */ = { + 0B8A89A32B369DBE00688BA6 /* DTO */ = { isa = PBXGroup; children = ( - 0B8A89B42B369F0100688BA6 /* B.swift */, + 3649239E2B505F0600BF7ACA /* ChallengeModel */, ); - path = DataModel; + path = DTO; sourceTree = ""; }; 0B8A89A42B369DCA00688BA6 /* Service */ = { isa = PBXGroup; children = ( - 0B8A89B62B369F1100688BA6 /* C.swift */, + 3649239A2B505B2600BF7ACA /* Providers.swift */, ); path = Service; sourceTree = ""; @@ -779,6 +789,35 @@ path = Cells; sourceTree = ""; }; + 364923962B50547F00BF7ACA /* Foundation */ = { + isa = PBXGroup; + children = ( + 364923642B4F4FB800BF7ACA /* Config.swift */, + 364923812B4FD68000BF7ACA /* APIConstants.swift */, + 364923922B50397100BF7ACA /* NetworkHelper.swift */, + 3649236F2B4F524D00BF7ACA /* MoyaLoggerPlugin.swift */, + 364923712B4F527200BF7ACA /* NetworkResult.swift */, + 3649237C2B4FC9CD00BF7ACA /* NetworkRequest.swift */, + ); + path = Foundation; + sourceTree = ""; + }; + 364923972B5054AE00BF7ACA /* Router */ = { + isa = PBXGroup; + children = ( + 3649239C2B505CED00BF7ACA /* ChallengeRouter.swift */, + ); + path = Router; + sourceTree = ""; + }; + 3649239E2B505F0600BF7ACA /* ChallengeModel */ = { + isa = PBXGroup; + children = ( + 3649239F2B505F2000BF7ACA /* CreateChallengeRequestDTO.swift */, + ); + path = ChallengeModel; + sourceTree = ""; + }; 364C4E6F2B4BC95E0015729C /* SwiftUIView */ = { isa = PBXGroup; children = ( @@ -1035,10 +1074,12 @@ 3666C87A2B45F4F900564874 /* SelectedBlocker.swift in Sources */, 0BC0EBD42B494459003EF5D4 /* OnboardingSwipeView.swift in Sources */, 17314F9B2B4C485B0089A551 /* UserPointHeaderView.swift in Sources */, + 364923862B4FDCBD00BF7ACA /* NetworkProvider.swift in Sources */, 364923702B4F524D00BF7ACA /* MoyaLoggerPlugin.swift in Sources */, 36A3D9C02B409CBD007EA272 /* Font.swift in Sources */, 174AF4902B447B3C00450D07 /* MyPageModels.swift in Sources */, 174AF4982B447CF100450D07 /* ChanllengeModels.swift in Sources */, + 364923932B50397100BF7ACA /* NetworkHelper.swift in Sources */, 174AF48E2B447B1F00450D07 /* MyPageCells.swift in Sources */, 3666C8A52B48644A00564874 /* AppModel.swift in Sources */, 174AF4942B447B5500450D07 /* MyPageViewController.swift in Sources */, @@ -1052,21 +1093,22 @@ 174AF49A2B447CFB00450D07 /* ChanllengeViews.swift in Sources */, 0B000CEB2B4D9D9100AEC582 /* SelectTotalTimeController.swift in Sources */, 17314F872B49853C0089A551 /* HMHQuitAlert.swift in Sources */, + 364923A02B505F2000BF7ACA /* CreateChallengeRequestDTO.swift in Sources */, 0BA193B62B4D08B7007E3F9C /* ProblemSurveyViewController.swift in Sources */, 0B000CED2B4D9DA800AEC582 /* ApprovePermisionController.swift in Sources */, - 0B8A89B72B369F1100688BA6 /* C.swift in Sources */, 0B2C2D3B2B443BE90023CCFA /* Image.swift in Sources */, 17314F852B497FDE0089A551 /* HMHLogoutAlert.swift in Sources */, 3666C84D2B45F41300564874 /* HMHAppSelectButtonView.swift in Sources */, 3666C8A32B4861A200564874 /* AppListCollectionViewCell.swift in Sources */, + 364923822B4FD68000BF7ACA /* APIConstants.swift in Sources */, 0BA193B92B4D4097007E3F9C /* SignInModel.swift in Sources */, 0B8A89AD2B369E3B00688BA6 /* HomeCell.swift in Sources */, 3666C8882B47110800564874 /* SpecificTimePickerView.swift in Sources */, 17314FB72B4D93D30089A551 /* StoreCollectionViewCell.swift in Sources */, 174AF4922B447B4600450D07 /* MyPageViews.swift in Sources */, + 364923992B505A3A00BF7ACA /* AuthInterceptor.swift in Sources */, 36A3D9BE2B409BCC007EA272 /* Color.swift in Sources */, 17314FB12B4D50380089A551 /* InfoHeaderView.swift in Sources */, - 0B8A89B52B369F0100688BA6 /* B.swift in Sources */, 174AF49C2B447D0700450D07 /* ChallengeViewController.swift in Sources */, 0BD98DB92B4D671600E35188 /* SplashViewController.swift in Sources */, 0BD98DBE2B4D6AB700E35188 /* LoginViewController.swift in Sources */, @@ -1074,16 +1116,19 @@ 17314F892B49A8B60089A551 /* AlertDelegate.swift in Sources */, 17314FAF2B4D3E1C0089A551 /* LogoutAndQuitFooterView.swift in Sources */, 0B78174E2B4BD96D0078E925 /* OnboardingBaseViewControllers.swift in Sources */, + 3649237D2B4FC9CD00BF7ACA /* NetworkRequest.swift in Sources */, 0B8A89B12B369E4C00688BA6 /* HomeView.swift in Sources */, 0BFD2FB42B4EE71900C6327F /* SignInCompleteViewController.swift in Sources */, + 3649239B2B505B2600BF7ACA /* Providers.swift in Sources */, 36A3D9B62B3EBBF7007EA272 /* Adjust+.swift in Sources */, 36A3D9BC2B3EBD2D007EA272 /* UIScreen+.swift in Sources */, 0B7817502B4BD9F10078E925 /* OnboardingButton.swift in Sources */, + 364923792B4FC8E800BF7ACA /* BaseModel.swift in Sources */, 364923722B4F527200BF7ACA /* NetworkResult.swift in Sources */, 0B50F9CD2B369813000C5046 /* SceneDelegate.swift in Sources */, 36A3D9B42B3EBBED007EA272 /* UIStackView+.swift in Sources */, + 3649239D2B505CED00BF7ACA /* ChallengeRouter.swift in Sources */, 364C4E712B4BC9780015729C /* AppAddButtonView.swift in Sources */, - 3649236E2B4F519E00BF7ACA /* StatusCode.swift in Sources */, 174AF4962B447CE700450D07 /* ChanllengeCells.swift in Sources */, 17314F832B486BEC0089A551 /* AlertViewController.swift in Sources */, 17314F9D2B4C554D0089A551 /* MypageCollectionViewCell.swift in Sources */, @@ -1091,7 +1136,6 @@ 0BC0EBD22B493B6B003EF5D4 /* OnboardingProgressView.swift in Sources */, 364923652B4F4FB800BF7ACA /* Config.swift in Sources */, 364C4E732B4BF27C0015729C /* AppAddCollectionReusableView.swift in Sources */, - 3649236C2B4F517900BF7ACA /* NetworkError.swift in Sources */, 17314F7F2B485E150089A551 /* CustomAlertButton.swift in Sources */, 0B000CF12B4DA30F00AEC582 /* AppSelectViewController.swift in Sources */, 36A3D9BA2B3EBC65007EA272 /* UIButton+.swift in Sources */, diff --git a/HMH_iOS/HMH_iOS/Network/Base/AuthInterceptor.swift b/HMH_iOS/HMH_iOS/Network/Base/AuthInterceptor.swift new file mode 100644 index 0000000..089f3e2 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Network/Base/AuthInterceptor.swift @@ -0,0 +1,25 @@ +// +// AuthInterceptor.swift +// HMH_iOS +// +// Created by 지희의 MAC on 1/12/24. +// + +import Foundation + +import Alamofire +import Moya + +///// 토큰 만료 시 자동으로 refresh를 위한 서버 통신 +final class AuthInterceptor: RequestInterceptor { + + static let shared = AuthInterceptor() + + private init() {} + + func adapt(_ urlRequest: URLRequest, for session: Session, completion: @escaping (Result) -> Void) { + } + + func retry(_ request: Request, for session: Session, dueTo error: Error, completion: @escaping (RetryResult) -> Void) { + } +} diff --git a/HMH_iOS/HMH_iOS/Network/Base/BaseModel.swift b/HMH_iOS/HMH_iOS/Network/Base/BaseModel.swift new file mode 100644 index 0000000..2fd4689 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Network/Base/BaseModel.swift @@ -0,0 +1,15 @@ +// +// BaseModel.swift +// HMH_iOS +// +// Created by 지희의 MAC on 1/11/24. +// + +import Foundation + +struct BaseResponse: Decodable { + var status: Int + var message: String? + var data: T? +} + diff --git a/HMH_iOS/HMH_iOS/Network/Base/BaseTargetType.swift b/HMH_iOS/HMH_iOS/Network/Base/BaseTargetType.swift index 82314d6..69b3c50 100644 --- a/HMH_iOS/HMH_iOS/Network/Base/BaseTargetType.swift +++ b/HMH_iOS/HMH_iOS/Network/Base/BaseTargetType.swift @@ -8,24 +8,30 @@ import Foundation import Moya + + protocol BaseTargetType: TargetType {} +typealias Parameters = [String: String] + extension BaseTargetType { + var baseURL: URL { - return URL(string: Config.baseURL)! + guard let baseURL = URL(string: Config.baseURL) else { + print("🚨🚨BASEURL ERROR🚨🚨") + fatalError() + } + return baseURL } - - var headers: [String: String]? { - return [ - "Content-Type": "application/json", - "Authorization": "Bearer " - ] + + var headers: Parameters? { + return APIConstants.hasTokenHeader } - + var sampleData: Data { return Data() } - + var validationType: ValidationType { return .successCodes } diff --git a/HMH_iOS/HMH_iOS/Network/Base/NetworkError.swift b/HMH_iOS/HMH_iOS/Network/Base/NetworkError.swift deleted file mode 100644 index 20a941b..0000000 --- a/HMH_iOS/HMH_iOS/Network/Base/NetworkError.swift +++ /dev/null @@ -1,15 +0,0 @@ -// -// NetworkError.swift -// HMH_iOS -// -// Created by 지희의 MAC on 1/11/24. -// - -import Foundation - -enum NetworkError: Error { - case httpError(ErrorResponse) - case decodedError - case networkFail - case error(Error?) -} diff --git a/HMH_iOS/HMH_iOS/Network/Base/NetworkProvider.swift b/HMH_iOS/HMH_iOS/Network/Base/NetworkProvider.swift new file mode 100644 index 0000000..f32f6e3 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Network/Base/NetworkProvider.swift @@ -0,0 +1,40 @@ +// +// NetworkWrapper.swift +// HMH_iOS +// +// Created by 지희의 MAC on 1/11/24. +// +import Moya +import UIKit + +class NetworkProvider : MoyaProvider { + func request(target : Provider, instance : Model.Type , viewController: UIViewController, completion : @escaping(Model) -> ()){ + self.request(target) { result in + switch result { + /// 서버 통신 성공 + case .success(let response): + if (200..<300).contains(response.statusCode) { + if let decodeData = try? JSONDecoder().decode(instance, from: response.data) { + completion(decodeData) + } else{ + print("🚨 decoding Error 발생") + } + } else { + print("🚨 Client Error") + } + /// 서버 통신 실패 + case .failure(let error): + if let response = error.response { + if let responseData = String(data: response.data, encoding: .utf8) { + print(responseData) + } else { + print(error.localizedDescription) + } + } else { + print(error.localizedDescription) + } + viewController.view.showToast(message: "네트워크 통신을 확인해주세요") + } + } + } +} diff --git a/HMH_iOS/HMH_iOS/Network/Base/NetworkResult.swift b/HMH_iOS/HMH_iOS/Network/Base/NetworkResult.swift deleted file mode 100644 index 59bfb61..0000000 --- a/HMH_iOS/HMH_iOS/Network/Base/NetworkResult.swift +++ /dev/null @@ -1,16 +0,0 @@ -// -// NetworkResult.swift -// HMH_iOS -// -// Created by 지희의 MAC on 1/11/24. -// - -import Foundation - -enum NetworkResult { - case success(T) // 서버 통신 성공했을 때, - case requestErr(T) // 요청 에러 발생했을 때, - case pathErr // 경로 에러 발생했을 때, - case serverErr // 서버의 내부적 에러가 발생했을 때, - case networkFail // 네트워크 연결 실패했을 때 -} diff --git a/HMH_iOS/HMH_iOS/Network/Base/StatusCode.swift b/HMH_iOS/HMH_iOS/Network/Base/StatusCode.swift deleted file mode 100644 index 9382776..0000000 --- a/HMH_iOS/HMH_iOS/Network/Base/StatusCode.swift +++ /dev/null @@ -1,48 +0,0 @@ -// -// StatusCode.swift -// HMH_iOS -// -// Created by 지희의 MAC on 1/11/24. -// - -import Foundation - -enum StatusCase: String, Decodable { - case okay = "OK" - case created = "CREATED" - case accepted = "ACCEPTED" - case noContent = "NO_CONTENT" - case badRequest = "BAD_REQUEST" - case unAuthorized = "UNAUTHORIZED" - case forbidden = "FORBIDDEN" - case notFound = "NOT_FOUND" - case methodNotAllowed = "METHOD_NOT_ALLOWED" - case notAcceptable = "NOT_ACCEPTABLE" - case conflict = "CONFLICT" - case unsupportedMediaType = "UNSUPPORTED_MEDIA_TYPE" - case internalSever = "INTERNAL_SERVER" - case badGateway = "BAD_GATEWAY" - case serviceUnavailable = "SERVICE_UNAVAILABLE" - case notDefined = "NOT_DEFINED_CLIENT_ERROR" - - // swiftlint: disable cyclomatic_complexity - init(_ statusCode: Int) { - switch statusCode { - case 200: self = .okay - case 201: self = .created - case 202: self = .noContent - case 204: self = .noContent - case 400: self = .badRequest - case 401: self = .unAuthorized - case 404: self = .notFound - case 405: self = .methodNotAllowed - case 406: self = .notAcceptable - case 409: self = .conflict - case 415: self = .unsupportedMediaType - case 500: self = .internalSever - case 502: self = .badRequest - case 503: self = .serviceUnavailable - default: self = .notDefined - } - } -} diff --git a/HMH_iOS/HMH_iOS/Network/DTO/ChallengeModel/CreateChallengeRequestDTO.swift b/HMH_iOS/HMH_iOS/Network/DTO/ChallengeModel/CreateChallengeRequestDTO.swift new file mode 100644 index 0000000..498edae --- /dev/null +++ b/HMH_iOS/HMH_iOS/Network/DTO/ChallengeModel/CreateChallengeRequestDTO.swift @@ -0,0 +1,12 @@ +// +// CreateChallengeRequestDTO.swift +// HMH_iOS +// +// Created by 지희의 MAC on 1/12/24. +// + +import Foundation + +class CreateChallengeRequestDTO: Request { + +} diff --git a/HMH_iOS/HMH_iOS/Network/DataModel/B.swift b/HMH_iOS/HMH_iOS/Network/DataModel/B.swift deleted file mode 100644 index 4ff38f7..0000000 --- a/HMH_iOS/HMH_iOS/Network/DataModel/B.swift +++ /dev/null @@ -1,8 +0,0 @@ -// -// B.swift -// HMH_iOS -// -// Created by Seonwoo Kim on 12/23/23. -// - -import Foundation diff --git a/HMH_iOS/HMH_iOS/Network/Foundation/APIConstants.swift b/HMH_iOS/HMH_iOS/Network/Foundation/APIConstants.swift new file mode 100644 index 0000000..7b66696 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Network/Foundation/APIConstants.swift @@ -0,0 +1,27 @@ +// +// APIConstants.swift +// HMH_iOS +// +// Created by 지희의 MAC on 1/11/24. +// + +import Foundation +import Moya + +struct APIConstants{ + static let contentType = "Content-Type" + static let applicationJSON = "application/json" + static let auth = "Authorization" + static let accessToken = "" // TO-DO: AccessToken + static let appleAccessToken = "" + static let OS = "OS" + static let iOS = "iOS" +} + +extension APIConstants{ + static let hasSocialTokenHeader = [contentType: applicationJSON, + auth : accessToken] + static let hasTokenHeader = [contentType: applicationJSON, + OS: iOS, + auth : accessToken] +} diff --git a/HMH_iOS/HMH_iOS/Network/Config.swift b/HMH_iOS/HMH_iOS/Network/Foundation/Config.swift similarity index 100% rename from HMH_iOS/HMH_iOS/Network/Config.swift rename to HMH_iOS/HMH_iOS/Network/Foundation/Config.swift diff --git a/HMH_iOS/HMH_iOS/Network/Base/MoyaLoggerPlugin.swift b/HMH_iOS/HMH_iOS/Network/Foundation/MoyaLoggerPlugin.swift similarity index 78% rename from HMH_iOS/HMH_iOS/Network/Base/MoyaLoggerPlugin.swift rename to HMH_iOS/HMH_iOS/Network/Foundation/MoyaLoggerPlugin.swift index e5e0500..7eb2566 100644 --- a/HMH_iOS/HMH_iOS/Network/Base/MoyaLoggerPlugin.swift +++ b/HMH_iOS/HMH_iOS/Network/Foundation/MoyaLoggerPlugin.swift @@ -14,12 +14,12 @@ final class MoyaLoggingPlugin: PluginType { // Request를 보낼 때 호출 func willSend(_ request: RequestType, target: TargetType) { guard let httpRequest = request.request else { - print("--> 유효하지 않은 요청") + print("❌-->유효하지 않은 요청") return } let url = httpRequest.description let method = httpRequest.httpMethod ?? "unknown method" - var log = "----------------------------------------------------\n\n[\(method)] \(url)\n\n----------------------------------------------------\n" + var log = "✨✨✨✨✨✨✨✨✨✨✨✨✨✨\n\n[\(method)] \(url)\n\n✨✨✨✨✨✨✨✨✨✨✨✨✨✨\n" log.append("API: \(target)\n") if let headers = httpRequest.allHTTPHeaderFields, !headers.isEmpty { log.append("header: \(headers)\n") @@ -27,7 +27,7 @@ final class MoyaLoggingPlugin: PluginType { if let body = httpRequest.httpBody, let bodyString = String(bytes: body, encoding: String.Encoding.utf8) { log.append("\(bodyString)\n") } - log.append("------------------- END \(method) --------------------------") + log.append("✨✨✨✨✨✨✨✨ END \(method) ✨✨✨✨✨✨✨✨") print(log) } // Response가 왔을 때 @@ -44,7 +44,7 @@ final class MoyaLoggingPlugin: PluginType { let request = response.request let url = request?.url?.absoluteString ?? "nil" let statusCode = response.statusCode - var log = "------------------- 네트워크 통신 성공 -------------------" + var log = "✅✅✅✅✅ 네트워크 통신 성공 ✅✅✅✅✅" log.append("\n[\(statusCode)] \(url)\n----------------------------------------------------\n") log.append("API: \(target)\n") response.response?.allHeaderFields.forEach { @@ -53,7 +53,7 @@ final class MoyaLoggingPlugin: PluginType { if let reString = String(bytes: response.data, encoding: String.Encoding.utf8) { log.append("\(reString)\n") } - log.append("------------------- END HTTP (\(response.data.count)-byte body) -------------------") + log.append("✅✅✅✅✅ END HTTP (\(response.data.count)-byte body) ✅✅✅✅✅") print(log) } @@ -63,9 +63,9 @@ final class MoyaLoggingPlugin: PluginType { return } var log = "네트워크 오류" - log.append("<-- \(error.errorCode) \(target)\n") + log.append("😭 <-- \(error.errorCode) \(target)\n") log.append("\(error.failureReason ?? error.errorDescription ?? "unknown error")\n") - log.append("<-- END HTTP") + log.append("😭 <-- END HTTP") print(log) } } diff --git a/HMH_iOS/HMH_iOS/Network/Foundation/NetworkHelper.swift b/HMH_iOS/HMH_iOS/Network/Foundation/NetworkHelper.swift new file mode 100644 index 0000000..010014e --- /dev/null +++ b/HMH_iOS/HMH_iOS/Network/Foundation/NetworkHelper.swift @@ -0,0 +1,38 @@ +// +// Encodable.swift +// HMH_iOS +// +// Created by 지희의 MAC on 1/11/24. +// + +import Foundation + +extension Encodable { + func toDictionary() -> [String: Any] { + do { + let data = try JSONEncoder().encode(self) + let dic = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [String: Any] + return dic ?? [:] + } catch { + return [:] + } + } +} + +struct NetworkHelper { + private init() {} + + // 상태 코드와 데이터, decoding type을 가지고 통신의 결과를 핸들링하는 함수 + static func parseJSON (by statusCode: Int, data: Data, type: T.Type) -> NetworkResult { + let decoder = JSONDecoder() + + guard let decodedData = try? decoder.decode(BaseResponse.self, from: data) else { return .pathErr } + + switch statusCode { + case 200..<300: return .success(decodedData.data as Any) + case 400..<500: return .requestErr(decodedData.data as Any) + case 500..<600: return .serverErr + default: return .networkFail + } + } +} diff --git a/HMH_iOS/HMH_iOS/Network/Foundation/NetworkRequest.swift b/HMH_iOS/HMH_iOS/Network/Foundation/NetworkRequest.swift new file mode 100644 index 0000000..18325c4 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Network/Foundation/NetworkRequest.swift @@ -0,0 +1,36 @@ +// +// NetworkRequest.swift +// HMH_iOS +// +// Created by 지희의 MAC on 1/11/24. +// + +import Foundation +import Moya + +struct NetworkRequest { + let url: String + let httpMethod: Moya.Method + let body: Data? // optional + let headers: [String: String]? // optional + + init(url: String, + httpMethod: Moya.Method, + requestBody: Data? = nil, + headers: [String: String]? = nil + ) { + self.url = url + self.httpMethod = httpMethod + self.body = requestBody + self.headers = headers + } + + func createURLRequest(with url: URL) -> URLRequest { + var urlRequest = URLRequest(url: url) + urlRequest.httpMethod = httpMethod.rawValue + urlRequest.httpBody = body + urlRequest.allHTTPHeaderFields = headers ?? [:] + return urlRequest + } +} + diff --git a/HMH_iOS/HMH_iOS/Network/Foundation/NetworkResult.swift b/HMH_iOS/HMH_iOS/Network/Foundation/NetworkResult.swift new file mode 100644 index 0000000..61378b2 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Network/Foundation/NetworkResult.swift @@ -0,0 +1,68 @@ +// +// NetworkResult.swift +// HMH_iOS +// +// Created by 지희의 MAC on 1/11/24. +// + +import Foundation + +import Moya +import Alamofire + +enum NetworkResult { + case success(T) // 서버 통신 성공했을 때, + case requestErr(T) // 요청 에러 발생했을 때, + case decodedErr // 디코딩 오류 발생했을 때, + case pathErr // 경로 에러 발생했을 때, + case authorizationFail(T) // 토큰 인증 오류, + case serverErr // 서버의 내부적 에러가 발생했을 때, + case networkFail // 네트워크 연결 실패했을 때 +} + +enum NetworkError: Error { + case empty + case timeout(Error) + case internetConnection(Error) + case restError(errorCode: String?, errorMessage: String?) +} + +extension NetworkError { + /// `Error` 타입을 `URLError`로 바꿉니다. + static func convertToURLError(_ error: Error) -> URLError? { + switch error { + case let MoyaError.underlying(afError as AFError, _): + fallthrough + case let afError as AFError: + return afError.underlyingError as? URLError + case let MoyaError.underlying(urlError as URLError, _): + fallthrough + case let urlError as URLError: + return urlError + default: + return nil + } + } + + /// 인터넷에 연결되어 있는지를 판별합니다. + static func isNotConnection(error: Error) -> Bool { + Self.convertToURLError(error)?.code == .notConnectedToInternet + } + + /// 중간에 인터넷 연결이 끊어졌는지를 판별합니다. + static func isLostConnection(error: Error) -> Bool { + switch error { + case let AFError.sessionTaskFailed(error: posixError as POSIXError) + where posixError.code == .ECONNABORTED: // eConnAboarted: Software caused connection abort. + break + case let MoyaError.underlying(urlError as URLError, _): + fallthrough + case let urlError as URLError: + guard urlError.code == URLError.networkConnectionLost else { fallthrough } // A client or server connection was severed in the middle of an in-progress load. + break + default: + return false + } + return true + } +} diff --git a/HMH_iOS/HMH_iOS/Network/Foundation/ResponseData.swift b/HMH_iOS/HMH_iOS/Network/Foundation/ResponseData.swift new file mode 100644 index 0000000..e670109 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Network/Foundation/ResponseData.swift @@ -0,0 +1,49 @@ +// +// ResponseData.swift +// HMH_iOS +// +// Created by 지희의 MAC on 1/11/24. +// + +import Foundation +import Moya + +struct ResponseData { + struct CommonResponse: Codable { + let result: Model + } + + static func processResponse(_ result: Result) -> Result { + switch result { + case .success(let response): + do { + // status code가 200...299인 경우만 success로 체크 (아니면 예외발생) + _ = try response.filterSuccessfulStatusCodes() + + let commonResponse = try JSONDecoder().decode(CommonResponse.self, from: response.data) + return .success(commonResponse.result) + } catch { + return .failure(error) + } + + case .failure(let error): + return .failure(error) + } + } + + static func processJSONResponse(_ result: Result) -> Result { + switch result { + case .success(let response): + do { + let model = try JSONDecoder().decode(Model.self, from: response.data) + return .success(model) + } catch { + return .failure(error) + } + case .failure(let error): + + return .failure(error) + } + } + +} diff --git a/HMH_iOS/HMH_iOS/Network/Router/ChallengeRouter.swift b/HMH_iOS/HMH_iOS/Network/Router/ChallengeRouter.swift new file mode 100644 index 0000000..5487f2a --- /dev/null +++ b/HMH_iOS/HMH_iOS/Network/Router/ChallengeRouter.swift @@ -0,0 +1,38 @@ +// +// ChallengeRouter.swift +// HMH_iOS +// +// Created by 지희의 MAC on 1/12/24. +// + +import Foundation + +import Moya + +enum ChallengeRouter { + case createChallenge +} + +extension ChallengeRouter: BaseTargetType { + var path: String { + switch self { + case .createChallenge: + return "challenge" + } + } + + var method: Moya.Method { + switch self { + case .createChallenge: + return .post + } + } + + var task: Moya.Task { + switch self { + case .createChallenge: + return .requestPlain // 추후 변경 완료 + } + } +} + diff --git a/HMH_iOS/HMH_iOS/Network/Service/C.swift b/HMH_iOS/HMH_iOS/Network/Service/C.swift deleted file mode 100644 index 5dc5ddc..0000000 --- a/HMH_iOS/HMH_iOS/Network/Service/C.swift +++ /dev/null @@ -1,8 +0,0 @@ -// -// C.swift -// HMH_iOS -// -// Created by Seonwoo Kim on 12/23/23. -// - -import Foundation diff --git a/HMH_iOS/HMH_iOS/Network/Service/Providers.swift b/HMH_iOS/HMH_iOS/Network/Service/Providers.swift new file mode 100644 index 0000000..5c7447b --- /dev/null +++ b/HMH_iOS/HMH_iOS/Network/Service/Providers.swift @@ -0,0 +1,24 @@ +// +// Providers.swift +// HMH_iOS +// +// Created by 지희의 MAC on 1/12/24. +// + +import Foundation +import Moya + +struct Providers { + static let departureSearchingProvider = MoyaProvider(withAuth: false) +} + +extension MoyaProvider { + convenience init(withAuth: Bool) { + if withAuth { + self.init(session: Session(interceptor: AuthInterceptor.shared), + plugins: [MoyaLoggingPlugin()]) + } else { + self.init(plugins: [MoyaLoggingPlugin()]) + } + } +} diff --git a/HMH_iOS/HMH_iOS/Network/Service/WeatherTarget.swift b/HMH_iOS/HMH_iOS/Network/Service/WeatherTarget.swift new file mode 100644 index 0000000..cd7aba1 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Network/Service/WeatherTarget.swift @@ -0,0 +1,79 @@ +// +// WheatherProvider.swift +// HMH_iOS +// +// Created by 지희의 MAC on 1/11/24. +// + +import Foundation +import Moya + +enum WeatherTarget { + case getWeather(WeatherRequestDTO) +} + +extension WeatherTarget: BaseTargetType { + var method: Moya.Method { + switch self { + case .getWeather: + return .get + } + } + + var path: String { + switch self { + case .getWeather: return "weather" + } + } + + var task: Task { + switch self { + case .getWeather(WeatherRequestDTO(q: "")) + return .requestPlain + } + } +} + + + + +struct APIManager { + + private let provider = MoyaProvider() + + let customEndpointClosure = { (target : WeatherTarget) -> Endpoint in + + return Endpoint(url: URL(target: target).absoluteString, sampleResponseClosure: {.networkResponse(400, target.sampleData)}, method: target.method, task: target.task, httpHeaderFields: target.headers) + + } + let weatherRequest = WeatherRequestDTO(q: "Seoul") + private var testingProvider : MoyaProvider? + + init(){ + + testingProvider = .init(endpointClosure: customEndpointClosure,stubClosure: MoyaProvider.immediatelyStub) + + } + + func weather(request: WeatherRequestDTO, completion : @escaping ([WeatherDTO]) -> () , failure : @escaping (String) -> ()){ + + provider.request(.getWeather(request), completion: { result in + switch result { + case let .success(response) : + do { + let weathermodel = try JSONDecoder().decode([WeatherDTO].self, from: response.data) + + completion(weathermodel) + } + catch let error{ + failure(error.localizedDescription) + } + + case let .failure(error): + failure(error.localizedDescription) + } + + }) + } + +} diff --git a/HMH_iOS/HMH_iOS/Presentation/Splash/ViewControllers/SplashViewController.swift b/HMH_iOS/HMH_iOS/Presentation/Splash/ViewControllers/SplashViewController.swift index c0839d4..6b15c60 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Splash/ViewControllers/SplashViewController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Splash/ViewControllers/SplashViewController.swift @@ -6,11 +6,21 @@ // import UIKit +import Moya final class SplashViewController: UIViewController { - + + let apiManager = APIManager() override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .systemYellow + let request = WeatherRequestDTO(q: "Seoul") + apiManager.weather(request: request) { data in + print(data) + } failure: { error in + print(error) + } + } } + From 71bb74d3570c33ec45e3c2784bc53b09084d356e Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Wed, 10 Jan 2024 21:39:36 +0900 Subject: [PATCH 064/101] =?UTF-8?q?[Fix/#47]=20pickerView=20-=20totalTime?= =?UTF-8?q?=20=EB=94=94=EC=9E=90=EC=9D=B8=20=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SelectTotalTimeController.swift | 18 ++++++++++--- .../Views/TotalTimePickerView.swift | 26 ++----------------- 2 files changed, 17 insertions(+), 27 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/SelectTotalTimeController.swift b/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/SelectTotalTimeController.swift index db3a35d..56f6271 100644 --- a/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/SelectTotalTimeController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/SelectTotalTimeController.swift @@ -12,6 +12,12 @@ import Then final class SelectTotalTimeController: OnboardingBaseViewController { private let pickerView = TotalTimePickerView() + private let titleLabel = UILabel().then { + $0.textColor = .gray2 + $0.font = .iosText2Medium20 + $0.text = "시간" + } + override func viewDidLoad() { super.viewDidLoad() setUI() @@ -30,13 +36,19 @@ final class SelectTotalTimeController: OnboardingBaseViewController { } private func setHierarchy() { - view.addSubview(pickerView) + view.addSubviews(pickerView,titleLabel) } private func setConstraints() { + titleLabel.snp.makeConstraints { + $0.top.equalTo(navigationBar.snp.bottom).offset(271.adjusted) + $0.leading.equalTo(pickerView.snp.trailing).inset(-12.adjusted) + } + pickerView.snp.makeConstraints { - $0.top.equalTo(mainTitleLabel.snp.bottom).offset(94.adjustedHeight) - $0.leading.trailing.equalTo(progressBar) + $0.leading.equalToSuperview().inset(137.adjusted) + $0.width.equalTo(65.adjusted) + $0.centerY.equalTo(titleLabel.snp.centerY) } } diff --git a/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/Views/TotalTimePickerView.swift b/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/Views/TotalTimePickerView.swift index a07ccd1..c50266e 100644 --- a/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/Views/TotalTimePickerView.swift +++ b/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/Views/TotalTimePickerView.swift @@ -19,16 +19,9 @@ final class TotalTimePickerView: UIPickerView { private let hours: [String] = ["1", "2", "3", "4", "5", "6"] - private let titleLabel = UILabel().then { - $0.textColor = .gray2 - $0.font = .iosText2Medium20 - $0.text = "시간" - } - override init(frame: CGRect) { super.init(frame: frame) - - setUI() + configurePickerView() setDelegate() } @@ -37,22 +30,6 @@ final class TotalTimePickerView: UIPickerView { fatalError("init(coder:) has not been implemented") } - private func setUI() { - setHierarchy() - setConstraints() - } - - private func setHierarchy() { - self.addSubview(titleLabel) - } - - private func setConstraints() { - titleLabel.snp.makeConstraints { - $0.centerY.equalToSuperview() - $0.trailing.equalToSuperview().inset(110.adjusted) - } - } - private func setDelegate() { self.delegate = self self.dataSource = self @@ -75,6 +52,7 @@ extension TotalTimePickerView: UIPickerViewDelegate { func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { self.reloadComponent(component) self.totalTimePickerDelegate?.updateAvailability() + print(hours[row]) } func pickerView(_ pickerView: UIPickerView, attributedTitleForRow row: Int, forComponent component: Int) -> NSAttributedString? { From b000098ea1bc44068d4dcdb58fe7474376a2bb1c Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Wed, 10 Jan 2024 22:45:16 +0900 Subject: [PATCH 065/101] =?UTF-8?q?[Fix/#47]=20String=20-=20=EC=8A=A4?= =?UTF-8?q?=ED=81=AC=EB=A6=B0=20=EA=B6=8C=ED=95=9C=20=ED=97=88=EC=9A=A9=20?= =?UTF-8?q?=ED=85=8D=EC=8A=A4=ED=8A=B8=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS/Global/Literals/String/String.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift b/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift index ff7ccba..4a11d67 100644 --- a/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift +++ b/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift @@ -86,7 +86,7 @@ enum StringLiteral { static let problemSurvey = "해당 문항은 최대 2개까지 선택할 수 있어요" static let selectPeriod = "첫 챌린지로 가볍게 도전하기 좋은 7일을 추천해요" static let selectTotalTime = "목표 이용 시간은 최대 6시간까지 설정할 수 있어요" - static let approvePermision = "언제든지 설정에서 스크린타임 권한을\n변경할 수 있어요" + static let approvePermision = "언제든지 설정에서 스크린타임과 알림\n권한을 변경할 수 있어요" static let appSelect = "목표 이용 시간이 지나면 앱이 잠겨요\n선택하고 싶은 앱은 언제든지 추가할 수 있어요" static let signInComplete = "이제 하면함에서 블랙홀 탈출을 위한\n여정을 시작해 볼까요?" } From a5d8e2283f188c9a9c754a2e1ded98b9b8d5ce9f Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Wed, 10 Jan 2024 22:51:21 +0900 Subject: [PATCH 066/101] =?UTF-8?q?[Fix/#47]=20TimePickerView=20-=20HMHTim?= =?UTF-8?q?ePickerView=20=ED=8C=8C=EC=9D=BC=20=ED=95=98=EB=82=98=EB=A1=9C?= =?UTF-8?q?=20=ED=86=B5=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj | 12 +- .../SelectTotalTimeController.swift | 12 +- ...ckerView.swift => HMHTimePickerView.swift} | 50 +++++-- .../Views/SpecificTimePickerView.swift | 136 ------------------ 4 files changed, 47 insertions(+), 163 deletions(-) rename HMH_iOS/HMH_iOS/Presentation/CreateChallenge/Views/{TotalTimePickerView.swift => HMHTimePickerView.swift} (62%) delete mode 100644 HMH_iOS/HMH_iOS/Presentation/CreateChallenge/Views/SpecificTimePickerView.swift diff --git a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj index 0b0e21e..285645b 100644 --- a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj +++ b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj @@ -82,8 +82,7 @@ 3666C8722B45F4B200564874 /* DeviceReport.appex in Embed ExtensionKit Extensions */ = {isa = PBXBuildFile; fileRef = 3666C8662B45F4B200564874 /* DeviceReport.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 3666C87A2B45F4F900564874 /* SelectedBlocker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3666C8792B45F4F900564874 /* SelectedBlocker.swift */; }; 3666C87C2B45F50F00564874 /* BlockingApplicationModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3666C87B2B45F50F00564874 /* BlockingApplicationModel.swift */; }; - 3666C8882B47110800564874 /* SpecificTimePickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3666C8862B47110800564874 /* SpecificTimePickerView.swift */; }; - 3666C8892B47110800564874 /* TotalTimePickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3666C8872B47110800564874 /* TotalTimePickerView.swift */; }; + 3666C8892B47110800564874 /* HMHTimePickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3666C8872B47110800564874 /* HMHTimePickerView.swift */; }; 3666C88B2B471B0D00564874 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3666C88A2B471B0D00564874 /* String.swift */; }; 3666C88D2B471B1D00564874 /* UIImage+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3666C88C2B471B1D00564874 /* UIImage+.swift */; }; 3666C88F2B471C5800564874 /* TabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3666C88E2B471C5800564874 /* TabBarController.swift */; }; @@ -251,8 +250,7 @@ 3666C8772B45F4C600564874 /* HMH_iOS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = HMH_iOS.entitlements; sourceTree = ""; }; 3666C8792B45F4F900564874 /* SelectedBlocker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectedBlocker.swift; sourceTree = ""; }; 3666C87B2B45F50F00564874 /* BlockingApplicationModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlockingApplicationModel.swift; sourceTree = ""; }; - 3666C8862B47110800564874 /* SpecificTimePickerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpecificTimePickerView.swift; sourceTree = ""; }; - 3666C8872B47110800564874 /* TotalTimePickerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TotalTimePickerView.swift; sourceTree = ""; }; + 3666C8872B47110800564874 /* HMHTimePickerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMHTimePickerView.swift; sourceTree = ""; }; 3666C88A2B471B0D00564874 /* String.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = String.swift; sourceTree = ""; }; 3666C88C2B471B1D00564874 /* UIImage+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImage+.swift"; sourceTree = ""; }; 3666C88E2B471C5800564874 /* TabBarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TabBarController.swift; sourceTree = ""; }; @@ -885,8 +883,7 @@ 3666C8852B47110800564874 /* Views */ = { isa = PBXGroup; children = ( - 3666C8862B47110800564874 /* SpecificTimePickerView.swift */, - 3666C8872B47110800564874 /* TotalTimePickerView.swift */, + 3666C8872B47110800564874 /* HMHTimePickerView.swift */, ); path = Views; sourceTree = ""; @@ -1088,7 +1085,7 @@ 0B50F9CB2B369813000C5046 /* AppDelegate.swift in Sources */, 0B7817522B4BE0280078E925 /* ProgressBarManager.swift in Sources */, 0B8A89C42B369FA000688BA6 /* F.swift in Sources */, - 3666C8892B47110800564874 /* TotalTimePickerView.swift in Sources */, + 3666C8892B47110800564874 /* HMHTimePickerView.swift in Sources */, 0B000CE92B4D9D6E00AEC582 /* SelectPeriodController.swift in Sources */, 174AF49A2B447CFB00450D07 /* ChanllengeViews.swift in Sources */, 0B000CEB2B4D9D9100AEC582 /* SelectTotalTimeController.swift in Sources */, @@ -1103,7 +1100,6 @@ 364923822B4FD68000BF7ACA /* APIConstants.swift in Sources */, 0BA193B92B4D4097007E3F9C /* SignInModel.swift in Sources */, 0B8A89AD2B369E3B00688BA6 /* HomeCell.swift in Sources */, - 3666C8882B47110800564874 /* SpecificTimePickerView.swift in Sources */, 17314FB72B4D93D30089A551 /* StoreCollectionViewCell.swift in Sources */, 174AF4922B447B4600450D07 /* MyPageViews.swift in Sources */, 364923992B505A3A00BF7ACA /* AuthInterceptor.swift in Sources */, diff --git a/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/SelectTotalTimeController.swift b/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/SelectTotalTimeController.swift index 56f6271..9da9e91 100644 --- a/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/SelectTotalTimeController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/ViewControllers/SelectTotalTimeController.swift @@ -11,7 +11,7 @@ import SnapKit import Then final class SelectTotalTimeController: OnboardingBaseViewController { - private let pickerView = TotalTimePickerView() + private let pickerView = HMHTimePickerView(type: .totalTime) private let titleLabel = UILabel().then { $0.textColor = .gray2 $0.font = .iosText2Medium20 @@ -41,13 +41,13 @@ final class SelectTotalTimeController: OnboardingBaseViewController { private func setConstraints() { titleLabel.snp.makeConstraints { - $0.top.equalTo(navigationBar.snp.bottom).offset(271.adjusted) - $0.leading.equalTo(pickerView.snp.trailing).inset(-12.adjusted) + $0.top.equalTo(progressBar.snp.bottom).offset(281.adjusted) + $0.leading.equalTo(pickerView.snp.trailing).inset(-2.adjusted) } pickerView.snp.makeConstraints { - $0.leading.equalToSuperview().inset(137.adjusted) - $0.width.equalTo(65.adjusted) + $0.leading.equalTo(progressBar.snp.leading).inset(106.adjusted) + $0.width.equalTo(67.adjusted) $0.centerY.equalTo(titleLabel.snp.centerY) } } @@ -77,7 +77,7 @@ extension SelectTotalTimeController: NextViewPushDelegate { } } -extension SelectTotalTimeController: TotalTimePickerDelegate { +extension SelectTotalTimeController: TimePickerDelegate { func updateAvailability() { nextButton.updateStatus(isEnabled: true) } diff --git a/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/Views/TotalTimePickerView.swift b/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/Views/HMHTimePickerView.swift similarity index 62% rename from HMH_iOS/HMH_iOS/Presentation/CreateChallenge/Views/TotalTimePickerView.swift rename to HMH_iOS/HMH_iOS/Presentation/CreateChallenge/Views/HMHTimePickerView.swift index c50266e..cc87afd 100644 --- a/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/Views/TotalTimePickerView.swift +++ b/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/Views/HMHTimePickerView.swift @@ -10,26 +10,49 @@ import UIKit import SnapKit import Then -protocol TotalTimePickerDelegate: AnyObject { +protocol TimePickerDelegate: AnyObject { func updateAvailability() } -final class TotalTimePickerView: UIPickerView { - weak var totalTimePickerDelegate: TotalTimePickerDelegate? +final class HMHTimePickerView: UIPickerView { + @frozen + enum TimePickerType { + case totalTime + case specificTime + case specificMinute + } + + private var type: TimePickerType = .totalTime + var isChanged: Bool = false + private var timeList: [String] = [] - private let hours: [String] = ["1", "2", "3", "4", "5", "6"] + weak var totalTimePickerDelegate: TimePickerDelegate? - override init(frame: CGRect) { - super.init(frame: frame) - + init(type: TimePickerType) { + super.init(frame: .zero) + self.type = type configurePickerView() setDelegate() + configureList() } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } + private func configureList() { + switch type { + case .totalTime: + timeList = ["1", "2", "3", "4", "5", "6"] + + case .specificTime: + timeList = ["0", "1"] + + case .specificMinute: + timeList = Array(0...59).map { String($0)} + } + } + private func setDelegate() { self.delegate = self self.dataSource = self @@ -40,9 +63,9 @@ final class TotalTimePickerView: UIPickerView { } } -extension TotalTimePickerView: UIPickerViewDelegate { +extension HMHTimePickerView: UIPickerViewDelegate { func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { - return hours[row] + return timeList[row] } var selectedRow: Int { @@ -51,8 +74,9 @@ extension TotalTimePickerView: UIPickerViewDelegate { func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { self.reloadComponent(component) + isChanged = true self.totalTimePickerDelegate?.updateAvailability() - print(hours[row]) + print(timeList[row]) } func pickerView(_ pickerView: UIPickerView, attributedTitleForRow row: Int, forComponent component: Int) -> NSAttributedString? { @@ -69,7 +93,7 @@ extension TotalTimePickerView: UIPickerViewDelegate { NSAttributedString.Key(rawValue: NSAttributedString.Key.font.rawValue): font ] - return NSAttributedString(string: hours[row], attributes: attributes) + return NSAttributedString(string: timeList[row], attributes: attributes) } func pickerView(_ pickerView: UIPickerView, rowHeightForComponent component: Int) -> CGFloat { @@ -77,13 +101,13 @@ extension TotalTimePickerView: UIPickerViewDelegate { } } -extension TotalTimePickerView: UIPickerViewDataSource{ +extension HMHTimePickerView: UIPickerViewDataSource{ func numberOfComponents(in pickerView: UIPickerView) -> Int { return 1 } func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { - return hours.count + return timeList.count } } diff --git a/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/Views/SpecificTimePickerView.swift b/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/Views/SpecificTimePickerView.swift deleted file mode 100644 index 72f0221..0000000 --- a/HMH_iOS/HMH_iOS/Presentation/CreateChallenge/Views/SpecificTimePickerView.swift +++ /dev/null @@ -1,136 +0,0 @@ -// -// SpecificTimePickerView.swift -// HMH_iOS -// -// Created by Seonwoo Kim on 1/4/24. -// - -import UIKit - -import SnapKit -import Then - -final class SpecificTimePickerView: UIPickerView { - private let hours: [String] = ["0", "1"] - private let minutes: [String] = Array(0...59).map { String($0) } - - private let hourLabel = UILabel().then { - $0.textColor = .gray2 - $0.font = .iosText2Medium20 - $0.text = "시간" - } - - private let minuteLabel = UILabel().then { - $0.textColor = .gray2 - $0.font = .iosText2Medium20 - $0.text = "분" - } - - override init(frame: CGRect) { - super.init(frame: frame) - - setUI() - configurePickerView() - setDelegate() - } - - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - private func setUI() { - setHierarchy() - setConstraints() - } - - private func setHierarchy() { - self.addSubviews(hourLabel, minuteLabel) - } - - private func setConstraints() { - hourLabel.snp.makeConstraints { - $0.centerY.equalToSuperview() - $0.leading.equalToSuperview().inset(122.adjusted) - } - - minuteLabel.snp.makeConstraints { - $0.centerY.equalToSuperview() - $0.trailing.equalToSuperview().inset(38.adjusted) - } - } - - private func setDelegate() { - self.delegate = self - self.dataSource = self - } - - private func configurePickerView() { - self.backgroundColor = .clear - } -} - -extension SpecificTimePickerView: UIPickerViewDelegate { - func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { - if component == 0 { - return hours[row] - } else { - return minutes[row] - } - } - - var selectedRow: Int { - return self.selectedRow(inComponent: 0) - } - - func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { - self.reloadComponent(component) - } - - func pickerView(_ pickerView: UIPickerView, attributedTitleForRow row: Int, forComponent component: Int) -> NSAttributedString? { - var color = UIColor.gray3 - var font = UIFont.iosText1Medium22 - - if component == 0 && row == pickerView.selectedRow(inComponent: 0) { - color = UIColor.whiteText - font = UIFont.iosText1Medium22 - } - - if component == 1 && row == pickerView.selectedRow(inComponent: 1) { - color = UIColor.whiteText - font = UIFont.iosText1Medium22 - } - - let attributes: [NSAttributedString.Key: Any] = [ - NSAttributedString.Key(rawValue: NSAttributedString.Key.foregroundColor.rawValue): color, - NSAttributedString.Key(rawValue: NSAttributedString.Key.font.rawValue): font - ] - - if component == 0 { - return NSAttributedString(string: hours[row], attributes: attributes) - } else { - return NSAttributedString(string: minutes[row], attributes: attributes) - } - } - - func pickerView(_ pickerView: UIPickerView, rowHeightForComponent component: Int) -> CGFloat { - return 53.adjustedHeight - } -} - -extension SpecificTimePickerView: UIPickerViewDataSource{ - func numberOfComponents(in pickerView: UIPickerView) -> Int { - return 2 - } - - func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { - if component == 0 { - return hours.count - } else { - return minutes.count - } - } -} - - - - From d8e17277a164d332a4c32266eba16a4f3e7fdfa2 Mon Sep 17 00:00:00 2001 From: Zoe Date: Fri, 12 Jan 2024 03:11:45 +0900 Subject: [PATCH 067/101] =?UTF-8?q?[Chore/#51]=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EC=BD=94=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Splash/ViewControllers/SplashViewController.swift | 8 -------- 1 file changed, 8 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/Splash/ViewControllers/SplashViewController.swift b/HMH_iOS/HMH_iOS/Presentation/Splash/ViewControllers/SplashViewController.swift index 6b15c60..75ac75c 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Splash/ViewControllers/SplashViewController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Splash/ViewControllers/SplashViewController.swift @@ -10,17 +10,9 @@ import Moya final class SplashViewController: UIViewController { - let apiManager = APIManager() override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .systemYellow - let request = WeatherRequestDTO(q: "Seoul") - apiManager.weather(request: request) { data in - print(data) - } failure: { error in - print(error) - } - } } From b722fd50432a6226db525eedb9c6898deb9309b6 Mon Sep 17 00:00:00 2001 From: Zoe Date: Fri, 12 Jan 2024 03:55:41 +0900 Subject: [PATCH 068/101] [Chore/#51] Code Convention --- HMH_iOS/HMH_iOS/Network/Base/BaseModel.swift | 1 - HMH_iOS/HMH_iOS/Network/Base/BaseTargetType.swift | 2 -- HMH_iOS/HMH_iOS/Network/Router/ChallengeRouter.swift | 1 - 3 files changed, 4 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Network/Base/BaseModel.swift b/HMH_iOS/HMH_iOS/Network/Base/BaseModel.swift index 2fd4689..399fd3d 100644 --- a/HMH_iOS/HMH_iOS/Network/Base/BaseModel.swift +++ b/HMH_iOS/HMH_iOS/Network/Base/BaseModel.swift @@ -12,4 +12,3 @@ struct BaseResponse: Decodable { var message: String? var data: T? } - diff --git a/HMH_iOS/HMH_iOS/Network/Base/BaseTargetType.swift b/HMH_iOS/HMH_iOS/Network/Base/BaseTargetType.swift index 69b3c50..7cedf55 100644 --- a/HMH_iOS/HMH_iOS/Network/Base/BaseTargetType.swift +++ b/HMH_iOS/HMH_iOS/Network/Base/BaseTargetType.swift @@ -8,8 +8,6 @@ import Foundation import Moya - - protocol BaseTargetType: TargetType {} typealias Parameters = [String: String] diff --git a/HMH_iOS/HMH_iOS/Network/Router/ChallengeRouter.swift b/HMH_iOS/HMH_iOS/Network/Router/ChallengeRouter.swift index 5487f2a..581e550 100644 --- a/HMH_iOS/HMH_iOS/Network/Router/ChallengeRouter.swift +++ b/HMH_iOS/HMH_iOS/Network/Router/ChallengeRouter.swift @@ -35,4 +35,3 @@ extension ChallengeRouter: BaseTargetType { } } } - From 3bc57c92dec25b1db4f76797b5dda7d420b2c0e6 Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Fri, 12 Jan 2024 14:24:17 +0900 Subject: [PATCH 069/101] =?UTF-8?q?[Feat/#46]=20LoginViewController=20-=20?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EC=84=B1=EA=B3=B5=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewControllers/LoginViewController.swift | 51 ++++++++++--------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift b/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift index 42a26ce..a1483b2 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift @@ -12,30 +12,9 @@ import Then import AuthenticationServices final class LoginViewController: UIViewController { - let authorizationButton = ASAuthorizationAppleIDButton(authorizationButtonType: .signIn, authorizationButtonStyle: .white) - func setAppleLoginButton() { - authorizationButton.addTarget(self, action: #selector(handleAuthorizationAppleIDButtonPress), for: .touchUpInside) - self.view.addSubview(authorizationButton) - authorizationButton.translatesAutoresizingMaskIntoConstraints = false - } - @objc - func handleAuthorizationAppleIDButtonPress() { - let appleIDProvider = ASAuthorizationAppleIDProvider() - let request = appleIDProvider.createRequest() - request.requestedScopes = [.fullName, .email] - print(request, "👍") - let authorizationController = ASAuthorizationController(authorizationRequests: [request]) - authorizationController.delegate = self - authorizationController.presentationContextProvider = self - authorizationController.performRequests() - } - - @objc func appleButtonTaped() { - print("tap") - } - - let swipeView = OnboardingSwipeView() + private let swipeView = OnboardingSwipeView() + let authorizationButton = ASAuthorizationAppleIDButton(authorizationButtonType: .signIn, authorizationButtonStyle: .white) override func viewDidLoad() { super.viewDidLoad() @@ -68,6 +47,32 @@ final class LoginViewController: UIViewController { } } +extension LoginViewController { + + func setAppleLoginButton() { + authorizationButton.addTarget(self, action: #selector(handleAuthorizationAppleIDButtonPress), for: .touchUpInside) + self.view.addSubview(authorizationButton) + authorizationButton.translatesAutoresizingMaskIntoConstraints = false + } + + @objc + func handleAuthorizationAppleIDButtonPress() { + let appleIDProvider = ASAuthorizationAppleIDProvider() + let request = appleIDProvider.createRequest() + request.requestedScopes = [.email] + print(request, "👍") + let authorizationController = ASAuthorizationController(authorizationRequests: [request]) + authorizationController.delegate = self + authorizationController.presentationContextProvider = self + authorizationController.performRequests() + } + + @objc func appleButtonTaped() { + print("tap") + } + +} + extension LoginViewController: ASAuthorizationControllerDelegate, ASAuthorizationControllerPresentationContextProviding{ func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor { From f3948fd40f3e036ad53dd37a3846f291bc37fd62 Mon Sep 17 00:00:00 2001 From: Zoe Date: Fri, 12 Jan 2024 14:51:52 +0900 Subject: [PATCH 070/101] =?UTF-8?q?[Set/#53]=20=EB=84=A4=ED=8A=B8=EC=9B=8C?= =?UTF-8?q?=ED=81=AC=20=EC=84=B8=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS/Info.plist | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/HMH_iOS/HMH_iOS/Info.plist b/HMH_iOS/HMH_iOS/Info.plist index 1c20cb8..9fcb576 100644 --- a/HMH_iOS/HMH_iOS/Info.plist +++ b/HMH_iOS/HMH_iOS/Info.plist @@ -33,5 +33,10 @@ + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + From 10f9fb8a7c238e96c700cafdaf5c4a663e0e1127 Mon Sep 17 00:00:00 2001 From: Zoe Date: Fri, 12 Jan 2024 15:46:30 +0900 Subject: [PATCH 071/101] =?UTF-8?q?[Fix/#53]=20=EB=84=A4=ED=8A=B8=EC=9B=8C?= =?UTF-8?q?=ED=81=AC=20=ED=86=B5=EC=8B=A0=20=EC=98=A4=EB=A5=98=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS/Network/Base/BaseTargetType.swift | 4 ---- HMH_iOS/HMH_iOS/Network/Service/Providers.swift | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Network/Base/BaseTargetType.swift b/HMH_iOS/HMH_iOS/Network/Base/BaseTargetType.swift index 7cedf55..b2c2d33 100644 --- a/HMH_iOS/HMH_iOS/Network/Base/BaseTargetType.swift +++ b/HMH_iOS/HMH_iOS/Network/Base/BaseTargetType.swift @@ -29,8 +29,4 @@ extension BaseTargetType { var sampleData: Data { return Data() } - - var validationType: ValidationType { - return .successCodes - } } diff --git a/HMH_iOS/HMH_iOS/Network/Service/Providers.swift b/HMH_iOS/HMH_iOS/Network/Service/Providers.swift index 5c7447b..0de78f3 100644 --- a/HMH_iOS/HMH_iOS/Network/Service/Providers.swift +++ b/HMH_iOS/HMH_iOS/Network/Service/Providers.swift @@ -9,7 +9,7 @@ import Foundation import Moya struct Providers { - static let departureSearchingProvider = MoyaProvider(withAuth: false) + static let challengeProvider = NetworkProvider(withAuth: false) } extension MoyaProvider { From 56d0881e63769a178d4d27c7b6d6d80ac6021843 Mon Sep 17 00:00:00 2001 From: Zoe Date: Fri, 12 Jan 2024 17:04:45 +0900 Subject: [PATCH 072/101] [Add/#54] Add Package Lottie --- HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj | 18 +++++++++++++++++- .../xcshareddata/swiftpm/Package.resolved | 9 +++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj index 92c7127..8c6b942 100644 --- a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj +++ b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj @@ -56,6 +56,7 @@ 174AF4982B447CF100450D07 /* ChanllengeModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 174AF4972B447CF100450D07 /* ChanllengeModels.swift */; }; 174AF49A2B447CFB00450D07 /* ChanllengeViews.swift in Sources */ = {isa = PBXBuildFile; fileRef = 174AF4992B447CFB00450D07 /* ChanllengeViews.swift */; }; 174AF49C2B447D0700450D07 /* ChallengeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 174AF49B2B447D0700450D07 /* ChallengeViewController.swift */; }; + 363863BD2B5129F2000FE5E7 /* Lottie in Frameworks */ = {isa = PBXBuildFile; productRef = 363863BC2B5129F2000FE5E7 /* Lottie */; }; 364923652B4F4FB800BF7ACA /* Config.swift in Sources */ = {isa = PBXBuildFile; fileRef = 364923642B4F4FB800BF7ACA /* Config.swift */; }; 364923682B4F513600BF7ACA /* BaseTargetType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 364923672B4F513600BF7ACA /* BaseTargetType.swift */; }; 3649236A2B4F514A00BF7ACA /* Moya in Frameworks */ = {isa = PBXBuildFile; productRef = 364923692B4F514A00BF7ACA /* Moya */; }; @@ -289,9 +290,9 @@ 36A3D8A62B3AB5A1007EA272 /* KakaoSDKFriend in Frameworks */, 36A3D89C2B3AB5A1007EA272 /* KakaoSDK in Frameworks */, 36A3D8AA2B3AB5A1007EA272 /* KakaoSDKNavi in Frameworks */, - 364923752B4F555F00BF7ACA /* Lottie in Frameworks */, 36A3D8AC2B3AB5A1007EA272 /* KakaoSDKShare in Frameworks */, 36A3D8992B3AB58A007EA272 /* Then in Frameworks */, + 363863BD2B5129F2000FE5E7 /* Lottie in Frameworks */, 36A3D8AE2B3AB5A1007EA272 /* KakaoSDKTalk in Frameworks */, 3649236A2B4F514A00BF7ACA /* Moya in Frameworks */, 36A3D8B22B3AB5A1007EA272 /* KakaoSDKUser in Frameworks */, @@ -936,6 +937,7 @@ 36A3D8AF2B3AB5A1007EA272 /* KakaoSDKTemplate */, 36A3D8B12B3AB5A1007EA272 /* KakaoSDKUser */, 364923692B4F514A00BF7ACA /* Moya */, + 363863BC2B5129F2000FE5E7 /* Lottie */, ); productName = HMH_iOS; productReference = 0B50F9C72B369813000C5046 /* HMH_iOS.app */; @@ -1010,6 +1012,7 @@ 36A3D8972B3AB58A007EA272 /* XCRemoteSwiftPackageReference "Then" */, 36A3D89A2B3AB5A1007EA272 /* XCRemoteSwiftPackageReference "kakao-ios-sdk" */, 364923662B4F510E00BF7ACA /* XCRemoteSwiftPackageReference "Moya" */, + 363863BB2B5129F1000FE5E7 /* XCRemoteSwiftPackageReference "lottie-spm" */, ); productRefGroup = 0B50F9C82B369813000C5046 /* Products */; projectDirPath = ""; @@ -1536,6 +1539,14 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ + 363863BB2B5129F1000FE5E7 /* XCRemoteSwiftPackageReference "lottie-spm" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/airbnb/lottie-spm.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 4.3.4; + }; + }; 364923662B4F510E00BF7ACA /* XCRemoteSwiftPackageReference "Moya" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/Moya/Moya"; @@ -1571,6 +1582,11 @@ /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ + 363863BC2B5129F2000FE5E7 /* Lottie */ = { + isa = XCSwiftPackageProductDependency; + package = 363863BB2B5129F1000FE5E7 /* XCRemoteSwiftPackageReference "lottie-spm" */; + productName = Lottie; + }; 364923692B4F514A00BF7ACA /* Moya */ = { isa = XCSwiftPackageProductDependency; package = 364923662B4F510E00BF7ACA /* XCRemoteSwiftPackageReference "Moya" */; diff --git a/HMH_iOS/HMH_iOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/HMH_iOS/HMH_iOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 5ed1b91..5074672 100644 --- a/HMH_iOS/HMH_iOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/HMH_iOS/HMH_iOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -18,6 +18,15 @@ "version" : "2.20.0" } }, + { + "identity" : "lottie-spm", + "kind" : "remoteSourceControl", + "location" : "https://github.com/airbnb/lottie-spm.git", + "state" : { + "revision" : "96790253c1a82223bd43da651121abfd7e96d0f3", + "version" : "4.3.4" + } + }, { "identity" : "moya", "kind" : "remoteSourceControl", From eede08b4d5f1bcbaaef6a9e15755bf0926fa5512 Mon Sep 17 00:00:00 2001 From: Zoe Date: Fri, 12 Jan 2024 17:06:09 +0900 Subject: [PATCH 073/101] =?UTF-8?q?[Fix/#54]=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Splash/ViewControllers/SplashViewController.swift | 8 -------- 1 file changed, 8 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/Splash/ViewControllers/SplashViewController.swift b/HMH_iOS/HMH_iOS/Presentation/Splash/ViewControllers/SplashViewController.swift index 6b15c60..75ac75c 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Splash/ViewControllers/SplashViewController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Splash/ViewControllers/SplashViewController.swift @@ -10,17 +10,9 @@ import Moya final class SplashViewController: UIViewController { - let apiManager = APIManager() override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .systemYellow - let request = WeatherRequestDTO(q: "Seoul") - apiManager.weather(request: request) { data in - print(data) - } failure: { error in - print(error) - } - } } From 7b114d9116e48a41c0771608fd2dff4d9e3a9488 Mon Sep 17 00:00:00 2001 From: Zoe Date: Fri, 12 Jan 2024 19:21:30 +0900 Subject: [PATCH 074/101] =?UTF-8?q?[Set/#53]=20=20=EB=84=A4=ED=8A=B8?= =?UTF-8?q?=EC=9B=8C=ED=81=AC=20=EC=84=B8=ED=8C=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HMH_iOS/Network/Base/BaseTargetType.swift | 1 + .../Network/Foundation/APIConstants.swift | 6 +-- .../Network/Foundation/NetworkHelper.swift | 1 + .../Network/Foundation/NetworkRequest.swift | 44 +++++++++---------- .../Network/Router/ChallengeRouter.swift | 13 ++++-- 5 files changed, 36 insertions(+), 29 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Network/Base/BaseTargetType.swift b/HMH_iOS/HMH_iOS/Network/Base/BaseTargetType.swift index b2c2d33..eb0b5cc 100644 --- a/HMH_iOS/HMH_iOS/Network/Base/BaseTargetType.swift +++ b/HMH_iOS/HMH_iOS/Network/Base/BaseTargetType.swift @@ -29,4 +29,5 @@ extension BaseTargetType { var sampleData: Data { return Data() } + } diff --git a/HMH_iOS/HMH_iOS/Network/Foundation/APIConstants.swift b/HMH_iOS/HMH_iOS/Network/Foundation/APIConstants.swift index 7b66696..6545e11 100644 --- a/HMH_iOS/HMH_iOS/Network/Foundation/APIConstants.swift +++ b/HMH_iOS/HMH_iOS/Network/Foundation/APIConstants.swift @@ -12,15 +12,15 @@ struct APIConstants{ static let contentType = "Content-Type" static let applicationJSON = "application/json" static let auth = "Authorization" - static let accessToken = "" // TO-DO: AccessToken - static let appleAccessToken = "" + static let accessToken = "Bearer " // TO-DO: AccessToken + static let appleAccessToken = "" static let OS = "OS" static let iOS = "iOS" } extension APIConstants{ static let hasSocialTokenHeader = [contentType: applicationJSON, - auth : accessToken] + auth : appleAccessToken] static let hasTokenHeader = [contentType: applicationJSON, OS: iOS, auth : accessToken] diff --git a/HMH_iOS/HMH_iOS/Network/Foundation/NetworkHelper.swift b/HMH_iOS/HMH_iOS/Network/Foundation/NetworkHelper.swift index 010014e..30c119e 100644 --- a/HMH_iOS/HMH_iOS/Network/Foundation/NetworkHelper.swift +++ b/HMH_iOS/HMH_iOS/Network/Foundation/NetworkHelper.swift @@ -35,4 +35,5 @@ struct NetworkHelper { default: return .networkFail } } + } diff --git a/HMH_iOS/HMH_iOS/Network/Foundation/NetworkRequest.swift b/HMH_iOS/HMH_iOS/Network/Foundation/NetworkRequest.swift index 18325c4..db9907b 100644 --- a/HMH_iOS/HMH_iOS/Network/Foundation/NetworkRequest.swift +++ b/HMH_iOS/HMH_iOS/Network/Foundation/NetworkRequest.swift @@ -8,29 +8,27 @@ import Foundation import Moya -struct NetworkRequest { - let url: String - let httpMethod: Moya.Method - let body: Data? // optional - let headers: [String: String]? // optional - - init(url: String, - httpMethod: Moya.Method, - requestBody: Data? = nil, - headers: [String: String]? = nil - ) { - self.url = url - self.httpMethod = httpMethod - self.body = requestBody - self.headers = headers +struct ResponseData { + struct CommonResponse: Codable { + let result: Model } - - func createURLRequest(with url: URL) -> URLRequest { - var urlRequest = URLRequest(url: url) - urlRequest.httpMethod = httpMethod.rawValue - urlRequest.httpBody = body - urlRequest.allHTTPHeaderFields = headers ?? [:] - return urlRequest + + static func processResponse(_ result: Result) -> Result { + switch result { + case .success(let response): + do { + // status code가 200...299인 경우만 success로 체크 (아니면 예외발생) + _ = try response.filterSuccessfulStatusCodes() + + let commonResponse = try JSONDecoder().decode(CommonResponse.self, from: response.data) + return .success(commonResponse.result) + } catch { + return .failure(error) + } + + case .failure(let error): + return .failure(error) + } } + } - diff --git a/HMH_iOS/HMH_iOS/Network/Router/ChallengeRouter.swift b/HMH_iOS/HMH_iOS/Network/Router/ChallengeRouter.swift index 581e550..91bc27d 100644 --- a/HMH_iOS/HMH_iOS/Network/Router/ChallengeRouter.swift +++ b/HMH_iOS/HMH_iOS/Network/Router/ChallengeRouter.swift @@ -10,10 +10,17 @@ import Foundation import Moya enum ChallengeRouter { - case createChallenge + case createChallenge(data: CreateChallengeRequestDTO) } extension ChallengeRouter: BaseTargetType { + private var headers: Parameters { + switch self { + case .createChallenge: + return APIConstants.hasTokenHeader + } + } + var path: String { switch self { case .createChallenge: @@ -30,8 +37,8 @@ extension ChallengeRouter: BaseTargetType { var task: Moya.Task { switch self { - case .createChallenge: - return .requestPlain // 추후 변경 완료 + case .createChallenge(let data): + return .requestJSONEncodable(data) } } } From 907a38275fee5528ea2d451819589da5e2f69404 Mon Sep 17 00:00:00 2001 From: Zoe Date: Fri, 12 Jan 2024 19:22:01 +0900 Subject: [PATCH 075/101] =?UTF-8?q?[Network/#53]=20DTO=20=EC=98=88?= =?UTF-8?q?=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CreateChallengeRequestDTO.swift | 10 ++++++++-- .../CreateChallengeResponseDTO.swift | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 HMH_iOS/HMH_iOS/Network/DTO/ChallengeModel/CreateChallengeResponseDTO.swift diff --git a/HMH_iOS/HMH_iOS/Network/DTO/ChallengeModel/CreateChallengeRequestDTO.swift b/HMH_iOS/HMH_iOS/Network/DTO/ChallengeModel/CreateChallengeRequestDTO.swift index 498edae..5086216 100644 --- a/HMH_iOS/HMH_iOS/Network/DTO/ChallengeModel/CreateChallengeRequestDTO.swift +++ b/HMH_iOS/HMH_iOS/Network/DTO/ChallengeModel/CreateChallengeRequestDTO.swift @@ -7,6 +7,12 @@ import Foundation -class CreateChallengeRequestDTO: Request { - +struct CreateChallengeRequestDTO: Codable { + let period, goalTime: Int + let apps: [App] +} + +struct App: Codable { + let appCode: String + let appGoalTime: Int } diff --git a/HMH_iOS/HMH_iOS/Network/DTO/ChallengeModel/CreateChallengeResponseDTO.swift b/HMH_iOS/HMH_iOS/Network/DTO/ChallengeModel/CreateChallengeResponseDTO.swift new file mode 100644 index 0000000..e510752 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Network/DTO/ChallengeModel/CreateChallengeResponseDTO.swift @@ -0,0 +1,17 @@ +// +// CreateChallengeResponseDTO.swift +// HMH_iOS +// +// Created by 지희의 MAC on 1/12/24. +// + +import Foundation + +struct CreateChallengeResponseDTO: Codable { + let challengeID: Int + + enum CodingKeys: String, CodingKey { + case challengeID = "challengeId" + + } +} From 438ba60a56cf9ee50ee4f063b55134ca070a844c Mon Sep 17 00:00:00 2001 From: Zoe Date: Fri, 12 Jan 2024 19:22:45 +0900 Subject: [PATCH 076/101] =?UTF-8?q?[Network/#53]=20Provider=20=EC=98=88?= =?UTF-8?q?=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS/Network/Service/Providers.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HMH_iOS/HMH_iOS/Network/Service/Providers.swift b/HMH_iOS/HMH_iOS/Network/Service/Providers.swift index 0de78f3..d0cccc9 100644 --- a/HMH_iOS/HMH_iOS/Network/Service/Providers.swift +++ b/HMH_iOS/HMH_iOS/Network/Service/Providers.swift @@ -12,7 +12,7 @@ struct Providers { static let challengeProvider = NetworkProvider(withAuth: false) } -extension MoyaProvider { +extension NetworkProvider { convenience init(withAuth: Bool) { if withAuth { self.init(session: Session(interceptor: AuthInterceptor.shared), From 587ac58050c889c58309df3b0d558a36943e157c Mon Sep 17 00:00:00 2001 From: Zoe Date: Fri, 12 Jan 2024 19:23:26 +0900 Subject: [PATCH 077/101] =?UTF-8?q?[Feat/#53]=20Interceptor=20=EC=84=B8?= =?UTF-8?q?=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS/Network/Base/AuthInterceptor.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/HMH_iOS/HMH_iOS/Network/Base/AuthInterceptor.swift b/HMH_iOS/HMH_iOS/Network/Base/AuthInterceptor.swift index 089f3e2..bfb3da4 100644 --- a/HMH_iOS/HMH_iOS/Network/Base/AuthInterceptor.swift +++ b/HMH_iOS/HMH_iOS/Network/Base/AuthInterceptor.swift @@ -21,5 +21,6 @@ final class AuthInterceptor: RequestInterceptor { } func retry(_ request: Request, for session: Session, dueTo error: Error, completion: @escaping (RetryResult) -> Void) { + print("retry") } } From 8f69dcfc0634240c869c97a0c9d0e69b92c3a64d Mon Sep 17 00:00:00 2001 From: Zoe Date: Fri, 12 Jan 2024 19:23:47 +0900 Subject: [PATCH 078/101] =?UTF-8?q?[Chore/#53]=20=ED=94=84=EB=A1=9C?= =?UTF-8?q?=EC=A0=9D=ED=8A=B8=ED=8C=8C=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj index 285645b..fad39ee 100644 --- a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj +++ b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj @@ -56,6 +56,7 @@ 174AF4982B447CF100450D07 /* ChanllengeModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 174AF4972B447CF100450D07 /* ChanllengeModels.swift */; }; 174AF49A2B447CFB00450D07 /* ChanllengeViews.swift in Sources */ = {isa = PBXBuildFile; fileRef = 174AF4992B447CFB00450D07 /* ChanllengeViews.swift */; }; 174AF49C2B447D0700450D07 /* ChallengeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 174AF49B2B447D0700450D07 /* ChallengeViewController.swift */; }; + 363863BA2B50782E000FE5E7 /* CreateChallengeResponseDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 363863B92B50782E000FE5E7 /* CreateChallengeResponseDTO.swift */; }; 364923652B4F4FB800BF7ACA /* Config.swift in Sources */ = {isa = PBXBuildFile; fileRef = 364923642B4F4FB800BF7ACA /* Config.swift */; }; 364923682B4F513600BF7ACA /* BaseTargetType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 364923672B4F513600BF7ACA /* BaseTargetType.swift */; }; 3649236A2B4F514A00BF7ACA /* Moya in Frameworks */ = {isa = PBXBuildFile; productRef = 364923692B4F514A00BF7ACA /* Moya */; }; @@ -219,6 +220,7 @@ 174AF4972B447CF100450D07 /* ChanllengeModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChanllengeModels.swift; sourceTree = ""; }; 174AF4992B447CFB00450D07 /* ChanllengeViews.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChanllengeViews.swift; sourceTree = ""; }; 174AF49B2B447D0700450D07 /* ChallengeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChallengeViewController.swift; sourceTree = ""; }; + 363863B92B50782E000FE5E7 /* CreateChallengeResponseDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateChallengeResponseDTO.swift; sourceTree = ""; }; 364923612B4F4E7D00BF7ACA /* Config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = ""; }; 364923642B4F4FB800BF7ACA /* Config.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Config.swift; sourceTree = ""; }; 364923672B4F513600BF7ACA /* BaseTargetType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseTargetType.swift; sourceTree = ""; }; @@ -812,6 +814,7 @@ isa = PBXGroup; children = ( 3649239F2B505F2000BF7ACA /* CreateChallengeRequestDTO.swift */, + 363863B92B50782E000FE5E7 /* CreateChallengeResponseDTO.swift */, ); path = ChallengeModel; sourceTree = ""; @@ -1141,6 +1144,7 @@ 3666C89B2B48516500564874 /* ChallengeView.swift in Sources */, 364923682B4F513600BF7ACA /* BaseTargetType.swift in Sources */, 3666C88D2B471B1D00564874 /* UIImage+.swift in Sources */, + 363863BA2B50782E000FE5E7 /* CreateChallengeResponseDTO.swift in Sources */, 3666C87C2B45F50F00564874 /* BlockingApplicationModel.swift in Sources */, 0B0035402B43D64D00DA140C /* HMHNavigationBar.swift in Sources */, 0BA193B22B4CE908007E3F9C /* SurveyView.swift in Sources */, From 75c9eb26833a50601232ba91fa649c3d2a76336f Mon Sep 17 00:00:00 2001 From: Zoe Date: Fri, 12 Jan 2024 21:53:42 +0900 Subject: [PATCH 079/101] =?UTF-8?q?[Fix/#51]=20=EC=BD=94=EB=93=9C=EB=A6=AC?= =?UTF-8?q?=EB=B7=B0=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS/Application/SceneDelegate.swift | 2 +- .../Challenge/ViewControllers/ChallengeViewController.swift | 3 +-- .../HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Application/SceneDelegate.swift b/HMH_iOS/HMH_iOS/Application/SceneDelegate.swift index 629882e..1c5370a 100644 --- a/HMH_iOS/HMH_iOS/Application/SceneDelegate.swift +++ b/HMH_iOS/HMH_iOS/Application/SceneDelegate.swift @@ -24,7 +24,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { DispatchQueue.main.asyncAfter(deadline: .now() + 2) { DispatchQueue.main.async{ - showLoginViewController() + showTabBarViewController() } } diff --git a/HMH_iOS/HMH_iOS/Presentation/Challenge/ViewControllers/ChallengeViewController.swift b/HMH_iOS/HMH_iOS/Presentation/Challenge/ViewControllers/ChallengeViewController.swift index 647fca0..9a7a70b 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Challenge/ViewControllers/ChallengeViewController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Challenge/ViewControllers/ChallengeViewController.swift @@ -49,7 +49,6 @@ final class ChallengeViewController: UIViewController { private func setDelegate() { challengeView.challengeCollectionView.delegate = self } - } extension ChallengeViewController: UICollectionViewDelegate { @@ -67,7 +66,7 @@ extension ChallengeViewController: UICollectionViewDelegate { selectedIndex = [1,0] } if challengeView.isDeleteMode { - if let previousSelectedCell = collectionView.cellForItem(at: selectedIndex) as? AppListCollectionViewCell { + if let previousSelectedCell = collectionView.cellForItem(at: selectedIndex) as? AppListCollectionViewCell { previousSelectedCell.isSelectedCell = false } if let currentSelectedCell = collectionView.cellForItem(at: indexPath) as? AppListCollectionViewCell { diff --git a/HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift b/HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift index 1acd2a3..ad3dac5 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift @@ -83,7 +83,6 @@ final class ChallengeView: UIView { @objc private func deleteButtonTapped() { isDeleteMode.toggle() - challengeCollectionView.reloadData() } } From 5f52d3e5f8dac615cc38577309188b245682f74d Mon Sep 17 00:00:00 2001 From: Zoe Date: Fri, 12 Jan 2024 22:02:50 +0900 Subject: [PATCH 080/101] =?UTF-8?q?[Chore/#53]=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=ED=8C=8C=EC=9D=BC=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Network/Service/WeatherTarget.swift | 79 ------------------- 1 file changed, 79 deletions(-) delete mode 100644 HMH_iOS/HMH_iOS/Network/Service/WeatherTarget.swift diff --git a/HMH_iOS/HMH_iOS/Network/Service/WeatherTarget.swift b/HMH_iOS/HMH_iOS/Network/Service/WeatherTarget.swift deleted file mode 100644 index cd7aba1..0000000 --- a/HMH_iOS/HMH_iOS/Network/Service/WeatherTarget.swift +++ /dev/null @@ -1,79 +0,0 @@ -// -// WheatherProvider.swift -// HMH_iOS -// -// Created by 지희의 MAC on 1/11/24. -// - -import Foundation -import Moya - -enum WeatherTarget { - case getWeather(WeatherRequestDTO) -} - -extension WeatherTarget: BaseTargetType { - var method: Moya.Method { - switch self { - case .getWeather: - return .get - } - } - - var path: String { - switch self { - case .getWeather: return "weather" - } - } - - var task: Task { - switch self { - case .getWeather(WeatherRequestDTO(q: "")) - return .requestPlain - } - } -} - - - - -struct APIManager { - - private let provider = MoyaProvider() - - let customEndpointClosure = { (target : WeatherTarget) -> Endpoint in - - return Endpoint(url: URL(target: target).absoluteString, sampleResponseClosure: {.networkResponse(400, target.sampleData)}, method: target.method, task: target.task, httpHeaderFields: target.headers) - - } - let weatherRequest = WeatherRequestDTO(q: "Seoul") - private var testingProvider : MoyaProvider? - - init(){ - - testingProvider = .init(endpointClosure: customEndpointClosure,stubClosure: MoyaProvider.immediatelyStub) - - } - - func weather(request: WeatherRequestDTO, completion : @escaping ([WeatherDTO]) -> () , failure : @escaping (String) -> ()){ - - provider.request(.getWeather(request), completion: { result in - switch result { - case let .success(response) : - do { - let weathermodel = try JSONDecoder().decode([WeatherDTO].self, from: response.data) - - completion(weathermodel) - } - catch let error{ - failure(error.localizedDescription) - } - - case let .failure(error): - failure(error.localizedDescription) - } - - }) - } - -} From 7a49efaeb685cb51db14f7fa990920543efaca6b Mon Sep 17 00:00:00 2001 From: boyeon Date: Fri, 12 Jan 2024 22:24:20 +0900 Subject: [PATCH 081/101] =?UTF-8?q?[Add/#44]=20Literals=20-=20=ED=99=88?= =?UTF-8?q?=ED=99=94=EB=A9=B4=20=EB=A6=AC=ED=84=B0=EB=9F=B4=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS/Global/Literals/String/String.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift b/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift index f05441f..1e73d35 100644 --- a/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift +++ b/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift @@ -15,7 +15,13 @@ enum StringLiteral { } enum Home { - static var blackHoleState = "블랙홀에 빠지지 않고\n우주를 유지해 보아요" + static var blackHoleFirstStep = "\(UserModel.dummy().userName)님을 위한\n우주가 생성되었어요" + static var blackHoleSecondStep = "블랙홀이 다가와요\n도파민의 유혹을 이겨내요" + static var blackHoleThridStep = "블랙홀이 가까워졌어요\n스마트폰을 멀리해 볼까요?" + static var blackHoleFourthStep = "블랙홀에 빠질 수 있어요\n스마트폰을 내려놓아요" + static var blackHoleFifthStep = "지금부터 앱을 사용하면\n챌린지를 실패해요" + + static var blackHoleFailure = "블랙홀에 빠졌어요\n내일은 목표를 이뤄보아요" static var totalGoalUsingTime = "총 목표 이용 시간" } From 6a4ff299707eb883c1ed1db946dd0c73a0cb9d6c Mon Sep 17 00:00:00 2001 From: boyeon Date: Fri, 12 Jan 2024 22:27:02 +0900 Subject: [PATCH 082/101] =?UTF-8?q?[Feat/#44]=20HomeViewCell=20-=20?= =?UTF-8?q?=ED=85=8D=EC=8A=A4=ED=8A=B8=EC=99=80=20=EC=9D=B4=EB=AF=B8?= =?UTF-8?q?=EC=A7=80=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=ED=98=B8=EC=B6=9C=20?= =?UTF-8?q?=ED=95=A8=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Presentation/Home/Cells/BlackHoleImageCell.swift | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/Home/Cells/BlackHoleImageCell.swift b/HMH_iOS/HMH_iOS/Presentation/Home/Cells/BlackHoleImageCell.swift index d12d2ca..ca0418c 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Home/Cells/BlackHoleImageCell.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Home/Cells/BlackHoleImageCell.swift @@ -15,13 +15,11 @@ final class BlackHoleImageCell: UICollectionViewCell { static let identifier = "BlackHoleImageCell" private let blackHoleImageView = UIImageView().then { - $0.image = ImageLiterals.TabBar.icHome $0.alpha = 0.1 } private let homeBlackHoleStateLabel = UILabel().then { $0.font = .iosTitle3Semibold22 $0.textColor = .whiteText - $0.setTextWithLineHeight(text: StringLiteral.Home.blackHoleState, lineHeight: 33) $0.numberOfLines = 2 } @@ -54,4 +52,11 @@ final class BlackHoleImageCell: UICollectionViewCell { $0.leading.equalToSuperview().inset(21.adjusted) } } + + func configureCell (image: UIImage, text: String){ + blackHoleImageView.image = image + homeBlackHoleStateLabel.text = text + homeBlackHoleStateLabel.setTextWithLineHeight(text: text, lineHeight: 33) + homeBlackHoleStateLabel.textAlignment = .left + } } From 9783f3f1f4a259f2aa32fd21b3bab7b72f99964b Mon Sep 17 00:00:00 2001 From: boyeon Date: Fri, 12 Jan 2024 22:27:58 +0900 Subject: [PATCH 083/101] =?UTF-8?q?[Fix/#44]=20HomeViewCell=20-=20?= =?UTF-8?q?=EC=8B=9C=EA=B0=84=20=EA=B3=84=EC=82=B0=20=EC=8B=9C=EC=A0=90=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS/Presentation/Home/Cells/MyGoalTimeCell.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/Home/Cells/MyGoalTimeCell.swift b/HMH_iOS/HMH_iOS/Presentation/Home/Cells/MyGoalTimeCell.swift index fbc5c88..6ded0dd 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Home/Cells/MyGoalTimeCell.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Home/Cells/MyGoalTimeCell.swift @@ -14,6 +14,8 @@ final class MyGoalTimeCell: UICollectionViewCell { static let identifier = "MyGoalTimeCell" + var progress: Float = 0 + private let totalGoalTimeLabel = UILabel().then { $0.font = .iosDetail4Medium12 $0.text = StringLiteral.Home.totalGoalUsingTime @@ -92,8 +94,9 @@ final class MyGoalTimeCell: UICollectionViewCell { updateTotalUsageTime(data: data) totalProgressBar.setProgress(0, animated: false) + let progress = Float(self.calculateTotalUsageTime(data: data)) / Float(self.totalTime) + self.progress = progress DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { - let progress = Float(self.calculateTotalUsageTime(data: data)) / Float(self.totalTime) self.totalProgressBar.setProgress(progress, animated: true) } } From 98356507a8ce3de15e037106e67134267cee6c65 Mon Sep 17 00:00:00 2001 From: boyeon Date: Fri, 12 Jan 2024 22:29:09 +0900 Subject: [PATCH 084/101] =?UTF-8?q?[Feat/#44]=20HomeView=20-=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EB=9E=98=EC=8A=A4=EB=B0=94=20=ED=8D=BC?= =?UTF-8?q?=EC=84=BC=ED=8A=B8=EC=97=90=20=EB=94=B0=EB=A5=B8=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=EC=99=80=20=ED=85=8D=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EB=B6=84=EA=B8=B0=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewControllers/HomeViewController.swift | 3 -- .../Presentation/Home/Views/HMHHomeView.swift | 34 +++++++++++++------ 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/Home/ViewControllers/HomeViewController.swift b/HMH_iOS/HMH_iOS/Presentation/Home/ViewControllers/HomeViewController.swift index 1a08238..b82f79b 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Home/ViewControllers/HomeViewController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Home/ViewControllers/HomeViewController.swift @@ -19,7 +19,6 @@ final class HomeViewController: UIViewController { private func setUI() { setHierarchy() setConstraints() - } private func setHierarchy() { @@ -37,5 +36,3 @@ final class HomeViewController: UIViewController { } } } - - diff --git a/HMH_iOS/HMH_iOS/Presentation/Home/Views/HMHHomeView.swift b/HMH_iOS/HMH_iOS/Presentation/Home/Views/HMHHomeView.swift index a20a763..da262fe 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Home/Views/HMHHomeView.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Home/Views/HMHHomeView.swift @@ -11,9 +11,10 @@ import SnapKit import Then final class HMHHomeView: UIView { - private let homeCollectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()).then { + let homeCollectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()).then { $0.backgroundColor = .clear } + var progressPrecent: Double = 0 override init(frame: CGRect) { super.init(frame: frame) @@ -80,20 +81,33 @@ extension HMHHomeView: UICollectionViewDataSource { } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + guard let blackholeImageCell = homeCollectionView.dequeueReusableCell(withReuseIdentifier: BlackHoleImageCell.identifier, for: indexPath) as? BlackHoleImageCell else { return UICollectionViewCell() } + guard let myGoalTimeCell = homeCollectionView.dequeueReusableCell(withReuseIdentifier: MyGoalTimeCell.identifier, for: indexPath) as? MyGoalTimeCell else { return UICollectionViewCell() } + guard let appUsingProgressViewCell = homeCollectionView.dequeueReusableCell(withReuseIdentifier: AppUsingProgressViewCell.identifier, for: indexPath) as? AppUsingProgressViewCell else { return UICollectionViewCell() } + + myGoalTimeCell.bindData(data: appUsingTimeModel) + self.progressPrecent = Double(myGoalTimeCell.progress) + switch indexPath.section { case 0: - guard let item = homeCollectionView.dequeueReusableCell(withReuseIdentifier: BlackHoleImageCell.identifier, for: indexPath) as? BlackHoleImageCell else { return UICollectionViewCell() } - return item - + if progressPrecent < 0.24 { + blackholeImageCell.configureCell(image: ImageLiterals.TabBar.icMyPage, text: StringLiteral.Home.blackHoleFirstStep) + } else if progressPrecent < 0.49 { + blackholeImageCell.configureCell(image: ImageLiterals.TabBar.icChallengeSelected, text: StringLiteral.Home.blackHoleSecondStep) + } else if progressPrecent < 0.74 { + blackholeImageCell.configureCell(image: ImageLiterals.TabBar.icChallenge, text: StringLiteral.Home.blackHoleThridStep) + } else if progressPrecent < 0.99 { + blackholeImageCell.configureCell(image: ImageLiterals.TabBar.icHomeSelected, text: StringLiteral.Home.blackHoleFourthStep) + } else { + blackholeImageCell.configureCell(image: ImageLiterals.TabBar.icMyPageSelected, text: StringLiteral.Home.blackHoleFifthStep) + } + return blackholeImageCell case 1: - guard let item = homeCollectionView.dequeueReusableCell(withReuseIdentifier: MyGoalTimeCell.identifier, for: indexPath) as? MyGoalTimeCell else { return UICollectionViewCell() } - item.bindData(data: appUsingTimeModel) - return item + return myGoalTimeCell case 2: - guard let item = homeCollectionView.dequeueReusableCell(withReuseIdentifier: AppUsingProgressViewCell.identifier, for: indexPath) as? AppUsingProgressViewCell else { return UICollectionViewCell() } - item.bindData(data: appUsingTimeModel[indexPath.row]) - return item + appUsingProgressViewCell.bindData(data: appUsingTimeModel[indexPath.row]) + return appUsingProgressViewCell default: return UICollectionViewCell() } From 6e6aec546cd84cadc84c7f3e8be671665f28a6ee Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Fri, 12 Jan 2024 22:34:20 +0900 Subject: [PATCH 085/101] =?UTF-8?q?[Add/#46]=20UserManager=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj | 16 ++++ .../SupportingFiles/User/UserManager.swift | 90 +++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 HMH_iOS/HMH_iOS/Global/SupportingFiles/User/UserManager.swift diff --git a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj index 6fc1f6e..918da6e 100644 --- a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj +++ b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj @@ -12,6 +12,8 @@ 0B000CED2B4D9DA800AEC582 /* ApprovePermisionController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B000CEC2B4D9DA800AEC582 /* ApprovePermisionController.swift */; }; 0B000CF12B4DA30F00AEC582 /* AppSelectViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B000CF02B4DA30F00AEC582 /* AppSelectViewController.swift */; }; 0B0035402B43D64D00DA140C /* HMHNavigationBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B00353F2B43D64D00DA140C /* HMHNavigationBar.swift */; }; + 0B17D3EB2B5104E000CFA3B7 /* UserManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B17D3EA2B5104E000CFA3B7 /* UserManager.swift */; }; + 0B17D3ED2B5108D200CFA3B7 /* UserDefaultWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B17D3EC2B5108D200CFA3B7 /* UserDefaultWrapper.swift */; }; 0B2C2D3B2B443BE90023CCFA /* Image.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B2C2D3A2B443BE90023CCFA /* Image.swift */; }; 0B2C2D412B4572240023CCFA /* HMHSelectButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B2C2D402B4572240023CCFA /* HMHSelectButton.swift */; }; 0B50F9CB2B369813000C5046 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B50F9CA2B369813000C5046 /* AppDelegate.swift */; }; @@ -163,6 +165,8 @@ 0B000CEC2B4D9DA800AEC582 /* ApprovePermisionController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApprovePermisionController.swift; sourceTree = ""; }; 0B000CF02B4DA30F00AEC582 /* AppSelectViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppSelectViewController.swift; sourceTree = ""; }; 0B00353F2B43D64D00DA140C /* HMHNavigationBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HMHNavigationBar.swift; sourceTree = ""; }; + 0B17D3EA2B5104E000CFA3B7 /* UserManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserManager.swift; sourceTree = ""; }; + 0B17D3EC2B5108D200CFA3B7 /* UserDefaultWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDefaultWrapper.swift; sourceTree = ""; }; 0B2C2D3A2B443BE90023CCFA /* Image.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Image.swift; sourceTree = ""; }; 0B2C2D402B4572240023CCFA /* HMHSelectButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HMHSelectButton.swift; sourceTree = ""; }; 0B50F9C72B369813000C5046 /* HMH_iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HMH_iOS.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -310,6 +314,15 @@ path = ViewControllers; sourceTree = ""; }; + 0B17D3E92B5104B900CFA3B7 /* User */ = { + isa = PBXGroup; + children = ( + 0B17D3EA2B5104E000CFA3B7 /* UserManager.swift */, + 0B17D3EC2B5108D200CFA3B7 /* UserDefaultWrapper.swift */, + ); + path = User; + sourceTree = ""; + }; 0B2C2D3C2B4559AE0023CCFA /* Onboarding */ = { isa = PBXGroup; children = ( @@ -458,6 +471,7 @@ 0B8A89982B369CF800688BA6 /* SupportingFiles */ = { isa = PBXGroup; children = ( + 0B17D3E92B5104B900CFA3B7 /* User */, 3666C8782B45F4D900564874 /* AppBlock */, 0B8A89992B369D0B00688BA6 /* Base */, ); @@ -1012,6 +1026,7 @@ 0B8A89AF2B369E4300688BA6 /* HomeModel.swift in Sources */, 3666C89F2B485C8F00564874 /* DateCollectionViewCell.swift in Sources */, 3666C87A2B45F4F900564874 /* SelectedBlocker.swift in Sources */, + 0B17D3ED2B5108D200CFA3B7 /* UserDefaultWrapper.swift in Sources */, 0BC0EBD42B494459003EF5D4 /* OnboardingSwipeView.swift in Sources */, 17314F9B2B4C485B0089A551 /* UserPointHeaderView.swift in Sources */, 36A3D9C02B409CBD007EA272 /* Font.swift in Sources */, @@ -1022,6 +1037,7 @@ 174AF4942B447B5500450D07 /* MyPageViewController.swift in Sources */, 0BA193B42B4D089C007E3F9C /* TimeSurveyViewController.swift in Sources */, 36A3D9B82B3EBC3B007EA272 /* UILabel+.swift in Sources */, + 0B17D3EB2B5104E000CFA3B7 /* UserManager.swift in Sources */, 0B50F9CB2B369813000C5046 /* AppDelegate.swift in Sources */, 0B7817522B4BE0280078E925 /* ProgressBarManager.swift in Sources */, 0B8A89C42B369FA000688BA6 /* F.swift in Sources */, diff --git a/HMH_iOS/HMH_iOS/Global/SupportingFiles/User/UserManager.swift b/HMH_iOS/HMH_iOS/Global/SupportingFiles/User/UserManager.swift new file mode 100644 index 0000000..7b9f626 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Global/SupportingFiles/User/UserManager.swift @@ -0,0 +1,90 @@ +// +// UserManager.swift +// HMH_iOS +// +// Created by Seonwoo Kim on 1/12/24. +// + +import Foundation + +final class UserManager { + static let shared = UserManager() + + @UserDefaultWrapper(key: "accessToken") private(set) var accessToken + @UserDefaultWrapper(key: "refreshToken") private(set) var refreshToken + @UserDefaultWrapper(key: "AppleToken") private(set) var appleToken + @UserDefaultWrapper(key: "userIdentifier") private(set) var appleUserIdentifier + @UserDefaultWrapper(key: "familyName") private(set) var familyName + @UserDefaultWrapper(key: "givenName") private(set) var givenName + @UserDefaultWrapper(key: "fullName") private(set) var fullName + @UserDefaultWrapper(key: "userId") private(set) var userId + + var hasAccessToken: Bool { return self.accessToken != nil } + var getAccessToken: String { return self.accessToken ?? "" } + var getRefreshToken: String { return self.refreshToken ?? "" } + var getAppleToken: String { return self.appleToken ?? "" } + var getUserIdentifier: String { return self.appleUserIdentifier ?? "" } + var getUserName: String { return self.familyName ?? "" } + var getGivenName: String { return self.givenName ?? "" } + var getFullName: String { return self.fullName ?? "" } + var getUserId: Int { return self.userId ?? 0} + + var haveFullName: Bool { + if fullName == "" { + return false + } else if fullName == nil { + return false + } else { + return true + } + } + + private init() {} +} + +extension UserManager { + func updateToken(_ accessToken: String, _ refreshToken: String) { + self.accessToken = accessToken + self.refreshToken = refreshToken + } + + func updateAppleToken(_ appleToken: String) { + self.appleToken = appleToken + } + + func updateUserIdentifier(_ appleUserIdentifier: String) { + self.appleUserIdentifier = appleUserIdentifier + } + + func updateUserName(_ givenName: String, _ familyName: String) { + self.givenName = givenName + self.familyName = familyName + self.fullName = familyName + givenName + } + + func updateUserId(_ userId: Int) { + self.userId = userId + } + + func setUserIdForApple(userId: String) { + self.appleUserIdentifier = appleUserIdentifier + } + + func clearAll() { + self.accessToken = nil + self.refreshToken = nil + self.appleToken = nil + self.appleUserIdentifier = nil + self.familyName = nil + self.givenName = nil + self.fullName = nil + self.userId = nil + } + + func clearData() { + self.accessToken = nil + self.refreshToken = nil + self.appleToken = nil + self.appleUserIdentifier = nil + } +} From 4c29f2b958b7d9de45ca4e8731cd43b62ffa9d50 Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Fri, 12 Jan 2024 22:35:06 +0900 Subject: [PATCH 086/101] =?UTF-8?q?[Add/#46]=20UserDefaultWrapper=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../User/UserDefaultWrapper.swift | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 HMH_iOS/HMH_iOS/Global/SupportingFiles/User/UserDefaultWrapper.swift diff --git a/HMH_iOS/HMH_iOS/Global/SupportingFiles/User/UserDefaultWrapper.swift b/HMH_iOS/HMH_iOS/Global/SupportingFiles/User/UserDefaultWrapper.swift new file mode 100644 index 0000000..d4c8f86 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Global/SupportingFiles/User/UserDefaultWrapper.swift @@ -0,0 +1,30 @@ +// +// UserDefaultWrapper.swift +// HMH_iOS +// +// Created by Seonwoo Kim on 1/12/24. +// + +import Foundation + +@propertyWrapper +struct UserDefaultWrapper { + + var wrappedValue: T? { + get { + return UserDefaults.standard.object(forKey: self.key) as? T + } + + set { + if newValue == nil { + UserDefaults.standard.removeObject(forKey: key) + } else { UserDefaults.standard.setValue(newValue, forKey: key) } + } + } + + private let key: String + + init(key: String) { + self.key = key + } +} From 9ae73f8688b9e07ecc88817e78d757887d2ddcfc Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Fri, 12 Jan 2024 22:42:57 +0900 Subject: [PATCH 087/101] =?UTF-8?q?[Feat/#46]=20SceneDelegate=20-=20?= =?UTF-8?q?=EC=95=A0=ED=94=8C=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EC=9C=A0?= =?UTF-8?q?=EC=A0=80=20=EC=83=81=ED=83=9C=20=EC=A1=B0=ED=9A=8C=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HMH_iOS/Application/SceneDelegate.swift | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Application/SceneDelegate.swift b/HMH_iOS/HMH_iOS/Application/SceneDelegate.swift index 629882e..9a3885a 100644 --- a/HMH_iOS/HMH_iOS/Application/SceneDelegate.swift +++ b/HMH_iOS/HMH_iOS/Application/SceneDelegate.swift @@ -6,11 +6,27 @@ // import UIKit +import AuthenticationServices class SceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? - + // + func sceneDidBecomeActive(_ scene: UIScene) { + let appleIDProvider = ASAuthorizationAppleIDProvider() + appleIDProvider.getCredentialState(forUserID: "000340.8d411a5d11d84e8da0c22ef43dce465a.1657" ?? "") { (credentialState, error) in + switch credentialState { + case .authorized: + print("authorized") + case .revoked: + print("revoked") + case .notFound: + print("notFound") + default: + break + } + } + } func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { guard let windowScene = (scene as? UIWindowScene) else { return } @@ -24,7 +40,15 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { DispatchQueue.main.asyncAfter(deadline: .now() + 2) { DispatchQueue.main.async{ - showLoginViewController() + if UserManager.shared.hasAccessToken { + //애플 로그인 토큰 리프레쉬 로직. 성공한다면 엑세스와 리프레시 토큰 업데이트 그러면서 이동 + // 토큰 리프레시가 실패 한다. 로그인 컨트롤러로 바로 이동. +// UserManager.shared.updateToken(,) + + showTabBarViewController() + } else { + showLoginViewController() + } } } From 72c5cd933e1e19f9ef83988c3807660ff1915c55 Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Fri, 12 Jan 2024 22:50:25 +0900 Subject: [PATCH 088/101] =?UTF-8?q?[Chore/#46]=20=EC=9E=90=EC=9E=98?= =?UTF-8?q?=ED=95=9C=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SupportingFiles/User/UserManager.swift | 8 +-- .../ViewControllers/LoginViewController.swift | 68 ++++++------------- 2 files changed, 26 insertions(+), 50 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Global/SupportingFiles/User/UserManager.swift b/HMH_iOS/HMH_iOS/Global/SupportingFiles/User/UserManager.swift index 7b9f626..2db9ca3 100644 --- a/HMH_iOS/HMH_iOS/Global/SupportingFiles/User/UserManager.swift +++ b/HMH_iOS/HMH_iOS/Global/SupportingFiles/User/UserManager.swift @@ -47,7 +47,7 @@ extension UserManager { self.accessToken = accessToken self.refreshToken = refreshToken } - + func updateAppleToken(_ appleToken: String) { self.appleToken = appleToken } @@ -55,7 +55,7 @@ extension UserManager { func updateUserIdentifier(_ appleUserIdentifier: String) { self.appleUserIdentifier = appleUserIdentifier } - + func updateUserName(_ givenName: String, _ familyName: String) { self.givenName = givenName self.familyName = familyName @@ -65,11 +65,11 @@ extension UserManager { func updateUserId(_ userId: Int) { self.userId = userId } - + func setUserIdForApple(userId: String) { self.appleUserIdentifier = appleUserIdentifier } - + func clearAll() { self.accessToken = nil self.refreshToken = nil diff --git a/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift b/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift index a1483b2..3189ce7 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift @@ -59,21 +59,14 @@ extension LoginViewController { func handleAuthorizationAppleIDButtonPress() { let appleIDProvider = ASAuthorizationAppleIDProvider() let request = appleIDProvider.createRequest() - request.requestedScopes = [.email] - print(request, "👍") + request.requestedScopes = [.fullName] let authorizationController = ASAuthorizationController(authorizationRequests: [request]) authorizationController.delegate = self authorizationController.presentationContextProvider = self authorizationController.performRequests() } - - @objc func appleButtonTaped() { - print("tap") - } - } - extension LoginViewController: ASAuthorizationControllerDelegate, ASAuthorizationControllerPresentationContextProviding{ func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor { return self.view.window! @@ -83,62 +76,45 @@ extension LoginViewController: ASAuthorizationControllerDelegate, ASAuthorizatio //로그인 성공 switch authorization.credential { case let appleIDCredential as ASAuthorizationAppleIDCredential: - // You can create an account in your system. let userIdentifier = appleIDCredential.user let fullName = appleIDCredential.fullName - let email = appleIDCredential.email - UserDefaults.standard.set(userIdentifier, forKey: "userIdentifier") if let authorizationCode = appleIDCredential.authorizationCode, let identityToken = appleIDCredential.identityToken, let authCodeString = String(data: authorizationCode, encoding: .utf8), let identifyTokenString = String(data: identityToken, encoding: .utf8) { - print("authorizationCode: \(authorizationCode)") - print("identityToken: \(identityToken)") - print("authCodeString: \(authCodeString)") - print("identifyTokenString: \(identifyTokenString)") - print("🚨", appleIDCredential) - if let bundleID = Bundle.main.bundleIdentifier { - UserDefaults.standard.removePersistentDomain(forName: bundleID) + if let unwrappedFullName = fullName, let givenName = unwrappedFullName.givenName, let familyName = unwrappedFullName.familyName { + UserManager.shared.updateUserName(givenName, familyName) + } else { + print("fullName이 없거나 givenName 또는 familyName이 없습니다.") } - // saveToUserDefaults("authorizationCode",keyValue: authorizationCode) - // saveToUserDefaults("identityToken",keyValue: identityToken) - // saveToUserDefaults(authCodeString,keyValue:"authCodeString") - // saveToUserDefaults(identifyTokenString,keyValue:"identifyTokenString") - // saveToUserDefaults("cool",keyValue:"userIdentifier") - + UserManager.shared.updateUserIdentifier(userIdentifier) } - print("useridentifier: \(userIdentifier)") - - - - //Move to MainPage - //let validVC = SignValidViewController() - //validVC.modalPresentationStyle = .fullScreen - //present(validVC, animated: true, completion: nil) - - case let passwordCredential as ASPasswordCredential: - // Sign in using an existing iCloud Keychain credential. - let username = passwordCredential.user - let password = passwordCredential.password - - print("username: \(username)") - print("password: \(password)") + // 로그인이 성공 한다면 + // 소셜 로그인 API 쏘기 403 -> 온보딩 뷰로 이동 + // 회원 가입이 필요한지 아닌지 확인, userId가 있는지 없는지 판별 + // 유저 메니저와 signInModel에 해당 값 저장 + print(UserManager.shared.getUserIdentifier) + print(UserManager.shared.getUserName) + if (UserManager.shared.appleUserIdentifier != nil) { + let nextViewController = TabBarController() + self.navigationController?.pushViewController(nextViewController, animated: true) + } else { + let nextViewController = TimeSurveyViewController() + self.navigationController?.pushViewController(nextViewController, animated: true) + } + default: break } } - func saveToUserDefaults(_ content: String, keyValue: String) { - // Save the userId to UserDefaults - UserDefaults.standard.set(content, forKey: keyValue) - } - - func authorizationController(controller: ASAuthorizationController, didCompleteWithError error: Error) { // 로그인 실패(유저의 취소도 포함) print("login failed - \(error.localizedDescription)") } } + + From 9ef10823824dc3c04b3515e9741e55a4d2fc7a8c Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Thu, 11 Jan 2024 17:41:52 +0900 Subject: [PATCH 089/101] =?UTF-8?q?[Feat/#46]=20=EC=95=A0=ED=94=8C?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=ED=83=80=EA=B2=9F=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS/HMH_iOS.entitlements | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/HMH_iOS/HMH_iOS/HMH_iOS.entitlements b/HMH_iOS/HMH_iOS/HMH_iOS.entitlements index e048c21..92f5bd8 100644 --- a/HMH_iOS/HMH_iOS/HMH_iOS.entitlements +++ b/HMH_iOS/HMH_iOS/HMH_iOS.entitlements @@ -2,6 +2,10 @@ + com.apple.developer.applesignin + + Default + com.apple.developer.family-controls From ad0cd830812ce8c2a2133815562b010f4d35cabc Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Thu, 11 Jan 2024 17:42:33 +0900 Subject: [PATCH 090/101] =?UTF-8?q?[Feat/#46]=20Login=20-=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=20=EB=B7=B0=20=EC=BB=A8=ED=8A=B8=EB=A1=A4?= =?UTF-8?q?=EB=9F=AC=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewControllers/LoginViewController.swift | 96 ++++++++++++++++++- 1 file changed, 91 insertions(+), 5 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift b/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift index da57696..42a26ce 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift @@ -13,10 +13,33 @@ import AuthenticationServices final class LoginViewController: UIViewController { let authorizationButton = ASAuthorizationAppleIDButton(authorizationButtonType: .signIn, authorizationButtonStyle: .white) + func setAppleLoginButton() { + authorizationButton.addTarget(self, action: #selector(handleAuthorizationAppleIDButtonPress), for: .touchUpInside) + self.view.addSubview(authorizationButton) + authorizationButton.translatesAutoresizingMaskIntoConstraints = false + } + + @objc + func handleAuthorizationAppleIDButtonPress() { + let appleIDProvider = ASAuthorizationAppleIDProvider() + let request = appleIDProvider.createRequest() + request.requestedScopes = [.fullName, .email] + print(request, "👍") + let authorizationController = ASAuthorizationController(authorizationRequests: [request]) + authorizationController.delegate = self + authorizationController.presentationContextProvider = self + authorizationController.performRequests() + } + + @objc func appleButtonTaped() { + print("tap") + } + let swipeView = OnboardingSwipeView() override func viewDidLoad() { super.viewDidLoad() + setAppleLoginButton() setUI() } @@ -43,11 +66,74 @@ final class LoginViewController: UIViewController { $0.height.equalTo(480) } } - - private func setAppleLoginButton() { - self.view.addSubview(authorizationButton) - authorizationButton.translatesAutoresizingMaskIntoConstraints = false - } } +extension LoginViewController: ASAuthorizationControllerDelegate, ASAuthorizationControllerPresentationContextProviding{ + func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor { + return self.view.window! + } + + func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) { + //로그인 성공 + switch authorization.credential { + case let appleIDCredential as ASAuthorizationAppleIDCredential: + // You can create an account in your system. + let userIdentifier = appleIDCredential.user + let fullName = appleIDCredential.fullName + let email = appleIDCredential.email + + UserDefaults.standard.set(userIdentifier, forKey: "userIdentifier") + if let authorizationCode = appleIDCredential.authorizationCode, + let identityToken = appleIDCredential.identityToken, + let authCodeString = String(data: authorizationCode, encoding: .utf8), + let identifyTokenString = String(data: identityToken, encoding: .utf8) { + print("authorizationCode: \(authorizationCode)") + print("identityToken: \(identityToken)") + print("authCodeString: \(authCodeString)") + print("identifyTokenString: \(identifyTokenString)") + print("🚨", appleIDCredential) + if let bundleID = Bundle.main.bundleIdentifier { + UserDefaults.standard.removePersistentDomain(forName: bundleID) + } + // saveToUserDefaults("authorizationCode",keyValue: authorizationCode) + // saveToUserDefaults("identityToken",keyValue: identityToken) + // saveToUserDefaults(authCodeString,keyValue:"authCodeString") + // saveToUserDefaults(identifyTokenString,keyValue:"identifyTokenString") + // saveToUserDefaults("cool",keyValue:"userIdentifier") + + } + + print("useridentifier: \(userIdentifier)") + + + + //Move to MainPage + //let validVC = SignValidViewController() + //validVC.modalPresentationStyle = .fullScreen + //present(validVC, animated: true, completion: nil) + + case let passwordCredential as ASPasswordCredential: + // Sign in using an existing iCloud Keychain credential. + let username = passwordCredential.user + let password = passwordCredential.password + + print("username: \(username)") + print("password: \(password)") + + default: + break + } + } + + func saveToUserDefaults(_ content: String, keyValue: String) { + // Save the userId to UserDefaults + UserDefaults.standard.set(content, forKey: keyValue) + } + + + func authorizationController(controller: ASAuthorizationController, didCompleteWithError error: Error) { + // 로그인 실패(유저의 취소도 포함) + print("login failed - \(error.localizedDescription)") + } +} From 42a5f156e14a6143b92d180cb1984fabd46983c8 Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Thu, 11 Jan 2024 17:43:11 +0900 Subject: [PATCH 091/101] =?UTF-8?q?[Fix/#46]=20SignModel=20-=20=EC=A3=BC?= =?UTF-8?q?=EC=84=9D=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Onboarding/Models/SignInModel.swift | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/Onboarding/Models/SignInModel.swift b/HMH_iOS/HMH_iOS/Presentation/Onboarding/Models/SignInModel.swift index 05871b7..d5d1095 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Onboarding/Models/SignInModel.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Onboarding/Models/SignInModel.swift @@ -5,26 +5,26 @@ // Created by Seonwoo Kim on 1/9/24. // -import Foundation - -struct SignInModel { - let socialPlatform: String - let onboarding: Onboarding - let challenge: Challenge -} - -struct Onboarding { - let averageUseTime: String - let problem: [String] -} - -struct Challenge { - let period: Int - let goalTime: Int - let apps: [Apps] -} - -struct Apps { - let appCode: String - let goalTime: Int -} +//import Foundation +// +//struct SignInModel { +// let socialPlatform: String +// let onboarding: Onboarding +// let challenge: Challenge +//} +// +//struct Onboarding { +// let averageUseTime: String +// let problem: [String] +//} +// +//struct Challenge { +// let period: Int +// let goalTime: Int +// let apps: [Apps] +//} +// +//struct Apps { +// let appCode: String +// let goalTime: Int +//} From dcf661a000415f523bae59a4516970d40212b0ec Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Fri, 12 Jan 2024 14:24:17 +0900 Subject: [PATCH 092/101] =?UTF-8?q?[Feat/#46]=20LoginViewController=20-=20?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EC=84=B1=EA=B3=B5=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewControllers/LoginViewController.swift | 51 ++++++++++--------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift b/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift index 42a26ce..a1483b2 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift @@ -12,30 +12,9 @@ import Then import AuthenticationServices final class LoginViewController: UIViewController { - let authorizationButton = ASAuthorizationAppleIDButton(authorizationButtonType: .signIn, authorizationButtonStyle: .white) - func setAppleLoginButton() { - authorizationButton.addTarget(self, action: #selector(handleAuthorizationAppleIDButtonPress), for: .touchUpInside) - self.view.addSubview(authorizationButton) - authorizationButton.translatesAutoresizingMaskIntoConstraints = false - } - @objc - func handleAuthorizationAppleIDButtonPress() { - let appleIDProvider = ASAuthorizationAppleIDProvider() - let request = appleIDProvider.createRequest() - request.requestedScopes = [.fullName, .email] - print(request, "👍") - let authorizationController = ASAuthorizationController(authorizationRequests: [request]) - authorizationController.delegate = self - authorizationController.presentationContextProvider = self - authorizationController.performRequests() - } - - @objc func appleButtonTaped() { - print("tap") - } - - let swipeView = OnboardingSwipeView() + private let swipeView = OnboardingSwipeView() + let authorizationButton = ASAuthorizationAppleIDButton(authorizationButtonType: .signIn, authorizationButtonStyle: .white) override func viewDidLoad() { super.viewDidLoad() @@ -68,6 +47,32 @@ final class LoginViewController: UIViewController { } } +extension LoginViewController { + + func setAppleLoginButton() { + authorizationButton.addTarget(self, action: #selector(handleAuthorizationAppleIDButtonPress), for: .touchUpInside) + self.view.addSubview(authorizationButton) + authorizationButton.translatesAutoresizingMaskIntoConstraints = false + } + + @objc + func handleAuthorizationAppleIDButtonPress() { + let appleIDProvider = ASAuthorizationAppleIDProvider() + let request = appleIDProvider.createRequest() + request.requestedScopes = [.email] + print(request, "👍") + let authorizationController = ASAuthorizationController(authorizationRequests: [request]) + authorizationController.delegate = self + authorizationController.presentationContextProvider = self + authorizationController.performRequests() + } + + @objc func appleButtonTaped() { + print("tap") + } + +} + extension LoginViewController: ASAuthorizationControllerDelegate, ASAuthorizationControllerPresentationContextProviding{ func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor { From 81541dffd204e6de88aabbed25340a9d2ba7f666 Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Fri, 12 Jan 2024 22:34:20 +0900 Subject: [PATCH 093/101] =?UTF-8?q?[Add/#46]=20UserManager=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj | 16 ++++ .../SupportingFiles/User/UserManager.swift | 90 +++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 HMH_iOS/HMH_iOS/Global/SupportingFiles/User/UserManager.swift diff --git a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj index 8c6b942..49b6085 100644 --- a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj +++ b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj @@ -12,6 +12,8 @@ 0B000CED2B4D9DA800AEC582 /* ApprovePermisionController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B000CEC2B4D9DA800AEC582 /* ApprovePermisionController.swift */; }; 0B000CF12B4DA30F00AEC582 /* AppSelectViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B000CF02B4DA30F00AEC582 /* AppSelectViewController.swift */; }; 0B0035402B43D64D00DA140C /* HMHNavigationBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B00353F2B43D64D00DA140C /* HMHNavigationBar.swift */; }; + 0B17D3EB2B5104E000CFA3B7 /* UserManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B17D3EA2B5104E000CFA3B7 /* UserManager.swift */; }; + 0B17D3ED2B5108D200CFA3B7 /* UserDefaultWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B17D3EC2B5108D200CFA3B7 /* UserDefaultWrapper.swift */; }; 0B2C2D3B2B443BE90023CCFA /* Image.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B2C2D3A2B443BE90023CCFA /* Image.swift */; }; 0B2C2D412B4572240023CCFA /* HMHSelectButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B2C2D402B4572240023CCFA /* HMHSelectButton.swift */; }; 0B50F9CB2B369813000C5046 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B50F9CA2B369813000C5046 /* AppDelegate.swift */; }; @@ -174,6 +176,8 @@ 0B000CEC2B4D9DA800AEC582 /* ApprovePermisionController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApprovePermisionController.swift; sourceTree = ""; }; 0B000CF02B4DA30F00AEC582 /* AppSelectViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppSelectViewController.swift; sourceTree = ""; }; 0B00353F2B43D64D00DA140C /* HMHNavigationBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HMHNavigationBar.swift; sourceTree = ""; }; + 0B17D3EA2B5104E000CFA3B7 /* UserManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserManager.swift; sourceTree = ""; }; + 0B17D3EC2B5108D200CFA3B7 /* UserDefaultWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDefaultWrapper.swift; sourceTree = ""; }; 0B2C2D3A2B443BE90023CCFA /* Image.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Image.swift; sourceTree = ""; }; 0B2C2D402B4572240023CCFA /* HMHSelectButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HMHSelectButton.swift; sourceTree = ""; }; 0B50F9C72B369813000C5046 /* HMH_iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HMH_iOS.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -333,6 +337,15 @@ path = ViewControllers; sourceTree = ""; }; + 0B17D3E92B5104B900CFA3B7 /* User */ = { + isa = PBXGroup; + children = ( + 0B17D3EA2B5104E000CFA3B7 /* UserManager.swift */, + 0B17D3EC2B5108D200CFA3B7 /* UserDefaultWrapper.swift */, + ); + path = User; + sourceTree = ""; + }; 0B2C2D3C2B4559AE0023CCFA /* Onboarding */ = { isa = PBXGroup; children = ( @@ -484,6 +497,7 @@ 0B8A89982B369CF800688BA6 /* SupportingFiles */ = { isa = PBXGroup; children = ( + 0B17D3E92B5104B900CFA3B7 /* User */, 3666C8782B45F4D900564874 /* AppBlock */, 0B8A89992B369D0B00688BA6 /* Base */, ); @@ -1073,6 +1087,7 @@ 0B8A89AF2B369E4300688BA6 /* HomeModel.swift in Sources */, 3666C89F2B485C8F00564874 /* DateCollectionViewCell.swift in Sources */, 3666C87A2B45F4F900564874 /* SelectedBlocker.swift in Sources */, + 0B17D3ED2B5108D200CFA3B7 /* UserDefaultWrapper.swift in Sources */, 0BC0EBD42B494459003EF5D4 /* OnboardingSwipeView.swift in Sources */, 17314F9B2B4C485B0089A551 /* UserPointHeaderView.swift in Sources */, 364923862B4FDCBD00BF7ACA /* NetworkProvider.swift in Sources */, @@ -1086,6 +1101,7 @@ 174AF4942B447B5500450D07 /* MyPageViewController.swift in Sources */, 0BA193B42B4D089C007E3F9C /* TimeSurveyViewController.swift in Sources */, 36A3D9B82B3EBC3B007EA272 /* UILabel+.swift in Sources */, + 0B17D3EB2B5104E000CFA3B7 /* UserManager.swift in Sources */, 0B50F9CB2B369813000C5046 /* AppDelegate.swift in Sources */, 0B7817522B4BE0280078E925 /* ProgressBarManager.swift in Sources */, 0B8A89C42B369FA000688BA6 /* F.swift in Sources */, diff --git a/HMH_iOS/HMH_iOS/Global/SupportingFiles/User/UserManager.swift b/HMH_iOS/HMH_iOS/Global/SupportingFiles/User/UserManager.swift new file mode 100644 index 0000000..7b9f626 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Global/SupportingFiles/User/UserManager.swift @@ -0,0 +1,90 @@ +// +// UserManager.swift +// HMH_iOS +// +// Created by Seonwoo Kim on 1/12/24. +// + +import Foundation + +final class UserManager { + static let shared = UserManager() + + @UserDefaultWrapper(key: "accessToken") private(set) var accessToken + @UserDefaultWrapper(key: "refreshToken") private(set) var refreshToken + @UserDefaultWrapper(key: "AppleToken") private(set) var appleToken + @UserDefaultWrapper(key: "userIdentifier") private(set) var appleUserIdentifier + @UserDefaultWrapper(key: "familyName") private(set) var familyName + @UserDefaultWrapper(key: "givenName") private(set) var givenName + @UserDefaultWrapper(key: "fullName") private(set) var fullName + @UserDefaultWrapper(key: "userId") private(set) var userId + + var hasAccessToken: Bool { return self.accessToken != nil } + var getAccessToken: String { return self.accessToken ?? "" } + var getRefreshToken: String { return self.refreshToken ?? "" } + var getAppleToken: String { return self.appleToken ?? "" } + var getUserIdentifier: String { return self.appleUserIdentifier ?? "" } + var getUserName: String { return self.familyName ?? "" } + var getGivenName: String { return self.givenName ?? "" } + var getFullName: String { return self.fullName ?? "" } + var getUserId: Int { return self.userId ?? 0} + + var haveFullName: Bool { + if fullName == "" { + return false + } else if fullName == nil { + return false + } else { + return true + } + } + + private init() {} +} + +extension UserManager { + func updateToken(_ accessToken: String, _ refreshToken: String) { + self.accessToken = accessToken + self.refreshToken = refreshToken + } + + func updateAppleToken(_ appleToken: String) { + self.appleToken = appleToken + } + + func updateUserIdentifier(_ appleUserIdentifier: String) { + self.appleUserIdentifier = appleUserIdentifier + } + + func updateUserName(_ givenName: String, _ familyName: String) { + self.givenName = givenName + self.familyName = familyName + self.fullName = familyName + givenName + } + + func updateUserId(_ userId: Int) { + self.userId = userId + } + + func setUserIdForApple(userId: String) { + self.appleUserIdentifier = appleUserIdentifier + } + + func clearAll() { + self.accessToken = nil + self.refreshToken = nil + self.appleToken = nil + self.appleUserIdentifier = nil + self.familyName = nil + self.givenName = nil + self.fullName = nil + self.userId = nil + } + + func clearData() { + self.accessToken = nil + self.refreshToken = nil + self.appleToken = nil + self.appleUserIdentifier = nil + } +} From b5f690c1e47365c41e11f721874d98b7924c7253 Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Fri, 12 Jan 2024 22:35:06 +0900 Subject: [PATCH 094/101] =?UTF-8?q?[Add/#46]=20UserDefaultWrapper=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../User/UserDefaultWrapper.swift | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 HMH_iOS/HMH_iOS/Global/SupportingFiles/User/UserDefaultWrapper.swift diff --git a/HMH_iOS/HMH_iOS/Global/SupportingFiles/User/UserDefaultWrapper.swift b/HMH_iOS/HMH_iOS/Global/SupportingFiles/User/UserDefaultWrapper.swift new file mode 100644 index 0000000..d4c8f86 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Global/SupportingFiles/User/UserDefaultWrapper.swift @@ -0,0 +1,30 @@ +// +// UserDefaultWrapper.swift +// HMH_iOS +// +// Created by Seonwoo Kim on 1/12/24. +// + +import Foundation + +@propertyWrapper +struct UserDefaultWrapper { + + var wrappedValue: T? { + get { + return UserDefaults.standard.object(forKey: self.key) as? T + } + + set { + if newValue == nil { + UserDefaults.standard.removeObject(forKey: key) + } else { UserDefaults.standard.setValue(newValue, forKey: key) } + } + } + + private let key: String + + init(key: String) { + self.key = key + } +} From 9160d14a349cc12e7921b2d998968924e383354b Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Fri, 12 Jan 2024 22:42:57 +0900 Subject: [PATCH 095/101] =?UTF-8?q?[Feat/#46]=20SceneDelegate=20-=20?= =?UTF-8?q?=EC=95=A0=ED=94=8C=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EC=9C=A0?= =?UTF-8?q?=EC=A0=80=20=EC=83=81=ED=83=9C=20=EC=A1=B0=ED=9A=8C=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HMH_iOS/Application/SceneDelegate.swift | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Application/SceneDelegate.swift b/HMH_iOS/HMH_iOS/Application/SceneDelegate.swift index 1c5370a..9a3885a 100644 --- a/HMH_iOS/HMH_iOS/Application/SceneDelegate.swift +++ b/HMH_iOS/HMH_iOS/Application/SceneDelegate.swift @@ -6,11 +6,27 @@ // import UIKit +import AuthenticationServices class SceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? - + // + func sceneDidBecomeActive(_ scene: UIScene) { + let appleIDProvider = ASAuthorizationAppleIDProvider() + appleIDProvider.getCredentialState(forUserID: "000340.8d411a5d11d84e8da0c22ef43dce465a.1657" ?? "") { (credentialState, error) in + switch credentialState { + case .authorized: + print("authorized") + case .revoked: + print("revoked") + case .notFound: + print("notFound") + default: + break + } + } + } func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { guard let windowScene = (scene as? UIWindowScene) else { return } @@ -24,7 +40,15 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { DispatchQueue.main.asyncAfter(deadline: .now() + 2) { DispatchQueue.main.async{ - showTabBarViewController() + if UserManager.shared.hasAccessToken { + //애플 로그인 토큰 리프레쉬 로직. 성공한다면 엑세스와 리프레시 토큰 업데이트 그러면서 이동 + // 토큰 리프레시가 실패 한다. 로그인 컨트롤러로 바로 이동. +// UserManager.shared.updateToken(,) + + showTabBarViewController() + } else { + showLoginViewController() + } } } From a11549bc42e656d48a2b4b005176662e4c94b291 Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Fri, 12 Jan 2024 22:50:25 +0900 Subject: [PATCH 096/101] =?UTF-8?q?[Chore/#46]=20=EC=9E=90=EC=9E=98?= =?UTF-8?q?=ED=95=9C=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SupportingFiles/User/UserManager.swift | 8 +-- .../ViewControllers/LoginViewController.swift | 68 ++++++------------- 2 files changed, 26 insertions(+), 50 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Global/SupportingFiles/User/UserManager.swift b/HMH_iOS/HMH_iOS/Global/SupportingFiles/User/UserManager.swift index 7b9f626..2db9ca3 100644 --- a/HMH_iOS/HMH_iOS/Global/SupportingFiles/User/UserManager.swift +++ b/HMH_iOS/HMH_iOS/Global/SupportingFiles/User/UserManager.swift @@ -47,7 +47,7 @@ extension UserManager { self.accessToken = accessToken self.refreshToken = refreshToken } - + func updateAppleToken(_ appleToken: String) { self.appleToken = appleToken } @@ -55,7 +55,7 @@ extension UserManager { func updateUserIdentifier(_ appleUserIdentifier: String) { self.appleUserIdentifier = appleUserIdentifier } - + func updateUserName(_ givenName: String, _ familyName: String) { self.givenName = givenName self.familyName = familyName @@ -65,11 +65,11 @@ extension UserManager { func updateUserId(_ userId: Int) { self.userId = userId } - + func setUserIdForApple(userId: String) { self.appleUserIdentifier = appleUserIdentifier } - + func clearAll() { self.accessToken = nil self.refreshToken = nil diff --git a/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift b/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift index a1483b2..3189ce7 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift @@ -59,21 +59,14 @@ extension LoginViewController { func handleAuthorizationAppleIDButtonPress() { let appleIDProvider = ASAuthorizationAppleIDProvider() let request = appleIDProvider.createRequest() - request.requestedScopes = [.email] - print(request, "👍") + request.requestedScopes = [.fullName] let authorizationController = ASAuthorizationController(authorizationRequests: [request]) authorizationController.delegate = self authorizationController.presentationContextProvider = self authorizationController.performRequests() } - - @objc func appleButtonTaped() { - print("tap") - } - } - extension LoginViewController: ASAuthorizationControllerDelegate, ASAuthorizationControllerPresentationContextProviding{ func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor { return self.view.window! @@ -83,62 +76,45 @@ extension LoginViewController: ASAuthorizationControllerDelegate, ASAuthorizatio //로그인 성공 switch authorization.credential { case let appleIDCredential as ASAuthorizationAppleIDCredential: - // You can create an account in your system. let userIdentifier = appleIDCredential.user let fullName = appleIDCredential.fullName - let email = appleIDCredential.email - UserDefaults.standard.set(userIdentifier, forKey: "userIdentifier") if let authorizationCode = appleIDCredential.authorizationCode, let identityToken = appleIDCredential.identityToken, let authCodeString = String(data: authorizationCode, encoding: .utf8), let identifyTokenString = String(data: identityToken, encoding: .utf8) { - print("authorizationCode: \(authorizationCode)") - print("identityToken: \(identityToken)") - print("authCodeString: \(authCodeString)") - print("identifyTokenString: \(identifyTokenString)") - print("🚨", appleIDCredential) - if let bundleID = Bundle.main.bundleIdentifier { - UserDefaults.standard.removePersistentDomain(forName: bundleID) + if let unwrappedFullName = fullName, let givenName = unwrappedFullName.givenName, let familyName = unwrappedFullName.familyName { + UserManager.shared.updateUserName(givenName, familyName) + } else { + print("fullName이 없거나 givenName 또는 familyName이 없습니다.") } - // saveToUserDefaults("authorizationCode",keyValue: authorizationCode) - // saveToUserDefaults("identityToken",keyValue: identityToken) - // saveToUserDefaults(authCodeString,keyValue:"authCodeString") - // saveToUserDefaults(identifyTokenString,keyValue:"identifyTokenString") - // saveToUserDefaults("cool",keyValue:"userIdentifier") - + UserManager.shared.updateUserIdentifier(userIdentifier) } - print("useridentifier: \(userIdentifier)") - - - - //Move to MainPage - //let validVC = SignValidViewController() - //validVC.modalPresentationStyle = .fullScreen - //present(validVC, animated: true, completion: nil) - - case let passwordCredential as ASPasswordCredential: - // Sign in using an existing iCloud Keychain credential. - let username = passwordCredential.user - let password = passwordCredential.password - - print("username: \(username)") - print("password: \(password)") + // 로그인이 성공 한다면 + // 소셜 로그인 API 쏘기 403 -> 온보딩 뷰로 이동 + // 회원 가입이 필요한지 아닌지 확인, userId가 있는지 없는지 판별 + // 유저 메니저와 signInModel에 해당 값 저장 + print(UserManager.shared.getUserIdentifier) + print(UserManager.shared.getUserName) + if (UserManager.shared.appleUserIdentifier != nil) { + let nextViewController = TabBarController() + self.navigationController?.pushViewController(nextViewController, animated: true) + } else { + let nextViewController = TimeSurveyViewController() + self.navigationController?.pushViewController(nextViewController, animated: true) + } + default: break } } - func saveToUserDefaults(_ content: String, keyValue: String) { - // Save the userId to UserDefaults - UserDefaults.standard.set(content, forKey: keyValue) - } - - func authorizationController(controller: ASAuthorizationController, didCompleteWithError error: Error) { // 로그인 실패(유저의 취소도 포함) print("login failed - \(error.localizedDescription)") } } + + From def8aef78bbaad7e987d919c72ba45f34053ac0b Mon Sep 17 00:00:00 2001 From: boyeon Date: Sat, 13 Jan 2024 01:48:55 +0900 Subject: [PATCH 097/101] =?UTF-8?q?[Fix/#44]=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EB=A6=AC=EB=B7=B0=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HMH_iOS/Global/Literals/String/String.swift | 2 +- .../Home/Cells/AppUsingProgressViewCell.swift | 4 ++-- .../Home/Cells/BlackHoleImageCell.swift | 2 +- .../Presentation/Home/Views/HMHHomeView.swift | 15 ++++++++++----- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift b/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift index 716b18e..0415b49 100644 --- a/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift +++ b/HMH_iOS/HMH_iOS/Global/Literals/String/String.swift @@ -20,10 +20,10 @@ enum StringLiteral { static var blackHoleThridStep = "블랙홀이 가까워졌어요\n스마트폰을 멀리해 볼까요?" static var blackHoleFourthStep = "블랙홀에 빠질 수 있어요\n스마트폰을 내려놓아요" static var blackHoleFifthStep = "지금부터 앱을 사용하면\n챌린지를 실패해요" - static var blackHoleFailure = "블랙홀에 빠졌어요\n내일은 목표를 이뤄보아요" static var totalGoalUsingTime = "총 목표 이용 시간" + static var remainedTimeUnit = "남음" } enum Challenge { diff --git a/HMH_iOS/HMH_iOS/Presentation/Home/Cells/AppUsingProgressViewCell.swift b/HMH_iOS/HMH_iOS/Presentation/Home/Cells/AppUsingProgressViewCell.swift index 01c00fe..03cf54d 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Home/Cells/AppUsingProgressViewCell.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Home/Cells/AppUsingProgressViewCell.swift @@ -52,7 +52,7 @@ final class AppUsingProgressViewCell: UICollectionViewCell { $0.font = .iosText6Medium14 $0.textColor = .gray2 $0.textAlignment = .center - $0.text = "남음" + $0.text = StringLiteral.Home.remainedTimeUnit } lazy var appProgressBar = UIProgressView().then { $0.trackTintColor = .gray7 @@ -89,7 +89,7 @@ final class AppUsingProgressViewCell: UICollectionViewCell { private func setConstraints() { appProgressBar.snp.makeConstraints { $0.height.equalTo(75.adjusted) - $0.horizontalEdges.equalToSuperview().inset(20) + $0.horizontalEdges.equalToSuperview().inset(20.adjustedWidth) } appStackView.snp.makeConstraints { diff --git a/HMH_iOS/HMH_iOS/Presentation/Home/Cells/BlackHoleImageCell.swift b/HMH_iOS/HMH_iOS/Presentation/Home/Cells/BlackHoleImageCell.swift index ca0418c..85d03e1 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Home/Cells/BlackHoleImageCell.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Home/Cells/BlackHoleImageCell.swift @@ -56,7 +56,7 @@ final class BlackHoleImageCell: UICollectionViewCell { func configureCell (image: UIImage, text: String){ blackHoleImageView.image = image homeBlackHoleStateLabel.text = text - homeBlackHoleStateLabel.setTextWithLineHeight(text: text, lineHeight: 33) + homeBlackHoleStateLabel.setTextWithLineHeight(text: text, lineHeight: 33.adjusted) homeBlackHoleStateLabel.textAlignment = .left } } diff --git a/HMH_iOS/HMH_iOS/Presentation/Home/Views/HMHHomeView.swift b/HMH_iOS/HMH_iOS/Presentation/Home/Views/HMHHomeView.swift index da262fe..8f1a3f8 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Home/Views/HMHHomeView.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Home/Views/HMHHomeView.swift @@ -91,15 +91,20 @@ extension HMHHomeView: UICollectionViewDataSource { switch indexPath.section { case 0: if progressPrecent < 0.24 { - blackholeImageCell.configureCell(image: ImageLiterals.TabBar.icMyPage, text: StringLiteral.Home.blackHoleFirstStep) + blackholeImageCell.configureCell(image: ImageLiterals.TabBar.icMyPage, + text: StringLiteral.Home.blackHoleFirstStep) } else if progressPrecent < 0.49 { - blackholeImageCell.configureCell(image: ImageLiterals.TabBar.icChallengeSelected, text: StringLiteral.Home.blackHoleSecondStep) + blackholeImageCell.configureCell(image: ImageLiterals.TabBar.icChallengeSelected, + text: StringLiteral.Home.blackHoleSecondStep) } else if progressPrecent < 0.74 { - blackholeImageCell.configureCell(image: ImageLiterals.TabBar.icChallenge, text: StringLiteral.Home.blackHoleThridStep) + blackholeImageCell.configureCell(image: ImageLiterals.TabBar.icChallenge, + text: StringLiteral.Home.blackHoleThridStep) } else if progressPrecent < 0.99 { - blackholeImageCell.configureCell(image: ImageLiterals.TabBar.icHomeSelected, text: StringLiteral.Home.blackHoleFourthStep) + blackholeImageCell.configureCell(image: ImageLiterals.TabBar.icHomeSelected, + text: StringLiteral.Home.blackHoleFourthStep) } else { - blackholeImageCell.configureCell(image: ImageLiterals.TabBar.icMyPageSelected, text: StringLiteral.Home.blackHoleFifthStep) + blackholeImageCell.configureCell(image: ImageLiterals.TabBar.icMyPageSelected, + text: StringLiteral.Home.blackHoleFifthStep) } return blackholeImageCell case 1: From 7c982c9a8dd65dfdba715a3e6a958e260f75a31c Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Sat, 13 Jan 2024 02:28:55 +0900 Subject: [PATCH 098/101] =?UTF-8?q?[Add#62]=20UIViewController+=20extensti?= =?UTF-8?q?on=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj | 4 ++++ .../Global/Extension/UIViewController+.swift | 20 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 HMH_iOS/HMH_iOS/Global/Extension/UIViewController+.swift diff --git a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj index ad168f3..93692b8 100644 --- a/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj +++ b/HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj @@ -14,6 +14,7 @@ 0B0035402B43D64D00DA140C /* HMHNavigationBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B00353F2B43D64D00DA140C /* HMHNavigationBar.swift */; }; 0B17D3EB2B5104E000CFA3B7 /* UserManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B17D3EA2B5104E000CFA3B7 /* UserManager.swift */; }; 0B17D3ED2B5108D200CFA3B7 /* UserDefaultWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B17D3EC2B5108D200CFA3B7 /* UserDefaultWrapper.swift */; }; + 0B17D3F12B51AD4B00CFA3B7 /* UIViewController+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B17D3F02B51AD4B00CFA3B7 /* UIViewController+.swift */; }; 0B2C2D3B2B443BE90023CCFA /* Image.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B2C2D3A2B443BE90023CCFA /* Image.swift */; }; 0B2C2D412B4572240023CCFA /* HMHSelectButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B2C2D402B4572240023CCFA /* HMHSelectButton.swift */; }; 0B50F9CB2B369813000C5046 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B50F9CA2B369813000C5046 /* AppDelegate.swift */; }; @@ -184,6 +185,7 @@ 0B00353F2B43D64D00DA140C /* HMHNavigationBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HMHNavigationBar.swift; sourceTree = ""; }; 0B17D3EA2B5104E000CFA3B7 /* UserManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserManager.swift; sourceTree = ""; }; 0B17D3EC2B5108D200CFA3B7 /* UserDefaultWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDefaultWrapper.swift; sourceTree = ""; }; + 0B17D3F02B51AD4B00CFA3B7 /* UIViewController+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+.swift"; sourceTree = ""; }; 0B2C2D3A2B443BE90023CCFA /* Image.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Image.swift; sourceTree = ""; }; 0B2C2D402B4572240023CCFA /* HMHSelectButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HMHSelectButton.swift; sourceTree = ""; }; 0B50F9C72B369813000C5046 /* HMH_iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HMH_iOS.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -485,6 +487,7 @@ 36A3D9B72B3EBC3B007EA272 /* UILabel+.swift */, 36A3D9BB2B3EBD2D007EA272 /* UIScreen+.swift */, 3666C88C2B471B1D00564874 /* UIImage+.swift */, + 0B17D3F02B51AD4B00CFA3B7 /* UIViewController+.swift */, ); path = Extension; sourceTree = ""; @@ -1111,6 +1114,7 @@ 364923862B4FDCBD00BF7ACA /* NetworkProvider.swift in Sources */, 364923702B4F524D00BF7ACA /* MoyaLoggerPlugin.swift in Sources */, 36A3D9C02B409CBD007EA272 /* Font.swift in Sources */, + 0B17D3F12B51AD4B00CFA3B7 /* UIViewController+.swift in Sources */, 174AF4902B447B3C00450D07 /* MyPageModels.swift in Sources */, 174AF4982B447CF100450D07 /* ChanllengeModels.swift in Sources */, 17CF9FBD2B4DC757000DD09C /* HMHHomeView.swift in Sources */, diff --git a/HMH_iOS/HMH_iOS/Global/Extension/UIViewController+.swift b/HMH_iOS/HMH_iOS/Global/Extension/UIViewController+.swift new file mode 100644 index 0000000..1cda129 --- /dev/null +++ b/HMH_iOS/HMH_iOS/Global/Extension/UIViewController+.swift @@ -0,0 +1,20 @@ +// +// UIViewController+.swift +// HMH_iOS +// +// Created by Seonwoo Kim on 1/13/24. +// + +import UIKit + +extension UIViewController { + func setRootViewController(_ viewController: UIViewController) { + let navigationController = UINavigationController(rootViewController: viewController) + let sceneDelegate = UIApplication.shared.connectedScenes.first?.delegate as? SceneDelegate + guard let delegate = sceneDelegate else { + return + } + delegate.window?.rootViewController = navigationController + } +} + From a151cd4ddefc0f0c7eda73f3de18e48d3171058f Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Sat, 13 Jan 2024 02:29:44 +0900 Subject: [PATCH 099/101] =?UTF-8?q?[Fix/#62]=20Extension=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=EC=9C=BC=EB=A1=9C=20root=EC=9D=B4=EB=8F=99=20?= =?UTF-8?q?=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_iOS/HMH_iOS/Application/SceneDelegate.swift | 4 +++- .../Login/ViewControllers/LoginViewController.swift | 6 ++---- .../ViewControllers/SignInCompleteViewController.swift | 8 +------- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Application/SceneDelegate.swift b/HMH_iOS/HMH_iOS/Application/SceneDelegate.swift index 628fc9e..ddb9347 100644 --- a/HMH_iOS/HMH_iOS/Application/SceneDelegate.swift +++ b/HMH_iOS/HMH_iOS/Application/SceneDelegate.swift @@ -33,9 +33,11 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { let window = UIWindow(windowScene: windowScene) self.window = window - let splashViewController = SplashViewController() window.rootViewController = splashViewController + if let navigationController = window.rootViewController as? UINavigationController { + navigationController.isNavigationBarHidden = true + } window.makeKeyAndVisible() DispatchQueue.main.asyncAfter(deadline: .now() + 2) { diff --git a/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift b/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift index 3189ce7..56caf28 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift @@ -99,11 +99,9 @@ extension LoginViewController: ASAuthorizationControllerDelegate, ASAuthorizatio print(UserManager.shared.getUserIdentifier) print(UserManager.shared.getUserName) if (UserManager.shared.appleUserIdentifier != nil) { - let nextViewController = TabBarController() - self.navigationController?.pushViewController(nextViewController, animated: true) + setRootViewController(TabBarController()) } else { - let nextViewController = TimeSurveyViewController() - self.navigationController?.pushViewController(nextViewController, animated: true) + setRootViewController(TimeSurveyViewController()) } default: diff --git a/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/SignInCompleteViewController.swift b/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/SignInCompleteViewController.swift index 44cb594..679b6fa 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/SignInCompleteViewController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Onboarding/ViewControllers/SignInCompleteViewController.swift @@ -77,13 +77,7 @@ final class SignInCompleteViewController: OnboardingBaseViewController { extension SignInCompleteViewController: NextViewPushDelegate { func didTapButton() { - let nextViewController = TabBarController() - let navigationController = UINavigationController(rootViewController: nextViewController) - let sceneDelegate = UIApplication.shared.connectedScenes.first?.delegate as? SceneDelegate - guard let delegate = sceneDelegate else { - return - } - delegate.window?.rootViewController = navigationController + setRootViewController(TabBarController()) } } From fb790e84a0445ecdb4fd2223c19208f6c9e83fbb Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Sat, 13 Jan 2024 02:40:19 +0900 Subject: [PATCH 100/101] =?UTF-8?q?[Fix/#62]=20NavigationBar=20-=20logo=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Common/UIComponets/HMHNavigationBar.swift | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/Common/UIComponets/HMHNavigationBar.swift b/HMH_iOS/HMH_iOS/Presentation/Common/UIComponets/HMHNavigationBar.swift index 823c47c..bc3ff2c 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Common/UIComponets/HMHNavigationBar.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Common/UIComponets/HMHNavigationBar.swift @@ -34,10 +34,6 @@ final class HMHNavigationBar: UIView { $0.tintColor = .gray3 } - private let logoImageView = UIImageView().then { - $0.backgroundColor = .blue - } - private let titleLabel = UILabel().then { $0.textColor = .white $0.font = UIFont.iosText3Semibold18 @@ -79,7 +75,7 @@ final class HMHNavigationBar: UIView { self.addSubviews(backArrowButton, titleLabel, pointButton) pointButton.addSubview(pointImageView) case .logo: - self.addSubviews(logoImageView) + return } } @@ -113,11 +109,7 @@ final class HMHNavigationBar: UIView { } case .logo: - logoImageView.snp.makeConstraints { - $0.centerY.equalToSuperview().offset(50.adjusted) - $0.leading.equalToSuperview().inset(20.adjusted) - $0.size.equalTo(24.adjusted) - } + return } } else { self.snp.makeConstraints { @@ -146,11 +138,7 @@ final class HMHNavigationBar: UIView { $0.edges.equalToSuperview() } case .logo: - logoImageView.snp.makeConstraints { - $0.centerY.equalToSuperview().offset(50.adjusted) - $0.leading.equalToSuperview().inset(20.adjusted) - $0.size.equalTo(24.adjusted) - } + return } } } From 896f402590ade11e6f65a3eea384c2e9c19b4cdf Mon Sep 17 00:00:00 2001 From: kim-seonwoo Date: Sat, 13 Jan 2024 02:55:36 +0900 Subject: [PATCH 101/101] =?UTF-8?q?[Feat/#62]=20TabBarViewController=20-?= =?UTF-8?q?=20default=20=EC=A7=84=EC=9E=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Presentation/Common/CustomTabbar/TabBarController.swift | 2 +- .../Login/ViewControllers/LoginViewController.swift | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/HMH_iOS/HMH_iOS/Presentation/Common/CustomTabbar/TabBarController.swift b/HMH_iOS/HMH_iOS/Presentation/Common/CustomTabbar/TabBarController.swift index 947fc83..8bad55e 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Common/CustomTabbar/TabBarController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Common/CustomTabbar/TabBarController.swift @@ -68,7 +68,6 @@ final class TabBarController: UITabBarController { let tabBarHeight: CGFloat = UIScreen.main.isLongerThan812pt ? 52.0.adjusted : 58.0.adjusted tabBar.frame.size.height = tabBarHeight + safeAreaHeight tabBar.frame.origin.y = view.frame.height - tabBarHeight - safeAreaHeight - } private func setTabBar() { @@ -117,5 +116,6 @@ final class TabBarController: UITabBarController { tabBarItem.tabBarItem.titlePositionAdjustment = UIOffset(horizontal: 0, vertical: -1.adjusted) } } + selectedIndex = 1 } } diff --git a/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift b/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift index 56caf28..27199ba 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Login/ViewControllers/LoginViewController.swift @@ -103,7 +103,6 @@ extension LoginViewController: ASAuthorizationControllerDelegate, ASAuthorizatio } else { setRootViewController(TimeSurveyViewController()) } - default: break }