Skip to content

Commit

Permalink
update readme + fix ui of example + refactor scroll on year selector
Browse files Browse the repository at this point in the history
  • Loading branch information
Clémence Roumy committed Jun 23, 2023
1 parent 9fab650 commit 9dee2be
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 36 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ dependencies {

![Basis](./doc/multiDatePicker.png)

# Features

- [x] Single date picker
- [x] Range date picker (start date to end date)
- [x] Customizable colors
- [x] Quickly select year by clicking on the month/year title

# Usage

1. By selecting a day on the first click, it will set the startDate value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,44 +63,51 @@ class MainActivity : ComponentActivity() {
.padding(paddings)
.padding(horizontal = 10.dp)
.fillMaxSize(),
verticalArrangement = Arrangement.Center,
) {
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
Column(
Modifier
.weight(1f),
verticalArrangement = Arrangement.Bottom,
) {
Text(
text = "startDate : ",
style = MaterialTheme.typography.bodyMedium.copy(fontWeight = FontWeight.Bold),
)
Spacer(Modifier.width(10.dp))
Text(
text = startDate.value?.asString("dd/MM/YYYY") ?: "null",
style = MaterialTheme.typography.bodyMedium,
)
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
) {
Text(
text = "startDate : ",
style = MaterialTheme.typography.bodyMedium.copy(fontWeight = FontWeight.Bold),
)
Spacer(Modifier.width(10.dp))
Text(
text = startDate.value?.asString("dd/MM/YYYY") ?: "null",
style = MaterialTheme.typography.bodyMedium,
)
}
Spacer(Modifier.height(5.dp))
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
) {
Text(
text = "endDate : ",
style = MaterialTheme.typography.bodyMedium.copy(fontWeight = FontWeight.Bold),
)
Spacer(Modifier.width(5.dp))
Text(
text = endDate.value?.asString("dd/MM/YYYY") ?: "null",
style = MaterialTheme.typography.bodyMedium,
)
}
Spacer(Modifier.height(20.dp))
}
Spacer(Modifier.height(5.dp))
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
) {
Text(
text = "endDate : ",
style = MaterialTheme.typography.bodyMedium.copy(fontWeight = FontWeight.Bold),
)
Spacer(Modifier.width(5.dp))
Text(
text = endDate.value?.asString("dd/MM/YYYY") ?: "null",
style = MaterialTheme.typography.bodyMedium,
Column( modifier = Modifier.weight(2f)) {
MultiDatePicker(
minDate = min.time,
maxDate = max.time,
startDate = startDate,
endDate = endDate,
)
}
Spacer(Modifier.height(20.dp))
MultiDatePicker(
minDate = min.time,
maxDate = max.time,
startDate = startDate,
endDate = endDate,
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ fun MultiDatePicker(
val calendar = remember { mutableStateOf(Calendar.getInstance()) }
val currDate = remember { mutableStateOf(calendar.value.time) }
val isSelectYear = remember { mutableStateOf(false) }
val yearScrollState = rememberLazyListState(
initialFirstVisibleItemIndex = allYears.indexOf(calendar.value.get(Calendar.YEAR)) - 3,
)
val yearScrollState = rememberLazyListState()
val pickerHeight = remember { mutableStateOf(0.dp) }

LaunchedEffect(isSelectYear.value) {
Expand Down

0 comments on commit 9dee2be

Please sign in to comment.