Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions waosSwift/config/default/development.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
"margin": 15,
},
"navigationBar": {
"transparent": "false",
"shadow": "false",
},
"tableView": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"auth_firstname"= "Firstname";
"auth_lastname"= "Lastname";
"auth_forgot"= "Forgot password?";
"auth_reset"= "Reset";
"auth_reset"= "Reset password";

// task
"tasks_title"= "Tasks";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"auth_firstname"= "Prénom";
"auth_lastname"= "Nom";
"auth_forgot"= "Mot de passe oublié?";
"auth_reset"= "Reset";
"auth_reset"= "Reset du mot de passe";

// task
"tasks_title"= "Tasks";
Expand Down
57 changes: 17 additions & 40 deletions waosSwift/modules/auth/controllers/AuthForgotController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ final class AuthForgotController: CoreController, View, Stepper {
var width: CGFloat = 0

// MARK: UI

let barButtonClose = UIBarButtonItem(barButtonSystemItem: .close, target: nil, action: nil)

let inputEmail = CoreUITextField().then {
$0.autocorrectionType = .no
Expand All @@ -31,9 +33,6 @@ final class AuthForgotController: CoreController, View, Stepper {
$0.setTitle(L10n.authReset, for: .normal)
$0.setTitleColor(Metric.secondary, for: .normal)
}
let buttonSignin = CoreUIButton().then {
$0.setTitle(L10n.authSignInTitle, for: .normal)
}
let labelErrors = CoreUILabel().then {
$0.numberOfLines = 4
$0.textAlignment = .center
Expand All @@ -48,13 +47,9 @@ final class AuthForgotController: CoreController, View, Stepper {
// background
let backgroundImage = UIImageView().then {
$0.contentMode = .scaleToFill
$0.alpha = 1
$0.image = UIImage(named: "authBackground")
$0.alpha = 0.4
}
let backgroundView = UIView().then {
$0.backgroundColor = .clear
}

// MARK: Properties

Expand All @@ -75,19 +70,21 @@ final class AuthForgotController: CoreController, View, Stepper {

override func viewDidLoad() {
super.viewDidLoad()
// navigation
self.navigationController?.navigationBar.standardAppearance = self.transparentNavigationBar
self.navigationController?.navigationBar.scrollEdgeAppearance = self.transparentNavigationBar
// background
self.view.addSubview(self.backgroundImage)
self.view.addSubview(self.backgroundView)
// content
self.view.registerAutomaticKeyboardConstraints() // active layout with snapkit
self.view.addSubview(self.inputEmail)
self.view.addSubview(self.buttonReset)
self.view.addSubview(self.buttonSignin)
self.view.addSubview(self.labelErrors)
self.view.addSubview(self.labelSuccess)
// config
self.view.backgroundColor = Metric.primary
self.navigationController?.clear()
self.view.backgroundColor = Metric.primary
self.navigationItem.rightBarButtonItem = self.barButtonClose
}

override func setupConstraints() {
Expand All @@ -111,19 +108,11 @@ final class AuthForgotController: CoreController, View, Stepper {
inputEmail.snp.prepareConstraints { (make) -> Void in
make.centerY.equalTo(self.view).offset(-130).keyboard(true, in: self.view)
}
buttonSignin.snp.makeConstraints { (make) -> Void in
make.width.equalTo(140)
make.height.equalTo(50)
make.centerX.equalTo(self.view).offset(-80)
make.centerY.equalTo(self.view).offset(30).keyboard(false, in: self.view)
}
buttonSignin.snp.prepareConstraints { (make) -> Void in
make.centerY.equalTo(self.view).offset(-70).keyboard(true, in: self.view)
}
buttonReset.snp.makeConstraints { (make) -> Void in
make.width.equalTo(140)
make.width.equalTo(300)

make.height.equalTo(50)
make.centerX.equalTo(self.view).offset(80)
make.centerX.equalTo(self.view)
make.centerY.equalTo(self.view).offset(30).keyboard(false, in: self.view)
}
buttonReset.snp.prepareConstraints { (make) -> Void in
Expand All @@ -139,11 +128,6 @@ final class AuthForgotController: CoreController, View, Stepper {
make.centerY.equalTo(self.view).offset(20).keyboard(true, in: self.view)
}
// background
self.backgroundView.snp.makeConstraints { make in
make.bottom.equalTo(self.view)
make.width.equalTo(self.view)
make.height.equalTo(self.view.snp.width)
}
self.backgroundImage.snp.makeConstraints { make in
make.top.equalTo(self.view)
make.centerX.equalTo(self.view)
Expand All @@ -169,6 +153,13 @@ private extension AuthForgotController {
// MARK: views (View -> View)

func bindView(_ reactor: AuthForgotReactor) {
// cancel
self.barButtonClose.rx.tap
.subscribe(onNext: { [weak self] _ in
guard let `self` = self else { return }
self.dismiss(animated: true, completion: nil)
})
.disposed(by: self.disposeBag)
// error
self.error.button?.rx.tap
.subscribe(onNext: { _ in
Expand All @@ -193,11 +184,6 @@ private extension AuthForgotController {
.map { _ in Reactor.Action.reset }
.bind(to: reactor.action)
.disposed(by: self.disposeBag)
// button signin
buttonSignin.rx.tap
.map { _ in Reactor.Action.signIn }
.bind(to: reactor.action)
.disposed(by: self.disposeBag)
// form
Observable.combineLatest([self.inputEmail].map { $0.rx.text.orEmpty })
.map { $0.map { $0.isEmpty } }
Expand Down Expand Up @@ -246,15 +232,6 @@ private extension AuthForgotController {
self.labelSuccess.text = success
})
.disposed(by: self.disposeBag)
reactor.state
.map { $0.success }
.filter { $0 != "" && $0 != "email" }
.distinctUntilChanged()
.debounce(.milliseconds(7000), scheduler: MainScheduler.instance)
.subscribe(onNext: { _ in
self.buttonSignin.sendActions(for: .touchUpInside)
})
.disposed(by: self.disposeBag)
// validation errors
reactor.state
.map { $0.errors }
Expand Down
15 changes: 3 additions & 12 deletions waosSwift/modules/auth/controllers/AuthSigninController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,9 @@ final class AuthSignInController: CoreController, View, Stepper {
// background
let backgroundImage = UIImageView().then {
$0.contentMode = .scaleToFill
$0.alpha = 1
$0.image = UIImage(named: "authBackground")
$0.alpha = 0.4
}
let backgroundView = UIView().then {
$0.backgroundColor = .clear
}

// MARK: Properties

Expand All @@ -92,9 +88,11 @@ final class AuthSignInController: CoreController, View, Stepper {

override func viewDidLoad() {
super.viewDidLoad()
// navigation
self.navigationController?.navigationBar.standardAppearance = self.transparentNavigationBar
self.navigationController?.navigationBar.scrollEdgeAppearance = self.transparentNavigationBar
// background
self.view.addSubview(self.backgroundImage)
self.view.addSubview(self.backgroundView)
// content
self.view.registerAutomaticKeyboardConstraints() // active layout with snapkit
self.view.addSubview(self.inputEmail)
Expand All @@ -106,7 +104,6 @@ final class AuthSignInController: CoreController, View, Stepper {
self.view.addSubview(self.buttonSignInApple)
// config
self.view.backgroundColor = Metric.primary
self.navigationController?.navigationBar.isHidden = true
}

override func setupConstraints() {
Expand Down Expand Up @@ -177,11 +174,6 @@ final class AuthSignInController: CoreController, View, Stepper {
make.bottom.equalTo(self.view).offset(-25)
}
// background
self.backgroundView.snp.makeConstraints { make in
make.bottom.equalTo(self.view)
make.width.equalTo(self.view)
make.height.equalTo(self.view.snp.width)
}
self.backgroundImage.snp.makeConstraints { make in
make.top.equalTo(self.view)
make.centerX.equalTo(self.view)
Expand Down Expand Up @@ -224,7 +216,6 @@ private extension AuthSignInController {
.subscribe(onNext: { [weak self] reactor in
guard let `self` = self else { return }
let viewController = AuthForgotController(reactor: reactor)
viewController.title = L10n.authForgot
let navigationController = UINavigationController(rootViewController: viewController)
self.present(navigationController, animated: true, completion: nil)
})
Expand Down
47 changes: 16 additions & 31 deletions waosSwift/modules/auth/controllers/AuthSignupController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ final class AuthSignUpController: CoreController, View, Stepper {

// MARK: UI

let barButtonClose = UIBarButtonItem(barButtonSystemItem: .close, target: nil, action: nil)

let inputFirstName = CoreUITextField().then {
$0.autocorrectionType = .no
$0.setFontAwesomeIcon("fa-user")
Expand Down Expand Up @@ -50,9 +52,6 @@ final class AuthSignUpController: CoreController, View, Stepper {
$0.setProgress(0, animated: true)
}

let buttonSignin = CoreUIButton().then {
$0.setTitle(L10n.authSignInTitle, for: .normal)
}
let buttonSignup = CoreUIButton().then {
$0.setTitle(L10n.authSignUpTitle, for: .normal)
$0.setTitleColor(Metric.secondary, for: .normal)
Expand All @@ -66,13 +65,9 @@ final class AuthSignUpController: CoreController, View, Stepper {
// background
let backgroundImage = UIImageView().then {
$0.contentMode = .scaleToFill
$0.alpha = 1
$0.image = UIImage(named: "authBackground")
$0.alpha = 0.4
}
let backgroundView = UIView().then {
$0.backgroundColor = .clear
}

// MARK: Properties

Expand All @@ -93,22 +88,24 @@ final class AuthSignUpController: CoreController, View, Stepper {

override func viewDidLoad() {
super.viewDidLoad()
// navigation
self.navigationController?.navigationBar.standardAppearance = self.transparentNavigationBar
self.navigationController?.navigationBar.scrollEdgeAppearance = self.transparentNavigationBar
// background
self.view.addSubview(self.backgroundImage)
self.view.addSubview(self.backgroundView)
// content
self.view.registerAutomaticKeyboardConstraints() // active layout with snapkit
self.view.addSubview(self.inputFirstName)
self.view.addSubview(self.inputLastName)
self.view.addSubview(self.inputEmail)
self.view.addSubview(self.inputPassword)
self.view.addSubview(self.progressPassword)
self.view.addSubview(self.buttonSignin)
self.view.addSubview(self.buttonSignup)
self.view.addSubview(self.labelErrors)
// config
self.view.backgroundColor = Metric.primary
self.navigationController?.clear()
self.view.backgroundColor = Metric.primary
self.navigationItem.rightBarButtonItem = self.barButtonClose
}

override func setupConstraints() {
Expand Down Expand Up @@ -163,23 +160,14 @@ final class AuthSignUpController: CoreController, View, Stepper {
}

buttonSignup.snp.makeConstraints { (make) -> Void in
make.width.equalTo(140)
make.width.equalTo(300)
make.height.equalTo(50)
make.centerX.equalTo(self.view).offset(80)
make.centerX.equalTo(self.view)
make.centerY.equalTo(self.view).offset(140).keyboard(false, in: self.view)
}
buttonSignup.snp.prepareConstraints { (make) -> Void in
make.centerY.equalTo(self.view).offset(40).keyboard(true, in: self.view)
}
buttonSignin.snp.makeConstraints { (make) -> Void in
make.width.equalTo(140)
make.height.equalTo(50)
make.centerX.equalTo(self.view).offset(-80)
make.centerY.equalTo(self.view).offset(140).keyboard(false, in: self.view)
}
buttonSignin.snp.prepareConstraints { (make) -> Void in
make.centerY.equalTo(self.view).offset(40).keyboard(true, in: self.view)
}
labelErrors.snp.makeConstraints { (make) -> Void in
make.left.equalTo(25)
make.right.equalTo(-25)
Expand All @@ -190,11 +178,6 @@ final class AuthSignUpController: CoreController, View, Stepper {
make.centerY.equalTo(self.view).offset(60).keyboard(true, in: self.view)
}
// background
self.backgroundView.snp.makeConstraints { make in
make.bottom.equalTo(self.view)
make.width.equalTo(self.view)
make.height.equalTo(self.view.snp.width)
}
self.backgroundImage.snp.makeConstraints { make in
make.top.equalTo(self.view)
make.centerX.equalTo(self.view)
Expand All @@ -220,6 +203,13 @@ private extension AuthSignUpController {
// MARK: views (View -> View)

func bindView(_ reactor: AuthSignUpReactor) {
// cancel
self.barButtonClose.rx.tap
.subscribe(onNext: { [weak self] _ in
guard let `self` = self else { return }
self.dismiss(animated: true, completion: nil)
})
.disposed(by: self.disposeBag)
// error
self.error.button?.rx.tap
.subscribe(onNext: { _ in
Expand All @@ -238,11 +228,6 @@ private extension AuthSignUpController {
// MARK: actions (View -> Reactor)

func bindAction(_ reactor: AuthSignUpReactor) {
// button signin
buttonSignin.rx.tap
.map { _ in Reactor.Action.signIn }
.bind(to: reactor.action)
.disposed(by: self.disposeBag)
// button signup
buttonSignup.rx.tap
.throttle(.milliseconds(Metric.timesButtonsThrottle), latest: false, scheduler: MainScheduler.instance)
Expand Down
1 change: 0 additions & 1 deletion waosSwift/modules/auth/flow/AuthFlow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ final class AuthFlow: Flow {
private func navigateToAuthScreen() -> FlowContributors {
let reactor = AuthSigninReactor(provider: self.services)
let viewController = AuthSignInController(reactor: reactor)
viewController.title = L10n.authSignInTitle
self.rootViewController.pushViewController(viewController, animated: false)
return .one(flowContributor: .contribute(withNextPresentable: viewController, withNextStepper: viewController))

Expand Down
25 changes: 15 additions & 10 deletions waosSwift/modules/core/controllers/CoreController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class CoreController: UIViewController {
static let secondary = UIColor(named: config["theme"]["themes"]["waos"]["secondary"].string ?? "")
static let background = UIColor(named: config["theme"]["themes"]["waos"]["background"].string ?? "")
static let onBackground = UIColor(named: config["theme"]["themes"]["waos"]["onBackground"].string ?? "")
static let navigationBarTransparent = NSString(string: config["theme"]["navigationBar"]["transparent"].string ?? "").boolValue
static let navigationBarShadow = NSString(string: config["theme"]["navigationBar"]["shadow"].string ?? "").boolValue
static let tabBarColor = NSString(string: config["theme"]["tabBar"]["color"].string ?? "").boolValue
static let tabBarTintColor = NSString(string: config["theme"]["tabBar"]["tintColor"].string ?? "").boolValue
Expand All @@ -41,8 +42,13 @@ class CoreController: UIViewController {

// MARK: UI

let clearNavigationBar = UINavigationBarAppearance().then {
$0.backgroundColor = .clear
let transparentNavigationBar = UINavigationBarAppearance().then {
$0.configureWithTransparentBackground()
$0.titleTextAttributes = [.foregroundColor: Metric.onPrimary!]
}
let defaultNavigationBar = UINavigationBarAppearance().then {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identical blocks of code found in 2 locations. Consider refactoring.

$0.configureWithDefaultBackground()
$0.backgroundColor = Metric.primary
$0.titleTextAttributes = [.foregroundColor: Metric.onPrimary!]
}

Expand Down Expand Up @@ -81,18 +87,17 @@ class CoreController: UIViewController {
override func viewDidLoad() {
self.view.setNeedsUpdateConstraints()
// navigation
self.navigationController?.navigationBar.standardAppearance = UINavigationBarAppearance().then {
$0.backgroundColor = Metric.primary
$0.titleTextAttributes = [.foregroundColor: Metric.onPrimary!]
}
self.navigationController?.navigationBar.scrollEdgeAppearance = UINavigationBarAppearance().then {
$0.backgroundColor = Metric.primary?.withAlphaComponent(0.9)
$0.titleTextAttributes = [.foregroundColor: Metric.onPrimary!]
if Metric.navigationBarTransparent == true {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identical blocks of code found in 2 locations. Consider refactoring.

self.navigationController?.navigationBar.standardAppearance = self.transparentNavigationBar
self.navigationController?.navigationBar.scrollEdgeAppearance = self.transparentNavigationBar
} else {
self.navigationController?.navigationBar.standardAppearance = self.defaultNavigationBar
self.navigationController?.navigationBar.scrollEdgeAppearance = self.defaultNavigationBar
}
if Metric.navigationBarShadow == false {
self.navigationController?.navigationBar.scrollEdgeAppearance?.shadowColor = .clear
self.navigationController?.navigationBar.standardAppearance.shadowColor = .clear
self.clearNavigationBar.shadowColor = .clear
self.transparentNavigationBar.shadowColor = .clear
}
self.navigationController?.navigationBar.tintColor = Metric.onPrimary
// tabar
Expand Down
Loading