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

set_base_node - set base node or select from list (ios) - add to advanced settings #639

Merged
merged 1 commit into from
Jul 29, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
146 changes: 145 additions & 1 deletion MobileWallet.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions MobileWallet/Common/Extensions/UITableView+Cells.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// UITableView+Cells.swift

/*
Package MobileWallet
Created by Adrian Truszczynski on 20/07/2021
Using Swift 5.0
Running on macOS 12.0

Copyright 2019 The Tari Project

Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the
following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of
its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

import UIKit

extension UITableView {

func register<T: UITableViewCell>(type: T.Type) {
register(type, forCellReuseIdentifier: type.identifier)
}

func dequeueReusableCell<T: UITableViewCell>(type: T.Type, indexPath: IndexPath) -> T {
dequeueReusableCell(withIdentifier: type.identifier, for: indexPath) as? T ?? T(style: .default, reuseIdentifier: type.identifier)
}
}

extension UITableViewCell {
static var identifier: String { String(describing: Self.self) }
}
44 changes: 44 additions & 0 deletions MobileWallet/Common/Persistant Data/GroupUserDefaults.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// GroupUserDefaults.swift

/*
Package MobileWallet
Created by Adrian Truszczynski on 16/07/2021
Using Swift 5.0
Running on macOS 12.0

Copyright 2019 The Tari Project

Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the
following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of
its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

enum GroupUserDefaults {
@UserDefault(key: "selectedBaseNode", suiteName: TariSettings.groupIndentifier) static var selectedBaseNode: BaseNode?
@UserDefault(key: "customBaseNodes", suiteName: TariSettings.groupIndentifier) static var customBaseNodes: [BaseNode]?
}
61 changes: 61 additions & 0 deletions MobileWallet/Common/Property Wrappers/UserDefault.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// UserDefault.swift

/*
Package MobileWallet
Created by Adrian Truszczynski on 16/07/2021
Using Swift 5.0
Running on macOS 12.0

Copyright 2019 The Tari Project

Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the
following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of
its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

@propertyWrapper struct UserDefault<T: Codable> {

private let key: String
private let userDefaults: UserDefaults

init(key: String, suiteName: String? = nil) {
self.key = key
userDefaults = UserDefaults(suiteName: suiteName) ?? UserDefaults.standard
}

var wrappedValue: T? {
get {
guard let encodedData = UserDefaults.standard.data(forKey: key) else { return nil }
return try? JSONDecoder().decode(T.self, from: encodedData)
}
set {
guard let encodedValue = try? JSONEncoder().encode(newValue) else { return }
UserDefaults.standard.set(encodedValue, forKey: key)
}
}
}
5 changes: 5 additions & 0 deletions MobileWallet/Common/Theme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,8 @@ struct Fonts: Loopable {
// App table view
let systemTableViewCell = UIFont.Avenir.medium.withSize(15.0)
let systemTableViewCellMarkDescription = UIFont.Avenir.medium.withSize(14.0)
let systemTableViewCellMarkDescriptionSmall = UIFont.Avenir.medium.withSize(11.0)
let tableViewSection = UIFont.Avenir.medium.withSize(14.0)

// Restore pending view
let restorePendingViewTitle = UIFont.Avenir.light.withSize(18.0)
Expand All @@ -433,6 +435,9 @@ struct Fonts: Loopable {
let settingsPasswordWarning = UIFont.Avenir.heavy.withSize(13.0)

let tooltip = UIFont.Avenir.heavy.withSize(12.0)

// Text Field
let textField = UIFont.Avenir.light.withSize(14.0)
}

struct Sizes {
Expand Down
84 changes: 84 additions & 0 deletions MobileWallet/Common/Views/ContentScrollView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// ContentScrollView.swift

/*
Package MobileWallet
Created by Adrian Truszczynski on 20/07/2021
Using Swift 5.0
Running on macOS 12.0

Copyright 2019 The Tari Project

Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the
following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of
its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

import UIKit

final class ContentScrollView: UIScrollView {

// MARK: - Subviews

let contentView: UIView = {
let view = UIView()
view.translatesAutoresizingMaskIntoConstraints = false
return view
}()

// MARK: - Initializers

override init(frame: CGRect) {
super.init(frame: .zero)
setupConstraints()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

// MARK: - Setups

private func setupConstraints() {

addSubview(contentView)

let heightContraint = contentView.heightAnchor.constraint(equalTo: heightAnchor)
heightContraint.priority = .defaultLow

let constraints = [
contentView.topAnchor.constraint(equalTo: topAnchor),
contentView.leadingAnchor.constraint(equalTo: leadingAnchor),
contentView.trailingAnchor.constraint(equalTo: trailingAnchor),
contentView.bottomAnchor.constraint(equalTo: bottomAnchor),
contentView.widthAnchor.constraint(equalTo: widthAnchor),
heightContraint
]

NSLayoutConstraint.activate(constraints)
}
}
67 changes: 67 additions & 0 deletions MobileWallet/Common/Views/RoundedInputField.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// RoundedInputField.swift

/*
Package MobileWallet
Created by Adrian Truszczynski on 20/07/2021
Using Swift 5.0
Running on macOS 12.0

Copyright 2019 The Tari Project

Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the
following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of
its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

import UIKit

final class RoundedInputField: UITextField {

// MARK: - Initializers

override init(frame: CGRect) {
super.init(frame: frame)
setupView()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

// MARK: - Setups

private func setupView() {
backgroundColor = Theme.shared.colors.appBackground
layer.cornerRadius = 10.0
}

// MARK: - Layout

override func textRect(forBounds bounds: CGRect) -> CGRect { bounds.insetBy(dx: 12.0, dy: 12.0) }
override func editingRect(forBounds bounds: CGRect) -> CGRect { textRect(forBounds: bounds) }
}