1+ package de.berlindroid.zepatch.patchable
2+
3+ import androidx.compose.foundation.background
4+ import androidx.compose.foundation.layout.Column
5+ import androidx.compose.foundation.layout.Spacer
6+ import androidx.compose.foundation.layout.fillMaxWidth
7+ import androidx.compose.foundation.layout.size
8+ import androidx.compose.foundation.shape.RoundedCornerShape
9+ import androidx.compose.material3.Text
10+ import androidx.compose.material3.TextField
11+ import androidx.compose.runtime.Composable
12+ import androidx.compose.runtime.getValue
13+ import androidx.compose.runtime.mutableStateOf
14+ import androidx.compose.runtime.remember
15+ import androidx.compose.runtime.setValue
16+ import androidx.compose.ui.Modifier
17+ import androidx.compose.ui.graphics.Brush
18+ import androidx.compose.ui.graphics.Color
19+ import androidx.compose.ui.graphics.ImageBitmap
20+ import androidx.compose.ui.graphics.Shadow
21+ import androidx.compose.ui.text.TextStyle
22+ import androidx.compose.ui.text.font.FontFamily
23+ import androidx.compose.ui.text.font.FontStyle
24+ import androidx.compose.ui.text.font.FontWeight
25+ import androidx.compose.ui.text.style.TextAlign
26+ import androidx.compose.ui.tooling.preview.Preview
27+ import androidx.compose.ui.unit.dp
28+ import androidx.compose.ui.unit.sp
29+ import de.berlindroid.zepatch.annotations.Patch
30+ import de.berlindroid.zepatch.ui.SafeArea
31+
32+ @Patch(" AndyA" )
33+ @Composable
34+ fun AndyA (
35+ shouldCapture : Boolean = false,
36+ onBitmap : (ImageBitmap ) -> Unit = {},
37+ ) {
38+ var name by remember { mutableStateOf(" Andy" ) }
39+ Column {
40+ SafeArea (
41+ shouldCapture = shouldCapture,
42+ onBitmap = onBitmap,
43+ ) {
44+ Column (
45+ modifier = Modifier
46+ .size(200 .dp)
47+ .background(
48+ brush = Brush .linearGradient(
49+ colors = listOf (
50+ Color .Red ,
51+ Color .Yellow ,
52+ Color .Green ,
53+ Color .Blue ,
54+ Color .Cyan
55+ )
56+ ),
57+ shape = RoundedCornerShape (
58+ topStartPercent = 50 ,
59+ topEndPercent = 50 ,
60+ bottomStartPercent = 50 ,
61+ bottomEndPercent = 0
62+ )
63+ ),
64+ ) {
65+ Spacer (modifier = Modifier .weight(1f ))
66+ Text (
67+ modifier = Modifier .fillMaxWidth(),
68+ fontFamily = FontFamily .Cursive ,
69+ textAlign = TextAlign .Center ,
70+ fontStyle = FontStyle .Italic ,
71+ fontWeight = FontWeight .ExtraBold ,
72+ fontSize = 70 .sp,
73+ text = name,
74+ )
75+ Spacer (modifier = Modifier .weight(1f ))
76+ }
77+ }
78+ TextField (value = name, onValueChange = { name = it })
79+ }
80+ }
81+
82+ @Patch(" AndyB" )
83+ @Composable
84+ fun AndyB (
85+ shouldCapture : Boolean = false,
86+ onBitmap : (ImageBitmap ) -> Unit = {},
87+ ) {
88+ SafeArea (
89+ shouldCapture = shouldCapture,
90+ onBitmap = onBitmap,
91+ ) {
92+ Column (
93+ modifier = Modifier
94+ .size(200 .dp)
95+ .background(
96+ color = Color .White ,
97+ shape = RoundedCornerShape (
98+ topStartPercent = 0 ,
99+ topEndPercent = 50 ,
100+ bottomStartPercent = 50 ,
101+ bottomEndPercent = 0
102+ )
103+ ),
104+ ) {
105+ Spacer (modifier = Modifier .weight(1f ))
106+ Text (
107+ modifier = Modifier .fillMaxWidth(),
108+ fontFamily = FontFamily .Cursive ,
109+ textAlign = TextAlign .Center ,
110+ fontWeight = FontWeight .ExtraBold ,
111+ fontSize = 64 .sp,
112+ style = TextStyle .Default .copy(shadow = Shadow (blurRadius = 12f )),
113+ color = Color .Black ,
114+ text = " AndyB" ,
115+ letterSpacing = (- 1 ).sp
116+ )
117+ Spacer (modifier = Modifier .weight(1f ))
118+ }
119+ }
120+ }
121+
122+ @Preview
123+ @Composable
124+ fun PreviewAndyA () {
125+ AndyA ()
126+ }
127+
128+ @Preview
129+ @Composable
130+ fun PreviewAndyB () {
131+ AndyB ()
132+ }
0 commit comments