diff --git a/1stWeek/.DS_Store b/1stWeek/.DS_Store index d585c84..d027eb7 100644 Binary files a/1stWeek/.DS_Store and b/1stWeek/.DS_Store differ diff --git a/1stWeek/Seminar/.DS_Store b/1stWeek/Seminar/.DS_Store index dcc831a..575b476 100644 Binary files a/1stWeek/Seminar/.DS_Store and b/1stWeek/Seminar/.DS_Store differ diff --git a/1stWeek/Seminar/Seminar.xcodeproj/project.xcworkspace/xcuserdata/shinjiwon.xcuserdatad/UserInterfaceState.xcuserstate b/1stWeek/Seminar/Seminar.xcodeproj/project.xcworkspace/xcuserdata/shinjiwon.xcuserdatad/UserInterfaceState.xcuserstate index 7bc2b61..fd900fe 100644 Binary files a/1stWeek/Seminar/Seminar.xcodeproj/project.xcworkspace/xcuserdata/shinjiwon.xcuserdatad/UserInterfaceState.xcuserstate and b/1stWeek/Seminar/Seminar.xcodeproj/project.xcworkspace/xcuserdata/shinjiwon.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/2ndWeek/Assignment/Assignment/AppDelegate.swift b/2ndWeek/Assignment/Assignment/AppDelegate.swift new file mode 100644 index 0000000..d73a51f --- /dev/null +++ b/2ndWeek/Assignment/Assignment/AppDelegate.swift @@ -0,0 +1,36 @@ +// +// AppDelegate.swift +// Assignment +// +// Created by 신지원 on 2023/07/01. +// + +import UIKit + +@main +class AppDelegate: UIResponder, UIApplicationDelegate { + + + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + // MARK: UISceneSession Lifecycle + + func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { + // Called when a new scene session is being created. + // Use this method to select a configuration to create the new scene with. + return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) + } + + func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { + // Called when the user discards a scene session. + // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. + // Use this method to release any resources that were specific to the discarded scenes, as they will not return. + } + + +} + diff --git a/2ndWeek/Assignment/Assignment/Assets.xcassets/AccentColor.colorset/Contents.json b/2ndWeek/Assignment/Assignment/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/2ndWeek/Assignment/Assignment/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/2ndWeek/Assignment/Assignment/Assets.xcassets/AppIcon.appiconset/Contents.json b/2ndWeek/Assignment/Assignment/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..13613e3 --- /dev/null +++ b/2ndWeek/Assignment/Assignment/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/2ndWeek/Assignment/Assignment/Assets.xcassets/Contents.json b/2ndWeek/Assignment/Assignment/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/2ndWeek/Assignment/Assignment/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/2ndWeek/Assignment/Assignment/Assets.xcassets/backBtn.imageset/Contents.json b/2ndWeek/Assignment/Assignment/Assets.xcassets/backBtn.imageset/Contents.json new file mode 100644 index 0000000..178fe51 --- /dev/null +++ b/2ndWeek/Assignment/Assignment/Assets.xcassets/backBtn.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "btn_before.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/2ndWeek/Assignment/Assignment/Assets.xcassets/backBtn.imageset/btn_before.png b/2ndWeek/Assignment/Assignment/Assets.xcassets/backBtn.imageset/btn_before.png new file mode 100644 index 0000000..488c9df Binary files /dev/null and b/2ndWeek/Assignment/Assignment/Assets.xcassets/backBtn.imageset/btn_before.png differ diff --git a/2ndWeek/Assignment/Assignment/Assets.xcassets/clearBtn.imageset/Contents.json b/2ndWeek/Assignment/Assignment/Assets.xcassets/clearBtn.imageset/Contents.json new file mode 100644 index 0000000..bb315f7 --- /dev/null +++ b/2ndWeek/Assignment/Assignment/Assets.xcassets/clearBtn.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "x-circle@3x 2.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/2ndWeek/Assignment/Assignment/Assets.xcassets/clearBtn.imageset/x-circle@3x 2.png b/2ndWeek/Assignment/Assignment/Assets.xcassets/clearBtn.imageset/x-circle@3x 2.png new file mode 100644 index 0000000..32ed0b8 Binary files /dev/null and b/2ndWeek/Assignment/Assignment/Assets.xcassets/clearBtn.imageset/x-circle@3x 2.png differ diff --git a/2ndWeek/Assignment/Assignment/Assets.xcassets/eyeBtn.imageset/Contents.json b/2ndWeek/Assignment/Assignment/Assets.xcassets/eyeBtn.imageset/Contents.json new file mode 100644 index 0000000..e6d4a57 --- /dev/null +++ b/2ndWeek/Assignment/Assignment/Assets.xcassets/eyeBtn.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "eye@3x 1.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/2ndWeek/Assignment/Assignment/Assets.xcassets/eyeBtn.imageset/eye@3x 1.png b/2ndWeek/Assignment/Assignment/Assets.xcassets/eyeBtn.imageset/eye@3x 1.png new file mode 100644 index 0000000..5ea73c2 Binary files /dev/null and b/2ndWeek/Assignment/Assignment/Assets.xcassets/eyeBtn.imageset/eye@3x 1.png differ diff --git a/2ndWeek/Assignment/Assignment/Assets.xcassets/noeyeBtn.imageset/Contents.json b/2ndWeek/Assignment/Assignment/Assets.xcassets/noeyeBtn.imageset/Contents.json new file mode 100644 index 0000000..e08bb07 --- /dev/null +++ b/2ndWeek/Assignment/Assignment/Assets.xcassets/noeyeBtn.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "eye-slash@3x 2.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/2ndWeek/Assignment/Assignment/Assets.xcassets/noeyeBtn.imageset/eye-slash@3x 2.png b/2ndWeek/Assignment/Assignment/Assets.xcassets/noeyeBtn.imageset/eye-slash@3x 2.png new file mode 100644 index 0000000..edcd782 Binary files /dev/null and b/2ndWeek/Assignment/Assignment/Assets.xcassets/noeyeBtn.imageset/eye-slash@3x 2.png differ diff --git a/2ndWeek/Assignment/Assignment/Assets.xcassets/tvingLogo.imageset/Contents.json b/2ndWeek/Assignment/Assignment/Assets.xcassets/tvingLogo.imageset/Contents.json new file mode 100644 index 0000000..7de61fd --- /dev/null +++ b/2ndWeek/Assignment/Assignment/Assets.xcassets/tvingLogo.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "image 3.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "image 3-2.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "image 4.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/2ndWeek/Assignment/Assignment/Assets.xcassets/tvingLogo.imageset/image 3-2.png b/2ndWeek/Assignment/Assignment/Assets.xcassets/tvingLogo.imageset/image 3-2.png new file mode 100644 index 0000000..c713c5e Binary files /dev/null and b/2ndWeek/Assignment/Assignment/Assets.xcassets/tvingLogo.imageset/image 3-2.png differ diff --git a/2ndWeek/Assignment/Assignment/Assets.xcassets/tvingLogo.imageset/image 3.png b/2ndWeek/Assignment/Assignment/Assets.xcassets/tvingLogo.imageset/image 3.png new file mode 100644 index 0000000..43b0040 Binary files /dev/null and b/2ndWeek/Assignment/Assignment/Assets.xcassets/tvingLogo.imageset/image 3.png differ diff --git a/2ndWeek/Assignment/Assignment/Assets.xcassets/tvingLogo.imageset/image 4.png b/2ndWeek/Assignment/Assignment/Assets.xcassets/tvingLogo.imageset/image 4.png new file mode 100644 index 0000000..43b0040 Binary files /dev/null and b/2ndWeek/Assignment/Assignment/Assets.xcassets/tvingLogo.imageset/image 4.png differ diff --git a/2ndWeek/Assignment/Assignment/Fonts/Pretendard-Black.ttf b/2ndWeek/Assignment/Assignment/Fonts/Pretendard-Black.ttf new file mode 100644 index 0000000..90d3951 Binary files /dev/null and b/2ndWeek/Assignment/Assignment/Fonts/Pretendard-Black.ttf differ diff --git a/2ndWeek/Assignment/Assignment/Fonts/Pretendard-Bold.ttf b/2ndWeek/Assignment/Assignment/Fonts/Pretendard-Bold.ttf new file mode 100644 index 0000000..315026a Binary files /dev/null and b/2ndWeek/Assignment/Assignment/Fonts/Pretendard-Bold.ttf differ diff --git a/2ndWeek/Assignment/Assignment/Fonts/Pretendard-Light.ttf b/2ndWeek/Assignment/Assignment/Fonts/Pretendard-Light.ttf new file mode 100644 index 0000000..cb0efd3 Binary files /dev/null and b/2ndWeek/Assignment/Assignment/Fonts/Pretendard-Light.ttf differ diff --git a/2ndWeek/Assignment/Assignment/Fonts/Pretendard-Medium.ttf b/2ndWeek/Assignment/Assignment/Fonts/Pretendard-Medium.ttf new file mode 100644 index 0000000..eefc6d5 Binary files /dev/null and b/2ndWeek/Assignment/Assignment/Fonts/Pretendard-Medium.ttf differ diff --git a/2ndWeek/Assignment/Assignment/Fonts/Pretendard-Regular.ttf b/2ndWeek/Assignment/Assignment/Fonts/Pretendard-Regular.ttf new file mode 100644 index 0000000..6b010bb Binary files /dev/null and b/2ndWeek/Assignment/Assignment/Fonts/Pretendard-Regular.ttf differ diff --git a/2ndWeek/Assignment/Assignment/Fonts/Pretendard-Thin.ttf b/2ndWeek/Assignment/Assignment/Fonts/Pretendard-Thin.ttf new file mode 100644 index 0000000..2cfcf49 Binary files /dev/null and b/2ndWeek/Assignment/Assignment/Fonts/Pretendard-Thin.ttf differ diff --git a/2ndWeek/Assignment/Assignment/Info.plist b/2ndWeek/Assignment/Assignment/Info.plist new file mode 100644 index 0000000..39b0e6b --- /dev/null +++ b/2ndWeek/Assignment/Assignment/Info.plist @@ -0,0 +1,32 @@ + + + + + UIAppFonts + + Pretendard-Black.ttf + Pretendard-Bold.ttf + Pretendard-Light.ttf + Pretendard-Medium.ttf + Pretendard-Regular.ttf + Pretendard-Thin.ttf + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + + + + + + diff --git a/2ndWeek/Assignment/Assignment/SceneDelegate.swift b/2ndWeek/Assignment/Assignment/SceneDelegate.swift new file mode 100644 index 0000000..a3bacd3 --- /dev/null +++ b/2ndWeek/Assignment/Assignment/SceneDelegate.swift @@ -0,0 +1,53 @@ +// +// SceneDelegate.swift +// Assignment +// +// Created by 신지원 on 2023/07/01. +// + +import UIKit + +class SceneDelegate: UIResponder, UIWindowSceneDelegate { + + var window: UIWindow? + + + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { + guard let windowScene = (scene as? UIWindowScene) else { return } + self.window = UIWindow(windowScene: windowScene) + let navigationController = UINavigationController(rootViewController: ViewController()) + self.window?.rootViewController = navigationController + self.window?.makeKeyAndVisible() + } + + func sceneDidDisconnect(_ scene: UIScene) { + // Called as the scene is being released by the system. + // This occurs shortly after the scene enters the background, or when its session is discarded. + // Release any resources associated with this scene that can be re-created the next time the scene connects. + // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). + } + + func sceneDidBecomeActive(_ scene: UIScene) { + // Called when the scene has moved from an inactive state to an active state. + // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. + } + + func sceneWillResignActive(_ scene: UIScene) { + // Called when the scene will move from an active state to an inactive state. + // This may occur due to temporary interruptions (ex. an incoming phone call). + } + + func sceneWillEnterForeground(_ scene: UIScene) { + // Called as the scene transitions from the background to the foreground. + // Use this method to undo the changes made on entering the background. + } + + func sceneDidEnterBackground(_ scene: UIScene) { + // Called as the scene transitions from the foreground to the background. + // Use this method to save data, release shared resources, and store enough scene-specific state information + // to restore the scene back to its current state. + } + + +} + diff --git a/2ndWeek/Assignment/Assignment/SecondViewController.swift b/2ndWeek/Assignment/Assignment/SecondViewController.swift new file mode 100644 index 0000000..9e47e78 --- /dev/null +++ b/2ndWeek/Assignment/Assignment/SecondViewController.swift @@ -0,0 +1,74 @@ +// +// SecondViewController.swift +// Assignment +// +// Created by 신지원 on 2023/07/04. +// + +import UIKit + +class SecondViewController: UIViewController { + + private var tvingLogoImage = UIImageView() + var showIdLabel = UILabel() + private var backButton = UIButton() + + var id : String? + var nickname : String? + + override func viewDidLoad() { + super.viewDidLoad() + + setStyle() + setLayout() + // Do any additional setup after loading the view. + } + + private func setStyle() { + view.addSubviews(tvingLogoImage,showIdLabel,backButton) + view.backgroundColor = .black + + tvingLogoImage.then { + $0.image = UIImage(named: "tvingLogo") + } + showIdLabel.then { + guard let nickname = nickname else { return } + + $0.text = "\(nickname) 님\n반가워요!" + $0.font = UIFont(name: "Pretendard-Bold", size: 23) + $0.textColor = .tvingGray1 + $0.textAlignment = .center + $0.numberOfLines = 2 + } + backButton.then { + $0.setTitle("메인으로", for: .normal) + $0.titleLabel?.font = UIFont(name: "Pretendard-Bold", size: 14) + $0.titleLabel?.textColor = .white + $0.layer.backgroundColor = UIColor.tvingRed.cgColor + + $0.addTarget(self, action: #selector(backButtonTapped), for: .touchUpInside) + } + } + + private func setLayout() { + + tvingLogoImage.snp.makeConstraints { + $0.top.equalToSuperview().inset(58) + $0.width.equalToSuperview() + $0.height.equalTo(210) + } + showIdLabel.snp.makeConstraints { + $0.top.equalTo(tvingLogoImage.snp.bottom).offset(67) + $0.centerX.equalToSuperview() + } + backButton.snp.makeConstraints { + $0.top.equalTo(tvingLogoImage.snp.bottom).offset(425) + $0.height.equalTo(52) + $0.leading.trailing.equalToSuperview().inset(20) + } + } + + @objc func backButtonTapped() { + self.dismiss(animated: true) + } +} diff --git a/2ndWeek/Assignment/Assignment/StringExtension.swift b/2ndWeek/Assignment/Assignment/StringExtension.swift new file mode 100644 index 0000000..dc7030d --- /dev/null +++ b/2ndWeek/Assignment/Assignment/StringExtension.swift @@ -0,0 +1,23 @@ +// +// StringExtension.swift +// Assignment +// +// Created by 신지원 on 2023/07/30. +// + +import UIKit + +extension String { + func isValidEmail() -> Bool { + let pattern = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}" + + guard self.range(of: pattern, options: .regularExpression) != nil else { return false } + return true + } + + func isOnlyKorean() -> Bool { + let pattern = "[가-힣]" + guard self.range(of: pattern, options: .regularExpression) != nil else { return false } + return true + } +} diff --git a/2ndWeek/Assignment/Assignment/ThirdViewController.swift b/2ndWeek/Assignment/Assignment/ThirdViewController.swift new file mode 100644 index 0000000..853d307 --- /dev/null +++ b/2ndWeek/Assignment/Assignment/ThirdViewController.swift @@ -0,0 +1,88 @@ +// +// ThirdViewController.swift +// Assignment +// +// Created by 신지원 on 2023/07/04. +// + +import UIKit + +class ThirdViewController: UIViewController { + + private var inputNickcnameLabel = UILabel() + private var nicknameTextField = UITextField() + private var saveButton = UIButton() + + override func viewDidLoad() { + super.viewDidLoad() + + setStyle() + setLayout() + } + + private func setStyle() { + view.addSubviews(inputNickcnameLabel, nicknameTextField, saveButton) + view.backgroundColor = .white + + inputNickcnameLabel.then { + $0.text = "닉네임을 입력해주세요" + $0.textColor = .black + $0.font = UIFont(name: "Pretendard-Bold", size: 23) + } + nicknameTextField.then { + $0.placeholder = "ex) 신지원 짱" + $0.setPlaceholder(color: .tvingGray2) + $0.layer.backgroundColor = UIColor.tvingGray1.cgColor + $0.textColor = .tvingGray4 + $0.font = UIFont(name: "Pretendard-Bold", size: 14) + $0.addLeftPadding() + + $0.addTarget(self, action: #selector(textFieldStartChange), for: .editingChanged) + } + saveButton.then { + $0.setTitle("저장하기", for: .normal) + $0.titleLabel?.font = UIFont(name: "Pretendard-Bold", size: 14) + $0.titleLabel?.textColor = .white + $0.layer.backgroundColor = UIColor.label.cgColor + $0.layer.cornerRadius = 3 + + $0.addTarget(self, action: #selector(saveButtonTapped), for: .touchUpInside) + } + } + + private func setLayout() { + inputNickcnameLabel.snp.makeConstraints() { + $0.bottom.equalTo(nicknameTextField.snp.top).offset(-21) + $0.leading.equalTo(nicknameTextField.snp.leading) + } + nicknameTextField.snp.makeConstraints(){ + $0.top.equalToSuperview().inset(93) + $0.leading.trailing.equalToSuperview().inset(20) + $0.height.equalTo(52) + } + saveButton.snp.makeConstraints() { + $0.top.equalTo(nicknameTextField.snp.bottom).offset(214) + $0.leading.trailing.equalToSuperview().inset(20) + $0.height.equalTo(52) + } + } + + @objc func saveButtonTapped() { + let firstVC = ViewController() + guard let nickname = nicknameTextField.text else { return } + firstVC.nickname = nickname + + self.present(firstVC, animated: false) + } + + @objc func textFieldStartChange() { + if nicknameTextField.text?.isOnlyKorean() == true { + saveButton.layer.backgroundColor = UIColor.tvingRed.cgColor + saveButton.isEnabled = true + } + else { + saveButton.layer.backgroundColor = UIColor.label.cgColor + saveButton.isEnabled = false + } + } +} diff --git a/2ndWeek/Assignment/Assignment/UIColorExtension.swift b/2ndWeek/Assignment/Assignment/UIColorExtension.swift new file mode 100644 index 0000000..52e746f --- /dev/null +++ b/2ndWeek/Assignment/Assignment/UIColorExtension.swift @@ -0,0 +1,30 @@ +// +// UIColorExtension.swift +// Assignment +// +// Created by 신지원 on 2023/07/02. +// + +import UIKit + +extension UIColor { + + static let tvingRed = UIColor(hex: 0xFF143C) + static let tvingGray5 = UIColor(hex: 0x191919) + static let tvingGray4 = UIColor(hex: 0x2E2E2E) + static let tvingGray3 = UIColor(hex: 0x626262) + static let tvingGray2 = UIColor(hex: 0x9C9C9C) + static let tvingGray1 = UIColor(hex: 0xD6D6D6) + +} + +extension UIColor { + convenience init(hex: UInt, alpha: CGFloat = 1.0) { + self.init( + red: CGFloat((hex & 0xFF0000) >> 16) / 255.0, + green: CGFloat((hex & 0x00FF00) >> 8) / 255.0, + blue: CGFloat(hex & 0x0000FF) / 255.0, + alpha: CGFloat(alpha) + ) + } +} diff --git a/2ndWeek/Assignment/Assignment/UIViewExtension.swift b/2ndWeek/Assignment/Assignment/UIViewExtension.swift new file mode 100644 index 0000000..6618157 --- /dev/null +++ b/2ndWeek/Assignment/Assignment/UIViewExtension.swift @@ -0,0 +1,33 @@ +// +// UIViewExtension.swift +// Assignment +// +// Created by 신지원 on 2023/07/04. +// + +import UIKit + +extension UIView { + func addSubviews(_ views: UIView...) { + for view in views { + addSubview(view) + } + } +} + +extension UITextField { + func setPlaceholder(color: UIColor) { + guard let string = self.placeholder else { + return + } + attributedPlaceholder = NSAttributedString(string: string, attributes: [.foregroundColor: color]) + } +} + +extension UITextField { + func addLeftPadding() { + let paddingView = UIView(frame: CGRect(x: 0, y: 0, width: 22, height: 14)) + self.leftView = paddingView + self.leftViewMode = ViewMode.always + } +} diff --git a/2ndWeek/Assignment/Assignment/ViewController.swift b/2ndWeek/Assignment/Assignment/ViewController.swift new file mode 100644 index 0000000..6645448 --- /dev/null +++ b/2ndWeek/Assignment/Assignment/ViewController.swift @@ -0,0 +1,261 @@ +// +// ViewController.swift +// Assignment +// +// Created by 신지원 on 2023/07/01. +// + +import UIKit +import SnapKit +import Then + +class ViewController: UIViewController, UIViewControllerTransitioningDelegate { + + private var titleLabel = UILabel() + + private var idTextField = UITextField() + private var passwordTextField = UITextField() + private var clearButton = UIButton() + private var eyeButton = UIButton() + private var loginButton = UIButton() + + private var findidButton = UIButton() + private var findpasswordButton = UIButton() + private var sidebar = UIView() + + private var noticeLabel = UILabel() + private lazy var makenicknameButton = UIButton() + + var nickname : String? + + override func viewDidLoad() { + super.viewDidLoad() + + setStyle() + setLayout() + // Do any additional setup after loading the view. + } + + private func setStyle() { + view.backgroundColor = .black + + view.addSubviews(titleLabel, + idTextField, passwordTextField,loginButton, + clearButton, eyeButton, + findidButton, findpasswordButton, sidebar, + noticeLabel, makenicknameButton) + + titleLabel.then { + $0.text = "TVING ID 로그인" + $0.font = UIFont(name: "Pretendard-Regular", size: 23) + $0.textColor = .tvingGray1 + } + idTextField.then { + $0.placeholder = "아이디" + $0.setPlaceholder(color: .tvingGray2) + $0.font = UIFont(name: "Pretendard-Bold", size: 15) + $0.textColor = .tvingGray2 + $0.layer.backgroundColor = UIColor.tvingGray4.cgColor + $0.layer.cornerRadius = 3 + $0.addLeftPadding() + + $0.addTarget(self, action: #selector(textFieldStartChange), for: .editingChanged) + $0.addTarget(self, action: #selector(textFieldEndChange), for: .editingDidEnd) + } + passwordTextField.then { + $0.placeholder = "비밀번호" + $0.setPlaceholder(color: .tvingGray2) + $0.font = UIFont(name: "Pretendard-Bold", size: 15) + $0.textColor = .tvingGray2 + $0.layer.backgroundColor = UIColor.tvingGray4.cgColor + $0.layer.cornerRadius = 3 + $0.addLeftPadding() + + $0.addTarget(self, action: #selector(textFieldStartChange), for: .editingChanged) + $0.addTarget(self, action: #selector(textFieldEndChange), for: .editingDidEnd) + + $0.isSecureTextEntry = true + } + clearButton.then { + $0.setImage(UIImage(named: "clearBtn"), for: .normal) + $0.isHidden = true + $0.contentVerticalAlignment = .fill + $0.contentHorizontalAlignment = .fill + + $0.addTarget(self, action: #selector(clearBtnTapped(sender:)), for: .touchUpInside) + } + eyeButton.then { + $0.setImage(UIImage(named: "noeyeBtn"), for: .normal) + $0.setImage(UIImage(named: "eyeBtn"), for: .selected) + $0.isHidden = true + $0.contentVerticalAlignment = .fill + $0.contentHorizontalAlignment = .fill + + $0.addTarget(self, action: #selector(eyeBtnTapped), for: .touchUpInside) + } + loginButton.then { + $0.setTitle("로그인하기", for: .normal) + $0.setTitleColor(.tvingGray2, for: .normal) + $0.layer.backgroundColor = UIColor.label.cgColor + $0.titleLabel?.font = UIFont(name: "Pretendard-Bold", size: 14) + $0.titleLabel?.textAlignment = .center + $0.layer.borderWidth = 1 + $0.layer.borderColor = UIColor.tvingGray4.cgColor + $0.layer.cornerRadius = 3 + + $0.addTarget(self, action: #selector(loginButtonTapped), for: .touchUpInside) + } + findidButton.then { + $0.setTitle("아이디 찾기", for: .normal) + $0.setTitleColor(.tvingGray2, for: .normal) + $0.titleLabel?.font = UIFont(name: "Pretendard-Bold", size: 14) + } + findpasswordButton.then { + $0.setTitle("비밀번호 찾기", for: .normal) + $0.setTitleColor(.tvingGray2, for: .normal) + $0.titleLabel?.font = UIFont(name: "Pretendard-Bold", size: 14) + } + sidebar.then { + $0.backgroundColor = .tvingGray4 + } + noticeLabel.then { + $0.text = "아직 계정이 없으신가요?" + $0.font = UIFont(name: "Pretendard-Regular", size: 14) + $0.textColor = .tvingGray3 + } + makenicknameButton.then { + $0.setTitle("닉네임 만들러가기", for: .normal) + $0.setTitleColor(.tvingGray2, for: .normal) + $0.titleLabel?.font = UIFont(name: "Pretendard-Regular", size: 14) + + $0.addTarget(self, action: #selector(makenicknameButtonTapped), for: .touchUpInside) + } + + } + + private func setLayout() { + + titleLabel.snp.makeConstraints() { + $0.centerX.equalToSuperview() + $0.top.equalToSuperview().inset(90) + } + idTextField.snp.makeConstraints() { + $0.top.equalTo(titleLabel.snp.bottom).offset(31) + $0.centerX.equalToSuperview() + $0.leading.trailing.equalToSuperview().inset(20) + $0.height.equalTo(52) + } + passwordTextField.snp.makeConstraints() { + $0.top.equalTo(idTextField.snp.bottom).offset(7) + $0.centerX.equalToSuperview() + $0.leading.trailing.equalToSuperview().inset(20) + $0.height.equalTo(52) + } + clearButton.snp.makeConstraints() { + $0.centerY.equalTo(passwordTextField.snp.centerY) + $0.trailing.equalToSuperview().inset(76) + $0.size.equalTo(20) + } + eyeButton.snp.makeConstraints() { + $0.centerY.equalTo(clearButton.snp.centerY) + $0.trailing.equalToSuperview().inset(40) + $0.size.equalTo(20) + } + loginButton.snp.makeConstraints() { + $0.top.equalTo(passwordTextField.snp.bottom).offset(21) + $0.centerX.equalToSuperview() + $0.leading.trailing.equalToSuperview().inset(20) + $0.height.equalTo(52) + } + findidButton.snp.makeConstraints() { + $0.centerY.equalTo(sidebar.snp.centerY) + $0.trailing.equalTo(sidebar.snp.leading).offset(-33) + } + findpasswordButton.snp.makeConstraints() { + $0.centerY.equalTo(sidebar.snp.centerY) + $0.leading.equalTo(sidebar.snp.leading).offset(36) + } + sidebar.snp.makeConstraints() { + $0.top.equalTo(loginButton.snp.bottom).offset(36) + $0.width.equalTo(1) + $0.height.equalTo(12) + $0.centerX.equalToSuperview() + } + noticeLabel.snp.makeConstraints() { + $0.top.equalTo(findidButton.snp.bottom).offset(28) + $0.trailing.equalTo(sidebar.snp.trailing) + } + makenicknameButton.snp.makeConstraints() { + $0.centerY.equalTo(noticeLabel.snp.centerY) + $0.leading.equalTo(noticeLabel.snp.trailing).offset(17) + } + } + + @objc func textFieldStartChange(_ TextField: UITextField) { + TextField.layer.borderColor = UIColor.tvingGray2.cgColor + TextField.layer.borderWidth = 1 + + if passwordTextField.hasText { + clearButton.isHidden = false + eyeButton.isHidden = false + } + else { + clearButton.isHidden = true + eyeButton.isHidden = true + } + + if idTextField.hasText && ((idTextField.text?.isValidEmail()) == true) && passwordTextField.hasText { + loginButton.layer.backgroundColor = UIColor.tvingRed.cgColor + loginButton.layer.borderColor = UIColor.tvingRed.cgColor + loginButton.setTitleColor(.white, for: .normal) + } + else if !idTextField.hasText || !passwordTextField.hasText || ((idTextField.text?.isValidEmail()) == false) { + loginButton.layer.backgroundColor = UIColor.label.cgColor + loginButton.layer.borderColor = UIColor.tvingGray4.cgColor + loginButton.setTitleColor(.tvingGray2, for: .normal) + } + } + + @objc func textFieldEndChange(_ TextField: UITextField) { + TextField.layer.borderWidth = 0 + } + + @objc func clearBtnTapped(sender : AnyObject) { + self.passwordTextField.text = "" + clearButton.isHidden.toggle() + eyeButton.isHidden.toggle() + loginButton.layer.backgroundColor = UIColor.label.cgColor + loginButton.layer.borderColor = UIColor.tvingGray4.cgColor + loginButton.setTitleColor(.tvingGray2, for: .normal) + } + + @objc func eyeBtnTapped() { + self.passwordTextField.isSecureTextEntry.toggle() + } + + @objc func loginButtonTapped() { + let secondVC = SecondViewController() + guard let id = idTextField.text else { return } + guard let nickname = nickname else { return } + secondVC.id = id + secondVC.nickname = nickname + + self.present(secondVC, animated: true) + } + + @objc func makenicknameButtonTapped() { + let bottomSheetVC = ThirdViewController() + bottomSheetVC.modalPresentationStyle = .pageSheet + bottomSheetVC.transitioningDelegate = self + + let sheet = bottomSheetVC.sheetPresentationController + sheet?.preferredCornerRadius = 30 + sheet?.prefersGrabberVisible = true + sheet?.detents = [ + .custom { context in + return context.maximumDetentValue * 0.55 + }] + self.present(bottomSheetVC, animated: true) + } +} + diff --git a/2ndWeek/Seminar-2/Seminar-2.xcodeproj/xcuserdata/shinjiwon.xcuserdatad/xcschemes/xcschememanagement.plist b/2ndWeek/Seminar-2/Seminar-2.xcodeproj/xcuserdata/shinjiwon.xcuserdatad/xcschemes/xcschememanagement.plist index 9c5eb5f..c388a2f 100644 --- a/2ndWeek/Seminar-2/Seminar-2.xcodeproj/xcuserdata/shinjiwon.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/2ndWeek/Seminar-2/Seminar-2.xcodeproj/xcuserdata/shinjiwon.xcuserdatad/xcschemes/xcschememanagement.plist @@ -7,7 +7,7 @@ Seminar-2.xcscheme_^#shared#^_ orderHint - 1 + 0 SnapKitPlayground (Playground) 1.xcscheme