Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New settings #623

Merged
merged 34 commits into from
Jan 18, 2020
Merged
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5d22218
Gen module
ivan-magda Jan 12, 2020
45e0513
Add table view style option
ivan-magda Jan 12, 2020
6d2df8f
Set profile edit table view style to insetGrouped
ivan-magda Jan 12, 2020
c2c0857
Tmp for right detail setting cell
ivan-magda Jan 12, 2020
4785bbc
Better header height
ivan-magda Jan 12, 2020
34ffbdb
Better layout
ivan-magda Jan 12, 2020
9a24f43
Revert isModalInPresentation for profile edit
ivan-magda Jan 12, 2020
b75e3d2
Fix constraints
ivan-magda Jan 13, 2020
3d48529
Add localizable
ivan-magda Jan 13, 2020
86b9f4e
Add select item view controller
ivan-magda Jan 13, 2020
226343b
Tmp for handling selection
ivan-magda Jan 13, 2020
c6d9bc2
Replace VideosInfo with storage managers
ivan-magda Jan 13, 2020
19bc610
Update checkmark on cell selected
ivan-magda Jan 13, 2020
0f30510
Fix video qualities parsing
ivan-magda Jan 13, 2020
fca255f
Provide actual data
ivan-magda Jan 13, 2020
53c7fe4
Modal presentation style
ivan-magda Jan 13, 2020
4e921ef
Fix constraints when no accessory item
ivan-magda Jan 13, 2020
12a3d99
Add ability to set default navigation bar appearance
ivan-magda Jan 14, 2020
6968da3
Setup navigation appearance
ivan-magda Jan 14, 2020
25c432b
Display detail lists
ivan-magda Jan 16, 2020
45fe8f8
Delete all content
ivan-magda Jan 16, 2020
d8bde75
Log out
ivan-magda Jan 16, 2020
4e40e14
Handle switch value changed
ivan-magda Jan 16, 2020
1704d3b
Adaptive layout for right detail cell
ivan-magda Jan 16, 2020
2458d85
Update code editor cell setting title
ivan-magda Jan 16, 2020
9554617
Add text color in naviagtion bar appearance
ivan-magda Jan 16, 2020
a4a2e7d
Clean up
ivan-magda Jan 16, 2020
e439e24
Remove go to catalog
ivan-magda Jan 16, 2020
2bf56a8
Delete legacy implementation
ivan-magda Jan 17, 2020
be7eebe
Refactor rename NewSettings -> Settings
ivan-magda Jan 17, 2020
c8c7bc7
Merge remote-tracking branch 'origin/dev' into feature/new-settings
ivan-magda Jan 17, 2020
1e5cf00
Add about app controller
ivan-magda Jan 17, 2020
91b6ac0
Add app version
ivan-magda Jan 18, 2020
5046c31
Clean up
ivan-magda Jan 18, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add app version
ivan-magda committed Jan 18, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 91b6ac0da6fa115420b6a1690ad7240c4495014e
4 changes: 4 additions & 0 deletions Stepic.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -454,6 +454,7 @@
2C3ABA8923D1DA8D00E90439 /* AboutAppViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C3ABA8823D1DA8D00E90439 /* AboutAppViewController.swift */; };
2C3ABA8B23D1F1F600E90439 /* StepikSocialNetworksView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C3ABA8A23D1F1F600E90439 /* StepikSocialNetworksView.swift */; };
2C3ABA8D23D1FE1D00E90439 /* StepikSocialNetwork.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C3ABA8C23D1FE1D00E90439 /* StepikSocialNetwork.swift */; };
2C3ABA9123D229C200E90439 /* Bundle+Version.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C3ABA9023D229C200E90439 /* Bundle+Version.swift */; };
2C3DAB8D233D71B100453B1C /* StepFontSizeStorageManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C3DAB8C233D71B100453B1C /* StepFontSizeStorageManager.swift */; };
2C3DAB91233D735E00453B1C /* StepFontSize.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C3DAB90233D735D00453B1C /* StepFontSize.swift */; };
2C4436B321356D960084489C /* CourseSubscriber.swift in Sources */ = {isa = PBXBuildFile; fileRef = 088FD8161FB242B3008A2953 /* CourseSubscriber.swift */; };
@@ -1589,6 +1590,7 @@
2C3ABA8823D1DA8D00E90439 /* AboutAppViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutAppViewController.swift; sourceTree = "<group>"; };
2C3ABA8A23D1F1F600E90439 /* StepikSocialNetworksView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StepikSocialNetworksView.swift; sourceTree = "<group>"; };
2C3ABA8C23D1FE1D00E90439 /* StepikSocialNetwork.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StepikSocialNetwork.swift; sourceTree = "<group>"; };
2C3ABA9023D229C200E90439 /* Bundle+Version.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Bundle+Version.swift"; sourceTree = "<group>"; };
2C3DAB8C233D71B100453B1C /* StepFontSizeStorageManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StepFontSizeStorageManager.swift; sourceTree = "<group>"; };
2C3DAB90233D735D00453B1C /* StepFontSize.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StepFontSize.swift; sourceTree = "<group>"; };
2C453397204D46E90061342A /* PinsMap.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PinsMap.swift; sourceTree = "<group>"; };
@@ -3525,6 +3527,7 @@
2C096584236C56AE005B771A /* Foundation */ = {
isa = PBXGroup;
children = (
2C3ABA9023D229C200E90439 /* Bundle+Version.swift */,
2C096582236C555D005B771A /* NSAttributedString+TrimmingCharacters.swift */,
);
path = Foundation;
@@ -6811,6 +6814,7 @@
62E98DE7FA0EE5EB23136B52 /* AchievementsListPresenter.swift in Sources */,
2C3ABA8923D1DA8D00E90439 /* AboutAppViewController.swift in Sources */,
62E98B8919D18CD0F8238F97 /* Collection+SafeSubscript.swift in Sources */,
2C3ABA9123D229C200E90439 /* Bundle+Version.swift in Sources */,
62E987CB113F6D20B108D070 /* AchievementPopupAlertManager.swift in Sources */,
08484F0A211AF4320006266F /* Story.swift in Sources */,
2CD87014230DF663003D9F1A /* NewMatchingQuizTitleView.swift in Sources */,
36 changes: 35 additions & 1 deletion Stepic/Sources/Controllers/AboutAppViewController.swift
Original file line number Diff line number Diff line change
@@ -25,6 +25,20 @@ final class AboutAppViewController: UIViewController {
return view
}()

private lazy var appVersionLabel: UILabel = {
let label = UILabel()
label.textColor = Appearance.appVersionLabelTextColor
label.font = Appearance.appVersionLabelFont
label.textAlignment = Appearance.appVersionLabelTextAlignment
label.text = FormatterHelper.prettyVersion(
versionNumber: Bundle.main.versionNumber,
buildNumber: Bundle.main.buildNumber
)
return label
}()

private lazy var appVersionContainerView = UIView()

override func viewDidLoad() {
super.viewDidLoad()
self.setup()
@@ -42,6 +56,13 @@ final class AboutAppViewController: UIViewController {
Cell.allCases.forEach {
self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: $0.uniqueIdentifier)
}

self.appVersionContainerView.addSubview(self.appVersionLabel)
self.appVersionLabel.translatesAutoresizingMaskIntoConstraints = false
self.appVersionLabel.snp.makeConstraints { make in
make.top.equalToSuperview().offset(Appearance.appVersionLabelInsets.top)
make.centerX.equalToSuperview()
}
}

private func openURLInWeb(_ urlOrNil: URL?) {
@@ -52,6 +73,13 @@ final class AboutAppViewController: UIViewController {

// MARK: Inner Types

private enum Appearance {
static var appVersionLabelTextColor = UIColor.mainDark
static var appVersionLabelFont = UIFont.systemFont(ofSize: 14)
static var appVersionLabelTextAlignment = NSTextAlignment.center
static var appVersionLabelInsets = UIEdgeInsets(top: 24, left: 16, bottom: 0, right: 16)
}

private enum Cell: String, CaseIterable, UniqueIdentifiable {
case termsOfService
case privacyPolicy
@@ -106,7 +134,13 @@ extension AboutAppViewController: UITableViewDataSource {
}

extension AboutAppViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { self.socialNetworksView }
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
self.socialNetworksView
}

func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
self.appVersionContainerView
}

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
11 changes: 11 additions & 0 deletions Stepic/Sources/Extensions/Foundation/Bundle+Version.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Foundation

extension Bundle {
var versionNumber: String? {
self.infoDictionary?["CFBundleShortVersionString"] as? String
}

var buildNumber: String? {
self.infoDictionary?["CFBundleVersion"] as? String
}
}
13 changes: 13 additions & 0 deletions Stepic/Sources/Helpers/FormatterHelper.swift
Original file line number Diff line number Diff line change
@@ -169,4 +169,17 @@ enum FormatterHelper {
return "\(NSLocalizedString("SettingStreamVideoQualityVeryHigh", comment: "")) \(suffix)"
}
}

static func prettyVersion(versionNumber: String?, buildNumber: String?) -> String {
guard let version = versionNumber else {
return NSLocalizedString("AppVersionUnknownTitle", comment: "")
}

let build = buildNumber ?? "0"

return String(
format: NSLocalizedString("AppVersionTitle", comment: ""),
arguments: [version, build]
)
}
}
43 changes: 24 additions & 19 deletions Stepic/Sources/Views/StepikSocialNetworksView.swift
Original file line number Diff line number Diff line change
@@ -4,22 +4,25 @@ import UIKit
extension StepikSocialNetworksView {
struct Appearance {
let backgroundColor = UIColor.clear
let insets = UIEdgeInsets(top: 16, left: 16, bottom: 16, right: 16)

let titleTextColor = UIColor.mainDark
let titleFont = UIFont.systemFont(ofSize: 14)
let titleInsets = UIEdgeInsets(top: 16, left: 0, bottom: 0, right: 0)
let titleInsets = UIEdgeInsets(top: 24, left: 0, bottom: 0, right: 0)

let stackViewHeight: CGFloat = 44
let stackViewInsets = UIEdgeInsets(top: 8, left: 16, bottom: 16, right: 16)
let stackViewSpacing: CGFloat = 32
let stackViewInsets = UIEdgeInsets(top: 16, left: 16, bottom: 24, right: 16)
let stackViewSpacing: CGFloat = 16

let socialNetworkButtonBackgroundColor = UIColor.white
let socialNetworkButtonCornerRadius: CGFloat = 6
let socialNetworkButtonSize = CGSize(width: 44, height: 44)
}
}

final class StepikSocialNetworksView: UIView {
let appearance: Appearance

private static let socialNetworkByID: [StepikSocialNetwork: Int] = {
private static let idBySocialNetwork: [StepikSocialNetwork: Int] = {
.init(uniqueKeysWithValues: StepikSocialNetwork.allCases.enumerated().map { ($1, $0) })
}()

@@ -35,13 +38,11 @@ final class StepikSocialNetworksView: UIView {
let stackView = UIStackView()
stackView.axis = .horizontal
stackView.alignment = .fill
stackView.distribution = .fillEqually
stackView.distribution = .fill
stackView.spacing = self.appearance.stackViewSpacing
return stackView
}()

private lazy var contentView = UIView()

var onSocialNetworkClick: ((StepikSocialNetwork) -> Void)?

init(
@@ -65,18 +66,25 @@ final class StepikSocialNetworksView: UIView {
let button = UIButton(type: .custom)
button.setImage(socialNetwork.icon, for: .normal)
button.imageView?.contentMode = .scaleAspectFit
button.backgroundColor = self.appearance.socialNetworkButtonBackgroundColor
button.layer.cornerRadius = self.appearance.socialNetworkButtonCornerRadius
button.addTarget(self, action: #selector(self.socialNetworkClicked(sender:)), for: .touchUpInside)

if let id = Self.socialNetworkByID[socialNetwork] {
if let id = Self.idBySocialNetwork[socialNetwork] {
button.tag = id
}

button.translatesAutoresizingMaskIntoConstraints = false
button.snp.makeConstraints { make in
make.size.equalTo(self.appearance.socialNetworkButtonSize)
}

return button
}

@objc
private func socialNetworkClicked(sender: UIButton) {
if let clickedSocialNetwork = Self.socialNetworkByID.first(where: { $1 == sender.tag })?.key {
if let clickedSocialNetwork = Self.idBySocialNetwork.first(where: { $1 == sender.tag })?.key {
self.onSocialNetworkClick?(clickedSocialNetwork)
}
}
@@ -88,18 +96,12 @@ extension StepikSocialNetworksView: ProgrammaticallyInitializableViewProtocol {
}

func addSubviews() {
self.addSubview(self.contentView)
self.contentView.addSubview(self.titleLabel)
self.contentView.addSubview(self.stackView)
self.addSubview(self.titleLabel)
self.addSubview(self.stackView)
StepikSocialNetwork.allCases.forEach { self.stackView.addArrangedSubview(self.makeSocialNetworkView(for: $0)) }
}

func makeConstraints() {
self.contentView.translatesAutoresizingMaskIntoConstraints = false
self.contentView.snp.makeConstraints { make in
make.edges.equalToSuperview().inset(self.appearance.insets)
}

self.titleLabel.translatesAutoresizingMaskIntoConstraints = false
self.titleLabel.snp.makeConstraints { make in
make.centerX.equalToSuperview()
@@ -108,9 +110,12 @@ extension StepikSocialNetworksView: ProgrammaticallyInitializableViewProtocol {

self.stackView.translatesAutoresizingMaskIntoConstraints = false
self.stackView.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.height.equalTo(self.appearance.stackViewHeight)
make.top.equalTo(self.titleLabel.snp.bottom).offset(self.appearance.stackViewInsets.top)
make.leading.bottom.trailing.equalToSuperview().inset(self.appearance.stackViewInsets)
make.leading.greaterThanOrEqualToSuperview().offset(self.appearance.stackViewInsets.left)
make.bottom.equalToSuperview().offset(-self.appearance.stackViewInsets.bottom)
make.trailing.lessThanOrEqualToSuperview().offset(-self.appearance.stackViewInsets.right)
}
}
}
3 changes: 3 additions & 0 deletions Stepic/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -606,6 +606,9 @@ LogOutConfirmationAlertTitle = "Log Out";
LogOutConfirmationAlertMessage = "Are you sure you want to log out?";
LogOutConfirmationAlertActionDestructiveTitle = "Log Out";

AppVersionTitle = "Version %@ (%@)";
AppVersionUnknownTitle = "The app version is unknown";

AboutAppTitle = "About";
TermsOfServiceTitle = "Terms of Service";
PrivacyPolicyTitle = "Privacy Policy";
3 changes: 3 additions & 0 deletions Stepic/ru.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -607,6 +607,9 @@ LogOutConfirmationAlertTitle = "Выйти";
LogOutConfirmationAlertMessage = "Вы уверены, что хотите выйти?";
LogOutConfirmationAlertActionDestructiveTitle = "Выйти";

AppVersionTitle = "Версия %@ (%@)";
AppVersionUnknownTitle = "Версия приложения неизвестна";

AboutAppTitle = "О приложении";
TermsOfServiceTitle = "Условия использования";
PrivacyPolicyTitle = "Условия конфиденциальности";