Skip to content
This repository was archived by the owner on Mar 6, 2024. It is now read-only.

Commit 19a9687

Browse files
committed
Add ComponentBoxScreen
1 parent 80d12fd commit 19a9687

File tree

7 files changed

+85
-24
lines changed

7 files changed

+85
-24
lines changed

samples/discovery/ios/ios.xcodeproj/project.pbxproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
33071932281A6A16230C3841 /* HomeScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33071ECAFCCA78581373E7B2 /* HomeScreen.swift */; };
1616
33071DF31FDF10941C1EA2A2 /* AccountScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33071206F5D3CBC31B9A9765 /* AccountScreen.swift */; };
1717
33071ED5854FEB12779EB378 /* PhotosScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33071576A17B16DDA1042633 /* PhotosScreen.swift */; };
18-
6677D6A627F0E8EF003A69D2 /* ComponentBoxUI in Frameworks */ = {isa = PBXBuildFile; productRef = 6677D6A527F0E8EF003A69D2 /* ComponentBoxUI */; };
1918
6677D6A927F0ECEE003A69D2 /* ComponentBox in Frameworks */ = {isa = PBXBuildFile; productRef = 6677D6A827F0ECEE003A69D2 /* ComponentBox */; };
19+
6677D6AB27F1245E003A69D2 /* ComponentBoxUI in Frameworks */ = {isa = PBXBuildFile; productRef = 6677D6AA27F1245E003A69D2 /* ComponentBoxUI */; };
2020
66A6A28027E7AD3500F27257 /* KMPNativeCoroutinesAsync in Frameworks */ = {isa = PBXBuildFile; productRef = 66A6A27F27E7AD3500F27257 /* KMPNativeCoroutinesAsync */; };
2121
66A6A28227E7AD3500F27257 /* KMPNativeCoroutinesCombine in Frameworks */ = {isa = PBXBuildFile; productRef = 66A6A28127E7AD3500F27257 /* KMPNativeCoroutinesCombine */; };
2222
66A6A28427E7AD3500F27257 /* KMPNativeCoroutinesCore in Frameworks */ = {isa = PBXBuildFile; productRef = 66A6A28327E7AD3500F27257 /* KMPNativeCoroutinesCore */; };
@@ -87,7 +87,7 @@
8787
66A6A28027E7AD3500F27257 /* KMPNativeCoroutinesAsync in Frameworks */,
8888
66A6A28227E7AD3500F27257 /* KMPNativeCoroutinesCombine in Frameworks */,
8989
66A6A28427E7AD3500F27257 /* KMPNativeCoroutinesCore in Frameworks */,
90-
6677D6A627F0E8EF003A69D2 /* ComponentBoxUI in Frameworks */,
90+
6677D6AB27F1245E003A69D2 /* ComponentBoxUI in Frameworks */,
9191
66A6A28627E7AD3500F27257 /* KMPNativeCoroutinesRxSwift in Frameworks */,
9292
);
9393
runOnlyForDeploymentPostprocessing = 0;
@@ -274,8 +274,8 @@
274274
66A6A28127E7AD3500F27257 /* KMPNativeCoroutinesCombine */,
275275
66A6A28327E7AD3500F27257 /* KMPNativeCoroutinesCore */,
276276
66A6A28527E7AD3500F27257 /* KMPNativeCoroutinesRxSwift */,
277-
6677D6A527F0E8EF003A69D2 /* ComponentBoxUI */,
278277
6677D6A827F0ECEE003A69D2 /* ComponentBox */,
278+
6677D6AA27F1245E003A69D2 /* ComponentBoxUI */,
279279
);
280280
productName = ios;
281281
productReference = 7555FF7B242A565900829871 /* ios.app */;
@@ -784,15 +784,15 @@
784784
/* End XCRemoteSwiftPackageReference section */
785785

786786
/* Begin XCSwiftPackageProductDependency section */
787-
6677D6A527F0E8EF003A69D2 /* ComponentBoxUI */ = {
788-
isa = XCSwiftPackageProductDependency;
789-
productName = ComponentBoxUI;
790-
};
791787
6677D6A827F0ECEE003A69D2 /* ComponentBox */ = {
792788
isa = XCSwiftPackageProductDependency;
793789
package = 6677D6A727F0ECED003A69D2 /* XCRemoteSwiftPackageReference "ComponentBoxPackage" */;
794790
productName = ComponentBox;
795791
};
792+
6677D6AA27F1245E003A69D2 /* ComponentBoxUI */ = {
793+
isa = XCSwiftPackageProductDependency;
794+
productName = ComponentBoxUI;
795+
};
796796
66A6A27F27E7AD3500F27257 /* KMPNativeCoroutinesAsync */ = {
797797
isa = XCSwiftPackageProductDependency;
798798
package = 66A6A27E27E7AD3500F27257 /* XCRemoteSwiftPackageReference "KMP-NativeCoroutines" */;
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"colors" : [
3+
{
4+
"color" : {
5+
"color-space" : "srgb",
6+
"components" : {
7+
"alpha" : "1.000",
8+
"blue" : "0x19",
9+
"green" : "0xDC",
10+
"red" : "0xB4"
11+
}
12+
},
13+
"idiom" : "universal"
14+
},
15+
{
16+
"appearances" : [
17+
{
18+
"appearance" : "luminosity",
19+
"value" : "dark"
20+
}
21+
],
22+
"color" : {
23+
"color-space" : "srgb",
24+
"components" : {
25+
"alpha" : "1.000",
26+
"blue" : "1.000",
27+
"green" : "1.000",
28+
"red" : "1.000"
29+
}
30+
},
31+
"idiom" : "universal"
32+
}
33+
],
34+
"info" : {
35+
"author" : "xcode",
36+
"version" : 1
37+
}
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//
2+
// Created by Matt Ramotar on 3/27/22.
3+
// Copyright (c) 2022 Dropbox, Inc. All rights reserved.
4+
5+
import Foundation
6+
import SwiftUI
7+
import componentbox
8+
9+
10+
@available(iOS 14.0, *)
11+
public struct ComponentBoxScreen: View, Identifiable {
12+
public let id: String
13+
let title: String?
14+
let verticalArrangement: componentbox.Arrangement?
15+
let horizontalAlignment: componentbox.Alignment?
16+
let components: [componentbox.Component]?
17+
18+
public init(id: String, title: String?, verticalArrangement: componentbox.Arrangement?, horizontalAlignment: componentbox.Alignment?, components: [componentbox.Component]?) {
19+
self.id = id
20+
self.title = title
21+
self.verticalArrangement = verticalArrangement
22+
self.horizontalAlignment = horizontalAlignment
23+
self.components = components
24+
}
25+
26+
public var body: some View {
27+
28+
if (self.components?.isEmpty == false) {
29+
30+
VStack {
31+
ForEach(self.components!, id: \.self) { component in
32+
component.inflate()
33+
}
34+
}.frame(maxWidth: .infinity, maxHeight: .infinity).padding(0)
35+
}
36+
}
37+
}
38+

samples/discovery/ios/ios/ComponentBoxUI/Sources/ComponentBoxUI/ComponentBoxUI.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,3 @@ enum ComponentBoxUI {
8888
}
8989
}
9090
}
91-
92-

samples/discovery/ios/ios/ComponentBoxUI/Sources/ComponentBoxUI/components/Icon.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ struct ComponentBoxUIIcon: View, Identifiable {
1717
let color: componentbox.Color?
1818

1919
func getForegroundColor() -> SwiftUI.Color {
20-
return color?.title != nil ? color!.title.ui() : "On background".ui()
20+
return color?.title != nil ? color!.title.ui() : modifier?.background?.title != nil ? modifier!.background!.title.ui() : "On background".ui()
2121
}
2222

2323
var body: some View {

samples/discovery/ios/ios/plans/PlansScreen.swift

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,8 @@ struct PlansScreen: View {
3232
private struct Content: View {
3333

3434
let screen: ComponentBox.Screen?
35-
let button: Component = Component.Button(id: "1", components: [Component.Text(id: "2", modifier: nil, text: "Upgrade", color: nil, textStyle: nil)], modifier: nil, isEnabled: true, action: nil, variant: nil)
3635

3736
var body: some View {
38-
VStack {
39-
40-
if (screen?.components != nil) {
41-
ForEach(screen!.components, id: \.self) { component in
42-
component.inflate()
43-
}
44-
}
45-
46-
47-
Text(screen?.title ?? "No title")
48-
49-
}
50-
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: Alignment.top).padding()
37+
ComponentBoxScreen(id: UUID().uuidString, title: screen?.title, verticalArrangement: screen?.verticalArrangement, horizontalAlignment: screen?.horizontalAlignment, components: screen?.components )
5138
}
5239
}

0 commit comments

Comments
 (0)