Skip to content

Commit 8bfa1aa

Browse files
authored
Merge pull request #4 from ServerDriven/dev/views
Dev/views
2 parents 868e877 + f385661 commit 8bfa1aa

26 files changed

+369
-78
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.pv.screendata.extensions
2+
3+
import com.pv.screendata.objects.SomeView
4+
import com.pv.screendata.types.ViewType
5+
import com.pv.screendata.views.SomeContainerView
6+
7+
fun SomeContainerView.toSomeView(): SomeView = SomeView(
8+
type = ViewType.container,
9+
someContainer = this,
10+
someImage = null,
11+
someLabel = null,
12+
someLabeledImage = null,
13+
someCustomView = null,
14+
someText = null,
15+
someButton = null
16+
)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.pv.screendata.extensions
2+
3+
import com.pv.screendata.objects.SomeView
4+
import com.pv.screendata.types.ViewType
5+
import com.pv.screendata.views.SomeLabel
6+
7+
fun SomeLabel.toSomeView(): SomeView = SomeView(
8+
type = ViewType.label,
9+
someContainer = null,
10+
someImage = null,
11+
someLabel = this,
12+
someLabeledImage = null,
13+
someCustomView = null,
14+
someText = null,
15+
someButton = null
16+
)
17+
18+
fun String.toSomeLabel(): SomeLabel = SomeLabel(
19+
id = null,
20+
this,
21+
null,
22+
null,
23+
null
24+
)
25+
26+
fun Pair<String, String>.toSomeLabel(): SomeLabel = SomeLabel(
27+
id = null,
28+
title = first,
29+
subtitle = second,
30+
null,
31+
null
32+
)

ScreenData/src/main/java/com/pv/screendata/objects/Color.kt

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
package com.pv.screendata.objects
22

3-
import com.pv.screendata.objects.destinations.DeepLinkDestination
4-
import com.pv.screendata.objects.destinations.ScreenDestination
5-
import com.pv.screendata.objects.destinations.URLDestination
63
import com.pv.screendata.types.DestinationType
74

85
data class Destination(
6+
val toId: String,
97
val type: DestinationType,
10-
val screen: ScreenDestination?,
11-
val url: URLDestination?,
12-
val deepLink: DeepLinkDestination?
138
)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.pv.screendata.objects
2+
3+
data class SomeColor(
4+
val red: Float,
5+
val green: Float,
6+
val blue: Float,
7+
val alpha: Float
8+
)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.pv.screendata.objects
2+
3+
data class SomeStyle(
4+
val backgroundColor: SomeColor?,
5+
val foregroundColor: SomeColor?,
6+
val isHidden: Boolean,
7+
val cornerRadius: Int
8+
)

ScreenData/src/main/java/com/pv/screendata/objects/SomeView.kt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ package com.pv.screendata.objects
33
import com.pv.screendata.types.ViewType
44
import com.pv.screendata.views.*
55

6+
// preview all models with Some?
7+
// add a spacer view?
68
data class SomeView(
79
val type: ViewType,
810

9-
val container: ContainerView?,
10-
val image: Image?,
11-
val label: Label?,
12-
val labeledImage: LabeledImage?,
13-
val view: View?
11+
val someText: SomeText?,
12+
val someButton: SomeButton?,
13+
val someContainer: SomeContainerView?,
14+
val someImage: SomeImage?,
15+
val someLabel: SomeLabel?,
16+
val someLabeledImage: SomeLabeledImage?,
17+
val someCustomView: SomeCustomView?
1418
)

ScreenData/src/main/java/com/pv/screendata/objects/Style.kt

Lines changed: 0 additions & 7 deletions
This file was deleted.

ScreenData/src/main/java/com/pv/screendata/objects/destinations/DeepLinkDestination.kt

Lines changed: 0 additions & 9 deletions
This file was deleted.

ScreenData/src/main/java/com/pv/screendata/objects/destinations/ScreenDestination.kt

Lines changed: 0 additions & 10 deletions
This file was deleted.

ScreenData/src/main/java/com/pv/screendata/objects/destinations/URLDestination.kt

Lines changed: 0 additions & 9 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
package com.pv.screendata.screens
22

3-
import com.pv.screendata.objects.Color
3+
import com.pv.screendata.objects.SomeColor
44
import com.pv.screendata.objects.SomeView
55

6-
data class Screen(
6+
// should view just be container view ? What screen would have a label ?
7+
8+
data class SomeScreen(
79
val id: String?,
810
val title: String,
911
val subtitle: String?,
10-
val backgroundColor: Color,
12+
val backgroundColor: SomeColor,
1113
val headerView: SomeView?,
12-
val view: SomeView,
14+
val someView: SomeView,
1315
val footerView: SomeView?
1416
)

ScreenData/src/main/java/com/pv/screendata/types/ViewType.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.pv.screendata.types
22

33
enum class ViewType {
4+
text,
5+
button,
46
label,
57
image,
68
labeledImage,
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.pv.screendata.views
2+
3+
import com.pv.screendata.objects.Destination
4+
import com.pv.screendata.objects.SomeStyle
5+
import com.pv.screendata.types.ViewType
6+
7+
// Runs action before destination
8+
data class SomeButton(
9+
val id: String?,
10+
val actionId: String?,
11+
val title: String,
12+
val destination: Destination?,
13+
val style: SomeStyle?
14+
) {
15+
val type: ViewType = ViewType.button
16+
}
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package com.pv.screendata.views
22

33
import com.pv.screendata.objects.SomeView
4-
import com.pv.screendata.objects.Style
4+
import com.pv.screendata.objects.SomeStyle
55
import com.pv.screendata.types.ViewDirectionAxis
66
import com.pv.screendata.types.ViewType
77

8-
data class ContainerView(
8+
data class SomeContainerView(
99
val id: String?,
1010
val axis: ViewDirectionAxis,
11-
val views: Array<SomeView>,
12-
val style: Style?
11+
val someViews: Array<SomeView>,
12+
val someStyle: SomeStyle?
1313
) {
1414
val type: ViewType = ViewType.container
1515
}

ScreenData/src/main/java/com/pv/screendata/views/View.kt renamed to ScreenData/src/main/java/com/pv/screendata/views/SomeCustomView.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ package com.pv.screendata.views
22

33
import com.pv.screendata.objects.Destination
44
import com.pv.screendata.objects.SomeView
5-
import com.pv.screendata.objects.Style
5+
import com.pv.screendata.objects.SomeStyle
66
import com.pv.screendata.types.ViewDirectionAxis
77
import com.pv.screendata.types.ViewType
88

9-
data class View(
9+
data class SomeCustomView(
1010
val id: String?,
1111
val title: String,
1212
val subtitle: String?,
13-
val style: Style?,
14-
val image: Image?,
13+
val someStyle: SomeStyle?,
14+
val someImage: SomeImage?,
1515
val destination: Destination?,
1616
val axis: ViewDirectionAxis,
17-
val views: Array<SomeView>
17+
val someViews: Array<SomeView>
1818
) {
1919
val type: ViewType = ViewType.custom
2020
}

ScreenData/src/main/java/com/pv/screendata/views/Image.kt renamed to ScreenData/src/main/java/com/pv/screendata/views/SomeImage.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package com.pv.screendata.views
22

33
import com.pv.screendata.objects.Destination
4-
import com.pv.screendata.objects.Style
4+
import com.pv.screendata.objects.SomeStyle
55
import com.pv.screendata.types.ViewType
66

7-
data class Image(
7+
data class SomeImage(
88
val id: String?,
99
val url: String,
10-
val style: Style?,
10+
val someStyle: SomeStyle?,
1111
val destination: Destination?
1212
) {
1313
val type: ViewType = ViewType.image

ScreenData/src/main/java/com/pv/screendata/views/Label.kt renamed to ScreenData/src/main/java/com/pv/screendata/views/SomeLabel.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package com.pv.screendata.views
22

33
import com.pv.screendata.objects.Destination
4-
import com.pv.screendata.objects.Style
4+
import com.pv.screendata.objects.SomeStyle
55
import com.pv.screendata.types.ViewType
66

7-
data class Label(
7+
data class SomeLabel(
88
val id: String?,
99
val title: String,
1010
val subtitle: String?,
11-
val style: Style?,
11+
val someStyle: SomeStyle?,
1212
val destination: Destination?
1313
) {
1414
val type: ViewType = ViewType.label

ScreenData/src/main/java/com/pv/screendata/views/LabeledImage.kt renamed to ScreenData/src/main/java/com/pv/screendata/views/SomeLabeledImage.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package com.pv.screendata.views
22

33
import com.pv.screendata.objects.Destination
4-
import com.pv.screendata.objects.Style
4+
import com.pv.screendata.objects.SomeStyle
55
import com.pv.screendata.types.ViewType
66

7-
data class LabeledImage(
7+
data class SomeLabeledImage(
88
val id: String?,
99
val title: String,
1010
val subtitle: String?,
11-
val image: Image,
12-
val style: Style?,
11+
val someImage: SomeImage,
12+
val someStyle: SomeStyle?,
1313
val destination: Destination?
1414
) {
1515
val type: ViewType = ViewType.labeledImage
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.pv.screendata.views
2+
3+
import com.pv.screendata.objects.SomeStyle
4+
import com.pv.screendata.types.ViewType
5+
6+
data class SomeText(
7+
val id: String?,
8+
val title: String,
9+
val style: SomeStyle?,
10+
) {
11+
val type: ViewType = ViewType.text
12+
}
Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,66 @@
11
package com.pv.screendata
22

3+
import androidx.compose.foundation.Text
4+
import androidx.compose.foundation.layout.fillMaxSize
5+
import androidx.compose.material.Scaffold
6+
import androidx.compose.material.TopAppBar
37
import androidx.compose.runtime.Composable
8+
import androidx.compose.ui.Modifier
9+
import androidx.compose.ui.graphics.Color
10+
import androidx.ui.tooling.preview.Preview
11+
import com.pv.screendata.extensions.toSomeLabel
12+
import com.pv.screendata.extensions.toSomeView
13+
import com.pv.screendata.objects.SomeColor as SomeColor
14+
import com.pv.screendata.screens.SomeScreen
15+
import com.pv.screendata.types.ViewDirectionAxis
16+
import com.pv.screendata.views.SomeContainerView
417

518
@Composable
6-
fun SDSCreen() {
19+
fun SDSCreen(screen: SomeScreen) {
20+
Scaffold(
21+
Modifier.fillMaxSize(),
22+
backgroundColor = Color(
23+
screen.backgroundColor.red,
24+
screen.backgroundColor.green,
25+
screen.backgroundColor.blue
26+
),
27+
topBar = {
28+
TopAppBar(title = {
29+
Text(screen.title)
30+
})
31+
},
32+
) {
33+
SDSomeView(someView = screen.someView)
34+
}
35+
}
736

37+
@Preview(showBackground = true)
38+
@Composable
39+
fun sdScreenPreview() {
40+
SDSCreen(
41+
screen = SomeScreen(
42+
id = "yoloId",
43+
title = "YoloTitile",
44+
subtitle = null,
45+
backgroundColor = SomeColor(
46+
0f,
47+
188f,
48+
212f,
49+
1f
50+
),
51+
headerView = null,
52+
someView = SomeContainerView(
53+
id = null,
54+
axis = ViewDirectionAxis.vertical,
55+
someViews = arrayOf(
56+
"monkaW".toSomeLabel().toSomeView(),
57+
"pogs".toSomeLabel().toSomeView(),
58+
Pair("Something", "Worse").toSomeLabel().toSomeView(),
59+
"Pogs".toSomeLabel().toSomeView()
60+
),
61+
someStyle = null
62+
).toSomeView(),
63+
footerView = null
64+
)
65+
)
866
}

0 commit comments

Comments
 (0)