Skip to content

Commit d3c256a

Browse files
committed
style(ui): add TextStyle drop shadow support; use on RoomCard
Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent f0431e2 commit d3c256a

2 files changed

Lines changed: 39 additions & 8 deletions

File tree

  • flipchatApp/src/main/kotlin/xyz/flipchat/app/ui/room
  • ui/components/src/main/kotlin/com/getcode/ui/utils

flipchatApp/src/main/kotlin/xyz/flipchat/app/ui/room/RoomCard.kt

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import androidx.compose.ui.draw.clip
2424
import androidx.compose.ui.geometry.Offset
2525
import androidx.compose.ui.graphics.Brush
2626
import androidx.compose.ui.graphics.Color
27+
import androidx.compose.ui.graphics.Shadow
2728
import androidx.compose.ui.platform.LocalDensity
2829
import androidx.compose.ui.res.painterResource
2930
import androidx.compose.ui.res.pluralStringResource
@@ -44,6 +45,7 @@ import com.getcode.ui.utils.ConstraintMode
4445
import com.getcode.ui.utils.Geometry
4546
import com.getcode.ui.utils.constrain
4647
import com.getcode.ui.utils.measured
48+
import com.getcode.ui.utils.withDropShadow
4749
import com.getcode.util.resources.LocalResources
4850
import com.getcode.utils.Kin
4951
import com.getcode.utils.decodeBase58
@@ -92,7 +94,8 @@ fun RoomCard(
9294
0.67f to roomInfo.gradientColors.third,
9395
),
9496
),
95-
).background(
97+
)
98+
.background(
9699
brush = Brush.radialGradient(
97100
colors = listOf(Color.White.copy(0.65f), Color.Transparent),
98101
center = Offset(-200f, -200f),
@@ -142,7 +145,9 @@ fun RoomCard(
142145
)
143146
) { textSize = it },
144147
text = roomInfo.title,
145-
style = CodeTheme.typography.displaySmall.copy(fontSize = textSize),
148+
style = CodeTheme.typography.displaySmall
149+
.copy(fontSize = textSize,)
150+
.withDropShadow(),
146151
color = Color.White,
147152
maxLines = 1
148153
)
@@ -155,18 +160,26 @@ fun RoomCard(
155160
) {
156161
if (roomInfo.hostName != null) {
157162
Text(
158-
text = stringResource(R.string.title_roomCardHostedBy, roomInfo.hostName),
159-
style = CodeTheme.typography.textSmall,
163+
text = stringResource(
164+
R.string.title_roomCardHostedBy,
165+
roomInfo.hostName
166+
),
167+
style = CodeTheme.typography.textSmall.withDropShadow(),
160168
color = Color.White.copy(0.80f)
161169
)
162170
}
163171
Text(
164-
text = pluralStringResource(R.plurals.title_roomCardMemberCount, roomInfo.memberCount, roomInfo.memberCount),
165-
style = CodeTheme.typography.textSmall,
172+
text = pluralStringResource(
173+
R.plurals.title_roomCardMemberCount,
174+
roomInfo.memberCount,
175+
roomInfo.memberCount
176+
),
177+
style = CodeTheme.typography.textSmall.withDropShadow(),
166178
color = Color.White.copy(0.80f)
167179
)
168180
Text(
169-
text = stringResource(R.string.title_roomCardJoinCost,
181+
text = stringResource(
182+
R.string.title_roomCardJoinCost,
170183
formatAmountString(
171184
resources = LocalResources.current!!,
172185
currency = Currency.Kin,
@@ -175,7 +188,7 @@ fun RoomCard(
175188
)
176189
),
177190
textAlign = TextAlign.Center,
178-
style = CodeTheme.typography.textSmall,
191+
style = CodeTheme.typography.textSmall.withDropShadow(),
179192
color = Color.White.copy(0.80f)
180193
)
181194
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.getcode.ui.utils
2+
3+
import androidx.compose.ui.geometry.Offset
4+
import androidx.compose.ui.graphics.Color
5+
import androidx.compose.ui.graphics.Shadow
6+
import androidx.compose.ui.text.TextStyle
7+
8+
fun TextStyle.withDropShadow(
9+
color: Color = Color.Black.copy(alpha = 0.5f),
10+
offset: Offset = Offset(4f, 4f),
11+
blurRadius: Float = 8f,
12+
): TextStyle = copy(
13+
shadow = Shadow(
14+
color = color,
15+
offset = offset,
16+
blurRadius = blurRadius
17+
)
18+
)

0 commit comments

Comments
 (0)