Skip to content

Commit 0bff175

Browse files
committed
Add search
1 parent 4b5726c commit 0bff175

2 files changed

Lines changed: 103 additions & 0 deletions

File tree

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
package de.berlindroid.zepatch.patchable
2+
3+
import androidx.compose.foundation.border
4+
import androidx.compose.foundation.layout.padding
5+
import androidx.compose.foundation.layout.wrapContentWidth
6+
import androidx.compose.foundation.shape.RoundedCornerShape
7+
import androidx.compose.material.icons.Icons
8+
import androidx.compose.material.icons.filled.Search
9+
import androidx.compose.material3.Text
10+
import androidx.compose.material3.TextFieldDefaults
11+
import androidx.compose.runtime.Composable
12+
import androidx.compose.ui.Modifier
13+
import androidx.compose.ui.graphics.Color
14+
import androidx.compose.ui.graphics.ImageBitmap
15+
import androidx.compose.ui.res.painterResource
16+
import androidx.compose.ui.text.font.FontWeight
17+
import androidx.compose.ui.tooling.preview.Preview
18+
import androidx.compose.ui.unit.dp
19+
import androidx.compose.ui.unit.sp
20+
import de.berlindroid.zepatch.R
21+
import de.berlindroid.zepatch.annotations.Patch
22+
import de.berlindroid.zepatch.ui.SafeArea
23+
24+
val borderColor = Color(0xFFFD6638) // alternative Color(0xFF6750A4)
25+
val backgroundColor = borderColor.copy(alpha = 0.2f)
26+
27+
@Preview
28+
@Composable
29+
fun PreviewSearch() {
30+
Search()
31+
}
32+
33+
@Patch("Search")
34+
@Composable
35+
fun Search(
36+
shouldCapture: Boolean = false,
37+
onBitmap: (ImageBitmap) -> Unit = {},
38+
) {
39+
40+
SafeArea(
41+
shouldCapture = shouldCapture,
42+
onBitmap = onBitmap,
43+
) {
44+
androidx.compose.material3.TextField(
45+
value = "",
46+
onValueChange = {},
47+
placeholder = {
48+
49+
Text(
50+
text = " ",
51+
fontSize = 16.sp,
52+
fontWeight = FontWeight.SemiBold
53+
)
54+
},
55+
leadingIcon = {
56+
androidx.compose.material3.Icon(
57+
imageVector = Icons.Default.Search,
58+
contentDescription = "Search"
59+
)
60+
},
61+
singleLine = true,
62+
shape = RoundedCornerShape(24.dp),
63+
colors = TextFieldDefaults.colors(
64+
unfocusedIndicatorColor = Color.Transparent,
65+
focusedIndicatorColor = Color.Transparent,
66+
disabledIndicatorColor = Color.Transparent,
67+
focusedContainerColor = backgroundColor,
68+
unfocusedContainerColor = backgroundColor,
69+
disabledContainerColor = backgroundColor,
70+
errorContainerColor = backgroundColor,
71+
72+
),
73+
trailingIcon = {
74+
75+
androidx.compose.material3.Icon(
76+
contentDescription = "Speak",
77+
modifier = Modifier.padding(end = 8.dp),
78+
painter = painterResource(R.drawable.mic_24dp_e3e3e3),
79+
)
80+
},
81+
modifier = Modifier
82+
.padding(16.dp)
83+
.border(
84+
width = 2.dp,
85+
color = borderColor,
86+
shape = RoundedCornerShape(24.dp)
87+
)
88+
.wrapContentWidth()
89+
)
90+
}
91+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24">
6+
<path
7+
android:pathData="M12,14c1.66,0 3,-1.34 3,-3V5c0,-1.66 -1.34,-3 -3,-3S9,3.34 9,5v6C9,12.66 10.34,14 12,14z"
8+
android:fillColor="#e3e3e3"/>
9+
<path
10+
android:pathData="M17,11c0,2.76 -2.24,5 -5,5s-5,-2.24 -5,-5H5c0,3.53 2.61,6.43 6,6.92V21h2v-3.08c3.39,-0.49 6,-3.39 6,-6.92H17z"
11+
android:fillColor="#e3e3e3"/>
12+
</vector>

0 commit comments

Comments
 (0)