Skip to content

Commit

Permalink
Automatically select workspace + Remove Snapkit (#42)
Browse files Browse the repository at this point in the history
* Allow for automatic workspace selection

* Remove snapkit from AccountListItemTableCell

* Remove snapkit from AccountDetailsUsageView

* Fix warnings

* Remove snapkit from AccountDetailsViewController

* Remove Snapkit from LoadingView

* Remove snapkit from AccountsListViewController

* Remove snapkit in favour of NSLayoutConstraint

* Remove workspace selection step

---------

Co-authored-by: George Nyakundi <[email protected]>
  • Loading branch information
DevAgani and George Nyakundi authored Dec 20, 2024
1 parent 9200325 commit 1f7b151
Show file tree
Hide file tree
Showing 10 changed files with 130 additions and 102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ final class AccountDetailsUsageRowView: UIView {

private lazy var stackView: UIStackView = {
let view = UIStackView(arrangedSubviews: [titleLabel, subtitleLabel])
view.translatesAutoresizingMaskIntoConstraints = false
view.axis = .vertical
view.distribution = .fill
view.spacing = DesignSystem.shared.spacer.sm
Expand Down Expand Up @@ -65,8 +66,11 @@ final class AccountDetailsUsageRowView: UIView {
}

private func setupConstraints() {
stackView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
NSLayoutConstraint.activate([
stackView.topAnchor.constraint(equalTo: self.topAnchor),
stackView.bottomAnchor.constraint(equalTo: self.bottomAnchor),
stackView.leadingAnchor.constraint(equalTo: self.leadingAnchor),
stackView.trailingAnchor.constraint(equalTo: self.trailingAnchor)
])
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import UIKit
import Resolver
import SnapKit
import BackbaseDesignSystem

final class AccountDetailsUsageView: UIView {
Expand All @@ -18,6 +17,7 @@ final class AccountDetailsUsageView: UIView {
view.axis = .vertical
view.alignment = .fill
view.spacing = DesignSystem.shared.spacer.md
view.translatesAutoresizingMaskIntoConstraints = false
return view
}()

Expand All @@ -29,6 +29,7 @@ final class AccountDetailsUsageView: UIView {

private lazy var card: Card = {
let card = Card(DesignSystem.shared.styles.cardView)
card.translatesAutoresizingMaskIntoConstraints = false
return card
}()

Expand Down Expand Up @@ -66,16 +67,23 @@ final class AccountDetailsUsageView: UIView {

// MARK: - Private Methods
private func setupConstraints() {
titleLabel.snp.makeConstraints { make in
make.top.equalToSuperview()
make.leading.trailing.equalToSuperview().inset(DesignSystem.shared.spacer.lg)
}
card.snp.makeConstraints { make in
make.top.equalTo(titleLabel.snp.bottom).offset(DesignSystem.shared.spacer.xs)
make.leading.trailing.bottom.equalToSuperview().inset(DesignSystem.shared.spacer.md)
}
stackView.snp.makeConstraints { make in
make.edges.equalToSuperview().inset(DesignSystem.shared.spacer.md)
}
NSLayoutConstraint.activate([
// Title Label
titleLabel.topAnchor.constraint(equalTo: self.topAnchor),
titleLabel.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: DesignSystem.shared.spacer.lg),
titleLabel.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: -DesignSystem.shared.spacer.lg),

// Card
card.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: DesignSystem.shared.spacer.xs),
card.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: DesignSystem.shared.spacer.md),
card.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: -DesignSystem.shared.spacer.md),
card.bottomAnchor.constraint(equalTo: self.bottomAnchor, constant: -DesignSystem.shared.spacer.md),

// StackView
stackView.topAnchor.constraint(equalTo: card.topAnchor, constant: DesignSystem.shared.spacer.md),
stackView.leadingAnchor.constraint(equalTo: card.leadingAnchor, constant: DesignSystem.shared.spacer.md),
stackView.trailingAnchor.constraint(equalTo: card.trailingAnchor, constant: -DesignSystem.shared.spacer.md),
stackView.bottomAnchor.constraint(equalTo: card.bottomAnchor, constant: -DesignSystem.shared.spacer.md)
])
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//

import UIKit
import SnapKit
import Combine
import Resolver
import BackbaseDesignSystem
Expand All @@ -22,7 +21,11 @@ final class AccountDetailsViewController: UIViewController {

// MARK: - UI Properties
private var stateView: StateView?
private let loadingView = LoadingView()
private let loadingView: LoadingView = {
let view = LoadingView()
view.translatesAutoresizingMaskIntoConstraints = false
return view
}()

private let header = SummaryStackView()

Expand All @@ -31,12 +34,14 @@ final class AccountDetailsViewController: UIViewController {
stackView.spacing = DesignSystem.shared.spacer.sm
stackView.axis = .vertical
stackView.distribution = .equalSpacing
stackView.translatesAutoresizingMaskIntoConstraints = false
return stackView
}()

private lazy var scrollView: UIScrollView = {
let scrollView = UIScrollView()
scrollView.alwaysBounceVertical = true
scrollView.translatesAutoresizingMaskIntoConstraints = false
return scrollView
}()

Expand Down Expand Up @@ -93,22 +98,26 @@ final class AccountDetailsViewController: UIViewController {
}

private func setupLayout() {
scrollView.snp.makeConstraints { make in
make.edges.width.equalToSuperview()
}

stackView.snp.makeConstraints { make in
make.leading.trailing.width.equalToSuperview()
make.top.equalToSuperview().inset(DesignSystem.shared.spacer.sm)
make.bottom.equalToSuperview().inset(DesignSystem.shared.spacer.md)
}

loadingView.snp.makeConstraints { make in
make.leading.trailing.equalToSuperview()
.inset(DesignSystem.shared.spacer.md)
make.centerY.equalToSuperview()
}

NSLayoutConstraint.activate([
// ScrollView
scrollView.topAnchor.constraint(equalTo: view.topAnchor),
scrollView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
scrollView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
scrollView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
scrollView.widthAnchor.constraint(equalTo: view.widthAnchor),

// StackView
stackView.leadingAnchor.constraint(equalTo: scrollView.leadingAnchor),
stackView.trailingAnchor.constraint(equalTo: scrollView.trailingAnchor),
stackView.widthAnchor.constraint(equalTo: scrollView.widthAnchor),
stackView.topAnchor.constraint(equalTo: scrollView.topAnchor, constant: DesignSystem.shared.spacer.sm),
stackView.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor, constant: -DesignSystem.shared.spacer.md),

// LoadingView
loadingView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: DesignSystem.shared.spacer.md),
loadingView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -DesignSystem.shared.spacer.md),
loadingView.centerYAnchor.constraint(equalTo: view.centerYAnchor)
])
}

private func setupBindings() {
Expand Down Expand Up @@ -246,16 +255,12 @@ final class AccountDetailsViewController: UIViewController {
stateView.accessibilityIdentifier = "AccountDetailsStateView"

view.addSubview(stateView)
stateView.snp.makeConstraints { make in
make
.leading
.trailing
.equalToSuperview()
.inset(DesignSystem.shared.spacer.md)
make
.centerY
.equalToSuperview()
}

NSLayoutConstraint.activate([
stateView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: DesignSystem.shared.spacer.md),
stateView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -DesignSystem.shared.spacer.md),
stateView.centerYAnchor.constraint(equalTo: view.centerYAnchor)
])
}

private func removeStateView() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import UIKit
import Resolver
import SnapKit
import BackbaseDesignSystem

final class AccountListItemTableCell: UITableViewCell, Reusable, CellCornerModifier {
Expand All @@ -21,6 +20,7 @@ final class AccountListItemTableCell: UITableViewCell, Reusable, CellCornerModif
stackView.alignment = .leading
stackView.spacing = DesignSystem.shared.sizer.sm
stackView.backgroundColor = .clear
stackView.translatesAutoresizingMaskIntoConstraints = false
return stackView
}()

Expand Down Expand Up @@ -99,12 +99,13 @@ final class AccountListItemTableCell: UITableViewCell, Reusable, CellCornerModif
infoStackView.addArrangedSubview(accountNameLabel)
infoStackView.addArrangedSubview(accountStateLabel)
infoStackView.addArrangedSubview(accountBalanceLabel)

containerStackView.snp.makeConstraints { make in
make.leading.top.trailing.bottom
.equalToSuperview().inset(DesignSystem.shared.spacer.md)
}


NSLayoutConstraint.activate([
containerStackView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: DesignSystem.shared.spacer.md),
containerStackView.topAnchor.constraint(equalTo: contentView.topAnchor, constant: DesignSystem.shared.spacer.md),
containerStackView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -DesignSystem.shared.spacer.md),
containerStackView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -DesignSystem.shared.spacer.md)
])
}

func setup(_ account: AccountUIModel?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import Combine

final class AccountListSearchBarHeaderView: UIView {
private let configuration: AccountsJourney.Configuration = Resolver.resolve()
private let searchBar = UISearchBar(frame: .zero)
private let searchBar: UISearchBar = {
let view = UISearchBar(frame: .zero)
view.translatesAutoresizingMaskIntoConstraints = false
return view
}()
let textChangeSubject = PassthroughSubject<String, Never>()

init() {
Expand All @@ -25,15 +29,12 @@ final class AccountListSearchBarHeaderView: UIView {

private func setupSubviews() {
addSubview(searchBar)
searchBar.snp.makeConstraints { make in
make.top.equalToSuperview()
make.bottom
.equalToSuperview()
.inset(DesignSystem.shared.spacer.md)
make.leading.trailing
.equalToSuperview()
.inset(-DesignSystem.shared.spacer.sm)
}
NSLayoutConstraint.activate([
searchBar.topAnchor.constraint(equalTo: self.topAnchor),
searchBar.bottomAnchor.constraint(equalTo: self.bottomAnchor, constant: -DesignSystem.shared.spacer.md),
searchBar.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: DesignSystem.shared.spacer.sm),
searchBar.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: -DesignSystem.shared.spacer.sm)
])
}

private func setupConfiguration() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import Combine
import BackbaseObservability
import Resolver
import BackbaseDesignSystem
import SnapKit

final class AccountsListViewController: UIViewController {

Expand All @@ -35,15 +34,22 @@ final class AccountsListViewController: UIViewController {
// MARK: - UI Properties
private var refreshControl: UIRefreshControl {
let refreshControl = UIRefreshControl()
refreshControl.translatesAutoresizingMaskIntoConstraints = false
refreshControl.addTarget(self, action: #selector(handleRefreshControl), for: .valueChanged)
return refreshControl
}

private var stateView: StateView?
private let loadingView = LoadingView()

private let loadingView: LoadingView = {
let view = LoadingView()
view.translatesAutoresizingMaskIntoConstraints = false
return view
}()

private lazy var accountsListTableView: UITableView = {
let table = UITableView()
table.translatesAutoresizingMaskIntoConstraints = false
let inset = DesignSystem.shared.spacer.md
table.contentInset = UIEdgeInsets(top: inset, left: 0, bottom: inset, right: 0)
table.alwaysBounceVertical = false
Expand Down Expand Up @@ -83,20 +89,15 @@ final class AccountsListViewController: UIViewController {
}

private func setupLayout() {
accountsListTableView.snp.makeConstraints { make in
make.trailing.leading
.equalToSuperview()
.inset(DesignSystem.shared.spacer.md)
make.top.bottom.equalTo(view.safeAreaLayoutGuide)
}

loadingView.snp.makeConstraints { make in
make.leading.trailing
.equalToSuperview()
.inset(DesignSystem.shared.spacer.md)
make.centerY
.equalToSuperview()
}
NSLayoutConstraint.activate([
accountsListTableView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: DesignSystem.shared.spacer.md),
accountsListTableView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -DesignSystem.shared.spacer.md),
accountsListTableView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
accountsListTableView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor),
loadingView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: DesignSystem.shared.spacer.md),
loadingView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -DesignSystem.shared.spacer.md),
loadingView.centerYAnchor.constraint(equalTo: view.centerYAnchor)
])
}

private func setupBindings() {
Expand Down Expand Up @@ -175,20 +176,21 @@ final class AccountsListViewController: UIViewController {
// Add state view to the view hierarchy
if isEmptyState {
accountsListTableView.addSubview(stateView)
stateView.snp.makeConstraints { make in
make.center.equalToSuperview()
}
NSLayoutConstraint.activate([
stateView.centerXAnchor.constraint(equalTo: view.centerXAnchor),
stateView.centerYAnchor.constraint(equalTo: view.superview!.centerYAnchor)
])
} else {
// HIDE TABLE
accountsListTableView.isHidden = true
// Add state view to the view hierarchy
view.addSubview(stateView)

stateView.snp.makeConstraints { make in
make.leading.trailing.equalToSuperview()
.inset(DesignSystem.shared.spacer.md)
make.centerY.equalToSuperview()
}
NSLayoutConstraint.activate([
stateView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: DesignSystem.shared.spacer.md),
stateView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -DesignSystem.shared.spacer.md),
stateView.centerYAnchor.constraint(equalTo: view.centerYAnchor)
])
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,21 @@
import Foundation
import UIKit
import BackbaseDesignSystem
import SnapKit
import Resolver

final class LoadingView: UIView {
private lazy var containerView = UIView()

private lazy var containerView: UIView = {
let view = UIView()
view.translatesAutoresizingMaskIntoConstraints = false
return view
}()

private lazy var activityIndicator: UIActivityIndicatorView = {
let activityIndicator = UIActivityIndicatorView()
activityIndicator.style = .large
activityIndicator.tintColor = DesignSystem.shared.colors.primary.lighter
activityIndicator.translatesAutoresizingMaskIntoConstraints = false
return activityIndicator
}()

Expand Down Expand Up @@ -49,17 +55,15 @@ final class LoadingView: UIView {
}
private func configureDesign() {
addSubview(containerView)

containerView.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.centerY.equalToSuperview()
}
containerView.addSubview(activityIndicator)
activityIndicator.snp.makeConstraints { make in
make.top.equalToSuperview()
make.centerX.equalToSuperview()
make.width.equalTo(DesignSystem.shared.sizer.xl)
make.height.equalTo(DesignSystem.shared.sizer.xl)
}

NSLayoutConstraint.activate([
containerView.centerXAnchor.constraint(equalTo: self.centerXAnchor ),
containerView.centerYAnchor.constraint(equalTo: self.centerYAnchor),
activityIndicator.topAnchor.constraint(equalTo: containerView.topAnchor),
activityIndicator.centerXAnchor.constraint(equalTo: containerView.centerXAnchor),
activityIndicator.widthAnchor.constraint(equalToConstant: DesignSystem.shared.sizer.xl),
activityIndicator.heightAnchor.constraint(equalToConstant: DesignSystem.shared.sizer.xl)
])
}
}
Loading

0 comments on commit 1f7b151

Please sign in to comment.