Skip to content

Commit

Permalink
Merge pull request #69 from Efimj/enhancement/minor
Browse files Browse the repository at this point in the history
Enhancement/minor
  • Loading branch information
Efimj authored Jul 15, 2024
2 parents b58d88e + 6165bc0 commit 96375cd
Show file tree
Hide file tree
Showing 9 changed files with 182 additions and 71 deletions.
Binary file added .idea/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
Expand All @@ -27,6 +28,7 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalUriHandler
Expand All @@ -42,6 +44,9 @@ import com.jobik.shkiper.helpers.IntentHelper
import com.jobik.shkiper.services.statistics.StatisticsService
import com.jobik.shkiper.ui.components.cards.MediaCard
import com.jobik.shkiper.ui.helpers.allWindowInsetsPadding
import com.jobik.shkiper.ui.helpers.bottomWindowInsetsPadding
import com.jobik.shkiper.ui.helpers.horizontalWindowInsetsPadding
import com.jobik.shkiper.ui.helpers.topWindowInsetsPadding
import com.jobik.shkiper.ui.theme.AppTheme
import com.jobik.shkiper.ui.theme.CustomThemeStyle
import com.jobik.shkiper.util.ContextUtils.isDarkModeEnabled
Expand All @@ -66,12 +71,10 @@ fun AboutNotepadScreen() {
.fillMaxSize()
.background(AppTheme.colors.background)
.verticalScroll(rememberScrollState())
.allWindowInsetsPadding()
.padding(top = 85.dp, bottom = 50.dp),
.horizontalWindowInsetsPadding(),
horizontalAlignment = Alignment.CenterHorizontally
) {
Header()
Spacer(modifier = Modifier.height(30.dp))
MediaContent()
}
}
Expand All @@ -92,7 +95,10 @@ private fun MediaContent() {
val uriHandler = LocalUriHandler.current

Column(
modifier = Modifier.padding(horizontal = 30.dp),
modifier = Modifier
.bottomWindowInsetsPadding()
.padding(top = 20.dp, bottom = 30.dp)
.padding(horizontal = 30.dp),
verticalArrangement = Arrangement.spacedBy(20.dp)
) {
MediaGroup(headline = stringResource(R.string.community), selected = selected == 0) {
Expand Down Expand Up @@ -234,20 +240,25 @@ private fun Header() {
}
}
Row(
modifier = Modifier.fillMaxWidth(),
modifier = Modifier
.fillMaxWidth()
.clip(RoundedCornerShape(bottomStart = 20.dp, bottomEnd = 20.dp))
.background(AppTheme.colors.container)
.topWindowInsetsPadding()
.padding(vertical = 30.dp),
horizontalArrangement = Arrangement.spacedBy(
space = 30.dp,
alignment = Alignment.CenterHorizontally
),
verticalAlignment = Alignment.CenterVertically
verticalAlignment = Alignment.Top
) {
Crossfade(
targetState = index,
animationSpec = tween(animationDelay),
label = "crossfade"
) { index ->
Image(
modifier = Modifier.size(160.dp),
modifier = Modifier.size(100.dp),
imageVector = ImageVector.vectorResource(id = icons[index]),
contentDescription = "icon",
)
Expand All @@ -268,7 +279,7 @@ private fun Header() {
text = stringResource(R.string.made_by_efim),
style = MaterialTheme.typography.titleMedium,
textAlign = TextAlign.Center,
color = AppTheme.colors.textSecondary,
color = AppTheme.colors.text,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
fontWeight = FontWeight.Normal
Expand All @@ -277,7 +288,7 @@ private fun Header() {
text = BuildConfig.VERSION_NAME,
style = MaterialTheme.typography.titleMedium,
textAlign = TextAlign.Center,
color = AppTheme.colors.textSecondary,
color = AppTheme.colors.text,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
fontWeight = FontWeight.Normal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package com.jobik.shkiper.screens.calendar
import androidx.activity.compose.BackHandler
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.DateRange
import androidx.compose.material3.Button
Expand Down Expand Up @@ -38,13 +38,13 @@ import java.util.*
@Composable
fun FullScreenCalendar(viewModel: CalendarViewModel) {
val currentMonth = remember { LocalDate.now().yearMonth }
val startMonth = remember { currentMonth }
val startMonth = remember { currentMonth.minusMonths(200) }
val endMonth = remember { currentMonth.plusMonths(200) }
val daysOfWeek = remember { daysOfWeek() }
val state = rememberCalendarState(
startMonth = startMonth,
endMonth = endMonth,
firstVisibleMonth = currentMonth,
firstVisibleMonth = viewModel.screenState.value.selectedDateRange.first.yearMonth,
firstDayOfWeek = daysOfWeek.first(),
outDateStyle = OutDateStyle.EndOfRow
)
Expand Down Expand Up @@ -103,7 +103,7 @@ fun FullScreenCalendar(viewModel: CalendarViewModel) {
Spacer(modifier = Modifier.width(10.dp))
Text(
text = stringResource(R.string.Apply),
style = MaterialTheme.typography.body1,
style = MaterialTheme.typography.titleMedium,
fontWeight = FontWeight.SemiBold,
color = AppTheme.colors.onPrimary,
maxLines = 1,
Expand All @@ -129,6 +129,7 @@ private fun DayContent(
CalendarDayView(
modifier = Modifier.padding(vertical = 4.dp),
day = day,
enabled = true,
isSelected = viewModel.screenState.value.selectedDateRange.first == day.date || viewModel.screenState.value.selectedDateRange.second == day.date,
showIndicator = day.date in viewModel.screenState.value.datesWithIndicator,
rangeStyle = inRange.value
Expand All @@ -140,7 +141,10 @@ private fun DayContent(
}
}

private fun inRange(date: LocalDate, range: Pair<LocalDate, LocalDate>): CalendarDayViewRangeStyle? {
private fun inRange(
date: LocalDate,
range: Pair<LocalDate, LocalDate>
): CalendarDayViewRangeStyle? {
if (date !in range.first..range.second) return null
if (range.first == range.second) return null

Expand Down Expand Up @@ -191,7 +195,7 @@ private fun MonthHeader(month: CalendarMonth) {
textAlign = TextAlign.Center,
text = month.yearMonth.displayText(),
color = AppTheme.colors.text,
style = MaterialTheme.typography.h6,
style = MaterialTheme.typography.headlineMedium,
fontWeight = FontWeight.SemiBold,
maxLines = 1,
overflow = TextOverflow.Ellipsis
Expand All @@ -212,7 +216,7 @@ private fun Header(daysOfWeek: List<DayOfWeek>) {
textAlign = TextAlign.Center,
text = dayOfWeek.getDisplayName(TextStyle.SHORT, Locale.getDefault()),
color = AppTheme.colors.textSecondary,
style = MaterialTheme.typography.body1,
style = MaterialTheme.typography.bodyMedium,
maxLines = 1,
overflow = TextOverflow.Clip,
fontWeight = FontWeight.SemiBold
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ fun ScreenCalendarTopBar(
val adjacentMonths = 500L
val currentDate = remember { LocalDate.now() }
val currentMonth = remember(currentDate) { currentDate.yearMonth }
val startMonth = remember(currentDate) { currentMonth }
val startMonth = remember(currentDate) { currentMonth.minusMonths(adjacentMonths) }
val endMonth = remember(currentDate) { currentMonth.plusMonths(adjacentMonths) }
val daysOfWeek = remember { daysOfWeek() }

val weekState = rememberWeekCalendarState(
startDate = startMonth.atStartOfMonth(),
endDate = endMonth.atEndOfMonth(),
firstVisibleWeekDate = currentDate,
firstVisibleWeekDate = viewModel.screenState.value.selectedDateRange.first,
firstDayOfWeek = daysOfWeek.first(),
)

Expand Down Expand Up @@ -82,7 +82,10 @@ fun ScreenCalendarTopBar(
dayContent = { day ->
val inRange = remember(viewModel.screenState.value.selectedDateRange) {
mutableStateOf(
inRange(date = day.date, range = viewModel.screenState.value.selectedDateRange)
inRange(
date = day.date,
range = viewModel.screenState.value.selectedDateRange
)
)
}

Expand All @@ -94,6 +97,7 @@ fun ScreenCalendarTopBar(
.height(60.dp)
.padding(4.dp),
day = day,
enabled = true,
rangeStyle = inRange.value,
isSelected = viewModel.screenState.value.selectedDateRange.first == day.date || viewModel.screenState.value.selectedDateRange.second == day.date,
showIndicator = day.date in viewModel.screenState.value.datesWithIndicator,
Expand All @@ -105,7 +109,10 @@ fun ScreenCalendarTopBar(
}
}

private fun inRange(date: LocalDate, range: Pair<LocalDate, LocalDate>): CalendarDayViewRangeStyle? {
private fun inRange(
date: LocalDate,
range: Pair<LocalDate, LocalDate>
): CalendarDayViewRangeStyle? {
if (date !in range.first..range.second) return null
if (range.first == range.second) return null
return CalendarDayViewRangeStyle.Rounded
Expand Down
135 changes: 95 additions & 40 deletions app/src/main/java/com/jobik/shkiper/screens/purchase/PurchaseScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,14 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.ClipboardManager
import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString
Expand Down Expand Up @@ -310,6 +312,14 @@ private fun ScreenContent(purchaseViewModel: PurchaseViewModel) {
)
}
Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
Text(
modifier = Modifier.fillMaxWidth(),
text = stringResource(R.string.high_taxes),
style = MaterialTheme.typography.bodyLarge,
fontWeight = FontWeight.Normal,
color = AppTheme.colors.textSecondary,
overflow = TextOverflow.Ellipsis,
)
Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
purchaseViewModel.screenState.value.purchases.forEachIndexed { index, it ->
ProductCard(
Expand Down Expand Up @@ -350,47 +360,40 @@ private fun ScreenContent(purchaseViewModel: PurchaseViewModel) {
val scope = rememberCoroutineScope()

Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
CryptoWalletCard(
isHighlight = highlight == 4,
image = R.drawable.ic_btc,
walletName = stringResource(id = R.string.btc),
walletAddress = stringResource(id = R.string.wallet_address_btc)
) {
copyToClipboard(
clipboardManager = clipboardManager,
context = context,
scope = scope,
walletAddress = context.getString(R.string.wallet_address_btc),
walletName = context.getString(R.string.btc)
)
}
CryptoWalletCard(
isHighlight = highlight == 5,
image = R.drawable.ic_eth,
walletName = stringResource(id = R.string.eth),
walletAddress = stringResource(id = R.string.wallet_address_eth)
) {
copyToClipboard(
clipboardManager = clipboardManager,
context = context,
scope = scope,
walletAddress = context.getString(R.string.wallet_address_eth),
walletName = context.getString(R.string.eth)
)
Text(
modifier = Modifier.fillMaxWidth(),
text = stringResource(R.string.minimal_taxes),
style = MaterialTheme.typography.bodyLarge,
fontWeight = FontWeight.Normal,
color = AppTheme.colors.textSecondary,
overflow = TextOverflow.Ellipsis,
)

val walletCards = listOf(
Triple(R.drawable.ic_btc, R.string.btc, R.string.wallet_address_btc),
Triple(R.drawable.ic_eth, R.string.eth, R.string.wallet_address_eth),
Triple(R.drawable.ic_usdt, R.string.usdt, R.string.wallet_address_usdt)
)

Box(modifier = Modifier.padding(bottom = 6.dp)) {
BuyMeACoffeeCard(isHighlight = highlight == 4)
}
CryptoWalletCard(
isHighlight = highlight == 6,
image = R.drawable.ic_usdt,
walletName = stringResource(id = R.string.usdt),
walletAddress = stringResource(id = R.string.wallet_address_usdt)
) {
copyToClipboard(
clipboardManager = clipboardManager,
context = context,
scope = scope,
walletAddress = context.getString(R.string.wallet_address_usdt),
walletName = context.getString(R.string.usdt)
)

walletCards.forEachIndexed { index, wallet ->
CryptoWalletCard(
isHighlight = highlight == index + 5,
image = wallet.first,
walletName = stringResource(id = wallet.second),
walletAddress = stringResource(id = wallet.third)
) {
copyToClipboard(
clipboardManager = clipboardManager,
context = context,
scope = scope,
walletAddress = context.getString(wallet.third),
walletName = context.getString(wallet.second)
)
}
}
}
}
Expand All @@ -415,6 +418,58 @@ private fun copyToClipboard(
}
}

@Composable
private fun BuyMeACoffeeCard(
isHighlight: Boolean = false
) {
val context = LocalContext.current
val uriHandler = LocalUriHandler.current

val scale by animateFloatAsState(if (isHighlight) 1.05f else 1f, tween(500))

Row(
modifier = Modifier
.graphicsLayer {
scaleX = scale
scaleY = scale
}
.bounceClick()
.clip(AppTheme.shapes.large)
.background(Color(0xFFF7D600))
.clickable {
uriHandler.openUri(context.getString(R.string.buy_me_a_coffee_link))
}
.padding(vertical = 10.dp, horizontal = 15.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(15.dp)
) {
Image(
modifier = Modifier.size(50.dp),
painter = painterResource(id = R.drawable.ic_buy_me_a_coffee),
contentDescription = null,
contentScale = ContentScale.FillHeight,
colorFilter = ColorFilter.tint(Color.Black)
)
Column(modifier = Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(3.dp)) {
Text(
modifier = Modifier.fillMaxWidth(),
text = stringResource(R.string.buy_me_a_coffee),
style = MaterialTheme.typography.titleLarge,
fontWeight = FontWeight.SemiBold,
color = Color.Black,
overflow = TextOverflow.Ellipsis,
)
Text(
modifier = Modifier.fillMaxWidth(),
text = stringResource(R.string.support_buy_me_a_coffee_description),
style = MaterialTheme.typography.bodyMedium,
color = Color.Black,
overflow = TextOverflow.Ellipsis,
)
}
}
}

@Composable
private fun CryptoWalletCard(
isHighlight: Boolean = false,
Expand Down
Loading

0 comments on commit 96375cd

Please sign in to comment.