From b078c1a00da9483fad4337d16a8da438d2757de4 Mon Sep 17 00:00:00 2001 From: InKwon James Kim Date: Mon, 19 Aug 2019 11:23:29 +0900 Subject: [PATCH] change PhoneBrand value --- GME Remit/APIs/Router/APIRouter.swift | 2 +- GME Remit/Extensions/UIDevice+Ext.swift | 127 ++++++++++++++++++ .../Cell/HomeCollectionTableViewCell.swift | 4 +- .../View/HomeViewController.swift | 5 +- .../View/RewardViewController.swift | 20 +-- 5 files changed, 144 insertions(+), 14 deletions(-) create mode 100644 GME Remit/Extensions/UIDevice+Ext.swift diff --git a/GME Remit/APIs/Router/APIRouter.swift b/GME Remit/APIs/Router/APIRouter.swift index 46f48af7..e7b774f3 100644 --- a/GME Remit/APIs/Router/APIRouter.swift +++ b/GME Remit/APIs/Router/APIRouter.swift @@ -326,7 +326,7 @@ extension APIRouter { "userId" : Utility.getMyUserName(), "uuid": self.uuid, "appVersion": Utility.getAppVersion() ?? "", - "phoneBrand": Utility.getPhoneBrand(), + "phoneBrand": UIDevice.modelName, "phoneOs": Utility.getPhoneOs(), "fcmId": firebaseToken, "osVersion": Utility.getOsVersion() diff --git a/GME Remit/Extensions/UIDevice+Ext.swift b/GME Remit/Extensions/UIDevice+Ext.swift new file mode 100644 index 00000000..4335d316 --- /dev/null +++ b/GME Remit/Extensions/UIDevice+Ext.swift @@ -0,0 +1,127 @@ +// +// UIDevice+Ext.swift +// GME Remit +// +// Created by InKwon James Kim on 19/08/2019. +// Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved. +// + +import SystemConfiguration +import UIKit + +public extension UIDevice { + static let modelName: String = { + var systemInfo = utsname() + uname(&systemInfo) + let machineMirror = Mirror(reflecting: systemInfo.machine) + let identifier = machineMirror.children.reduce("") { identifier, element in + guard let value = element.value as? Int8, value != 0 else { return identifier } + return identifier + String(UnicodeScalar(UInt8(value))) + } + + func mapToDevice(identifier: String) -> String { + #if os(iOS) + switch identifier { + case "iPod5,1": + return "iPod Touch 5" + case "iPod7,1": + return "iPod Touch 6" + case "iPhone3,1", "iPhone3,2", "iPhone3,3": + return "iPhone 4" + case "iPhone4,1": + return "iPhone 4s" + case "iPhone5,1", "iPhone5,2": + return "iPhone 5" + case "iPhone5,3", "iPhone5,4": + return "iPhone 5c" + case "iPhone6,1", "iPhone6,2": + return "iPhone 5s" + case "iPhone7,2": + return "iPhone 6" + case "iPhone7,1": + return "iPhone 6 Plus" + case "iPhone8,1": + return "iPhone 6s" + case "iPhone8,2": + return "iPhone 6s Plus" + case "iPhone9,1", "iPhone9,3": + return "iPhone 7" + case "iPhone9,2", "iPhone9,4": + return "iPhone 7 Plus" + case "iPhone8,4": + return "iPhone SE" + case "iPhone10,1", "iPhone10,4": + return "iPhone 8" + case "iPhone10,2", "iPhone10,5": + return "iPhone 8 Plus" + case "iPhone10,3", "iPhone10,6": + return "iPhone X" + case "iPhone11,2": + return "iPhone XS" + case "iPhone11,4", "iPhone11,6": + return "iPhone XS Max" + case "iPhone11,8": + return "iPhone XR" + case "iPad2,1", "iPad2,2", "iPad2,3", "iPad2,4": + return "iPad 2" + case "iPad3,1", "iPad3,2", "iPad3,3": + return "iPad 3" + case "iPad3,4", "iPad3,5", "iPad3,6": + return "iPad 4" + case "iPad4,1", "iPad4,2", "iPad4,3": + return "iPad Air" + case "iPad5,3", "iPad5,4": + return "iPad Air 2" + case "iPad6,11", "iPad6,12": + return "iPad 5" + case "iPad7,5", "iPad7,6": + return "iPad 6" + case "iPad2,5", "iPad2,6", "iPad2,7": + return "iPad Mini" + case "iPad4,4", "iPad4,5", "iPad4,6": + return "iPad Mini 2" + case "iPad4,7", "iPad4,8", "iPad4,9": + return "iPad Mini 3" + case "iPad5,1", "iPad5,2": + return "iPad Mini 4" + case "iPad6,3", "iPad6,4": + return "iPad Pro (9.7-inch)" + case "iPad6,7", "iPad6,8": + return "iPad Pro (12.9-inch)" + case "iPad7,1", "iPad7,2": + return "iPad Pro (12.9-inch) (2nd generation)" + case "iPad7,3", "iPad7,4": + return "iPad Pro (10.5-inch)" + case "iPad8,1", "iPad8,2", "iPad8,3", "iPad8,4": + return "iPad Pro (11-inch)" + case "iPad8,5", "iPad8,6", "iPad8,7", "iPad8,8": + return "iPad Pro (12.9-inch) (3rd generation)" + case "AppleTV5,3": + return "Apple TV" + case "AppleTV6,2": + return "Apple TV 4K" + case "AudioAccessory1,1": + return "HomePod" + case "i386", "x86_64": + let info = mapToDevice(identifier: ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"] ?? "iOS") + return "Simulator \(info)" + default: + return identifier + } + #elseif os(tvOS) + switch identifier { + case "AppleTV5,3": + return "Apple TV 4" + case "AppleTV6,2": + return "Apple TV 4K" + case "i386", "x86_64": + let info = mapToDevice(identifier: ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"] ?? "tvOS") + return "Simulator \(info)" + default: return identifier + } + #endif + } + + return mapToDevice(identifier: identifier) + }() +} diff --git a/GME Remit/Modules/Home/User Interface/View/Cell/HomeCollectionTableViewCell.swift b/GME Remit/Modules/Home/User Interface/View/Cell/HomeCollectionTableViewCell.swift index 3d3fced7..2814a7c7 100644 --- a/GME Remit/Modules/Home/User Interface/View/Cell/HomeCollectionTableViewCell.swift +++ b/GME Remit/Modules/Home/User Interface/View/Cell/HomeCollectionTableViewCell.swift @@ -152,9 +152,9 @@ class HomeCollectionTableViewCell: UITableViewCell, UICollectionViewDelegateFlow insetForSectionAt section: Int ) -> UIEdgeInsets { if Utility.getDeviceModel() == .iphone5 { - return UIEdgeInsets(top: 20, left: 10, bottom: 10, right: 10) + return UIEdgeInsets(top: 10, left: 5, bottom: 10, right: 5) } else { - return UIEdgeInsets(top: 20, left: 15, bottom: 10, right: 15) + return UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10) } } diff --git a/GME Remit/Modules/Home/User Interface/View/HomeViewController.swift b/GME Remit/Modules/Home/User Interface/View/HomeViewController.swift index d000d667..35fbc1ed 100644 --- a/GME Remit/Modules/Home/User Interface/View/HomeViewController.swift +++ b/GME Remit/Modules/Home/User Interface/View/HomeViewController.swift @@ -12,7 +12,7 @@ import Localize_Swift import ChannelIO import LGSideMenuController -class HomeViewController: UIViewController, UICollectionViewDelegateFlowLayout { +class HomeViewController: UIViewController { enum Sections: Int { case balance = 0 case collection @@ -796,12 +796,15 @@ extension HomeViewController { func getTodaysRateNotificationName() -> Notification.Name { return Notification.Name.init(rawValue: MenuNotificationName.todaysRate) } + func getTrackYourTransferNotificationName() -> Notification.Name { return Notification.Name.init(rawValue: MenuNotificationName.resend) } + func getTransactionStatementNotificationName() -> Notification.Name { return Notification.Name.init(rawValue: MenuNotificationName.transactionStatement) } + func getWalletToWalletNotificationName() -> Notification.Name { return Notification.Name.init(rawValue: MenuNotificationName.walletToWallet) } diff --git a/GME Remit/Modules/RewardModules/Reward/User Interface/View/RewardViewController.swift b/GME Remit/Modules/RewardModules/Reward/User Interface/View/RewardViewController.swift index 5189a442..5ae82da9 100644 --- a/GME Remit/Modules/RewardModules/Reward/User Interface/View/RewardViewController.swift +++ b/GME Remit/Modules/RewardModules/Reward/User Interface/View/RewardViewController.swift @@ -105,7 +105,6 @@ class RewardViewController: UIViewController { height = (view.frame.width - 20) / 2 - 3.5 + 30 } - let cellSize = CGSize( width: width, height: height @@ -118,14 +117,13 @@ class RewardViewController: UIViewController { layout.minimumLineSpacing = 5.0 layout.minimumInteritemSpacing = 5.0 - collectionView.setCollectionViewLayout(layout, animated: true) collectionView.reloadData() collectionView.collectionViewLayout.invalidateLayout() } private func addRefreshControlCollectionView() { - let colorOption = [NSAttributedString.Key.foregroundColor : UIColor.themeWhite]; + let colorOption = [NSAttributedString.Key.foregroundColor : UIColor.themeWhite] let title = NSAttributedString(string: "pull to refresh", attributes: colorOption) @@ -144,7 +142,7 @@ class RewardViewController: UIViewController { private func refresh() { self.presenter?.viewIsReady() - DispatchQueue.main.asyncAfter(deadline: .now() + 1.0){[weak self] in + DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {[weak self] in guard let `self` = self else {return} if #available(iOS 10.0, *) { @@ -154,7 +152,6 @@ class RewardViewController: UIViewController { } } } - } // MARK: RewardViewInterface @@ -185,19 +182,22 @@ extension RewardViewController: UICollectionViewDataSource { return models?.count ?? 0 } - func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { - let cell = collectionView.dequeueReusableCell( + func collectionView( + _ collectionView: UICollectionView, + cellForItemAt indexPath: IndexPath + ) -> UICollectionViewCell { + guard let cell = collectionView.dequeueReusableCell( withReuseIdentifier: "RewardItemCollectionViewCell", for: indexPath - ) as! RewardItemCollectionViewCell - + ) as? RewardItemCollectionViewCell else { + return UICollectionViewCell() + } cell.setModel(with: models?[indexPath.row], delegate: self) return cell } } - // MARK: - XLPagerTabStrip's IndicatorInfoProvider extension RewardViewController: IndicatorInfoProvider { func indicatorInfo(for pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo {