Skip to content

Commit ee37699

Browse files
committed
Merge branch 'trunk' into feat/5742-update-placeholder-separately
2 parents 447fd5d + 6d75b53 commit ee37699

File tree

61 files changed

+1451
-840
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1451
-840
lines changed

WooCommerce/Classes/Extensions/DateFormatter+Helpers.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,22 @@ extension DateFormatter {
1010

1111
// MARK: - Chark axis formatters
1212

13+
/// Date formatter used for creating the date for a selected date displayed on the time range bar for **hour** granularity.
14+
///
15+
public static let chartSelectedDateHourFormatter: DateFormatter = {
16+
let formatter = DateFormatter()
17+
formatter.setLocalizedDateFormatFromTemplate("EEEE, MMM d, h:mm a")
18+
return formatter
19+
}()
20+
21+
/// Date formatter used for creating the date for a selected date displayed on the time range bar for **hour** granularity.
22+
///
23+
public static let legacyChartSelectedDateHourFormatter: DateFormatter = {
24+
let formatter = DateFormatter()
25+
formatter.setLocalizedDateFormatFromTemplate("ha")
26+
return formatter
27+
}()
28+
1329
/// Date formatter used for creating the date displayed on a chart axis for **hour** granularity.
1430
///
1531
public static let chartAxisHourFormatter: DateFormatter = {
@@ -53,6 +69,14 @@ extension DateFormatter {
5369
/// Date formatter used for displaying the full month on a chart axis.
5470
///
5571
public static let chartAxisFullMonthFormatter: DateFormatter = {
72+
let formatter = DateFormatter()
73+
formatter.setLocalizedDateFormatFromTemplate("MMMM yyyy")
74+
return formatter
75+
}()
76+
77+
/// Date formatter used for displaying the full month on a chart axis.
78+
///
79+
public static let legacyChartAxisFullMonthFormatter: DateFormatter = {
5680
let formatter = DateFormatter()
5781
formatter.setLocalizedDateFormatFromTemplate("MMMM")
5882
return formatter

WooCommerce/Classes/ViewRelated/Coupons/CouponListViewController.swift

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1+
import Combine
12
import UIKit
23
import WordPressUI
34

45
final class CouponListViewController: UIViewController {
56
@IBOutlet private weak var tableView: UITableView!
6-
private var viewModel: CouponListViewModel!
7+
private let viewModel: CouponListViewModel
78

89
/// Set when an empty state view controller is displayed.
910
///
1011
private var emptyStateViewController: UIViewController?
1112

13+
private var subscriptions: Set<AnyCancellable> = []
14+
1215
init(siteID: Int64) {
16+
self.viewModel = CouponListViewModel(siteID: siteID)
1317
super.init(nibName: type(of: self).nibName, bundle: nil)
14-
self.viewModel = CouponListViewModel(siteID: siteID,
15-
didLeaveState: didLeave(state:),
16-
didEnterState: didEnter(state:))
1718
}
1819

1920
required init?(coder: NSCoder) {
@@ -24,32 +25,32 @@ final class CouponListViewController: UIViewController {
2425
super.viewDidLoad()
2526
configureNavigation()
2627
configureTableView()
28+
configureViewModel()
29+
}
30+
31+
private func configureViewModel() {
32+
viewModel.$state
33+
.removeDuplicates()
34+
.sink { [weak self] state in
35+
guard let self = self else { return }
36+
self.removeNoResultsOverlay()
37+
self.removePlaceholderCoupons()
38+
switch state {
39+
case .empty:
40+
self.displayNoResultsOverlay()
41+
case .loading:
42+
self.displayPlaceholderCoupons()
43+
case .coupons:
44+
self.tableView.reloadData()
45+
case .initialized:
46+
break
47+
}
48+
}
49+
.store(in: &subscriptions)
50+
51+
// Call this after the state subscription for extra safety
2752
viewModel.viewDidLoad()
2853
}
29-
30-
private func didLeave(state: CouponListState) {
31-
switch state {
32-
case .empty:
33-
removeNoResultsOverlay()
34-
case .loading:
35-
removePlaceholderCoupons()
36-
default:
37-
break
38-
}
39-
}
40-
41-
private func didEnter(state: CouponListState) {
42-
switch state {
43-
case .loading:
44-
displayPlaceholderCoupons()
45-
case .coupons:
46-
tableView.reloadData()
47-
case .empty:
48-
displayNoResultsOverlay()
49-
default:
50-
break
51-
}
52-
}
5354
}
5455

5556

WooCommerce/Classes/ViewRelated/Coupons/CouponManagementListViewModel.swift

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Foundation
1+
import Combine
22
import Yosemite
33
import protocol Storage.StorageManagerType
44
import class AutomatticTracks.CrashLogging
@@ -18,26 +18,10 @@ enum CouponListState {
1818
}
1919

2020
final class CouponListViewModel {
21-
/// onListStateChange
22-
///
23-
private var didLeaveState: (CouponListState) -> ()
24-
25-
/// onListStateChange
26-
///
27-
private var didEnterState: (CouponListState) -> ()
2821

2922
/// Active state
3023
///
31-
private var state: CouponListState = .initialized {
32-
didSet {
33-
guard oldValue != state else {
34-
return
35-
}
36-
37-
didLeaveState(oldValue)
38-
didEnterState(state)
39-
}
40-
}
24+
@Published private(set) var state: CouponListState = .initialized
4125

4226
/// couponViewModels: ViewModels for the cells representing Coupons
4327
///
@@ -69,15 +53,11 @@ final class CouponListViewModel {
6953
init(siteID: Int64,
7054
syncingCoordinator: SyncingCoordinatorProtocol = SyncingCoordinator(),
7155
storesManager: StoresManager = ServiceLocator.stores,
72-
storageManager: StorageManagerType = ServiceLocator.storageManager,
73-
didLeaveState: @escaping (CouponListState) -> (),
74-
didEnterState: @escaping (CouponListState) -> ()) {
56+
storageManager: StorageManagerType = ServiceLocator.storageManager) {
7557
self.siteID = siteID
7658
self.syncingCoordinator = syncingCoordinator
7759
self.storesManager = storesManager
7860
self.storageManager = storageManager
79-
self.didLeaveState = didLeaveState
80-
self.didEnterState = didEnterState
8161
self.resultsController = Self.createResultsController(siteID: siteID,
8262
storageManager: storageManager)
8363
configureSyncingCoordinator()

WooCommerce/Classes/ViewRelated/Dashboard/Dashboard.storyboard

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
33
<device id="retina4_7" orientation="portrait" appearance="light"/>
44
<dependencies>
5-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
5+
<deployment identifier="iOS"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19519"/>
67
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
78
<capability name="System colors in document resources" minToolsVersion="11.0"/>
89
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@@ -189,36 +190,6 @@
189190
</objects>
190191
<point key="canvasLocation" x="4192.8000000000002" y="2236.7316341829087"/>
191192
</scene>
192-
<!--Card Reader Settings Searching View Controller-->
193-
<scene sceneID="1hM-QM-F7H">
194-
<objects>
195-
<viewController storyboardIdentifier="CardReaderSettingsSearchingViewController" id="QbQ-It-W6j" customClass="CardReaderSettingsSearchingViewController" customModule="WooCommerce" customModuleProvider="target" sceneMemberID="viewController">
196-
<view key="view" contentMode="scaleToFill" id="OI1-Kx-TMr">
197-
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
198-
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
199-
<subviews>
200-
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="none" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="wIN-aE-q96">
201-
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
202-
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
203-
</tableView>
204-
</subviews>
205-
<viewLayoutGuide key="safeArea" id="H3D-HM-LVk"/>
206-
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
207-
<constraints>
208-
<constraint firstItem="wIN-aE-q96" firstAttribute="top" secondItem="H3D-HM-LVk" secondAttribute="top" id="Jhc-e4-GIy"/>
209-
<constraint firstItem="wIN-aE-q96" firstAttribute="leading" secondItem="H3D-HM-LVk" secondAttribute="leading" id="oLF-Wz-7a3"/>
210-
<constraint firstItem="H3D-HM-LVk" firstAttribute="trailing" secondItem="wIN-aE-q96" secondAttribute="trailing" id="qD0-0x-GvW"/>
211-
<constraint firstItem="H3D-HM-LVk" firstAttribute="bottom" secondItem="wIN-aE-q96" secondAttribute="bottom" id="yfC-kN-EGt"/>
212-
</constraints>
213-
</view>
214-
<connections>
215-
<outlet property="tableView" destination="wIN-aE-q96" id="Cyr-Hj-o4e"/>
216-
</connections>
217-
</viewController>
218-
<placeholder placeholderIdentifier="IBFirstResponder" id="lvw-3c-XCx" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
219-
</objects>
220-
<point key="canvasLocation" x="4929" y="2237"/>
221-
</scene>
222193
<!--Card Reader Settings Connected View Controller-->
223194
<scene sceneID="A3p-G9-5R7">
224195
<objects>
@@ -249,6 +220,14 @@
249220
</objects>
250221
<point key="canvasLocation" x="5658" y="2237"/>
251222
</scene>
223+
<!--Card Reader Settings Searching View Controller-->
224+
<scene sceneID="yFf-zp-ex7">
225+
<objects>
226+
<hostingController storyboardIdentifier="CardReaderSettingsSearchingViewController" id="6OW-B9-dhi" customClass="CardReaderSettingsSearchingViewController" customModule="WooCommerce" customModuleProvider="target" sceneMemberID="viewController"/>
227+
<placeholder placeholderIdentifier="IBFirstResponder" id="gkw-di-0a6" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
228+
</objects>
229+
<point key="canvasLocation" x="4937" y="2237"/>
230+
</scene>
252231
</scenes>
253232
<resources>
254233
<systemColor name="groupTableViewBackgroundColor">

WooCommerce/Classes/ViewRelated/Dashboard/Settings/CardReadersV2/CardReaderSettingsPresentingViewController.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ final class CardReaderSettingsPresentingViewController: UIViewController {
5454

5555
self.addChild(childViewController)
5656
self.view.addSubview(childViewController.view)
57+
childViewController.view.translatesAutoresizingMaskIntoConstraints = false
58+
self.view.pinSubviewToAllEdges(childViewController.view)
5759
childViewController.didMove(toParent: self)
5860
}
5961
}

0 commit comments

Comments
 (0)