Skip to content

Commit e10dc45

Browse files
committed
Move WooViewModifiers over to woofoundation
1 parent de202aa commit e10dc45

File tree

4 files changed

+51
-27
lines changed

4 files changed

+51
-27
lines changed

WooCommerce/Classes/ViewRelated/ReusableViews/SwiftUI Components/TitleAndValueRow.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import SwiftUI
2+
import WooFoundation
23

34
/// Renders a row with a label on the left side, a value on the right side and a disclosure indicator if selectable
45
///

WooCommerce/WooCommerce.xcodeproj/project.pbxproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,6 @@
501501
261AA30C2753119E009530FE /* PaymentMethodsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 261AA30B2753119E009530FE /* PaymentMethodsViewModel.swift */; };
502502
261AA30E275506DE009530FE /* PaymentMethodsViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 261AA30D275506DE009530FE /* PaymentMethodsViewModelTests.swift */; };
503503
26281776278F0B0100C836D3 /* View+NoticesModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26281775278F0B0100C836D3 /* View+NoticesModifier.swift */; };
504-
262A09812628A8F40033AD20 /* WooStyleModifiers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 262A09802628A8F40033AD20 /* WooStyleModifiers.swift */; };
505504
262A098B2628C51D0033AD20 /* OrderAddOnListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 262A098A2628C51D0033AD20 /* OrderAddOnListViewModel.swift */; };
506505
262A0999262908A60033AD20 /* OrderAddOnListI1Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 262A0998262908A60033AD20 /* OrderAddOnListI1Tests.swift */; };
507506
262A09A5262F65690033AD20 /* OrderAddOnTopBanner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 262A09A4262F65690033AD20 /* OrderAddOnTopBanner.swift */; };
@@ -2347,7 +2346,6 @@
23472346
261AA30B2753119E009530FE /* PaymentMethodsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentMethodsViewModel.swift; sourceTree = "<group>"; };
23482347
261AA30D275506DE009530FE /* PaymentMethodsViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentMethodsViewModelTests.swift; sourceTree = "<group>"; };
23492348
26281775278F0B0100C836D3 /* View+NoticesModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+NoticesModifier.swift"; sourceTree = "<group>"; };
2350-
262A09802628A8F40033AD20 /* WooStyleModifiers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WooStyleModifiers.swift; sourceTree = "<group>"; };
23512349
262A098A2628C51D0033AD20 /* OrderAddOnListViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderAddOnListViewModel.swift; sourceTree = "<group>"; };
23522350
262A0998262908A60033AD20 /* OrderAddOnListI1Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderAddOnListI1Tests.swift; sourceTree = "<group>"; };
23532351
262A09A4262F65690033AD20 /* OrderAddOnTopBanner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderAddOnTopBanner.swift; sourceTree = "<group>"; };
@@ -4881,7 +4879,6 @@
48814879
262A097F2628A8BF0033AD20 /* View Modifiers */ = {
48824880
isa = PBXGroup;
48834881
children = (
4884-
262A09802628A8F40033AD20 /* WooStyleModifiers.swift */,
48854882
2664210226F40FB1001FC5B4 /* View+ScrollModifiers.swift */,
48864883
26E0AE12263359F900A5EB3B /* View+Conditionals.swift */,
48874884
DE4B3B5526A68DD000EEF2D8 /* View+InsetPaddings.swift */,
@@ -9778,7 +9775,6 @@
97789775
02ECD1DF24FF48D000735BE5 /* PaginationTracker.swift in Sources */,
97799776
02645D8627BA2DB40065DC68 /* InboxNoteRow.swift in Sources */,
97809777
020886572499E643001D784E /* ProductExternalLinkViewController.swift in Sources */,
9781-
262A09812628A8F40033AD20 /* WooStyleModifiers.swift in Sources */,
97829778
DEC2962526C122DF005A056B /* ShippingLabelCustomsFormInputViewModel.swift in Sources */,
97839779
02F4F50F237AFC1E00E13A9C /* ImageAndTitleAndTextTableViewCell.swift in Sources */,
97849780
021E2A1C23AA0DD100B1DE07 /* ProductBackordersSettingListSelectorCommand.swift in Sources */,

WooFoundation/WooFoundation.xcodeproj/project.pbxproj

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
26AF1F5428B8362800937BA9 /* ColorStudio.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26AF1F5028B8362800937BA9 /* ColorStudio.swift */; };
1212
26AF1F5528B8362800937BA9 /* UIColor+ColorStudio.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26AF1F5128B8362800937BA9 /* UIColor+ColorStudio.swift */; };
1313
26AF1F5628B8362800937BA9 /* UIColor+SystemColors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26AF1F5228B8362800937BA9 /* UIColor+SystemColors.swift */; };
14+
26AF1F5928B9011100937BA9 /* WooStyleModifiers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26AF1F5828B9011100937BA9 /* WooStyleModifiers.swift */; };
1415
397702D42D32EAEEEA3B29FC /* Pods_WooFoundationTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 532D4D63493CE8FA6F13C85B /* Pods_WooFoundationTests.framework */; };
1516
686BE912288EE0D300967C86 /* TypedPredicates.swift in Sources */ = {isa = PBXBuildFile; fileRef = 686BE911288EE0D300967C86 /* TypedPredicates.swift */; };
1617
686BE915288EE2CA00967C86 /* TypedPredicateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 686BE914288EE2CA00967C86 /* TypedPredicateTests.swift */; };
@@ -43,6 +44,7 @@
4344
26AF1F5028B8362800937BA9 /* ColorStudio.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ColorStudio.swift; sourceTree = "<group>"; };
4445
26AF1F5128B8362800937BA9 /* UIColor+ColorStudio.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIColor+ColorStudio.swift"; sourceTree = "<group>"; };
4546
26AF1F5228B8362800937BA9 /* UIColor+SystemColors.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIColor+SystemColors.swift"; sourceTree = "<group>"; };
47+
26AF1F5828B9011100937BA9 /* WooStyleModifiers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WooStyleModifiers.swift; sourceTree = "<group>"; };
4648
532D4D63493CE8FA6F13C85B /* Pods_WooFoundationTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_WooFoundationTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4749
5BC355411C0A805BF29F38A6 /* Pods-WooFoundationTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WooFoundationTests.release.xcconfig"; path = "Target Support Files/Pods-WooFoundationTests/Pods-WooFoundationTests.release.xcconfig"; sourceTree = "<group>"; };
4850
686BE911288EE0D300967C86 /* TypedPredicates.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TypedPredicates.swift; sourceTree = "<group>"; };
@@ -102,6 +104,15 @@
102104
path = Colors;
103105
sourceTree = "<group>";
104106
};
107+
26AF1F5728B9011100937BA9 /* ViewModifiers */ = {
108+
isa = PBXGroup;
109+
children = (
110+
26AF1F5828B9011100937BA9 /* WooStyleModifiers.swift */,
111+
);
112+
name = ViewModifiers;
113+
path = WooFoundation/ViewModifiers;
114+
sourceTree = SOURCE_ROOT;
115+
};
105116
686BE910288EE09B00967C86 /* Utilities */ = {
106117
isa = PBXGroup;
107118
children = (
@@ -164,6 +175,7 @@
164175
B9C9C661283E7296001B879F /* Internal */,
165176
B9C9C65A283E71C8001B879F /* Currency */,
166177
B9C9C657283E7174001B879F /* Extensions */,
178+
26AF1F5728B9011100937BA9 /* ViewModifiers */,
167179
);
168180
path = WooFoundation;
169181
sourceTree = "<group>";
@@ -416,6 +428,7 @@
416428
B987B06F284540D300C53CF6 /* CurrencyCode.swift in Sources */,
417429
B9C9C660283E71F4001B879F /* Double+Woo.swift in Sources */,
418430
689D11D02891B3A300F6A83F /* CrashLogger.swift in Sources */,
431+
26AF1F5928B9011100937BA9 /* WooStyleModifiers.swift in Sources */,
419432
686BE912288EE0D300967C86 /* TypedPredicates.swift in Sources */,
420433
B9C9C65E283E71C8001B879F /* CurrencySettings.swift in Sources */,
421434
26AF1F5528B8362800937BA9 /* UIColor+ColorStudio.swift in Sources */,

WooCommerce/Classes/View Modifiers/WooStyleModifiers.swift renamed to WooFoundation/WooFoundation/ViewModifiers/WooStyleModifiers.swift

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,53 +6,63 @@ import SwiftUI
66
///
77

88
// MARK: Woo Styles
9-
struct BodyStyle: ViewModifier {
9+
public struct BodyStyle: ViewModifier {
1010
/// Whether the View being modified is enabled
1111
///
1212
var isEnabled: Bool
1313

14-
func body(content: Content) -> some View {
14+
public init(isEnabled: Bool) {
15+
self.isEnabled = isEnabled
16+
}
17+
18+
public func body(content: Content) -> some View {
1519
content
1620
.font(.body)
1721
.foregroundColor(isEnabled ? Color(.text) : Color(.textTertiary))
1822
}
1923
}
2024

2125

22-
struct LargeTitleStyle: ViewModifier {
23-
func body(content: Content) -> some View {
26+
public struct LargeTitleStyle: ViewModifier {
27+
public func body(content: Content) -> some View {
2428
content
2529
.font(.largeTitle)
2630
.foregroundColor(Color(.text))
2731
}
2832
}
2933

30-
struct TitleStyle: ViewModifier {
31-
func body(content: Content) -> some View {
34+
public struct TitleStyle: ViewModifier {
35+
public func body(content: Content) -> some View {
3236
content
3337
.font(.title)
3438
.foregroundColor(Color(.text))
3539
}
3640
}
3741

38-
struct SecondaryTitleStyle: ViewModifier {
39-
func body(content: Content) -> some View {
42+
public struct SecondaryTitleStyle: ViewModifier {
43+
public func body(content: Content) -> some View {
4044
content
4145
.font(.title2.weight(.bold))
4246
.foregroundColor(Color(.text))
4347
}
4448
}
4549

46-
struct SecondaryBodyStyle: ViewModifier {
47-
func body(content: Content) -> some View {
50+
public struct SecondaryBodyStyle: ViewModifier {
51+
52+
public init() {}
53+
54+
public func body(content: Content) -> some View {
4855
content
4956
.font(.body)
5057
.foregroundColor(Color(.textSubtle))
5158
}
5259
}
5360

54-
struct HeadlineStyle: ViewModifier {
55-
func body(content: Content) -> some View {
61+
public struct HeadlineStyle: ViewModifier {
62+
63+
public init() {}
64+
65+
public func body(content: Content) -> some View {
5666
content
5767
.font(.headline)
5868
.foregroundColor(Color(.text))
@@ -67,7 +77,7 @@ struct SubheadlineStyle: ViewModifier {
6777
}
6878
}
6979

70-
struct FootnoteStyle: ViewModifier {
80+
public struct FootnoteStyle: ViewModifier {
7181
/// Whether the View being modified is enabled
7282
///
7383
var isEnabled: Bool
@@ -76,7 +86,7 @@ struct FootnoteStyle: ViewModifier {
7686
///
7787
var isError: Bool
7888

79-
func body(content: Content) -> some View {
89+
public func body(content: Content) -> some View {
8090
content
8191
.font(.footnote)
8292
.foregroundColor(textColor)
@@ -94,47 +104,51 @@ struct FootnoteStyle: ViewModifier {
94104
}
95105
}
96106

97-
struct ErrorStyle: ViewModifier {
98-
func body(content: Content) -> some View {
107+
public struct ErrorStyle: ViewModifier {
108+
public func body(content: Content) -> some View {
99109
content
100110
.font(.body)
101111
.foregroundColor(Color(.error))
102112
}
103113
}
104114

105-
struct WooNavigationBarStyle: ViewModifier {
106-
func body(content: Content) -> some View {
115+
public struct WooNavigationBarStyle: ViewModifier {
116+
public func body(content: Content) -> some View {
107117
content
108118
.accentColor(Color(.accent)) // The color of bar button items in the navigation bar
109119
}
110120
}
111121

112-
struct LinkStyle: ViewModifier {
122+
public struct LinkStyle: ViewModifier {
113123
/// Environment `enabled` state.
114124
///
115125
@Environment(\.isEnabled) var isEnabled
116126

117-
func body(content: Content) -> some View {
127+
public init() {}
128+
129+
public func body(content: Content) -> some View {
118130
content
119131
.font(.body)
120132
.foregroundColor(isEnabled ? Color(.accent) : Color(.textTertiary))
121133
}
122134
}
123135

124-
struct HeadlineLinkStyle: ViewModifier {
136+
public struct HeadlineLinkStyle: ViewModifier {
125137
/// Environment `enabled` state.
126138
///
127139
@Environment(\.isEnabled) var isEnabled
128140

129-
func body(content: Content) -> some View {
141+
public init() {}
142+
143+
public func body(content: Content) -> some View {
130144
content
131145
.font(.headline)
132146
.foregroundColor(isEnabled ? Color(.accent) : Color(.textTertiary))
133147
}
134148
}
135149

136150
// MARK: View extensions
137-
extension View {
151+
public extension View {
138152
/// - Parameters:
139153
/// - isEnabled: Whether the view is enabled (to apply specific styles for disabled view)
140154
func bodyStyle(_ isEnabled: Bool = true) -> some View {

0 commit comments

Comments
 (0)