Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upstream fetch #3

Merged
merged 33 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
0768d84
Add module with a support for kotlinx-datetime (#61)
boguszpawlowski Apr 16, 2022
2492ad7
Change working in Readme KotlinXDateTime section.
boguszpawlowski Apr 16, 2022
4ae9e0e
Add compatibility check to workflow (#62)
boguszpawlowski Apr 16, 2022
1fb5cfc
Fix wrong implementation of decrementing and incrementing months (#67)
boguszpawlowski May 1, 2022
269a63e
Add vetoing functionality to the selection state (#68)
boguszpawlowski May 1, 2022
6e0a936
Run ui tests on FTL on CI (#70)
boguszpawlowski May 11, 2022
45c3e4a
Bump Compose to 1.2.0 (#74)
boguszpawlowski Jul 29, 2022
6a1f424
Add information about compose versions to the Readme (#75)
boguszpawlowski Jul 29, 2022
c491f7e
Add screenshot back to the readme (#76)
boguszpawlowski Jul 30, 2022
6a1b44a
Add vertical center alignment into DefaultMonthHeader (#78)
jeongth9446 Sep 14, 2022
6fa69c9
Bump dependencies (#77)
boguszpawlowski Oct 17, 2022
e46fed1
Update README.md
boguszpawlowski Oct 17, 2022
f2886b9
Revert version of publish plugin (#82)
boguszpawlowski Oct 31, 2022
269c795
Update README.md
boguszpawlowski Oct 31, 2022
93a25fb
Update README.md
boguszpawlowski Oct 31, 2022
f5f2f02
Remove pager in favor of lazy list (#85)
boguszpawlowski Nov 13, 2022
f070b62
Update README.md
boguszpawlowski Nov 13, 2022
9435077
Simplify calculating showed month, add animations when changing month…
boguszpawlowski Nov 15, 2022
4109165
Add Week calendar (#91)
boguszpawlowski Mar 3, 2023
29258fb
Add info about new Compose version in readme (#92)
boguszpawlowski Mar 3, 2023
2962892
Update README.md
boguszpawlowski Mar 14, 2023
d7cd040
Add month changes throttling (#95)
boguszpawlowski Mar 18, 2023
6a3c71b
Add api call scenario to viewmodel sample (#100)
boguszpawlowski May 17, 2023
2a9692b
Update publishing plugin (#101)
boguszpawlowski May 17, 2023
50aa31a
Update sample code in the readme to be valid (#109)
yonghanJu Aug 25, 2023
3ad64ca
Make week header optionally not scrollable (#107)
anvukelic Sep 27, 2023
a3ad7a4
Added support for min and max month (#113)
kevinvanmierlo Jan 23, 2024
1cdea2b
Migrate to gradle 8.2.0 (#115)
boguszpawlowski Jan 23, 2024
5a46a78
Add min/max week (#116)
boguszpawlowski Jan 27, 2024
b345a86
Fix publishing snapshots (#117)
boguszpawlowski Jan 28, 2024
1562277
Upstream fetch
shrikanth-zuper Feb 21, 2024
f000c02
Merge branch 'main' into refactoring/Feb2024Fetch
shrikanth-zuper Feb 21, 2024
621179a
Fixes
shrikanth-zuper Feb 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,57 @@
name: Check
on:
pull_request:

jobs:
detekt:
name: Detekt Check
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Cache Gradle
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: |
~/.gradle/caches/
~/.gradle/wrapper/
key: cache-gradle-${{ hashFiles('**/*.gradle', '**/gradle-wrapper.properties') }}
restore-keys: cache-gradle-

- name: Setup Java 15
uses: actions/setup-java@v1
- name: Setup Java 17
uses: actions/setup-java@v3
with:
java-version: '15'
distribution: zulu
java-version: 17

- name: Run Detekt
run: ./gradlew detekt --stacktrace

- name: Stop Gradle
run: ./gradlew --stop

unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Cache Gradle
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: |
~/.gradle/caches/
~/.gradle/wrapper/
key: cache-gradle-${{ hashFiles('**/*.gradle', '**/gradle-wrapper.properties') }}
restore-keys: cache-gradle-

- name: Setup Java 15
uses: actions/setup-java@v1
- name: Setup Java 17
uses: actions/setup-java@v3
with:
java-version: '15'
distribution: zulu
java-version: 17

- name: Run Debug Unit Tests
run: ./gradlew test --stacktrace
Expand Down
40 changes: 0 additions & 40 deletions .github/workflows/publish-snapshot.yml

This file was deleted.

52 changes: 0 additions & 52 deletions .github/workflows/publish.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/publish_package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'adopt'
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b
Expand Down
5 changes: 0 additions & 5 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 31 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ Library is available on jitpack.

## Supported features
- Selection (single, multiple or a range of days)
- Every day as first day of week
- Chose day as first day of week
- Showing/hiding adjacent months
- Month and week headers
- Customizable month container
- Fully customizable day content
- Horizontal swipe for changing a current month
- Month / Week mode
- Min / Max Month (or Week)

## Basic Usage
Initialize the timezone information in your Application.onCreate() method
Expand All @@ -42,7 +44,15 @@ To show the basic version of the calendar, without any kind of selection mechani

```
This chunk will render the calendar with default components for each day, and also month and week headers.
See the `StaticCalendarSample` file for a full example.
See the `StaticCalendarSample` file for a full example. For showing a week calendar, you can similarly use `StaticWeekCalendar`:
```kotlin

@Composable
fun MainScreen() {
StaticWeekCalendar()
}

```

<img src="https://github.com/boguszpawlowski/ComposeCalendar/blob/main/blob/screenshot_1.jpg" width="260">

Expand All @@ -59,7 +69,16 @@ Calendar with a mechanism for selection. The default implementation uses `Dynami

```
By the default, after changing the selection mode, selection is cleared.
See the `SelectableCalendarSample` file for a full example
See the `SelectableCalendarSample` file for a full example. For showing a week calendar, you can similarly use `SelectableWeekCalendar`:
```kotlin

@Composable
fun MainScreen() {
SelectableWeekCalendar()
}

```
See the `WeekCalendarSample` file for a full example.

https://user-images.githubusercontent.com/36514058/126049987-685a7b81-1596-48a4-95a1-c342f6c796bf.mp4

Expand Down Expand Up @@ -117,6 +136,10 @@ Apart from rendering your own components inside the calendar, you can modify it
- `showAdjacentMonths` - whenever to render days from adjacent months. Defaults to `true`.
- `firstDayOfWeek` - you can pass the `DayOfWeek` which you want you week to start with. It defaults to the first day of week of the `Locale.default()`.
- `horizontalScrollEnabled` - a Boolean flag which enables month to be changed by a horizontal swipe. Defaults to `true`.
- `minMonth` - a `YearMonth` object representing the minimum month that can be shown in the calendar. By default there is no minimum month.
- `maxMonth` - a `YearMonth` object representing the maximum month that can be shown in the calendar. By default there is no maximum month.

> :exclamation: You cannot set `minMonth` to be lower than `maxMonth` and vice versa. If you do so, the calendar state won't change.

Apart from this, `Calendar` you can pass a `Modifier` object like in any other composable.

Expand All @@ -137,7 +160,7 @@ Initial state for the static calendar is provided by the `rememberCalendarState(
fun MainScreen() {
StaticCalendar(
calendarState = rememberCalendarState(
initialDate = YearMonth.now().plusYears(1),
initialMonth = YearMonth.now().plusYears(1),
)
)
}
Expand All @@ -151,7 +174,7 @@ In case of the selectable calendar, the state has additional parameters, used to
fun MainScreen() {
SelectableCalendar(
calendarState = rememberSelectableCalendarState(
initialDate = YearMonth.now().plusYears(1),
initialMonth = YearMonth.now().plusYears(1),
initialSelection = listOf(LocalDate.parse("20-01-2020")),
initialSelectionMode = SelectionMode.Period,
)
Expand All @@ -172,7 +195,7 @@ you need to hoist the state out of the `Calendar` composable:
StaticCalendar(calendarState = calendarState)

// now you can manipulate the state from scope of this composable
calendarState.monthState.currentMonth = MonthYear.of(2020, 5)
calendarState.monthState.currentMonth = YearMonth.of(2020, 5)
}

```
Expand All @@ -186,9 +209,8 @@ Selection modes are represented by `SelectionMode` enum, with following values:
- `Period` - selectable period - implemented by `start` and `end` dates. - selection will contain all dates between start and the end date.
This implementation of SelectionState also allows for handling side-effects and vetoing the state change via `confirmSelectionChange` callback.

## KotlinX DateTime
As the core of the library is built on `java.time` library, on Android it requires to use [core libary desugaring](https://developer.android.com/studio/write/java8-support) to be able to access it's API.
As a result it's features may be unavailable to some project built around different date-time libraries (e.g. kotlinx-datetime). Although the project wont be migrating from `java.time`, as it's the best suited for it, there is a separate `kotlinx-datetime` artifact for those who need to use the library from a codebase based on it. It doesn't consist of a separate version of `ComposeCalendar` features, but offers a small bunch of utilities, that will enable you to create your own wrapper, as briefly presented in `KotlinDateTimeSample`. If the provided functionality, doesn't match your use-case, please submit an issue.
## Week Calendar
Apart from the default calendar, there is also a week calendar, which shows a single week at a time. It can be used in the same way as the default calendar, and has the same customization options.

## License

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ allprojects {

tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "11"
jvmTarget = "17"
freeCompilerArgs = freeCompilerArgs + listOf(
"-progressive",
"-Xopt-in=kotlin.RequiresOptIn",
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ gradlePlugin {
}

dependencies {
implementation("com.android.tools.build:gradle:7.2.1")
implementation(kotlin("gradle-plugin", "1.7.20"))
implementation("com.android.tools.build:gradle:8.2.0")
implementation(kotlin("gradle-plugin", "1.8.10"))
}
6 changes: 3 additions & 3 deletions buildSrc/src/main/kotlin/CommonAndroidPlugin.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import com.android.build.gradle.BaseExtension
import org.gradle.api.JavaVersion.VERSION_1_8
import org.gradle.api.JavaVersion.VERSION_17
import org.gradle.api.Plugin
import org.gradle.api.Project

Expand All @@ -18,8 +18,8 @@ class CommonAndroidPlugin : Plugin<Project> {
}

compileOptions {
sourceCompatibility = VERSION_1_8
targetCompatibility = VERSION_1_8
sourceCompatibility = VERSION_17
targetCompatibility = VERSION_17
isCoreLibraryDesugaringEnabled = false
}

Expand Down
25 changes: 15 additions & 10 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
@file:Suppress("ObjectPropertyNaming", "ClassNaming", "UnderscoresInNumericLiterals")
object AndroidSdk {
const val Min = 21
const val Compile = 32
const val Compile = 33
const val Target = Compile
}

object Kotlin {
const val Version = "1.7.20"
const val Version = "1.9.20"
const val CompatibilityPluginVersion = "0.11.0"

const val GradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$Version"
const val DokkaGradlePlugin = "org.jetbrains.dokka:dokka-gradle-plugin:$Version"
const val DokkaGradlePlugin = "org.jetbrains.dokka:dokka-gradle-plugin:1.7.20"

const val SafeArgsPlugin = "androidx.navigation:navigation-safe-args-gradle-plugin:2.2.0"

Expand All @@ -29,7 +29,7 @@ object Kotlin {
}

object Android {
const val GradlePlugin = "com.android.tools.build:gradle:7.2.1"
const val GradlePlugin = "com.android.tools.build:gradle:8.2.0"

const val ApplicationPluginId = "com.android.application"
const val LibraryPluginId = "com.android.library"
Expand Down Expand Up @@ -72,16 +72,16 @@ object AndroidX {
const val Version = "1.0.0"
const val LifecycleVersion = "2.2.0"

const val AppCompat = "androidx.appcompat:appcompat:1.4.1"
const val ComposeActivity = "androidx.activity:activity-compose:1.5.1"
const val AppCompat = "androidx.appcompat:appcompat:1.6.1"
const val ComposeActivity = "androidx.activity:activity-compose:1.6.1"
}

object Material {
const val Core = "com.google.android.material:material:1.5.0"
}

object DetektLib {
const val Version = "1.21.0"
const val Version = "1.23.4"

const val PluginId = "io.gitlab.arturbosch.detekt"
const val Plugin = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:$Version"
Expand All @@ -96,8 +96,8 @@ object Timber {
}

object Compose {
const val Version = "1.2.1"
const val CompilerVersion = "1.3.2"
const val Version = "1.3.1"
const val CompilerVersion = "1.4.3"
const val AccompanistVersion = "0.25.1"

const val Runtime = "androidx.compose.runtime:runtime:$Version"
Expand Down Expand Up @@ -127,7 +127,7 @@ object Hyperion {
}

object Kotest {
const val Version = "5.1.0"
const val Version = "5.4.2"

const val RunnerJunit5 = "io.kotest:kotest-runner-junit5-jvm:$Version"

Expand All @@ -144,3 +144,8 @@ object ComposeTest {
const val Core = "androidx.compose.ui:ui-test-junit4:${Compose.Version}"
const val Manifest = "androidx.compose.ui:ui-test-manifest:${Compose.Version}"
}

object Firebase {
const val Bom = "com.google.firebase:firebase-bom:30.0.0"
const val GoogleServicesPlugin = "com.google.gms:google-services:4.3.10"
}
Loading
Loading