diff --git a/FunnyPuny.xcodeproj/project.pbxproj b/FunnyPuny.xcodeproj/project.pbxproj index 214a9e1..0c06dac 100644 --- a/FunnyPuny.xcodeproj/project.pbxproj +++ b/FunnyPuny.xcodeproj/project.pbxproj @@ -18,11 +18,17 @@ CE10453028F759B8006B31D6 /* AddHabitViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE10452F28F759B8006B31D6 /* AddHabitViewController.swift */; }; CE10453228F7696E006B31D6 /* AddHabitView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE10453128F7696E006B31D6 /* AddHabitView.swift */; }; CE11DCF7295C4CE700CBE37A /* UIViewController+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE11DCF6295C4CE700CBE37A /* UIViewController+Extension.swift */; }; + CE11DCFC296C657400CBE37A /* ProfileCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE11DCFB296C657400CBE37A /* ProfileCell.swift */; }; + CE11DCFE296C658200CBE37A /* ProfileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE11DCFD296C658100CBE37A /* ProfileView.swift */; }; + CE11DD00296C658900CBE37A /* ProfileViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE11DCFF296C658900CBE37A /* ProfileViewController.swift */; }; + CE11DD02296C68CB00CBE37A /* ProfileCellType.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE11DD01296C68CB00CBE37A /* ProfileCellType.swift */; }; + CE11DD04296C6D7700CBE37A /* profile.gif in Resources */ = {isa = PBXBuildFile; fileRef = CE11DD03296C6D7700CBE37A /* profile.gif */; }; CE3429692925482B0037EE0E /* CalendarAnalyticHeaderMonthView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE3429682925482B0037EE0E /* CalendarAnalyticHeaderMonthView.swift */; }; CE351C312911927F00ACCF0C /* AnalyticsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE351C302911927F00ACCF0C /* AnalyticsView.swift */; }; CE351C332911929900ACCF0C /* AnalyticsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE351C322911929900ACCF0C /* AnalyticsViewController.swift */; }; CE351C352911BC7400ACCF0C /* AchivmentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE351C342911BC7400ACCF0C /* AchivmentView.swift */; }; CE351C372911BD8000ACCF0C /* ScoreView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE351C362911BD8000ACCF0C /* ScoreView.swift */; }; + CE5D91C0297B0F9600640E85 /* NotificationsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE5D91BF297B0F9600640E85 /* NotificationsViewController.swift */; }; CE6B77BC29184F2F00996142 /* HabitManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE6B77BB29184F2F00996142 /* HabitManager.swift */; }; CE6B77BE2918586200996142 /* Results+Extension .swift in Sources */ = {isa = PBXBuildFile; fileRef = CE6B77BD2918586200996142 /* Results+Extension .swift */; }; CE6B77C0291AD5DE00996142 /* CalendarAnalyticDateCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE6B77BF291AD5DE00996142 /* CalendarAnalyticDateCell.swift */; }; @@ -42,6 +48,7 @@ CE6D4BB72930D25700647D7D /* FirebaseCrashlytics in Frameworks */ = {isa = PBXBuildFile; productRef = CE6D4BB62930D25700647D7D /* FirebaseCrashlytics */; }; CE6D4BB92930D25700647D7D /* FirebasePerformance in Frameworks */ = {isa = PBXBuildFile; productRef = CE6D4BB82930D25700647D7D /* FirebasePerformance */; }; CE6D4BC32930ED0F00647D7D /* Texts.strings in Resources */ = {isa = PBXBuildFile; fileRef = CE6D4BC52930ED0F00647D7D /* Texts.strings */; }; + CE71E1D929707082003AD465 /* ProfileCellViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE71E1D829707082003AD465 /* ProfileCellViewModel.swift */; }; CE7381CE29265EDE00FCAAAC /* AnalyticsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE7381CD29265EDE00FCAAAC /* AnalyticsViewModel.swift */; }; CE7381D029266D7800FCAAAC /* MenuButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE7381CF29266D7800FCAAAC /* MenuButtonView.swift */; }; CE7808E528FEF8140016AD41 /* HomeCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE7808E428FEF8140016AD41 /* HomeCell.swift */; }; @@ -93,11 +100,17 @@ CE10452F28F759B8006B31D6 /* AddHabitViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddHabitViewController.swift; sourceTree = ""; }; CE10453128F7696E006B31D6 /* AddHabitView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddHabitView.swift; sourceTree = ""; }; CE11DCF6295C4CE700CBE37A /* UIViewController+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+Extension.swift"; sourceTree = ""; }; + CE11DCFB296C657400CBE37A /* ProfileCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProfileCell.swift; sourceTree = ""; }; + CE11DCFD296C658100CBE37A /* ProfileView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProfileView.swift; sourceTree = ""; }; + CE11DCFF296C658900CBE37A /* ProfileViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProfileViewController.swift; sourceTree = ""; }; + CE11DD01296C68CB00CBE37A /* ProfileCellType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileCellType.swift; sourceTree = ""; }; + CE11DD03296C6D7700CBE37A /* profile.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = profile.gif; sourceTree = ""; }; CE3429682925482B0037EE0E /* CalendarAnalyticHeaderMonthView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarAnalyticHeaderMonthView.swift; sourceTree = ""; }; CE351C302911927F00ACCF0C /* AnalyticsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalyticsView.swift; sourceTree = ""; }; CE351C322911929900ACCF0C /* AnalyticsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalyticsViewController.swift; sourceTree = ""; }; CE351C342911BC7400ACCF0C /* AchivmentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AchivmentView.swift; sourceTree = ""; }; CE351C362911BD8000ACCF0C /* ScoreView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScoreView.swift; sourceTree = ""; }; + CE5D91BF297B0F9600640E85 /* NotificationsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationsViewController.swift; sourceTree = ""; }; CE6B77BB29184F2F00996142 /* HabitManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HabitManager.swift; sourceTree = ""; }; CE6B77BD2918586200996142 /* Results+Extension .swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Results+Extension .swift"; sourceTree = ""; }; CE6B77BF291AD5DE00996142 /* CalendarAnalyticDateCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarAnalyticDateCell.swift; sourceTree = ""; }; @@ -113,6 +126,7 @@ CE6B77DC29240D1100996142 /* CalendarCellViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarCellViewModel.swift; sourceTree = ""; }; CE6D4BB12930D06800647D7D /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; CE6D4BC42930ED0F00647D7D /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Texts.strings; sourceTree = ""; }; + CE71E1D829707082003AD465 /* ProfileCellViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileCellViewModel.swift; sourceTree = ""; }; CE7381CD29265EDE00FCAAAC /* AnalyticsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalyticsViewModel.swift; sourceTree = ""; }; CE7381CF29266D7800FCAAAC /* MenuButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuButtonView.swift; sourceTree = ""; }; CE7808E428FEF8140016AD41 /* HomeCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeCell.swift; sourceTree = ""; }; @@ -209,6 +223,7 @@ children = ( CEBE1AD029392DA800F52C3F /* chillState.gif */, CEBE1ACC2938E80C00F52C3F /* emptyState.gif */, + CE11DD03296C6D7700CBE37A /* profile.gif */, ); path = GIF; sourceTree = ""; @@ -232,6 +247,18 @@ path = AddHabit; sourceTree = ""; }; + CE11DCFA296C653500CBE37A /* Profile */ = { + isa = PBXGroup; + children = ( + CE11DCFB296C657400CBE37A /* ProfileCell.swift */, + CE11DCFD296C658100CBE37A /* ProfileView.swift */, + CE11DCFF296C658900CBE37A /* ProfileViewController.swift */, + CE11DD01296C68CB00CBE37A /* ProfileCellType.swift */, + CE71E1D829707082003AD465 /* ProfileCellViewModel.swift */, + ); + path = Profile; + sourceTree = ""; + }; CE34296729241D580037EE0E /* Models */ = { isa = PBXGroup; children = ( @@ -262,6 +289,14 @@ path = Fonts; sourceTree = ""; }; + CE5D91C1297B0F9D00640E85 /* Notifications */ = { + isa = PBXGroup; + children = ( + CE5D91BF297B0F9600640E85 /* NotificationsViewController.swift */, + ); + path = Notifications; + sourceTree = ""; + }; CE6AFF2228F6123E0079FD83 /* Presentation */ = { isa = PBXGroup; children = ( @@ -269,6 +304,8 @@ CE351C2F2911924200ACCF0C /* Analytics */, CE10452E28F756CD006B31D6 /* AddHabit */, CE6AFF2528F6192A0079FD83 /* Home */, + CE5D91C1297B0F9D00640E85 /* Notifications */, + CE11DCFA296C653500CBE37A /* Profile */, ); path = Presentation; sourceTree = ""; @@ -505,6 +542,7 @@ CE6B77D52923C3A300996142 /* SF-Pro-Text-Medium.otf in Resources */, CEDAFF3C28E7199E006136B3 /* Assets.xcassets in Resources */, CEB1EA8A2909CB840087ED24 /* SF-Pro-Text-Regular.otf in Resources */, + CE11DD04296C6D7700CBE37A /* profile.gif in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -585,21 +623,27 @@ CE11DCF7295C4CE700CBE37A /* UIViewController+Extension.swift in Sources */, CE6B77C8291C303C00996142 /* JTACMonthView+Extension.swift in Sources */, CEB1EA8E290C170A0087ED24 /* Fonts.swift in Sources */, + CE5D91C0297B0F9600640E85 /* NotificationsViewController.swift in Sources */, CEBE1ACB2938E37C00F52C3F /* HomeStateView.swift in Sources */, CE944F732901BB940000697A /* CalendarHomeView.swift in Sources */, CEA71A2428F8A18600D2CE36 /* NavigationController.swift in Sources */, CE7808E528FEF8140016AD41 /* HomeCell.swift in Sources */, + CE11DCFC296C657400CBE37A /* ProfileCell.swift in Sources */, CE0C56D02915AC710080ED5C /* UIView+Extension.swift in Sources */, CE6B77CC29201DD600996142 /* String+Extension.swift in Sources */, CE6B77D9292406ED00996142 /* Configurable.swift in Sources */, CEB1EA90290D931A0087ED24 /* TextField.swift in Sources */, CEADCCCF29354EB600BFD545 /* Constants.swift in Sources */, + CE11DD02296C68CB00CBE37A /* ProfileCellType.swift in Sources */, CEC51B10292D5B3200DCC848 /* CalendarManager.swift in Sources */, CE351C312911927F00ACCF0C /* AnalyticsView.swift in Sources */, CE6B77C0291AD5DE00996142 /* CalendarAnalyticDateCell.swift in Sources */, + CE11DCFE296C658200CBE37A /* ProfileView.swift in Sources */, CEA0CAF72900753B00EDCDFD /* CalendarHomeHeaderView.swift in Sources */, CEDAFF3728E7199C006136B3 /* HomeViewController.swift in Sources */, CE6B77D1292261FA00996142 /* ProgressView.swift in Sources */, + CE71E1D929707082003AD465 /* ProfileCellViewModel.swift in Sources */, + CE11DD00296C658900CBE37A /* ProfileViewController.swift in Sources */, CEA0BF5528FEBA7A009B6BFD /* DateFormats.swift in Sources */, CE351C372911BD8000ACCF0C /* ScoreView.swift in Sources */, CE7808E728FF10CE0016AD41 /* UITableView+Extension.swift in Sources */, diff --git a/FunnyPuny/Application/Assets.xcassets/profile.imageset/Contents.json b/FunnyPuny/Application/Assets.xcassets/profile.imageset/Contents.json new file mode 100644 index 0000000..f738fcf --- /dev/null +++ b/FunnyPuny/Application/Assets.xcassets/profile.imageset/Contents.json @@ -0,0 +1,15 @@ +{ + "images" : [ + { + "filename" : "Profile.pdf", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" + } +} diff --git a/FunnyPuny/Application/Assets.xcassets/profile.imageset/Profile.pdf b/FunnyPuny/Application/Assets.xcassets/profile.imageset/Profile.pdf new file mode 100644 index 0000000..fa32901 Binary files /dev/null and b/FunnyPuny/Application/Assets.xcassets/profile.imageset/Profile.pdf differ diff --git a/FunnyPuny/Application/GIF/profile.gif b/FunnyPuny/Application/GIF/profile.gif new file mode 100644 index 0000000..5c7fa0a Binary files /dev/null and b/FunnyPuny/Application/GIF/profile.gif differ diff --git a/FunnyPuny/Application/en.lproj/Texts.strings b/FunnyPuny/Application/en.lproj/Texts.strings index e3ef9fe..4e37b6c 100644 --- a/FunnyPuny/Application/en.lproj/Texts.strings +++ b/FunnyPuny/Application/en.lproj/Texts.strings @@ -41,3 +41,12 @@ "sat" = "Sat"; "sun" = "Sun"; "everyday" = "Everyday"; + +//MARK: Profile + +"profile" = "Profile"; +"notifications" = "Notifications"; +"appearance" = "Appearance"; +"achievments" = "Achievments"; +"donation" = "Donation"; +"soon" = "soon"; diff --git a/FunnyPuny/Application/ru.lproj/Texts.strings b/FunnyPuny/Application/ru.lproj/Texts.strings index d7c887a..6ab8abf 100644 --- a/FunnyPuny/Application/ru.lproj/Texts.strings +++ b/FunnyPuny/Application/ru.lproj/Texts.strings @@ -41,3 +41,12 @@ "sat" = "Сб"; "sun" = "Вс"; "everyday" = "Каждый день"; + +//MARK: Profile + +"profile" = "Профайл"; +"notifications" = "Уведомления"; +"appearance" = "Тема"; +"achievments" = "Достижения"; +"donation" = "Поддержать разработчика"; +"soon" = "soon"; diff --git a/FunnyPuny/Presentation/Common /UIElements/TabBarController.swift b/FunnyPuny/Presentation/Common /UIElements/TabBarController.swift index 48ec559..0f71d01 100644 --- a/FunnyPuny/Presentation/Common /UIElements/TabBarController.swift +++ b/FunnyPuny/Presentation/Common /UIElements/TabBarController.swift @@ -36,7 +36,14 @@ class TabBarController: UITabBarController { tag: 1 ) - viewControllers = [firstViewController, secondViewController] + let thirdViewController = ProfileViewController() + thirdViewController.tabBarItem = UITabBarItem( + title: Texts.profile, + image: Images.profile.image, + tag: 2 + ) + + viewControllers = [firstViewController, secondViewController, thirdViewController] selectedIndex = 0 } } diff --git a/FunnyPuny/Presentation/Notifications/NotificationsViewController.swift b/FunnyPuny/Presentation/Notifications/NotificationsViewController.swift new file mode 100644 index 0000000..cdb7116 --- /dev/null +++ b/FunnyPuny/Presentation/Notifications/NotificationsViewController.swift @@ -0,0 +1,10 @@ +// NotificationsViewController.swift +// FunnyPuny. Created by Zlata Guseva. + +import UIKit + +class NotificationsViewController: UIViewController { + override func viewDidLoad() { + super.viewDidLoad() + } +} diff --git a/FunnyPuny/Presentation/Profile/ProfileCell.swift b/FunnyPuny/Presentation/Profile/ProfileCell.swift new file mode 100644 index 0000000..aaabddc --- /dev/null +++ b/FunnyPuny/Presentation/Profile/ProfileCell.swift @@ -0,0 +1,92 @@ +// ProfileCell.swift +// FunnyPuny. Created by Zlata Guseva. + +import SwiftDate +import UIKit + +// MARK: - ProfileCell + +class ProfileCell: UITableViewCell { + private var iconImageView: UIImageView = { + let imageView = UIImageView() + imageView.layer.cornerRadius = 16 + imageView.image = Images.right.image + imageView.tintColor = Colors.iconsOther.color + imageView.backgroundColor = Colors.backgroundGlobe.color + return imageView + }() + + private var label: UILabel = { + let label = UILabel() + label.font = .bodyRegular + label.textColor = Colors.textPrimary.color + return label + }() + + private var availabilityLabel: UILabel = { + let label = UILabel() + label.text = Texts.soon + label.font = .bodyRegular + label.textColor = Colors.iconsOther.color + label.backgroundColor = Colors.backgroundGlobe.color + return label + }() + + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + super.init(style: style, reuseIdentifier: reuseIdentifier) + commonInit() + } + + @available(*, unavailable) + required init?(coder _: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + private func commonInit() { + addSubviews() + makeConstraints() + setupStyle() + } + + private func setupStyle() { + backgroundColor = Colors.backgroundGlobe.color + selectionStyle = .none + } + + private func addSubviews() { + contentView.addSubview(iconImageView) + contentView.addSubview(label) + contentView.addSubview(availabilityLabel) + } + + private func makeConstraints() { + contentView.snp.makeConstraints { make in + make.top.bottom.equalToSuperview().inset(8) + make.trailing.leading.equalToSuperview().inset(16) + } + + label.snp.makeConstraints { make in + make.leading.equalToSuperview().inset(16) + make.top.bottom.equalToSuperview() + make.trailing.equalToSuperview().inset(48) + } + + iconImageView.snp.makeConstraints { make in + make.trailing.equalToSuperview().inset(8) + make.centerY.equalToSuperview() + make.width.height.equalTo(24) + } + + availabilityLabel.snp.makeConstraints { make in + make.trailing.equalToSuperview().inset(8) + make.centerY.equalToSuperview() + } + } +} + +extension ProfileCell: Configurable { + func configure(with viewModel: ProfileCellViewModel) { + label.text = viewModel.itemName + availabilityLabel.isHidden = viewModel.isAvailable + } +} diff --git a/FunnyPuny/Presentation/Profile/ProfileCellType.swift b/FunnyPuny/Presentation/Profile/ProfileCellType.swift new file mode 100644 index 0000000..e23b5bd --- /dev/null +++ b/FunnyPuny/Presentation/Profile/ProfileCellType.swift @@ -0,0 +1,25 @@ +// ProfileCellType.swift +// FunnyPuny. Created by Zlata Guseva. + +enum ProfileCellType: CaseIterable { + case notifications + case appearance + case achievments + case donation + + var name: String { + switch self { + case .notifications: return Texts.notifications + case .appearance: return Texts.appearance + case .achievments: return Texts.achievments + case .donation: return Texts.donation + } + } + + var isAvailable: Bool { + switch self { + case .notifications: return true + default: return false + } + } +} diff --git a/FunnyPuny/Presentation/Profile/ProfileCellViewModel.swift b/FunnyPuny/Presentation/Profile/ProfileCellViewModel.swift new file mode 100644 index 0000000..0a348d0 --- /dev/null +++ b/FunnyPuny/Presentation/Profile/ProfileCellViewModel.swift @@ -0,0 +1,9 @@ +// ProfileCellViewModel.swift +// FunnyPuny. Created by Zlata Guseva. + +import Foundation + +struct ProfileCellViewModel { + var itemName: String + var isAvailable: Bool +} diff --git a/FunnyPuny/Presentation/Profile/ProfileView.swift b/FunnyPuny/Presentation/Profile/ProfileView.swift new file mode 100644 index 0000000..60cfffc --- /dev/null +++ b/FunnyPuny/Presentation/Profile/ProfileView.swift @@ -0,0 +1,60 @@ +// ProfileView.swift +// FunnyPuny. Created by Zlata Guseva. + +import SwiftyGif +import UIKit + +class ProfileView: UIView { + private var gifImageView: UIImageView = .profileGIF + + var tableView: UITableView = { + let tableView = UITableView() + tableView.backgroundColor = Colors.backgroundGlobe.color + tableView.register(cellWithClass: ProfileCell.self) + tableView.rowHeight = 64 + tableView.separatorStyle = .singleLine + tableView.layer.cornerRadius = 16 + tableView.layer.borderColor = Colors.backgroundIsland.color.cgColor + tableView.layer.borderWidth = 2 + return tableView + }() + + override init(frame: CGRect) { + super.init(frame: frame) + commonInit() + } + + @available(*, unavailable) + required init?(coder _: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + private func commonInit() { + setupStyle() + addSubviews() + makeConstraints() + } + + private func setupStyle() { + backgroundColor = Colors.backgroundGlobe.color + } + + private func addSubviews() { + addSubview(gifImageView) + addSubview(tableView) + } + + private func makeConstraints() { + gifImageView.snp.makeConstraints { make in + make.width.height.equalTo(100) + make.centerX.equalToSuperview() + make.top.equalTo(safeAreaLayoutGuide.snp.top) + } + + tableView.snp.makeConstraints { make in + make.top.equalTo(gifImageView.snp.bottom).offset(44) + make.leading.trailing.equalToSuperview().inset(16) + make.height.equalTo(256) + } + } +} diff --git a/FunnyPuny/Presentation/Profile/ProfileViewController.swift b/FunnyPuny/Presentation/Profile/ProfileViewController.swift new file mode 100644 index 0000000..e58819a --- /dev/null +++ b/FunnyPuny/Presentation/Profile/ProfileViewController.swift @@ -0,0 +1,51 @@ +// ProfileViewController.swift +// FunnyPuny. Created by Zlata Guseva. + +import SwiftDate +import UIKit + +class ProfileViewController: ViewController { + private var profileView = ProfileView() + private var profileCellTypes = ProfileCellType.allCases + + override func viewDidLoad() { + super.viewDidLoad() + title = Texts.profile + view = profileView + setupTableView() + } + + private func setupTableView() { + profileView.tableView.dataSource = self + profileView.tableView.delegate = self + } +} + +// MARK: UITableViewDelegate + +extension ProfileViewController: UITableViewDelegate { + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + if indexPath.row == 0 { + let viewController = NavigationController(rootViewController: NotificationsViewController()) + viewController.modalPresentationStyle = .fullScreen + navigationController?.pushViewController(viewController, animated: true) + present(viewController, animated: true) + } + } +} + +// MARK: UITableViewDataSource + +extension ProfileViewController: UITableViewDataSource { + func tableView(_: UITableView, numberOfRowsInSection _: Int) -> Int { + profileCellTypes.count + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell(withClass: ProfileCell.self) + let cellType = profileCellTypes[indexPath.row] + let profileCellViewModel = ProfileCellViewModel(itemName: cellType.name, isAvailable: cellType.isAvailable) + cell.configure(with: profileCellViewModel) + return cell + } +}