Skip to content

Commit

Permalink
Merge branch 'feature/staking' into develop
Browse files Browse the repository at this point in the history
# Conflicts:
#	Kukai Mobile.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
  • Loading branch information
simonmcl committed Dec 2, 2024
2 parents 3d02742 + d34b976 commit 0ea53e6
Show file tree
Hide file tree
Showing 64 changed files with 6,222 additions and 2,487 deletions.
132 changes: 98 additions & 34 deletions Kukai Mobile.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/kukai-wallet/kukai-core-swift",
"state" : {
"branch" : "develop",
"revision" : "192d9cd46876e493a113d81833cac1d1969056bf"
"branch" : "feature/bakers_and_staking",
"revision" : "67b9f749b1e14d536877e9b6ec806c90fb33c43c"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1600"
LastUpgradeVersion = "1610"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1600"
LastUpgradeVersion = "1610"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1600"
LastUpgradeVersion = "1610"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Kukai Mobile/Controls/BottomSheetLargeSegue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class BottomSheetLargeSegue: UIStoryboardSegue {

let customId = UISheetPresentationController.Detent.Identifier("large-minus-background-effect")
let customDetent = UISheetPresentationController.Detent.custom(identifier: customId) { context in
return context.maximumDetentValue - 0.1
return context.maximumDetentValue - 1
}
dest.detents = [customDetent]
dest.prefersGrabberVisible = true
Expand Down
2 changes: 1 addition & 1 deletion Kukai Mobile/Controls/BottomSheetVariableSegue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class BottomSheetCustomSegue: UIStoryboardSegue {
} else {
let customId = UISheetPresentationController.Detent.Identifier("large-minus-background-effect")
let customDetent = UISheetPresentationController.Detent.custom(identifier: customId) { context in
return context.maximumDetentValue - 0.1
return context.maximumDetentValue - 1
}
dest.detents = [customDetent]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ public class EnterAddressComponent: UIView {
private var currentSelectedType: AddressType = .tezosAddress

public weak var delegate: EnterAddressComponentDelegate? = nil
public var allowEmpty: Bool = false {
didSet {
if (self.textField.text == nil || self.textField.text == "") && allowEmpty {
self.sendButton.isEnabled = true
}
}
}


required init?(coder aDecoder: NSCoder) {
Expand Down Expand Up @@ -71,7 +78,7 @@ public class EnterAddressComponent: UIView {
textField.validatorTextFieldDelegate = self

self.hideError(animate: false)
self.sendButton.isEnabled = false
self.sendButton.isEnabled = allowEmpty
}

public func updateAvilableAddressTypes(_ types: [AddressType]) {
Expand Down Expand Up @@ -275,7 +282,7 @@ extension EnterAddressComponent: ValidatorTextFieldDelegate {
self.sendButton.isEnabled = true

} else if text == "" {
self.sendButton.isEnabled = false
self.sendButton.isEnabled = allowEmpty

} else {
self.sendButton.isEnabled = false
Expand Down
29 changes: 20 additions & 9 deletions Kukai Mobile/Controls/OnboardingPageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ protocol OnboardingPageViewControllerDelegate: AnyObject {

/// A wrapper around the UIPageViewController that takes in a collection of viewControllers via an `IBInspectable`, and implements all the standard scroll logic and UIPageControl
/// to create an onboarding / intro / explanitory section in the app, to visually explain a topic or collection of topics to the user.
class OnboardingPageViewController: UIPageViewController, UIPageViewControllerDataSource, UIPageViewControllerDelegate {
class OnboardingPageViewController: UIViewController, UIPageViewControllerDataSource, UIPageViewControllerDelegate {

public var pageController = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal)
public var items: [UIViewController] = []
public var startIndex: Int = 0
private var pageControl: UIPageControl? = nil
public var pageControl: UIPageControl? = nil

/**
comma separated string containing any number of UIViewController storyboard ids, used to init UIViewControllers to act as pages in the page view controller
Expand All @@ -30,20 +31,29 @@ class OnboardingPageViewController: UIPageViewController, UIPageViewControllerDa
public weak var pageDelegate: OnboardingPageViewControllerDelegate? = nil

required init?(coder: NSCoder) {
super.init(transitionStyle: .scroll, navigationOrientation: .horizontal)
super.init(coder: coder)
}

override func viewDidLoad() {
super.viewDidLoad()

self.addChild(pageController)
self.view.addSubview(pageController.view)
NSLayoutConstraint.activate([
pageController.view.leadingAnchor.constraint(equalTo: self.view.leadingAnchor),
pageController.view.trailingAnchor.constraint(equalTo: self.view.trailingAnchor),
pageController.view.topAnchor.constraint(equalTo: self.view.topAnchor),
pageController.view.bottomAnchor.constraint(equalTo: self.view.bottomAnchor)
])

let ids = commaSeperatedStoryboardIds.components(separatedBy: ",")
for id in ids {
items.append(self.storyboard?.instantiateViewController(identifier: id) ?? UIViewController())
}

setViewControllers([items[0]], direction: .forward, animated: false, completion: nil)
self.dataSource = self
self.delegate = self
pageController.setViewControllers([items[0]], direction: .forward, animated: false, completion: nil)
pageController.dataSource = self
pageController.delegate = self

pageControl = UIPageControl()
pageControl?.translatesAutoresizingMaskIntoConstraints = false
Expand All @@ -63,7 +73,7 @@ class OnboardingPageViewController: UIPageViewController, UIPageViewControllerDa
}


self.setViewControllers([items[startIndex]], direction: .forward, animated: false, completion: nil)
pageController.setViewControllers([items[startIndex]], direction: .forward, animated: false, completion: nil)
self.pageControl?.currentPage = startIndex

if !showPageControl {
Expand Down Expand Up @@ -117,12 +127,13 @@ class OnboardingPageViewController: UIPageViewController, UIPageViewControllerDa
}

public func scrollTo(index: Int) {
guard let currentVc = self.viewControllers?.first, let viewControllerIndex = items.firstIndex(of: currentVc) else {
guard let currentVc = pageController.viewControllers?.first, let viewControllerIndex = items.firstIndex(of: currentVc) else {
return
}

let vc = items[index]
let isForward = viewControllerIndex < index
self.setViewControllers([vc], direction: isForward ? .forward : .reverse, animated: true, completion: nil)
pageController.setViewControllers([vc], direction: isForward ? .forward : .reverse, animated: true, completion: nil)
self.pageControl?.currentPage = index
}
}
141 changes: 141 additions & 0 deletions Kukai Mobile/Controls/PageIndicatorContainerView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
//
// PageIndicatorContainerView.swift
// Kukai Mobile
//
// Created by Simon Mcloughlin on 27/11/2024.
//

import UIKit

public class PageIndicatorContainerView: UIView {

let pagePendingView = UIView()
let pageInprogressView = UIView()
let pageNumberLabel = UILabel()
let pageCompleteView = UIView()
let checkImageView = UIImageView(image: UIImage(named: "Check"))

public override init(frame: CGRect) {
super.init(frame: frame)
setup()
}

public required init?(coder: NSCoder) {
super.init(coder: coder)
setup()
}

private func setup() {
self.backgroundColor = .clear

pagePendingView.translatesAutoresizingMaskIntoConstraints = false
pagePendingView.frame = CGRect(x: 0, y: 0, width: 14, height: 14)
pagePendingView.backgroundColor = .colorNamed("BG6")
pagePendingView.customCornerRadius = 7
self.addSubview(pagePendingView)

pageInprogressView.translatesAutoresizingMaskIntoConstraints = false
pageInprogressView.frame = CGRect(x: 0, y: 0, width: self.frame.width, height: self.frame.height)
pageInprogressView.backgroundColor = .colorNamed("BG0")
pageInprogressView.customCornerRadius = 14
pageInprogressView.borderColor = .colorNamed("BGB4")
pageInprogressView.borderWidth = 2
pageInprogressView.maskToBounds = true
pageInprogressView.alpha = 0

pageNumberLabel.translatesAutoresizingMaskIntoConstraints = false
pageNumberLabel.font = .custom(ofType: .medium, andSize: 16)
pageNumberLabel.textColor = .white
pageNumberLabel.textAlignment = .center
pageInprogressView.addSubview(pageNumberLabel)
self.addSubview(pageInprogressView)

pageCompleteView.translatesAutoresizingMaskIntoConstraints = false
pageCompleteView.frame = CGRect(x: 0, y: 0, width: self.frame.width, height: self.frame.height)
pageCompleteView.backgroundColor = .colorNamed("BGB4")
pageCompleteView.customCornerRadius = 14
pageCompleteView.alpha = 0

checkImageView.translatesAutoresizingMaskIntoConstraints = false
checkImageView.tintColor = .white
pageCompleteView.addSubview(checkImageView)
self.addSubview(pageCompleteView)

NSLayoutConstraint.activate([
pagePendingView.widthAnchor.constraint(equalToConstant: 14),
pagePendingView.heightAnchor.constraint(equalToConstant: 14),
pagePendingView.centerXAnchor.constraint(equalTo: self.centerXAnchor),
pagePendingView.centerYAnchor.constraint(equalTo: self.centerYAnchor),

pageInprogressView.leadingAnchor.constraint(equalTo: self.leadingAnchor),
pageInprogressView.trailingAnchor.constraint(equalTo: self.trailingAnchor),
pageInprogressView.topAnchor.constraint(equalTo: self.topAnchor),
pageInprogressView.bottomAnchor.constraint(equalTo: self.bottomAnchor),

pageNumberLabel.leadingAnchor.constraint(equalTo: pageInprogressView.leadingAnchor),
pageNumberLabel.trailingAnchor.constraint(equalTo: pageInprogressView.trailingAnchor),
pageNumberLabel.topAnchor.constraint(equalTo: pageInprogressView.topAnchor),
pageNumberLabel.bottomAnchor.constraint(equalTo: pageInprogressView.bottomAnchor),

pageCompleteView.leadingAnchor.constraint(equalTo: self.leadingAnchor),
pageCompleteView.trailingAnchor.constraint(equalTo: self.trailingAnchor),
pageCompleteView.topAnchor.constraint(equalTo: self.topAnchor),
pageCompleteView.bottomAnchor.constraint(equalTo: self.bottomAnchor),

checkImageView.leadingAnchor.constraint(equalTo: pageCompleteView.leadingAnchor, constant: 2),
checkImageView.trailingAnchor.constraint(equalTo: pageCompleteView.trailingAnchor, constant: -2),
checkImageView.topAnchor.constraint(equalTo: pageCompleteView.topAnchor, constant: 2),
checkImageView.bottomAnchor.constraint(equalTo: pageCompleteView.bottomAnchor, constant: -2),
])
}

public func setPending() {
pagePendingView.alpha = 1
pageInprogressView.alpha = 0
pageNumberLabel.alpha = 0
pageCompleteView.alpha = 0
checkImageView.alpha = 0
}

/**
- Animate the size of pagePendingView to the size of pageInprogressView
- After a brief delay to allow effect to show, start hiding pagePendingView and start showing pageInprogressView
- Setup the next stage by transforming checkImageView to a fraction of its current size
*/
public func setInprogress(pageNumber: Int) {
pageNumberLabel.text = pageNumber.description
UIView.animate(withDuration: 0.3) { [weak self] in
self?.pagePendingView.transform = CGAffineTransform(scaleX: 2, y: 2)

} completion: { [weak self] _ in
self?.pageCompleteView.alpha = 0
self?.checkImageView.alpha = 0
self?.checkImageView.transform = CGAffineTransform(scaleX: 0.1, y: 0.1)
}

UIView.animate(withDuration: 0.3, delay: 0.2) { [weak self] in
self?.pagePendingView.alpha = 0

self?.pageNumberLabel.alpha = 1
self?.pageInprogressView.alpha = 1
}
}

/**
- Animate hiding pageNumberLabel, and animate showing pageCompleteView
- Afterwards transform checkImageView back to its size, to give the appearance of it popping into the control
*/
public func setComplete() {
UIView.animate(withDuration: 0.3) { [weak self] in
self?.pageNumberLabel.alpha = 0
self?.pageCompleteView.alpha = 1

} completion: { _ in
UIView.animate(withDuration: 0.3) { [weak self] in
self?.checkImageView.alpha = 1
self?.checkImageView.transform = CGAffineTransform(scaleX: 1, y: 1)
}
}

}
}
21 changes: 21 additions & 0 deletions Kukai Mobile/Controls/SlideSegue.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// SlideSegue.swift
// Kukai Mobile
//
// Created by Simon Mcloughlin on 28/11/2024.
//

import UIKit

class SlideSegue: UIStoryboardSegue {

override func perform() {
let transition: CATransition = CATransition()
transition.duration = 0.3
transition.type = CATransitionType.push
transition.subtype = UIApplication.shared.userInterfaceLayoutDirection == UIUserInterfaceLayoutDirection.rightToLeft ? .fromLeft : .fromRight

source.navigationController?.view.layer.add(transition, forKey: nil)
source.navigationController?.pushViewController(destination, animated: false)
}
}
2 changes: 1 addition & 1 deletion Kukai Mobile/Extensions/UIImageView+extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extension UIImageView {
}

if token.isXTZ() {
self.image = UIImage.tezosToken().resizedImage(size: CGSize(width: self.frame.width+2, height: self.frame.height+2))
self.image = UIImage.tezosToken().resizedImage(size: CGSize(width: self.frame.width, height: self.frame.height))
} else {
var tokenURL = token.thumbnailURL
if fallbackToAvatar, tokenURL == nil, let address = token.tokenContractAddress {
Expand Down
2 changes: 1 addition & 1 deletion Kukai Mobile/Extensions/UIViewController+extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ extension UIViewController {
activityViewStatusLabel.font = UIFont.custom(ofType: .medium, andSize: 16)
activityViewStatusLabel.textColor = UIColor.white
activityViewStatusLabel.textAlignment = .center
activityViewStatusLabel.frame = CGRect(x: view.center.x, y: view.center.y, width: view.frame.width - 64, height: 50)
activityViewStatusLabel.frame = CGRect(x: view.center.x, y: view.center.y, width: view.frame.width - 64, height: 200)

UIViewController.activityViewActivityIndicator.color = UIColor.white

Expand Down
Loading

0 comments on commit 0ea53e6

Please sign in to comment.