Commit 3e0d2b4e authored by Maurice Kraus's avatar Maurice Kraus
Browse files

feat(viewlayer): this adds the ChangePasswordViewController without vm

parent 67f2490b
Pipeline #1900 passed with stages
in 15 minutes and 33 seconds
......@@ -184,6 +184,7 @@
496ABC9E23C016A800F45E34 /* RealmQuickSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 496ABC9D23C016A800F45E34 /* RealmQuickSpec.swift */; };
496D8D3524B1E63C00EA8D3A /* CustomNotificationNames.swift in Sources */ = {isa = PBXBuildFile; fileRef = 499438F424B0F5260072564F /* CustomNotificationNames.swift */; };
4975875C23B694B0002AF645 /* InvalidJWT.json in Resources */ = {isa = PBXBuildFile; fileRef = 4975875B23B694B0002AF645 /* InvalidJWT.json */; };
49863A4124C4E70200E2AE7D /* ChangePasswordViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49863A4024C4E70200E2AE7D /* ChangePasswordViewController.swift */; };
498670002438F42100E90004 /* SpinnerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49866FFF2438F42100E90004 /* SpinnerViewController.swift */; };
498869B923BD13F20021BADA /* successGetAllTitles.json in Resources */ = {isa = PBXBuildFile; fileRef = 498869B823BD13F20021BADA /* successGetAllTitles.json */; };
4989626C242967AA0080E7BB /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4989626B242967AA0080E7BB /* SceneDelegate.swift */; };
......@@ -853,6 +854,7 @@
496ABC9923C00A0800F45E34 /* TitleDatastoreTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TitleDatastoreTests.swift; sourceTree = "<group>"; };
496ABC9D23C016A800F45E34 /* RealmQuickSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RealmQuickSpec.swift; sourceTree = "<group>"; };
4975875B23B694B0002AF645 /* InvalidJWT.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = InvalidJWT.json; sourceTree = "<group>"; };
49863A4024C4E70200E2AE7D /* ChangePasswordViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChangePasswordViewController.swift; sourceTree = "<group>"; };
49866FFF2438F42100E90004 /* SpinnerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpinnerViewController.swift; sourceTree = "<group>"; };
498869B823BD13F20021BADA /* successGetAllTitles.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = successGetAllTitles.json; sourceTree = "<group>"; };
4989626B242967AA0080E7BB /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
......@@ -1472,6 +1474,7 @@
49F6DD5D242004F4001333DE /* SelectDuelPoolViewController.swift */,
49866FFF2438F42100E90004 /* SpinnerViewController.swift */,
49AB5AD024A8BF99009DD9D1 /* LoginViewController.swift */,
49863A4024C4E70200E2AE7D /* ChangePasswordViewController.swift */,
);
path = ViewControllers;
sourceTree = "<group>";
......@@ -3767,6 +3770,7 @@
49294617234154B100F424BF /* UIView+hideKeyboard.swift in Sources */,
4929460B234154B100F424BF /* FindOpponentCoordinator.swift in Sources */,
4920E1E324A5136400E1E4BA /* UITextField+Rx.swift in Sources */,
49863A4124C4E70200E2AE7D /* ChangePasswordViewController.swift in Sources */,
49FAE43C24A47EF4008DAA59 /* Keyboard+EventObservable.swift in Sources */,
49294623234154B100F424BF /* DuelFrameViewController.swift in Sources */,
4929465723415B0E00F424BF /* SelectDuelViewController.swift in Sources */,
......
//
// ChangePasswordViewController.swift
// Akamu_iOS
//
// Created by Maurice Kraus on 19.07.20.
// Copyright © 2020 Akamu e.V. All rights reserved.
//
import AkamuUIKit
import UIKit
class ChangePasswordViewController: UITableViewController {
var firstPasswordCell: UITableViewCell = UITableViewCell()
var secondPasswordCell: UITableViewCell = UITableViewCell()
var firstPasswordField: UITextField = UITextField()
var secondPasswordField: UITextField = UITextField()
override func viewDidLoad() {
super.viewDidLoad()
tableView = UITableView(frame: tableView.frame, style: .grouped)
}
override func loadView() {
super.loadView()
// construct first name cell, section 0, row 0
firstPasswordCell.backgroundColor = UIColor(red: 1.0, green: 1.0, blue: 1.0, alpha: 0.5)
firstPasswordField = UITextField(frame: firstPasswordCell.contentView.bounds.insetBy(dx: 15, dy: 0))
firstPasswordField.placeholder = "New Password"
firstPasswordField.isSecureTextEntry = true
firstPasswordCell.addSubview(firstPasswordField)
// construct last name cell, section 0, row 1
secondPasswordCell.backgroundColor = UIColor(red: 1.0, green: 1.0, blue: 1.0, alpha: 0.5)
secondPasswordField = UITextField(frame: secondPasswordCell.contentView.bounds.insetBy(dx: 15, dy: 0))
secondPasswordField.placeholder = "Retype New Password"
secondPasswordField.isSecureTextEntry = true
secondPasswordCell.addSubview(secondPasswordField)
}
override func numberOfSections(in tableView: UITableView) -> Int {
return 2
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
switch indexPath.section {
case 0:
switch indexPath.row {
case 0:
return firstPasswordCell // section 0, row 0 is the first name
default:
fatalError("Unknown row in section 0")
}
case 1:
switch indexPath.row {
case 0:
return secondPasswordCell // section 1, row 0 is the share option
default:
fatalError("Unknown row in section 1")
}
default:
fatalError("Unknown section")
}
}
override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
if section == 1 {
return 100
} else {
return 0
}
}
override func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
guard section != 0 else { return nil }
let footerView = UIView()
footerView.backgroundColor = .clear
let button = UIButton()
button.setTitle("Update Password", for: .normal)
button.setTitleColor(Colors.akamuBlue, for: .normal)
button.layer.borderWidth = 1
button.layer.borderColor = Colors.akamuBlue.cgColor
button.layer.cornerRadius = 5
footerView.addSubview(button)
button.translatesAutoresizingMaskIntoConstraints = false
button.centerInSuperview()
button.heightAnchor.constraint(equalToConstant: 50).isActive = true
button.titleEdgeInsets = .init(top: 0, left: 10, bottom: 0, right: 10)
button.widthAnchor.constraint(greaterThanOrEqualToConstant: 200).isActive = true
return footerView
}
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
switch section {
case 0:
return "New Password"
case 1:
return "Retype Password"
default:
fatalError("Unknown section")
}
}
}
#if canImport(SwiftUI) && PREVIEW
import SwiftUI
import Swinject
@available(iOS 13, *)
struct ChangePasswordViewControllerPreview: PreviewProvider {
static var previews: some View {
ForEach(Devices.all, id: \.identity) { deviceName in
NavigationView {
ChangePasswordViewController().toPreview()
.navigationBarTitle(Text("Change Password"))
}
.previewDevice(PreviewDevice(rawValue: deviceName)).previewDisplayName(deviceName)
}
}
}
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment