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

Home view UI tweaks #553

Merged
merged 1 commit into from
Aug 12, 2020
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
8 changes: 8 additions & 0 deletions MobileWallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@
0053873024065F6C00901A68 /* SlideView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0053872F24065F6C00901A68 /* SlideView.swift */; };
0053873124065F6C00901A68 /* SlideView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0053872F24065F6C00901A68 /* SlideView.swift */; };
0053873224065F6C00901A68 /* SlideView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0053872F24065F6C00901A68 /* SlideView.swift */; };
00665E7524E422C500030A13 /* CustomTabBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00665E7424E422C500030A13 /* CustomTabBar.swift */; };
00665E7624E422CC00030A13 /* CustomTabBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00665E7424E422C500030A13 /* CustomTabBar.swift */; };
00665E7724E422CC00030A13 /* CustomTabBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00665E7424E422C500030A13 /* CustomTabBar.swift */; };
006D211D23CEDF16007D1C10 /* MicroTari.swift in Sources */ = {isa = PBXBuildFile; fileRef = 006D211C23CEDF16007D1C10 /* MicroTari.swift */; };
006D211E23CEDF16007D1C10 /* MicroTari.swift in Sources */ = {isa = PBXBuildFile; fileRef = 006D211C23CEDF16007D1C10 /* MicroTari.swift */; };
006D211F23CEDF16007D1C10 /* MicroTari.swift in Sources */ = {isa = PBXBuildFile; fileRef = 006D211C23CEDF16007D1C10 /* MicroTari.swift */; };
Expand Down Expand Up @@ -653,6 +656,7 @@
004997BA2382F5ED000A0B7D /* WalletTestDataExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletTestDataExtension.swift; sourceTree = "<group>"; };
005387232405136700901A68 /* AddNoteViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddNoteViewController.swift; sourceTree = "<group>"; };
0053872F24065F6C00901A68 /* SlideView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SlideView.swift; sourceTree = "<group>"; };
00665E7424E422C500030A13 /* CustomTabBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomTabBar.swift; sourceTree = "<group>"; };
006D211C23CEDF16007D1C10 /* MicroTari.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MicroTari.swift; sourceTree = "<group>"; };
0070A7BB2379847100C25E1C /* LocalAuthentication.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = LocalAuthentication.framework; path = System/Library/Frameworks/LocalAuthentication.framework; sourceTree = SDKROOT; };
0072BF23247E735700BD28FB /* ReminderNotifications.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReminderNotifications.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1394,6 +1398,7 @@
isa = PBXGroup;
children = (
3730E15024C884D500827DFA /* MenuTabBarController.swift */,
00665E7424E422C500030A13 /* CustomTabBar.swift */,
);
path = TabBar;
sourceTree = "<group>";
Expand Down Expand Up @@ -2204,6 +2209,7 @@
373CCDBD2490B66E00D0A2C9 /* CircularProgressView.swift in Sources */,
001F6CE02380198D00FA7002 /* Contacts.swift in Sources */,
0072BF24247E735700BD28FB /* ReminderNotifications.swift in Sources */,
00665E7524E422C500030A13 /* CustomTabBar.swift in Sources */,
00BBD80E237DA07400EBF5E6 /* ByteVector.swift in Sources */,
00BBD81A237EB31900EBF5E6 /* CommsConfig.swift in Sources */,
00E2BCA9236AB28200C2A105 /* TransactionTableViewCell.swift in Sources */,
Expand Down Expand Up @@ -2391,6 +2397,7 @@
00230B0A23770CEA00F23E34 /* CALayer.swift in Sources */,
0039B1B323FA925500F91E0F /* PasteEmojisView.swift in Sources */,
004997B82382ED79000A0B7D /* PendingInboundTransactions.swift in Sources */,
00665E7724E422CC00030A13 /* CustomTabBar.swift in Sources */,
37765D2724A35BA20091AE2A /* AESEncryption.swift in Sources */,
00E2BC9C236AAFB100C2A105 /* TransactionsTableViewController.swift in Sources */,
001F6CED2381A39300FA7002 /* CompletedTransaction.swift in Sources */,
Expand Down Expand Up @@ -2492,6 +2499,7 @@
00A057B623D979DA0029C22A /* UserFeedback.swift in Sources */,
376B502524924BB700278ACC /* PendingView.swift in Sources */,
004997B12382E938000A0B7D /* PendingOutboundTransaction.swift in Sources */,
00665E7624E422CC00030A13 /* CustomTabBar.swift in Sources */,
005387262405136700901A68 /* AddNoteViewController.swift in Sources */,
00230AFC2376C6DE00F23E34 /* Sequence.swift in Sources */,
491AB89B23F1B36100372189 /* AnimatedBalanceLabel.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion MobileWallet/Backup/BackupPrompts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ private class BackupPrompts {
actionTitle: content.ctaButton,
cancelTitle: content.cancelButton,
onAction: {
UIApplication.shared.menuTabBarController()?.setTab(.settings)
UIApplication.shared.menuTabBarController?.setTab(.settings)
}
)
break
Expand Down
2 changes: 1 addition & 1 deletion MobileWallet/Common/DeepLinkManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class DeepLinkManager {
return
}

if let tabBar = UIApplication.shared.menuTabBarController() {
if let tabBar = UIApplication.shared.menuTabBarController {
//Slight delay so the home view finishes loading. Else next view ends up without a navbar
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
DeeplinkNavigator.shared.proceedToDeeplink(deeplinkType, tabBar: tabBar)
Expand Down
8 changes: 4 additions & 4 deletions MobileWallet/Common/Extensions/UIApplication+KeyWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ extension UIApplication {
return UIApplication.shared.windows.filter({$0.isKeyWindow}).first
}

var menuTabBarController: MenuTabBarController? {
return findViewController(kindOf: MenuTabBarController.self)
}

func topController() -> UIViewController? {
if var topController = keyWindow?.rootViewController {
while let presentedViewController = topController.presentedViewController {
Expand All @@ -55,10 +59,6 @@ extension UIApplication {
return nil
}

func menuTabBarController() -> MenuTabBarController? {
return findViewController(kindOf: MenuTabBarController.self)
}

func findViewController<T: UIViewController>(kindOf: T.Type? = nil) -> T? {
guard let window = keyWindow else { return nil }
if let vc = window.rootViewController as? T {
Expand Down
4 changes: 2 additions & 2 deletions MobileWallet/Screens/Home/HomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ extension HomeViewController {
balanceLabel.textColor = Theme.shared.colors.homeScreenTotalBalanceLabel

balanceLabel.translatesAutoresizingMaskIntoConstraints = false
balanceLabel.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 15).isActive = true
balanceLabel.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 6).isActive = true
balanceLabel.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: 30).isActive = true
balanceLabel.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: 25).isActive = true
}
Expand All @@ -527,7 +527,7 @@ extension HomeViewController {
balanceContainer.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: 30).isActive = true
balanceContainer.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: 25).isActive = true
balanceContainer.heightAnchor.constraint(equalToConstant: 35).isActive = true
balanceContainer.topAnchor.constraint(equalTo: balanceLabel.bottomAnchor).isActive = true
balanceContainer.topAnchor.constraint(equalTo: balanceLabel.bottomAnchor, constant: -1).isActive = true

let valueIcon = UIImageView()
valueIcon.image = Theme.shared.images.currencySymbol
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ class AddNoteViewController: UIViewController, UITextViewDelegate, SlideViewDele
}

@objc private func showGiffyPanel() {
giphyModal.layout = .waterfall
giphyModal.mediaTypeConfig = [.gifs]
giphyModal.theme = TariGiphyTheme()
giphyModal.delegate = self
Expand Down Expand Up @@ -499,14 +498,12 @@ extension AddNoteViewController {
giphyVC.cellPadding = giffPadding
giphyVC.direction = .horizontal
giphyVC.numberOfTracks = 1
giphyVC.showCheckeredBackground = false
giphyVC.view.backgroundColor = .clear
giphyVC.imageType = .gif
giphyVC.layout = .carousel
giphyVC.direction = .horizontal
giphyVC.rating = .ratedPG13
giphyVC.fixedSizeCells = true
giphyVC.theme = TariGiphyTheme()

giphyVC.delegate = self
addChild(giphyVC)
giphyCaroursalContainerView.addSubview(giphyVC.view)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ class SendingTariViewController: UIViewController {
[weak self] _ in
// return to home
self?.navigationController?.dismiss(animated: true, completion: {
UIApplication.shared.menuTabBarController()?.setTab(.home)
UIApplication.shared.menuTabBarController?.setTab(.home)
})
}
}
Expand Down
8 changes: 4 additions & 4 deletions MobileWallet/UIElements/EmoticonView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,8 @@ extension EmoticonView {
guard let gf = globalFrame else { return }
blackoutView.frame = CGRect(x: -gf.origin.x, y: -gf.origin.y, width: blackoutView.bounds.width, height: blackoutView.bounds.height)
}
UIApplication.shared.menuTabBarController()?.tabBar.alpha = 0.15
UIApplication.shared.menuTabBarController()?.tabBar.isUserInteractionEnabled = false
UIApplication.shared.menuTabBarController?.tabBar.alpha = 0.15
UIApplication.shared.menuTabBarController?.tabBar.isUserInteractionEnabled = false
fadeView(view: blackoutView, fade: false, maxAlpha: 0.62)
showMenu()
}
Expand All @@ -374,8 +374,8 @@ extension EmoticonView {
fadeView(view: blackoutView, fade: true) { [weak self] in
self?.blackoutView.removeFromSuperview()
}
UIApplication.shared.menuTabBarController()?.tabBar.alpha = 1
UIApplication.shared.menuTabBarController()?.tabBar.isUserInteractionEnabled = true
UIApplication.shared.menuTabBarController?.tabBar.alpha = 1
UIApplication.shared.menuTabBarController?.tabBar.isUserInteractionEnabled = true
hideMenu()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ class HomeViewFloatingPanelLayout: FloatingPanelLayout {

public func insetFor(position: FloatingPanelPosition) -> CGFloat? {
let topInset: CGFloat = navBarHeight - 12
let lowestHeight = UIScreen.main.bounds.height - 120
//Raising the lowest postion of the panel slightly for phones without the notch
let lowestHeight = UIScreen.main.bounds.height - 76 - (UIApplication.shared.keyWindow?.safeAreaInsets.top ?? 0)

switch position {
case .full: return topInset // A top inset from safe area
Expand Down
74 changes: 74 additions & 0 deletions MobileWallet/UIElements/TabBar/CustomTabBar.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// CustomTabBar.swift

/*
Package MobileWallet
Created by Jason van den Berg on 2020/08/12
Using Swift 5.0
Running on macOS 10.15

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

class CustomTabBar: UITabBar {
override init(frame: CGRect) {
super.init(frame: frame)
setup()
}

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

func setup() {
unselectedItemTintColor = .black
tintColor = Theme.shared.colors.homeScreenBackground
barTintColor = .white
barStyle = .black

layer.shadowColor = UIColor.black.cgColor
layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
layer.shadowRadius = 8
layer.shadowOpacity = 0.25
layer.masksToBounds = false
}

override open func sizeThatFits(_ size: CGSize) -> CGSize {
super.sizeThatFits(size)
var sizeThatFits = super.sizeThatFits(size)
let bottomInset = UIApplication.shared.keyWindow?.safeAreaInsets.bottom ?? 0
sizeThatFits.height = 59 + bottomInset
return sizeThatFits
}
}
23 changes: 9 additions & 14 deletions MobileWallet/UIElements/TabBar/MenuTabBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import UIKit

class MenuTabBarController: UITabBarController {

enum Tab: Int {
case home
case ttlStore
Expand All @@ -55,25 +54,17 @@ class MenuTabBarController: UITabBarController {
var addRecipientViewController = AddRecipientViewController()
var profileViewController = ProfileViewController()
var settingsViewController = SettingsViewController()
let customTabBar = CustomTabBar(frame: .null)

override func viewDidLoad() {
super.viewDidLoad()
setValue(CustomTabBar(), forKey: "tabBar")
self.delegate = self

tabBar.unselectedItemTintColor = .black
tabBar.tintColor = Theme.shared.colors.homeScreenBackground
tabBar.barTintColor = .white
tabBar.barStyle = .black

tabBar.layer.shadowColor = UIColor.black.cgColor
tabBar.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
tabBar.layer.shadowRadius = 8
tabBar.layer.shadowOpacity = 0.25
tabBar.layer.masksToBounds = false

homeViewController.tabBarItem.image = Theme.shared.images.homeItem
storeViewController.tabBarItem.image = Theme.shared.images.ttlItem
addRecipientViewController.tabBarItem.image = Theme.shared.images.sendItem
addRecipientViewController.tabBarItem.tag = 1 //Using this to determine which icon to move upwards
profileViewController.tabBarItem.image = Theme.shared.images.profileItem
settingsViewController.tabBarItem.image = Theme.shared.images.settingsItem

Expand All @@ -82,7 +73,12 @@ class MenuTabBarController: UITabBarController {
viewControllers = [homeViewController, storeViewController, addRecipientViewController, profileViewController, settingsViewController]

for tabBarItem in tabBar.items! {
tabBarItem.imageInsets = UIEdgeInsets(top: 3, left: 0, bottom: -3, right: 0)
//For the send image we need to raise it higher than the others
if tabBarItem.tag == 1 {
tabBarItem.imageInsets = UIEdgeInsets(top: -16, left: 0, bottom: -12, right: 0)
} else if hasNotch { //On phones without notches the icons should stay vertically centered
tabBarItem.imageInsets = UIEdgeInsets(top: 13, left: 0, bottom: -13, right: 0)
}
}
}

Expand Down Expand Up @@ -130,7 +126,6 @@ private class Transition: NSObject, UIViewControllerAnimatedTransitioning {
}

func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {

guard
let fromVC = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from),
let fromView = fromVC.view,
Expand Down
24 changes: 12 additions & 12 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PODS:
- DeepDiff (2.3.1)
- FloatingPanel (1.7.4)
- Giphy (1.3.0):
- FloatingPanel (1.7.5)
- Giphy (2.0.0):
- DeepDiff
- libwebp
- PINCache
Expand All @@ -14,10 +14,10 @@ PODS:
- libwebp/mux (1.1.0):
- libwebp/demux
- libwebp/webp (1.1.0)
- lottie-ios (3.1.6)
- MatomoTracker (7.2.0):
- MatomoTracker/Core (= 7.2.0)
- MatomoTracker/Core (7.2.0)
- lottie-ios (3.1.8)
- MatomoTracker (7.2.1):
- MatomoTracker/Core (= 7.2.1)
- MatomoTracker/Core (7.2.1)
- PINCache (2.3)
- QuickLayout (3.0.0)
- ReachabilitySwift (5.0.0)
Expand All @@ -27,7 +27,7 @@ PODS:
- SwiftEntryKit (1.2.3):
- QuickLayout (= 3.0.0)
- SwiftKeychainWrapper (3.4.0)
- SwiftLint (0.39.1)
- SwiftLint (0.40.0)
- ZIPFoundation (0.9.11)

DEPENDENCIES:
Expand Down Expand Up @@ -70,18 +70,18 @@ CHECKOUT OPTIONS:

SPEC CHECKSUMS:
DeepDiff: e5ae6c50d0321568e4508cec5930b9f10bb293fc
FloatingPanel: 3c9d0e30fe350e1613157557769d2ec97f76b96b
Giphy: 7296cc64929aabf325655ac1472e1ec96b665ed4
FloatingPanel: bb17fd6fc7ae519f877f7bd30f4f6115a78acf07
Giphy: 41adc93795979bd5a7e5a4ad27f52107d824fb1f
libwebp: 946cb3063cea9236285f7e9a8505d806d30e07f3
lottie-ios: 85ce835dd8c53e02509f20729fc7d6a4e6645a0a
MatomoTracker: 6f89e2561083685a360e223fb663e9ccd57c1d1a
lottie-ios: 48fac6be217c76937e36e340e2d09cf7b10b7f5f
MatomoTracker: 246b6b0693cf39b356134dec7561f719d3538b96
PINCache: ce36ed282031b92fc7733ffe831f474ff80fddc2
QuickLayout: 07b45a72b10083fee3f095990cfed1c1e7b27f0a
ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825
Sentry: 1279f37a5691c19b1b761f7e260bba5dab7c2311
SwiftEntryKit: 340713c2e4a6662c5149629990bf1088bf5f0389
SwiftKeychainWrapper: 6fc49fbf7d4a6b0772917acb0e53a1639f6078d6
SwiftLint: 55e96a4a4d537d4a3156859fc1c54bd24851a046
SwiftLint: 4154893c73a4c52d6240195507eb7a3e3c64087e
ZIPFoundation: b1f0de4eed33e74a676f76e12559ab6b75990197

PODFILE CHECKSUM: 64a9adfe5c1b44618fd68ee7d55c8b61a038cc99
Expand Down