diff --git a/.swiftlint.yml b/.swiftlint.yml index 2329a83..2748f83 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -1,5 +1,4 @@ disabled_rules: - - line_length - trailing_whitespace - leading_whitespace - force_try diff --git a/RespectU.xcodeproj/project.pbxproj b/RespectU.xcodeproj/project.pbxproj index 9274289..f3029b6 100644 --- a/RespectU.xcodeproj/project.pbxproj +++ b/RespectU.xcodeproj/project.pbxproj @@ -501,6 +501,32 @@ name = Frameworks; sourceTree = ""; }; + 1914B521223889F200BA057E /* XIBs */ = { + isa = PBXGroup; + children = ( + 0A55900F26C3996946BE4F93D6DA3621 /* AchievementCell.xib */, + 8345DDA3C2BB8226C719046C36C1C125 /* GuideFirstCell.xib */, + 27B3098AC1D795D61653C34864ED20F9 /* GuideSecondCell.xib */, + 87BC688E45E35568921856EA90F48939 /* GuideThirdCell.xib */, + 274D0B448B5CE4F3F072A2E8F1A08173 /* MissionCell.xib */, + DF44E865CAECD23B67EC669F4F499627 /* RankingCell.xib */, + 8872346BBBB0B7BAFD7D7D14AB637E94 /* RecordCell.xib */, + 9CCC3BF2DFAE7E90D1AB5AE1DDA0283F /* RecordView.xib */, + 447A6CDF1125075CFA6FF3AA94D38056 /* SearchByLevelView.xib */, + BB408736A795C68EBA417CAF1C9391F9 /* SearchByNoteView.xib */, + D550E00BAB0ADC8AEF6EFE91AD2134E9 /* SearchByRatingView.xib */, + D538492B9D665E6049971A842544B8F0 /* SearchRecordDetailCell.xib */, + 58F94B11D0652E774E5A75E6FC9875E3 /* SkillLevelCell.xib */, + 0D06706BBF1BDD733B678B932EBBB7D5 /* SkillLevelDetailView.xib */, + E566F2224770BCDA7139D3E7C9B1AC34 /* SongCell.xib */, + EC0C1D43DE39EACC238837AEAB67663B /* SummaryCell.xib */, + C6F278314CCBAFC8DD80108CFDC5B48D /* SummaryCollectionCell.xib */, + 3329CE7FE589A94E7D6F4B0D771A64AE /* Top50Cell.xib */, + E4592DA185138E2C675A2E63C84920D1 /* TrophyCell.xib */, + ); + path = XIBs; + sourceTree = ""; + }; 20CD4E18015C56EA046398F6514DA8D4 /* Top50 */ = { isa = PBXGroup; children = ( @@ -813,45 +839,27 @@ DF613463216FC79F328D85241366F912 /* Views */ = { isa = PBXGroup; children = ( + 1914B521223889F200BA057E /* XIBs */, 623DBE7ABE62C6ED2C6A96D8B561D1BC /* AchievementCell.swift */, - 0A55900F26C3996946BE4F93D6DA3621 /* AchievementCell.xib */, 48EB4DE7C46CAC769FAD64B4062EA5AC /* GuideFirstCell.swift */, - 8345DDA3C2BB8226C719046C36C1C125 /* GuideFirstCell.xib */, 88C214B5C6340C681D687A5837D49CB2 /* GuideSecondCell.swift */, - 27B3098AC1D795D61653C34864ED20F9 /* GuideSecondCell.xib */, C2C849886AF9CEC2084D57D6610826D0 /* GuideThirdCell.swift */, - 87BC688E45E35568921856EA90F48939 /* GuideThirdCell.xib */, 5E6BC6E8EAEFF1FB31DF48435303F350 /* MissionCell.swift */, - 274D0B448B5CE4F3F072A2E8F1A08173 /* MissionCell.xib */, B6DC6B20F4435BC55F0363155B189EA9 /* RankingCell.swift */, - DF44E865CAECD23B67EC669F4F499627 /* RankingCell.xib */, 2991773C4B90001F83182265FA5298FA /* RecordCell.swift */, - 8872346BBBB0B7BAFD7D7D14AB637E94 /* RecordCell.xib */, 6D899C6158365DC40A43EFA3FBD53860 /* RecordView.swift */, - 9CCC3BF2DFAE7E90D1AB5AE1DDA0283F /* RecordView.xib */, 16CA587AC64BBF7D9615B18AE922CCA5 /* SearchByLevelView.swift */, - 447A6CDF1125075CFA6FF3AA94D38056 /* SearchByLevelView.xib */, D8DA77CE4436FD7F1B3A85A2993A6875 /* SearchByNoteView.swift */, - BB408736A795C68EBA417CAF1C9391F9 /* SearchByNoteView.xib */, DF1CBDA6DFA6F7DC1C8CFDE819CB27EC /* SearchByRatingView.swift */, - D550E00BAB0ADC8AEF6EFE91AD2134E9 /* SearchByRatingView.xib */, 5C7E6B6B900C98599DF992D190397ED8 /* SearchRecordDetailCell.swift */, - D538492B9D665E6049971A842544B8F0 /* SearchRecordDetailCell.xib */, C48AF305EFDF8EDEE8CE8D136BC9FEEB /* SignInTextField.swift */, 2AC69B55FC64D7C31A86A33852EAB0AC /* SkillLevelCell.swift */, - 58F94B11D0652E774E5A75E6FC9875E3 /* SkillLevelCell.xib */, F0CC6B551EBD0EC656F35FD74247ED8D /* SkillLevelDetailView.swift */, - 0D06706BBF1BDD733B678B932EBBB7D5 /* SkillLevelDetailView.xib */, 59AC73FB70CC51A8AFAC0050C039CF14 /* SongCell.swift */, - E566F2224770BCDA7139D3E7C9B1AC34 /* SongCell.xib */, D8D3AEF54E1F8CB4F0C230AE0F4A274D /* SummaryCell.swift */, - EC0C1D43DE39EACC238837AEAB67663B /* SummaryCell.xib */, 7141F43FD5DD9A34D35E2692CB721D4A /* SummaryCollectionCell.swift */, - C6F278314CCBAFC8DD80108CFDC5B48D /* SummaryCollectionCell.xib */, 4A4C312CB6DC58847B1ACBECB8F95A8F /* Top50Cell.swift */, - 3329CE7FE589A94E7D6F4B0D771A64AE /* Top50Cell.xib */, 7C8E87A2B03543FCDFA459E10DCEBCDF /* TrophyCell.swift */, - E4592DA185138E2C675A2E63C84920D1 /* TrophyCell.xib */, ); path = Views; sourceTree = ""; diff --git a/RespectU/Sources/AppDelegate.swift b/RespectU/Sources/AppDelegate.swift index 743400c..207fab7 100644 --- a/RespectU/Sources/AppDelegate.swift +++ b/RespectU/Sources/AppDelegate.swift @@ -41,15 +41,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate { let id = KeychainWrapper.standard.string(forKey: "id") ?? "" if !id.isEmpty { if TipInfo.fetch().count != 0 { - let controller = UIViewController.instantiate(storyboard: "Performance", identifier: "PerformanceNavigationController") + let controller = StoryboardScene.Performance.performanceNavigationController.instantiate() window?.rootViewController = controller } else { - UserDefaults.standard.set(450, forKey: "bpm") - let controller = UIViewController.instantiate(storyboard: "Init", identifier: InitViewController.name) + Persistence.bpm = 450 + let controller = StoryboardScene.Init.initViewController.instantiate() window?.rootViewController = controller } } else { - let controller = UIViewController.instantiate(storyboard: "SignIn", identifier: "SignNavigationController") + let controller = StoryboardScene.SignIn.signNavigationController.instantiate() window?.rootViewController = controller } window?.makeKeyAndVisible() @@ -60,19 +60,21 @@ class AppDelegate: UIResponder, UIApplicationDelegate { UserDefaults.standard.set(favoriteButton.lowercased(), forKey: "favoriteButton") } // 전역 프로퍼티 설정 - let navigationBar = UINavigationBar.appearance() - navigationBar.setBackgroundImage(.init(), for: .default) - navigationBar.shadowImage = .init() - navigationBar.backgroundColor = .clear - navigationBar.isTranslucent = true - let tableView = UITableView.appearance() - tableView.backgroundColor = .white - tableView.separatorColor = .lightGray - tableView.separatorInset = .init(top: 0, left: 16, bottom: 0, right: 16) - tableView.layer.borderColor = UIColor.main.cgColor - tableView.layer.borderWidth = 3 - tableView.layer.cornerRadius = 10 - tableView.tableFooterView = .init() + UINavigationBar.appearance().do { + $0.setBackgroundImage(.init(), for: .default) + $0.shadowImage = .init() + $0.backgroundColor = .clear + $0.isTranslucent = true + } + UITableView.appearance().do { + $0.backgroundColor = .white + $0.separatorColor = .lightGray + $0.separatorInset = .init(top: 0, left: 16, bottom: 0, right: 16) + $0.layer.borderColor = UIColor.main.cgColor + $0.layer.borderWidth = 3 + $0.layer.cornerRadius = 10 + $0.tableFooterView = .init() + } return true } } diff --git a/RespectU/Sources/Common/Button.swift b/RespectU/Sources/Common/Button.swift index 345cad6..24a247e 100644 --- a/RespectU/Sources/Common/Button.swift +++ b/RespectU/Sources/Common/Button.swift @@ -26,11 +26,6 @@ enum Button: String { /// Only in mission - TECHNIKA mode. case tb -} - -// MARK: - Extension - -extension Button { /// Expands the raw value of each case. /// @@ -45,4 +40,6 @@ extension Button { default: return nil } } + + static let all: [Button] = [.button4, .button5, .button6, .button8] } diff --git a/RespectU/Sources/Common/Difficulty.swift b/RespectU/Sources/Common/Difficulty.swift index cd78fed..d620e89 100644 --- a/RespectU/Sources/Common/Difficulty.swift +++ b/RespectU/Sources/Common/Difficulty.swift @@ -26,4 +26,6 @@ enum Difficulty: String { /// Only in mission - REDESIGN. case redesign + + static let all: [Difficulty] = [.normal, .hard, .maximum] } diff --git a/RespectU/Sources/Extension/String+.swift b/RespectU/Sources/Extension/String+.swift index 57d5b69..9ad2810 100644 --- a/RespectU/Sources/Extension/String+.swift +++ b/RespectU/Sources/Extension/String+.swift @@ -15,56 +15,56 @@ extension String { return NSLocalizedString(self, tableName: nil, bundle: Bundle.main, value: "", comment: "") } - func missionGradient(_ direction: GradientDirection) -> CAGradientLayer? { - let startPoint = direction == .horizontal ? CGPoint(x: 0, y: 0.5) : CGPoint(x: 0.5, y: 0) - let endPoint = direction == .horizontal ? CGPoint(x: 1, y: 0.5) : CGPoint(x: 0.5, y: 1) - switch self { - case MissionSection.Respect.departure: - return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.137254902, green: 0.6549019608, blue: 0.3921568627, alpha: 1), #colorLiteral(red: 0.2431372549, green: 0.8235294118, blue: 0.8274509804, alpha: 1)], locations: [0, 0.5, 1]) - case MissionSection.Respect.clubRoad645: - return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.1568627451, green: 0.6431372549, blue: 0.7725490196, alpha: 1), #colorLiteral(red: 0.2352941176, green: 0.8235294118, blue: 0.8, alpha: 1)], locations: [0, 0.5, 1]) - case MissionSection.Respect.maxTheater: - return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.5176470588, green: 0.737254902, blue: 0.5019607843, alpha: 1), #colorLiteral(red: 0.2941176471, green: 0.7137254902, blue: 0.9176470588, alpha: 1)], locations: [0, 0.5, 1]) - case MissionSection.Respect.anotherWorld: - return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.2156862745, green: 0.6392156863, blue: 0.7098039216, alpha: 1), #colorLiteral(red: 0.3215686275, green: 0.537254902, blue: 0.9333333333, alpha: 1)], locations: [0, 0.5, 1]) - case MissionSection.Respect.backStage: - return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.631372549, green: 0.4117647059, blue: 0.9254901961, alpha: 1), #colorLiteral(red: 0.3450980392, green: 0.431372549, blue: 0.937254902, alpha: 1)], locations: [0, 0.5, 1]) - case MissionSection.Respect.chaosTheory: - return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.6705882353, green: 0.3254901961, blue: 0.7725490196, alpha: 1), #colorLiteral(red: 0.5294117647, green: 0.3647058824, blue: 0.9764705882, alpha: 1)], locations: [0, 0.5, 1]) - case MissionSection.Respect.soundLab: - return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.7098039216, green: 0.3294117647, blue: 0.8941176471, alpha: 1), #colorLiteral(red: 0.7568627451, green: 0.5529411765, blue: 0.3725490196, alpha: 1)], locations: [0, 0.5, 1]) - case MissionSection.Respect.visualizer: - return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.7294117647, green: 0.3137254902, blue: 0.9254901961, alpha: 1), #colorLiteral(red: 0.9843137255, green: 0.4078431373, blue: 0.8156862745, alpha: 1)], locations: [0, 0.5, 1]) - case MissionSection.Respect.developers: - return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.6392156863, green: 0.2784313725, blue: 0.6901960784, alpha: 1), #colorLiteral(red: 0.9803921569, green: 0.4470588235, blue: 0.4392156863, alpha: 1)], locations: [0, 0.5, 1]) - case MissionSection.Respect.destination: - return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.5921568627, green: 0.2588235294, blue: 0.2588235294, alpha: 1), #colorLiteral(red: 0.6470588235, green: 0.06274509804, blue: 0.1803921569, alpha: 1)], locations: [0, 0.5, 1]) - case MissionSection.Trilogy.tSide: - return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.2980392157, green: 0.337254902, blue: 0.9843137255, alpha: 1), #colorLiteral(red: 0.4, green: 0.6980392157, blue: 0.9764705882, alpha: 1)], locations: [0, 0.5, 1]) - case MissionSection.Trilogy.rSide: - return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.2941176471, green: 0.337254902, blue: 0.9843137255, alpha: 1), #colorLiteral(red: 0.5882352941, green: 0.4352941176, blue: 0.9568627451, alpha: 1)], locations: [0, 0.5, 1]) - case MissionSection.CE.electronicCity: - return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.2509803922, green: 0.2352941176, blue: 0.1960784314, alpha: 1), #colorLiteral(red: 0.8352941176, green: 0.7254901961, blue: 0.2235294118, alpha: 1)], locations: [0, 0.5, 1]) - case MissionSection.CE.metropolis: - return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.9254901961, green: 0.6980392157, blue: 0.2509803922, alpha: 1), #colorLiteral(red: 0.6274509804, green: 0.4784313725, blue: 0.7450980392, alpha: 1)], locations: [0, 0.5, 1]) - case MissionSection.Technika1.platinumMixing: - return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.09803921569, green: 0.1882352941, blue: 0.2980392157, alpha: 1), #colorLiteral(red: 0.5490196078, green: 0.6862745098, blue: 0.7921568627, alpha: 1)], locations: [0, 0.5, 1]) - case MissionSection.Technika1.technicalMixing: - return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.4, green: 0.07450980392, blue: 0.3803921569, alpha: 1), #colorLiteral(red: 0.8705882353, green: 0.2039215686, blue: 0.6392156863, alpha: 1)], locations: [0, 0.5, 1]) - case MissionSection.BS.stylishPerformance: - return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.3411764706, green: 0.6274509804, blue: 0.9215686275, alpha: 1), #colorLiteral(red: 0.09803921569, green: 0.262745098, blue: 0.6784313725, alpha: 1)], locations: [0, 0.5, 1]) - case MissionSection.BS.absoluteSound: - return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.8588235294, green: 0.2078431373, blue: 0.5960784314, alpha: 1), #colorLiteral(red: 0.3960784314, green: 0.05490196078, blue: 0.1960784314, alpha: 1)], locations: [0, 0.5, 1]) - case MissionSection.LinkDisk.whiteDisk: - return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.6549019608, green: 0.03529411765, blue: 0.06274509804, alpha: 1), #colorLiteral(red: 0.9333333333, green: 0.7960784314, blue: 0.8117647059, alpha: 1)], locations: [0, 0.5, 1]) - case MissionSection.LinkDisk.blackDisk: - return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.1333333333, green: 0.1176470588, blue: 0.1098039216, alpha: 1), #colorLiteral(red: 0.5921568627, green: 0.5411764706, blue: 0.3843137255, alpha: 1)], locations: [0, 0.5, 1]) - case MissionSection.Technika2.starMixing: - return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.537254902, green: 0.07058823529, blue: 0.5058823529, alpha: 1), #colorLiteral(red: 0.1058823529, green: 0.3882352941, blue: 0.6392156863, alpha: 1), #colorLiteral(red: 0.2470588235, green: 0.6588235294, blue: 0.1921568627, alpha: 1), #colorLiteral(red: 0.9333333333, green: 0.7333333333, blue: 0.1843137255, alpha: 1)], locations: [0, 0.25, 0.5, 0.75, 1]) - case MissionSection.Technika2.clubMixing: - return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.07843137255, green: 0.2470588235, blue: 0.6705882353, alpha: 1), #colorLiteral(red: 0.9843137255, green: 0.7960784314, blue: 0.1882352941, alpha: 1)], locations: [0, 0.5, 1]) - default: - return nil - } - } +// func missionGradient(_ direction: GradientDirection) -> CAGradientLayer? { +// let startPoint = direction == .horizontal ? CGPoint(x: 0, y: 0.5) : CGPoint(x: 0.5, y: 0) +// let endPoint = direction == .horizontal ? CGPoint(x: 1, y: 0.5) : CGPoint(x: 0.5, y: 1) +// switch self { +// case MissionSection.Respect.departure: +// return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.137254902, green: 0.6549019608, blue: 0.3921568627, alpha: 1), #colorLiteral(red: 0.2431372549, green: 0.8235294118, blue: 0.8274509804, alpha: 1)], locations: [0, 0.5, 1]) +// case MissionSection.Respect.clubRoad645: +// return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.1568627451, green: 0.6431372549, blue: 0.7725490196, alpha: 1), #colorLiteral(red: 0.2352941176, green: 0.8235294118, blue: 0.8, alpha: 1)], locations: [0, 0.5, 1]) +// case MissionSection.Respect.maxTheater: +// return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.5176470588, green: 0.737254902, blue: 0.5019607843, alpha: 1), #colorLiteral(red: 0.2941176471, green: 0.7137254902, blue: 0.9176470588, alpha: 1)], locations: [0, 0.5, 1]) +// case MissionSection.Respect.anotherWorld: +// return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.2156862745, green: 0.6392156863, blue: 0.7098039216, alpha: 1), #colorLiteral(red: 0.3215686275, green: 0.537254902, blue: 0.9333333333, alpha: 1)], locations: [0, 0.5, 1]) +// case MissionSection.Respect.backStage: +// return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.631372549, green: 0.4117647059, blue: 0.9254901961, alpha: 1), #colorLiteral(red: 0.3450980392, green: 0.431372549, blue: 0.937254902, alpha: 1)], locations: [0, 0.5, 1]) +// case MissionSection.Respect.chaosTheory: +// return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.6705882353, green: 0.3254901961, blue: 0.7725490196, alpha: 1), #colorLiteral(red: 0.5294117647, green: 0.3647058824, blue: 0.9764705882, alpha: 1)], locations: [0, 0.5, 1]) +// case MissionSection.Respect.soundLab: +// return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.7098039216, green: 0.3294117647, blue: 0.8941176471, alpha: 1), #colorLiteral(red: 0.7568627451, green: 0.5529411765, blue: 0.3725490196, alpha: 1)], locations: [0, 0.5, 1]) +// case MissionSection.Respect.visualizer: +// return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.7294117647, green: 0.3137254902, blue: 0.9254901961, alpha: 1), #colorLiteral(red: 0.9843137255, green: 0.4078431373, blue: 0.8156862745, alpha: 1)], locations: [0, 0.5, 1]) +// case MissionSection.Respect.developers: +// return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.6392156863, green: 0.2784313725, blue: 0.6901960784, alpha: 1), #colorLiteral(red: 0.9803921569, green: 0.4470588235, blue: 0.4392156863, alpha: 1)], locations: [0, 0.5, 1]) +// case MissionSection.Respect.destination: +// return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.5921568627, green: 0.2588235294, blue: 0.2588235294, alpha: 1), #colorLiteral(red: 0.6470588235, green: 0.06274509804, blue: 0.1803921569, alpha: 1)], locations: [0, 0.5, 1]) +// case MissionSection.Trilogy.tSide: +// return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.2980392157, green: 0.337254902, blue: 0.9843137255, alpha: 1), #colorLiteral(red: 0.4, green: 0.6980392157, blue: 0.9764705882, alpha: 1)], locations: [0, 0.5, 1]) +// case MissionSection.Trilogy.rSide: +// return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.2941176471, green: 0.337254902, blue: 0.9843137255, alpha: 1), #colorLiteral(red: 0.5882352941, green: 0.4352941176, blue: 0.9568627451, alpha: 1)], locations: [0, 0.5, 1]) +// case MissionSection.CE.electronicCity: +// return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.2509803922, green: 0.2352941176, blue: 0.1960784314, alpha: 1), #colorLiteral(red: 0.8352941176, green: 0.7254901961, blue: 0.2235294118, alpha: 1)], locations: [0, 0.5, 1]) +// case MissionSection.CE.metropolis: +// return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.9254901961, green: 0.6980392157, blue: 0.2509803922, alpha: 1), #colorLiteral(red: 0.6274509804, green: 0.4784313725, blue: 0.7450980392, alpha: 1)], locations: [0, 0.5, 1]) +// case MissionSection.Technika1.platinumMixing: +// return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.09803921569, green: 0.1882352941, blue: 0.2980392157, alpha: 1), #colorLiteral(red: 0.5490196078, green: 0.6862745098, blue: 0.7921568627, alpha: 1)], locations: [0, 0.5, 1]) +// case MissionSection.Technika1.technicalMixing: +// return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.4, green: 0.07450980392, blue: 0.3803921569, alpha: 1), #colorLiteral(red: 0.8705882353, green: 0.2039215686, blue: 0.6392156863, alpha: 1)], locations: [0, 0.5, 1]) +// case MissionSection.BS.stylishPerformance: +// return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.3411764706, green: 0.6274509804, blue: 0.9215686275, alpha: 1), #colorLiteral(red: 0.09803921569, green: 0.262745098, blue: 0.6784313725, alpha: 1)], locations: [0, 0.5, 1]) +// case MissionSection.BS.absoluteSound: +// return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.8588235294, green: 0.2078431373, blue: 0.5960784314, alpha: 1), #colorLiteral(red: 0.3960784314, green: 0.05490196078, blue: 0.1960784314, alpha: 1)], locations: [0, 0.5, 1]) +// case MissionSection.LinkDisk.whiteDisk: +// return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.6549019608, green: 0.03529411765, blue: 0.06274509804, alpha: 1), #colorLiteral(red: 0.9333333333, green: 0.7960784314, blue: 0.8117647059, alpha: 1)], locations: [0, 0.5, 1]) +// case MissionSection.LinkDisk.blackDisk: +// return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.1333333333, green: 0.1176470588, blue: 0.1098039216, alpha: 1), #colorLiteral(red: 0.5921568627, green: 0.5411764706, blue: 0.3843137255, alpha: 1)], locations: [0, 0.5, 1]) +// case MissionSection.Technika2.starMixing: +// return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.537254902, green: 0.07058823529, blue: 0.5058823529, alpha: 1), #colorLiteral(red: 0.1058823529, green: 0.3882352941, blue: 0.6392156863, alpha: 1), #colorLiteral(red: 0.2470588235, green: 0.6588235294, blue: 0.1921568627, alpha: 1), #colorLiteral(red: 0.9333333333, green: 0.7333333333, blue: 0.1843137255, alpha: 1)], locations: [0, 0.25, 0.5, 0.75, 1]) +// case MissionSection.Technika2.clubMixing: +// return CAGradientLayer.makeGradient(startPoint: startPoint, endPoint: endPoint, colors: [#colorLiteral(red: 0.07843137255, green: 0.2470588235, blue: 0.6705882353, alpha: 1), #colorLiteral(red: 0.9843137255, green: 0.7960784314, blue: 0.1882352941, alpha: 1)], locations: [0, 0.5, 1]) +// default: +// return nil +// } +// } } diff --git a/RespectU/Sources/Extension/UIView+.swift b/RespectU/Sources/Extension/UIView+.swift index 3c4db7d..74ff2a2 100644 --- a/RespectU/Sources/Extension/UIView+.swift +++ b/RespectU/Sources/Extension/UIView+.swift @@ -15,7 +15,7 @@ extension UIView { /// - Parameter xibName: The name of xib file. /// /// - Returns: The instantiated view. - static func instantiateFromXib(xibName: String) -> UIView? { + static func instantiateFromXIB(xibName: String) -> UIView? { return UINib(nibName: xibName, bundle: nil) .instantiate(withOwner: nil, options: nil).first as? UIView } diff --git a/RespectU/Sources/Models/Persistence.swift b/RespectU/Sources/Models/Persistence.swift index 2fc7652..0a4ef8e 100644 --- a/RespectU/Sources/Models/Persistence.swift +++ b/RespectU/Sources/Models/Persistence.swift @@ -46,4 +46,16 @@ struct Persistence { } } } + + static var bpm: Double { + get { + return UserDefaults.standard.double(forKey: "bpm") + } + set { + UserDefaults.standard.do { + $0.set(newValue, forKey: "bpm") + $0.synchronize() + } + } + } } diff --git a/RespectU/Sources/Utils/Utils.swift b/RespectU/Sources/Utils/Utils.swift index 885deab..5f5072f 100644 --- a/RespectU/Sources/Utils/Utils.swift +++ b/RespectU/Sources/Utils/Utils.swift @@ -317,7 +317,7 @@ final class Utils { return 0 } - /// Fetches the skill level of 4B of `skillPoint`. + /// Accesses the skill level of 4B of `skillPoint`. /// /// - Parameter skillPoint: The given skill point. /// @@ -356,7 +356,7 @@ final class Utils { } } - /// Fetches the skill level of 5B of `skillPoint`. + /// Accesses the skill level of 5B of `skillPoint`. /// /// - Parameter skillPoint: The given skill point. /// @@ -396,7 +396,7 @@ final class Utils { } } - /// Fetches the skill level of 6B and 8B of `skillPoint`. + /// Accesses the skill level of 6B and 8B of `skillPoint`. /// /// - Parameter skillPoint: The given skill point. /// @@ -436,7 +436,7 @@ final class Utils { } } - /// Fetches the weight of specific `difficulty`. + /// Accesses the weight of specific `difficulty`. /// /// - Parameter difficulty: The given difficulty. /// diff --git a/RespectU/Sources/ViewControllers/Record/RecordBaseTableViewController.swift b/RespectU/Sources/ViewControllers/Record/RecordBaseTableViewController.swift index 87f907a..36ca507 100644 --- a/RespectU/Sources/ViewControllers/Record/RecordBaseTableViewController.swift +++ b/RespectU/Sources/ViewControllers/Record/RecordBaseTableViewController.swift @@ -85,7 +85,7 @@ extension RecordBaseTableViewController { songResult.title?.english ?? "") guard let object = recordResults?.filter(predicate).first else { return } cell.setColorsInSong(object.series, labels: cell.labels) - recordView = UIView.instantiateFromXib(xibName: RecordView.name) as? RecordView + recordView = UIView.instantiateFromXIB(xibName: RecordView.name) as? RecordView recordView.delegate = self recordView.translatesAutoresizingMaskIntoConstraints = false recordViewController.view.addSubview(recordView) diff --git a/RespectU/Sources/ViewControllers/SearchRecordViewController.swift b/RespectU/Sources/ViewControllers/SearchRecordViewController.swift index be65398..4ba5ee9 100644 --- a/RespectU/Sources/ViewControllers/SearchRecordViewController.swift +++ b/RespectU/Sources/ViewControllers/SearchRecordViewController.swift @@ -87,8 +87,8 @@ final class SearchRecordViewController: UIViewController { controller.levelIndex = selectedLevelIndex } else if searchByRateButton.isSelected { guard let rateView = subView.subviews.first as? SearchByRatingView else { return } - let lowerRate = Double(rateView.lowerRateTextField.text ?? "") ?? 0 - let upperRate = Double(rateView.upperRateTextField.text ?? "") ?? 0 + let lowerRate = Double(rateView.lowerRatingTextField.text ?? "") ?? 0 + let upperRate = Double(rateView.upperRatingTextField.text ?? "") ?? 0 controller.lowerRange = lowerRate controller.upperRange = upperRate } else if searchByNoteButton.isSelected { @@ -148,7 +148,7 @@ final class SearchRecordViewController: UIViewController { case 0: selectedMethodIndex = 0 guard let newView = UIView - .instantiateFromXib(xibName: SearchByLevelView.name) as? SearchByLevelView + .instantiateFromXIB(xibName: SearchByLevelView.name) as? SearchByLevelView else { return } newView.pickerView.delegate = self newView.pickerView.dataSource = self @@ -163,12 +163,12 @@ final class SearchRecordViewController: UIViewController { case 1: selectedMethodIndex = 1 guard let newView = UIView - .instantiateFromXib(xibName: SearchByRatingView.name) as? SearchByRatingView + .instantiateFromXIB(xibName: SearchByRatingView.name) as? SearchByRatingView else { return } newView.delegate = self - newView.lowerRateTextField + newView.lowerRatingTextField .addTarget(self, action: #selector(ratingTextFieldEditingDidEnd), for: .editingDidEnd) - newView.upperRateTextField + newView.upperRatingTextField .addTarget(self, action: #selector(ratingTextFieldEditingDidEnd), for: .editingDidEnd) subView.addSubview(newView) newView.translatesAutoresizingMaskIntoConstraints = false @@ -181,7 +181,7 @@ final class SearchRecordViewController: UIViewController { case 2: selectedMethodIndex = 2 guard let newView = UIView - .instantiateFromXib(xibName: SearchByNoteView.name) as? SearchByNoteView + .instantiateFromXIB(xibName: SearchByNoteView.name) as? SearchByNoteView else { return } newView.delegate = self newView.noMaxComboButton @@ -315,8 +315,8 @@ private extension SearchRecordViewController { } case is SearchByRatingView: guard let newView = view as? SearchByRatingView else { return } - guard let lowerText = newView.lowerRateTextField.text else { return } - guard let upperText = newView.upperRateTextField.text else { return } + guard let lowerText = newView.lowerRatingTextField.text else { return } + guard let upperText = newView.upperRatingTextField.text else { return } guard let lower = Double(lowerText) else { return } guard let upper = Double(upperText) else { return } if upper > lower { diff --git a/RespectU/Sources/ViewControllers/SkillLevelDetailViewController.swift b/RespectU/Sources/ViewControllers/SkillLevelDetailViewController.swift index cbdcd01..87b1e64 100644 --- a/RespectU/Sources/ViewControllers/SkillLevelDetailViewController.swift +++ b/RespectU/Sources/ViewControllers/SkillLevelDetailViewController.swift @@ -32,16 +32,16 @@ final class SkillLevelDetailViewController: UIViewController { private func configure() { guard let button4View - = UIView.instantiateFromXib(xibName: SkillLevelDetailView.name) as? SkillLevelDetailView + = UIView.instantiateFromXIB(xibName: SkillLevelDetailView.name) as? SkillLevelDetailView else { return } guard let button5View - = UIView.instantiateFromXib(xibName: SkillLevelDetailView.name) as? SkillLevelDetailView + = UIView.instantiateFromXIB(xibName: SkillLevelDetailView.name) as? SkillLevelDetailView else { return } guard let button6View - = UIView.instantiateFromXib(xibName: SkillLevelDetailView.name) as? SkillLevelDetailView + = UIView.instantiateFromXIB(xibName: SkillLevelDetailView.name) as? SkillLevelDetailView else { return } guard let button8View - = UIView.instantiateFromXib(xibName: SkillLevelDetailView.name) as? SkillLevelDetailView + = UIView.instantiateFromXIB(xibName: SkillLevelDetailView.name) as? SkillLevelDetailView else { return } let recordViews = [button4View, button5View, button6View, button8View] let backgroundViews = [ diff --git a/RespectU/Sources/Views/AchievementCell.swift b/RespectU/Sources/Views/AchievementCell.swift index df721fa..dad0fac 100644 --- a/RespectU/Sources/Views/AchievementCell.swift +++ b/RespectU/Sources/Views/AchievementCell.swift @@ -12,13 +12,13 @@ import UIKit final class AchievementCell: UITableViewCell { /// The stage label. - @IBOutlet weak var stageLabel: UILabel! + @IBOutlet private weak var stageLabel: UILabel! /// The item label. - @IBOutlet weak var itemLabel: UILabel! + @IBOutlet private weak var itemLabel: UILabel! /// The type label. - @IBOutlet weak var typeLabel: UILabel! + @IBOutlet private weak var typeLabel: UILabel! /// Configures the cell with `achievementInfo`. /// diff --git a/RespectU/Sources/Views/GuideFirstCell.swift b/RespectU/Sources/Views/GuideFirstCell.swift index 1f13772..6008fa0 100644 --- a/RespectU/Sources/Views/GuideFirstCell.swift +++ b/RespectU/Sources/Views/GuideFirstCell.swift @@ -45,7 +45,7 @@ final class GuideFirstCell: UITableViewCell { static let imageNames = ["song", "mission", "trophy", "achievement", "tip", "manual"] } - /// The object that acts as the delegate of the guide first cell. + /// The object that acts as the delegate of the `GuideFirstCell`. weak var delegate: GuideFirstCellDelegate? /// The background view. @@ -83,10 +83,12 @@ final class GuideFirstCell: UITableViewCell { /// Configures initial settings. private func configure() { - view.layer.cornerRadius = 15 - view.layer.borderWidth = 1 - view.layer.borderColor = UIColor.lightGray.cgColor - view.layer.masksToBounds = true + view.layer.do { + $0.cornerRadius = 15 + $0.borderWidth = 1 + $0.borderColor = UIColor.lightGray.cgColor + $0.masksToBounds = true + } let stackViews = [ songStackView, missionStackView, diff --git a/RespectU/Sources/Views/GuideSecondCell.swift b/RespectU/Sources/Views/GuideSecondCell.swift index 7750510..c89ab30 100644 --- a/RespectU/Sources/Views/GuideSecondCell.swift +++ b/RespectU/Sources/Views/GuideSecondCell.swift @@ -66,10 +66,12 @@ final class GuideSecondCell: UITableViewCell { /// Configures initial settings. private func configure() { - view.layer.cornerRadius = 15 - view.layer.borderWidth = 1 - view.layer.borderColor = UIColor.lightGray.cgColor - view.layer.masksToBounds = true + view.layer.do { + $0.cornerRadius = 15 + $0.borderWidth = 1 + $0.borderColor = UIColor.lightGray.cgColor + $0.masksToBounds = true + } let stackViews = [logInOutStackView, bpmSettingStackView, favoriteButtonStackView] stackViews.indices.forEach { index in let stackView = stackViews[index] diff --git a/RespectU/Sources/Views/RecordView.swift b/RespectU/Sources/Views/RecordView.swift index 040fcb7..546ca2b 100644 --- a/RespectU/Sources/Views/RecordView.swift +++ b/RespectU/Sources/Views/RecordView.swift @@ -46,6 +46,7 @@ final class RecordView: UIView { static let rating = "%05.2f%%" } + /// The object that acts as the delegate of the `RecordView`. weak var delegate: RecordViewDelegate? /// The title label. @@ -99,19 +100,30 @@ final class RecordView: UIView { /// The ranking label. @IBOutlet private weak var rankingLabel: UILabel! + /// The current button private var currentButton: Button { return Button(rawValue: (buttonButton.title(for: .normal) ?? "4b").lowercased()) ?? .button4 } override func awakeFromNib() { super.awakeFromNib() - layer.borderWidth = 1 - layer.cornerRadius = 15 - layer.borderColor = UIColor.lightGray.cgColor - cancelButton.setTitle(L10n.cancel, for: .normal) - cancelButton.addTarget(self, action: #selector(cancelButtonDidTap(_:)), for: .touchUpInside) + configure() } + /// Configures initial settings. + private func configure() { + layer.do { + $0.borderWidth = 1 + $0.cornerRadius = 15 + $0.borderColor = UIColor.lightGray.cgColor + } + cancelButton.do { + $0.setTitle(L10n.cancel, for: .normal) + $0.addTarget(self, action: #selector(cancelButtonDidTap(_:)), for: .touchUpInside) + } + } + + /// Tells the `sender` that the record button is tapped. @IBAction private func recordButtonDidTap(_ sender: UIButton) { switch sender.tag { case 0: @@ -164,10 +176,12 @@ final class RecordView: UIView { } } + /// Tells the `sender` that the type button is tapped. @IBAction private func typeButtonDidTap(_ sender: UIButton) { delegate?.recordView(self, didTapTypeButton: sender) } + /// Tells the `sender` that the cancel button is tapped. @IBAction private func cancelButtonDidTap(_ sender: UIButton) { delegate?.recordView(self, didTapCancelButton: sender) } diff --git a/RespectU/Sources/Views/SearchByLevelView.swift b/RespectU/Sources/Views/SearchByLevelView.swift index 675348c..7fce60d 100644 --- a/RespectU/Sources/Views/SearchByLevelView.swift +++ b/RespectU/Sources/Views/SearchByLevelView.swift @@ -8,12 +8,19 @@ import UIKit +/// The search by level view. final class SearchByLevelView: UIView { - @IBOutlet weak var pickerView: UIPickerView! + /// The picker view. + @IBOutlet private weak var pickerView: UIPickerView! override func awakeFromNib() { super.awakeFromNib() + configure() + } + + /// Configures initial settings. + private func configure() { pickerView.selectRow(0, inComponent: 0, animated: true) pickerView.layer.borderWidth = 1 pickerView.layer.borderColor = UIColor.main.cgColor diff --git a/RespectU/Sources/Views/SearchByNoteView.swift b/RespectU/Sources/Views/SearchByNoteView.swift index a47a1f6..d14b508 100644 --- a/RespectU/Sources/Views/SearchByNoteView.swift +++ b/RespectU/Sources/Views/SearchByNoteView.swift @@ -8,31 +8,40 @@ import UIKit +/// The `protocol` that defines delegate methods of the `SearchByNoteView`. protocol SearchByNoteViewDelegate: class { + /// Tells the delegate that the note button is tapped. func searchByNoteView(_ view: SearchByNoteView, didTapNoteButton button: UIButton) - - //func didTouchUpNoteButtons(_ sender: UIButton) } +/// The search by note view. final class SearchByNoteView: UIView { + /// The object that acts as the delegate of the `SearchByNoteView`. weak var delegate: SearchByNoteViewDelegate? - @IBOutlet weak var noMaxComboButton: UIButton! + /// The no max combo button. + @IBOutlet private weak var noMaxComboButton: UIButton! - @IBOutlet weak var perfectPlayButton: UIButton! + /// The perfect play button. + @IBOutlet private weak var perfectPlayButton: UIButton! override func awakeFromNib() { super.awakeFromNib() + configure() + } + + /// Configures initial settings. + private func configure() { noMaxComboButton.setTitle(L10n.noMAXCOMBOs, for: .normal) perfectPlayButton.setTitle(L10n.perfectplaYs, for: .normal) initializeButtons() } + /// Tells the `sender` that the buttons are tapped. @IBAction private func buttonsDidTap(_ sender: UIButton) { delegate?.searchByNoteView(self, didTapNoteButton: sender) - //delegate?.didTouchUpNoteButtons(sender) initializeButtons() noMaxComboButton.isSelected = false perfectPlayButton.isSelected = false @@ -42,6 +51,7 @@ final class SearchByNoteView: UIView { } } + /// Initializes buttons. private func initializeButtons() { UIView.animate(withDuration: 0.3) { [weak self] in self?.noMaxComboButton.backgroundColor = .white diff --git a/RespectU/Sources/Views/SearchByRatingView.swift b/RespectU/Sources/Views/SearchByRatingView.swift index ccd6eaa..29ab393 100644 --- a/RespectU/Sources/Views/SearchByRatingView.swift +++ b/RespectU/Sources/Views/SearchByRatingView.swift @@ -8,54 +8,69 @@ import UIKit +/// The `protocol` that defines delegate methods of the `SearchByRatingView`. protocol SearchByRatingViewDelegate: class { - func didTouchUpDoneButton(_ textFields: [UITextField]) + + /// Tells the delegate that the done button is tapped. + func searchByRatingView(_ view: SearchByRatingView, didTapDoneButton button: UIButton) } +/// The search by rating view. final class SearchByRatingView: UIView { + /// The object that acts as the delegate of the `SearchByRatingView`. weak var delegate: SearchByRatingViewDelegate? - @IBOutlet weak var lowerRateTextField: UITextField! + /// The text field that takes lower rating. + @IBOutlet private weak var lowerRatingTextField: UITextField! - @IBOutlet weak var upperRateTextField: UITextField! + /// The text field that takes upper rating. + @IBOutlet private weak var upperRatingTextField: UITextField! - lazy var textFields: [UITextField] = { - return [lowerRateTextField, upperRateTextField] - }() + /// The all text fields. + private var textFields: [UITextField] { + return [lowerRatingTextField, upperRatingTextField] + } override func awakeFromNib() { super.awakeFromNib() - lowerRateTextField.placeholder = "More Than".localized - upperRateTextField.placeholder = "Below".localized - for textField in textFields { - textField.layer.borderColor = UIColor.main.cgColor - textField.layer.borderWidth = 1 - textField.layer.cornerRadius = textField.bounds.height / 2 - textField.keyboardType = .decimalPad + configure() + } + + /// Configures initial settings. + private func configure() { + lowerRatingTextField.placeholder = L10n.moreThan + upperRatingTextField.placeholder = L10n.below + textFields.forEach { + $0.layer.borderColor = UIColor.main.cgColor + $0.layer.borderWidth = 1 + $0.layer.cornerRadius = $0.bounds.height / 2 + $0.keyboardType = .decimalPad } - setToolBar() + let toolBar = makeToolBar() + textFields.forEach { $0.inputAccessoryView = toolBar } } - @objc func didTouchUpDoneButton() { - delegate?.didTouchUpDoneButton(textFields) + /// Tells the `sender` that the done button is tapped. + @objc private func doneButtonDidTap(_ sender: UIButton) { + delegate?.searchByRatingView(self, didTapDoneButton: sender) } -} - -extension SearchByRatingView { - - private func setToolBar() { - let toolBar = UIToolbar() - toolBar.barStyle = .default - toolBar.isTranslucent = true - toolBar.tintColor = .main - let flexibleSpace = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: self, action: nil) - let doneButton = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(didTouchUpDoneButton)) - toolBar.setItems([flexibleSpace, doneButton], animated: false) - toolBar.isUserInteractionEnabled = true - toolBar.sizeToFit() - for textField in textFields { - textField.inputAccessoryView = toolBar + + /// Creates the tool bar. + /// + /// - Returns: The created tool bar. + private func makeToolBar() -> UIToolbar { + let flexibleSpace + = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil) + let doneButton = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(doneButtonDidTap(_:))) + let toolBar = UIToolbar().then { + $0.barStyle = .default + $0.isTranslucent = true + $0.tintColor = .main + $0.setItems([flexibleSpace, doneButton], animated: false) + $0.isUserInteractionEnabled = true + $0.sizeToFit() } + return toolBar } } diff --git a/RespectU/Sources/Views/SearchRecordDetailCell.swift b/RespectU/Sources/Views/SearchRecordDetailCell.swift index 4e49b5e..9773428 100644 --- a/RespectU/Sources/Views/SearchRecordDetailCell.swift +++ b/RespectU/Sources/Views/SearchRecordDetailCell.swift @@ -30,15 +30,18 @@ final class SearchRecordDetailCell: UITableViewCell { setup() } + /// Configures initial settings. private func setup() { colorLabel.layer.cornerRadius = colorLabel.bounds.width / 2 colorLabel.layer.masksToBounds = true } + /// Configures the cell with `searchRecordDetail`. func configure(with searchRecordDetail: SearchRecordDetail) { let series = Series(rawValue: searchRecordDetail.series) ?? .respect - let gradient = series.makeGradient(by: .vertical) ?? CAGradientLayer() - gradient.frame = colorLabel.bounds + let gradient = (series.makeGradient(by: .vertical) ?? CAGradientLayer()).then { + $0.frame = colorLabel.bounds + } colorLabel.layer.addSublayer(gradient) titleLabel.text = searchRecordDetail.title difficultyLabel.text = searchRecordDetail.difficulty.uppercased() diff --git a/RespectU/Sources/Views/SignInTextField.swift b/RespectU/Sources/Views/SignInTextField.swift index 93b31d8..382c206 100644 --- a/RespectU/Sources/Views/SignInTextField.swift +++ b/RespectU/Sources/Views/SignInTextField.swift @@ -8,8 +8,11 @@ import UIKit +/// The sign in text field. final class SignInTextField: UITextField { + // MARK: - Initializer + override init(frame: CGRect) { super.init(frame: frame) setup() @@ -20,12 +23,13 @@ final class SignInTextField: UITextField { setup() } + /// Configures initial settings. private func setup() { layer.cornerRadius = bounds.height / 2 layer.borderWidth = 1 layer.borderColor = UIColor.lightGray.cgColor layer.masksToBounds = true - leftView = UIView(frame: CGRect(x: 0, y: 0, width: 16, height: self.frame.height)) + leftView = UIView(frame: .init(x: 0, y: 0, width: 16, height: bounds.height)) leftViewMode = .always } } diff --git a/RespectU/Sources/Views/SkillLevelCell.swift b/RespectU/Sources/Views/SkillLevelCell.swift index e272a4c..47e18f8 100644 --- a/RespectU/Sources/Views/SkillLevelCell.swift +++ b/RespectU/Sources/Views/SkillLevelCell.swift @@ -11,40 +11,55 @@ import UIKit import GaugeKit import RealmSwift +/// The `protocol` that defines delegate methods of the `SkillLevelCell`. protocol SkillLevelCellDelegate: class { + /// Tells the delegate that the top50 button is tapped. func skillLevelCell(_ cell: SkillLevelCell, didTapTop50Button button: UIButton) + /// Tells the delegate that the more button is tapped. func skillLevelCell(_ cell: SkillLevelCell, didTapMoreButton button: UIButton) } +/// The skill level table view cell. final class SkillLevelCell: UITableViewCell { + /// The object that acts as the delegate of the `SkillLevelCell`. weak var delegate: SkillLevelCellDelegate? + /// The background view. @IBOutlet private weak var view: UIView! + /// The gauge view. @IBOutlet private var gauge: Gauge! + /// The title label. @IBOutlet private weak var titleLabel: UILabel! + /// The skill level label. @IBOutlet private weak var skillLevelLabel: UILabel! + /// The skill point label. @IBOutlet private weak var skillPointLabel: UILabel! - @IBOutlet private weak var top50Button: UIButton! - - @IBOutlet private weak var moreButton: UIButton! - + /// The percent label. @IBOutlet private weak var percentLabel: UILabel! + /// The next level label. @IBOutlet private weak var nextLevelLabel: UILabel! + /// The top50 button. + @IBOutlet private weak var top50Button: UIButton! + + /// The more button. + @IBOutlet private weak var moreButton: UIButton! + override func awakeFromNib() { super.awakeFromNib() setup() } + /// Configures initial settings. private func setup() { titleLabel.text = L10n.myRecord view.layer.cornerRadius = 15 @@ -56,6 +71,13 @@ final class SkillLevelCell: UITableViewCell { moreButton.addTarget(self, action: #selector(moreButtonDidTap(_:)), for: .touchUpInside) } + /// Configures the cell in `button` with `max` and `record`. + /// + /// - Parameters: + /// - button: The specific button. + /// - max: The maximum skill point. + /// - record: The tuple with the total skill point + /// and the highest series of the total skill point. func configure(inButton button: Button, max: Double, record: (Double, Series?)) { let totalSkillPoint = record.0 let highestSeries = record.1 @@ -81,11 +103,13 @@ final class SkillLevelCell: UITableViewCell { nextLevelLabel.text = Utils.nextSkillLevel(of: skillLevelEnum, in: button)?.rawValue percentLabel.text = String(format: "%05.2f%%", totalSkillPoint * 100 / max) } - + + /// Tells the `sender` that the top50 button is tapped. @objc private func top50ButtonDidTap(_ sender: UIButton) { delegate?.skillLevelCell(self, didTapTop50Button: sender) } + /// Tells the `sender` that the more button is tapped. @objc private func moreButtonDidTap(_ sender: UIButton) { delegate?.skillLevelCell(self, didTapMoreButton: sender) } diff --git a/RespectU/Sources/Views/SkillLevelDetailView.swift b/RespectU/Sources/Views/SkillLevelDetailView.swift index 0ea59fd..826abe1 100644 --- a/RespectU/Sources/Views/SkillLevelDetailView.swift +++ b/RespectU/Sources/Views/SkillLevelDetailView.swift @@ -13,8 +13,6 @@ import GaugeKit /// The skill level detail view. final class SkillLevelDetailView: UIView { - // MARK: Property - /// The button label. @IBOutlet private weak var buttonLabel: UILabel! @@ -40,12 +38,16 @@ final class SkillLevelDetailView: UIView { setup() } + /// Configures initial settings. private func setup() { layer.borderColor = UIColor.lightGray.cgColor layer.borderWidth = 1 layer.cornerRadius = 15 } + /// Configures the view with `button`. + /// + /// - Parameter button: The specific button. func configure(with button: Button) { let recordRate = Utils.recordRate(in: button) let maxSkillPoint = Utils.maxSkillPoint(in: button) diff --git a/RespectU/Sources/Views/SongCell.swift b/RespectU/Sources/Views/SongCell.swift index a5e9f37..6c8389f 100644 --- a/RespectU/Sources/Views/SongCell.swift +++ b/RespectU/Sources/Views/SongCell.swift @@ -34,6 +34,7 @@ final class SongCell: UITableViewCell { /// The maximum difficulty label. @IBOutlet private weak var maximumLabel: UILabel! + /// The all labels. private var allLabel: [UILabel] { return [ titleLabel, diff --git a/RespectU/Sources/Views/SummaryCell.swift b/RespectU/Sources/Views/SummaryCell.swift index b4d46ca..3135a4b 100644 --- a/RespectU/Sources/Views/SummaryCell.swift +++ b/RespectU/Sources/Views/SummaryCell.swift @@ -10,16 +10,20 @@ import UIKit import RealmSwift +/// The `protocol` that defines delegate methods of the `SummaryCell`. protocol SummaryCellDelegate: class { + /// Tells the delegate that the search button is tapped. func summaryCell(_ cell: SummaryCell, didTapSearchButton button: UIButton) + /// Tells the delegate that the detail button is tapped. func summaryCell(_ cell: SummaryCell, didTapDetailButton button: UIButton) } /// The summary table view cell. final class SummaryCell: UITableViewCell { + /// The object that acts as the delegate of the `SummaryCell`. weak var delegate: SummaryCellDelegate? /// The title label. @@ -55,10 +59,12 @@ final class SummaryCell: UITableViewCell { searchButton.addTarget(self, action: #selector(searchButtonDidTap(_:)), for: .touchUpInside) } + /// Tells the `sender` that the search button is tapped. @objc private func searchButtonDidTap(_ sender: UIButton) { delegate?.summaryCell(self, didTapSearchButton: sender) } + /// Tells the `sender` that the detail button is tapped. @objc private func detailButtonDidTap(_ sender: UIButton) { delegate?.summaryCell(self, didTapDetailButton: sender) } diff --git a/RespectU/Sources/Views/SummaryCollectionCell.swift b/RespectU/Sources/Views/SummaryCollectionCell.swift index d919b29..41d214f 100644 --- a/RespectU/Sources/Views/SummaryCollectionCell.swift +++ b/RespectU/Sources/Views/SummaryCollectionCell.swift @@ -10,35 +10,60 @@ import UIKit import RealmSwift +/// The summary collection cell. final class SummaryCollectionCell: UICollectionViewCell { - @IBOutlet weak var contentLabel: UILabel! + /// The content label. + @IBOutlet private weak var contentLabel: UILabel! - @IBOutlet weak var valueLabel: UILabel! + /// The value label. + @IBOutlet private weak var valueLabel: UILabel! - let contents = [Rank.s, Rank.a, Rank.b, Rank.c, Note.maxCombo, Note.perfectPlay, "\(Note.maxCombo)+\(Note.perfectPlay)"] + /// The content titles. + private let contentTitles = [ + Rank.s.rawValue, + Rank.a.rawValue, + Rank.b.rawValue, + Rank.c.rawValue, + Note.maxCombo.rawValue, + Note.perfectPlay.rawValue, + "\(Note.maxCombo.rawValue)+\(Note.perfectPlay.rawValue)" + ] override func awakeFromNib() { super.awakeFromNib() + setup() + } + + /// Configures initial settings. + private func setup() { layer.borderColor = UIColor.main.cgColor layer.borderWidth = 1 layer.cornerRadius = 15 } - func setProperties(_ results: Results, at item: Int) { - let buttons = ["button4", "button5", "button6", "button8"] - let difficulties = ["normal", "hard", "maximum"] + /// Configures the `item`th cell with `records`. + /// + /// - Parameters: + /// - records: The results of record. + /// - item: The index of the cell. + func configure(with records: Results, at item: Int) { + let buttons = Button.all.map { $0.expansion }.compactMap { $0 } + let difficulties = Difficulty.all.map { $0.rawValue }.compactMap { $0 } var count: Int = 0 - self.contentLabel.text = self.contents[item] + contentLabel.text = contentTitles[item] switch item { case 0, 1, 2, 3: - self.valueLabel.text = { - for result in results { + valueLabel.text = { + for result in records { for button in buttons { - guard let buttonResult = result.value(forKey: button) as? RecordButtonInfo else { return nil } + guard let buttonResult = result.value(forKey: button) as? RecordButtonInfo + else { return nil } for difficulty in difficulties { - guard let difficultyResult = buttonResult.value(forKey: difficulty) as? RecordDifficultyInfo else { return nil } - if difficultyResult.rank == self.contents[item] { + guard let difficultyResult + = buttonResult.value(forKey: difficulty) as? RecordDifficultyInfo + else { return nil } + if difficultyResult.rank == contentTitles[item] { count += 1 } } @@ -47,13 +72,16 @@ final class SummaryCollectionCell: UICollectionViewCell { return "\(count)" }() case 4, 5: - self.valueLabel.text = { - for result in results { + valueLabel.text = { + for result in records { for button in buttons { - guard let buttonResult = result.value(forKey: button) as? RecordButtonInfo else { return nil } + guard let buttonResult = result.value(forKey: button) as? RecordButtonInfo + else { return nil } for difficulty in difficulties { - guard let difficultyResult = buttonResult.value(forKey: difficulty) as? RecordDifficultyInfo else { return nil } - if difficultyResult.note == self.contents[item] { + guard let difficultyResult + = buttonResult.value(forKey: difficulty) as? RecordDifficultyInfo + else { return nil } + if difficultyResult.note == contentTitles[item] { count += 1 } } @@ -62,13 +90,17 @@ final class SummaryCollectionCell: UICollectionViewCell { return "\(count)" }() case 6: - self.valueLabel.text = { - for result in results { + valueLabel.text = { + for result in records { for button in buttons { - guard let buttonResult = result.value(forKey: button) as? RecordButtonInfo else { return nil } + guard let buttonResult = result.value(forKey: button) as? RecordButtonInfo + else { return nil } for difficulty in difficulties { - guard let difficultyResult = buttonResult.value(forKey: difficulty) as? RecordDifficultyInfo else { return nil } - if difficultyResult.note == self.contents[4] || difficultyResult.note == self.contents[5] { + guard let difficultyResult + = buttonResult.value(forKey: difficulty) as? RecordDifficultyInfo + else { return nil } + if difficultyResult.note == contentTitles[4] + || difficultyResult.note == contentTitles[5] { count += 1 } } diff --git a/RespectU/Sources/Views/AchievementCell.xib b/RespectU/Sources/Views/XIBs/AchievementCell.xib similarity index 100% rename from RespectU/Sources/Views/AchievementCell.xib rename to RespectU/Sources/Views/XIBs/AchievementCell.xib diff --git a/RespectU/Sources/Views/GuideFirstCell.xib b/RespectU/Sources/Views/XIBs/GuideFirstCell.xib similarity index 100% rename from RespectU/Sources/Views/GuideFirstCell.xib rename to RespectU/Sources/Views/XIBs/GuideFirstCell.xib diff --git a/RespectU/Sources/Views/GuideSecondCell.xib b/RespectU/Sources/Views/XIBs/GuideSecondCell.xib similarity index 100% rename from RespectU/Sources/Views/GuideSecondCell.xib rename to RespectU/Sources/Views/XIBs/GuideSecondCell.xib diff --git a/RespectU/Sources/Views/GuideThirdCell.xib b/RespectU/Sources/Views/XIBs/GuideThirdCell.xib similarity index 100% rename from RespectU/Sources/Views/GuideThirdCell.xib rename to RespectU/Sources/Views/XIBs/GuideThirdCell.xib diff --git a/RespectU/Sources/Views/MissionCell.xib b/RespectU/Sources/Views/XIBs/MissionCell.xib similarity index 100% rename from RespectU/Sources/Views/MissionCell.xib rename to RespectU/Sources/Views/XIBs/MissionCell.xib diff --git a/RespectU/Sources/Views/RankingCell.xib b/RespectU/Sources/Views/XIBs/RankingCell.xib similarity index 100% rename from RespectU/Sources/Views/RankingCell.xib rename to RespectU/Sources/Views/XIBs/RankingCell.xib diff --git a/RespectU/Sources/Views/RecordCell.xib b/RespectU/Sources/Views/XIBs/RecordCell.xib similarity index 100% rename from RespectU/Sources/Views/RecordCell.xib rename to RespectU/Sources/Views/XIBs/RecordCell.xib diff --git a/RespectU/Sources/Views/RecordView.xib b/RespectU/Sources/Views/XIBs/RecordView.xib similarity index 100% rename from RespectU/Sources/Views/RecordView.xib rename to RespectU/Sources/Views/XIBs/RecordView.xib diff --git a/RespectU/Sources/Views/SearchByLevelView.xib b/RespectU/Sources/Views/XIBs/SearchByLevelView.xib similarity index 100% rename from RespectU/Sources/Views/SearchByLevelView.xib rename to RespectU/Sources/Views/XIBs/SearchByLevelView.xib diff --git a/RespectU/Sources/Views/SearchByNoteView.xib b/RespectU/Sources/Views/XIBs/SearchByNoteView.xib similarity index 100% rename from RespectU/Sources/Views/SearchByNoteView.xib rename to RespectU/Sources/Views/XIBs/SearchByNoteView.xib diff --git a/RespectU/Sources/Views/SearchByRatingView.xib b/RespectU/Sources/Views/XIBs/SearchByRatingView.xib similarity index 96% rename from RespectU/Sources/Views/SearchByRatingView.xib rename to RespectU/Sources/Views/XIBs/SearchByRatingView.xib index f178ee9..6514e9c 100644 --- a/RespectU/Sources/Views/SearchByRatingView.xib +++ b/RespectU/Sources/Views/XIBs/SearchByRatingView.xib @@ -55,8 +55,8 @@ - - + + diff --git a/RespectU/Sources/Views/SearchRecordDetailCell.xib b/RespectU/Sources/Views/XIBs/SearchRecordDetailCell.xib similarity index 100% rename from RespectU/Sources/Views/SearchRecordDetailCell.xib rename to RespectU/Sources/Views/XIBs/SearchRecordDetailCell.xib diff --git a/RespectU/Sources/Views/SkillLevelCell.xib b/RespectU/Sources/Views/XIBs/SkillLevelCell.xib similarity index 100% rename from RespectU/Sources/Views/SkillLevelCell.xib rename to RespectU/Sources/Views/XIBs/SkillLevelCell.xib diff --git a/RespectU/Sources/Views/SkillLevelDetailView.xib b/RespectU/Sources/Views/XIBs/SkillLevelDetailView.xib similarity index 100% rename from RespectU/Sources/Views/SkillLevelDetailView.xib rename to RespectU/Sources/Views/XIBs/SkillLevelDetailView.xib diff --git a/RespectU/Sources/Views/SongCell.xib b/RespectU/Sources/Views/XIBs/SongCell.xib similarity index 100% rename from RespectU/Sources/Views/SongCell.xib rename to RespectU/Sources/Views/XIBs/SongCell.xib diff --git a/RespectU/Sources/Views/SummaryCell.xib b/RespectU/Sources/Views/XIBs/SummaryCell.xib similarity index 100% rename from RespectU/Sources/Views/SummaryCell.xib rename to RespectU/Sources/Views/XIBs/SummaryCell.xib diff --git a/RespectU/Sources/Views/SummaryCollectionCell.xib b/RespectU/Sources/Views/XIBs/SummaryCollectionCell.xib similarity index 100% rename from RespectU/Sources/Views/SummaryCollectionCell.xib rename to RespectU/Sources/Views/XIBs/SummaryCollectionCell.xib diff --git a/RespectU/Sources/Views/Top50Cell.xib b/RespectU/Sources/Views/XIBs/Top50Cell.xib similarity index 100% rename from RespectU/Sources/Views/Top50Cell.xib rename to RespectU/Sources/Views/XIBs/Top50Cell.xib diff --git a/RespectU/Sources/Views/TrophyCell.xib b/RespectU/Sources/Views/XIBs/TrophyCell.xib similarity index 100% rename from RespectU/Sources/Views/TrophyCell.xib rename to RespectU/Sources/Views/XIBs/TrophyCell.xib