Skip to content

Commit fe0dbd8

Browse files
committed
Create calendar dialog
1 parent 6a78ad0 commit fe0dbd8

File tree

73 files changed

+2896
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+2896
-0
lines changed

Diff for: .gitignore

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Built application files
2+
*.apk
3+
*.ap_
4+
*.aab
5+
6+
# Files for the ART/Dalvik VM
7+
*.dex
8+
9+
# Java class files
10+
*.class
11+
12+
# Generated files
13+
bin/
14+
gen/
15+
out/
16+
release/
17+
18+
# Gradle files
19+
.gradle/
20+
build/
21+
22+
# Local configuration file (sdk path, etc)
23+
local.properties
24+
25+
# Proguard folder generated by Eclipse
26+
proguard/
27+
28+
# Log Files
29+
*.log
30+
31+
# Android Studio Navigation editor temp files
32+
.navigation/
33+
34+
# Android Studio captures folder
35+
captures/
36+
37+
# IntelliJ
38+
*.iml
39+
.idea/
40+
.idea/workspace.xml
41+
.idea/tasks.xml
42+
.idea/gradle.xml
43+
.idea/assetWizardSettings.xml
44+
.idea/dictionaries
45+
.idea/libraries
46+
# Android Studio 3 in .gitignore file.
47+
.idea/caches
48+
.idea/modules.xml
49+
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
50+
.idea/navEditor.xml
51+
52+
# Keystore files
53+
# Uncomment the following lines if you do not want to check your keystore files in.
54+
#*.jks
55+
#*.keystore
56+
57+
# External native build folder generated in Android Studio 2.2 and later
58+
.externalNativeBuild
59+
60+
# Google Services (e.g. APIs or Firebase)
61+
# google-services.json
62+
63+
# Freeline
64+
freeline.py
65+
freeline/
66+
freeline_project_description.json
67+
68+
# fastlane
69+
fastlane/report.xml
70+
fastlane/Preview.html
71+
fastlane/screenshots
72+
fastlane/test_output
73+
fastlane/readme.md
74+
75+
# Version control
76+
vcs.xml
77+
78+
# lint
79+
lint/intermediates/
80+
lint/generated/
81+
lint/outputs/
82+
lint/tmp/
83+
# lint/reports/
84+
85+
# Built application files
86+
/*/build/
87+
88+
# Signing files
89+
.signing/
90+
91+
# OS-specific files
92+
.DS_Store
93+
.DS_Store?
94+
._*
95+
.Spotlight-V100
96+
.Trashes
97+
ehthumbs.db
98+
Thumbs.db
99+

Diff for: app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

Diff for: app/build.gradle

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
plugins {
2+
id 'com.android.application'
3+
id 'org.jetbrains.kotlin.android'
4+
id "kotlin-android"
5+
}
6+
apply plugin: 'kotlin-android'
7+
8+
android {
9+
compileSdk 32
10+
11+
defaultConfig {
12+
applicationId "com.mk.sheets"
13+
minSdk 27
14+
targetSdk 32
15+
versionCode 1
16+
versionName "1.0"
17+
18+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
19+
vectorDrawables {
20+
useSupportLibrary true
21+
}
22+
}
23+
24+
buildTypes {
25+
release {
26+
minifyEnabled false
27+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
28+
}
29+
}
30+
compileOptions {
31+
sourceCompatibility JavaVersion.VERSION_1_8
32+
targetCompatibility JavaVersion.VERSION_1_8
33+
}
34+
kotlinOptions {
35+
jvmTarget = '1.8'
36+
}
37+
buildFeatures {
38+
compose true
39+
}
40+
composeOptions {
41+
kotlinCompilerExtensionVersion compose_version
42+
}
43+
packagingOptions {
44+
resources {
45+
excludes += '/META-INF/{AL2.0,LGPL2.1}'
46+
}
47+
}
48+
}
49+
50+
dependencies {
51+
52+
api project(':core')
53+
api project(':calendar')
54+
55+
implementation 'androidx.core:core-ktx:1.7.0'
56+
implementation "androidx.compose.ui:ui:$compose_version"
57+
implementation 'androidx.compose.material3:material3:1.0.0-alpha01'
58+
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
59+
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
60+
implementation 'androidx.activity:activity-compose:1.3.1'
61+
testImplementation 'junit:junit:4.13.2'
62+
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
63+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
64+
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
65+
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
66+
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
67+
implementation "androidx.core:core-ktx:+"
68+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
69+
}

Diff for: app/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.mk.sheets
2+
3+
import androidx.test.platform.app.InstrumentationRegistry
4+
import androidx.test.ext.junit.runners.AndroidJUnit4
5+
6+
import org.junit.Test
7+
import org.junit.runner.RunWith
8+
9+
import org.junit.Assert.*
10+
11+
/**
12+
* Instrumented test, which will execute on an Android device.
13+
*
14+
* See [testing documentation](http://d.android.com/tools/testing).
15+
*/
16+
@RunWith(AndroidJUnit4::class)
17+
class ExampleInstrumentedTest {
18+
@Test
19+
fun useAppContext() {
20+
// Context of the app under test.
21+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22+
assertEquals("com.mk.sheets", appContext.packageName)
23+
}
24+
}

Diff for: app/src/main/AndroidManifest.xml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
package="com.mk.sheets">
5+
6+
<application
7+
android:allowBackup="true"
8+
android:dataExtractionRules="@xml/data_extraction_rules"
9+
android:fullBackupContent="@xml/backup_rules"
10+
android:icon="@mipmap/ic_launcher"
11+
android:label="@string/app_name"
12+
android:roundIcon="@mipmap/ic_launcher_round"
13+
android:supportsRtl="true"
14+
android:theme="@style/Theme.SheetsCompose"
15+
tools:targetApi="31">
16+
<activity
17+
android:name=".MainActivity"
18+
android:exported="true"
19+
android:label="@string/app_name"
20+
android:theme="@style/Theme.SheetsCompose">
21+
<intent-filter>
22+
<action android:name="android.intent.action.MAIN" />
23+
24+
<category android:name="android.intent.category.LAUNCHER" />
25+
</intent-filter>
26+
</activity>
27+
</application>
28+
29+
</manifest>

Diff for: app/src/main/java/com/mk/sheets/MainActivity.kt

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
package com.mk.sheets
2+
3+
import android.os.Bundle
4+
import android.util.Range
5+
import androidx.activity.ComponentActivity
6+
import androidx.activity.compose.setContent
7+
import androidx.compose.foundation.clickable
8+
import androidx.compose.foundation.layout.fillMaxSize
9+
import androidx.compose.material3.ExperimentalMaterial3Api
10+
import androidx.compose.material3.MaterialTheme
11+
import androidx.compose.material3.Surface
12+
import androidx.compose.material3.Text
13+
import androidx.compose.runtime.Composable
14+
import androidx.compose.runtime.mutableStateOf
15+
import androidx.compose.runtime.remember
16+
import androidx.compose.ui.Modifier
17+
import androidx.compose.ui.tooling.preview.Preview
18+
import com.maxkeppeler.sheets.calendar.CalendarDialog
19+
import com.maxkeppeler.sheets.calendar.models.CalendarConfig
20+
import com.maxkeppeler.sheets.calendar.models.CalendarSelection
21+
import com.maxkeppeler.sheets.calendar.models.CalendarStyle
22+
import com.maxkeppeler.sheets.calendar.models.CalendarTimeline
23+
import com.mk.sheets.ui.theme.SheetsComposeTheme
24+
import java.time.LocalDate
25+
import kotlin.random.Random
26+
import kotlin.random.nextInt
27+
28+
@ExperimentalMaterial3Api
29+
class MainActivity : ComponentActivity() {
30+
override fun onCreate(savedInstanceState: Bundle?) {
31+
super.onCreate(savedInstanceState)
32+
setContent {
33+
SheetsComposeTheme {
34+
// A surface container using the 'background' color from the theme
35+
Surface(
36+
modifier = Modifier.fillMaxSize(),
37+
color = MaterialTheme.colorScheme.background
38+
) {
39+
40+
val dialogVisible = remember { mutableStateOf(true) }
41+
42+
val date = remember { mutableStateOf(LocalDate.now()) }
43+
Text(
44+
text = date.value.toString(),
45+
modifier = Modifier.clickable { dialogVisible.value = true })
46+
47+
val disabledDates = listOf(
48+
LocalDate.now().minusDays(Random.nextInt(60).toLong()),
49+
LocalDate.now().minusDays(Random.nextInt(30).toLong()),
50+
LocalDate.now().minusDays(Random.nextInt(30).toLong()),
51+
LocalDate.now().minusDays(Random.nextInt(30).toLong()),
52+
LocalDate.now().minusDays(Random.nextInt(30).toLong()),
53+
LocalDate.now().minusDays(Random.nextInt(30).toLong()),
54+
LocalDate.now().minusDays(Random.nextInt(30).toLong()),
55+
)
56+
57+
CalendarDialog(
58+
show = dialogVisible,
59+
config = CalendarConfig(
60+
minYear = 1900,
61+
maxYear = 2100,
62+
// monthSelection = true,
63+
yearSelection = true,
64+
monthSelection = true,
65+
// disabledTimeline = CalendarTimeline.FUTURE,
66+
style = CalendarStyle.WEEK,
67+
// disabledDates = disabledDates,
68+
// disabledTimeline = CalendarTimeline.PAST
69+
),
70+
// selection = CalendarSelection.Date(withButtons = true) {
71+
// date.value = it
72+
// }
73+
selection = CalendarSelection.Dates(
74+
positiveButtonText = "Yeahh",
75+
negativeButtonText = "Nahh"
76+
) {
77+
date.value = it.lastOrNull()
78+
}
79+
// selection = CalendarSelection.Period(
80+
// withButtons = Random.nextBoolean(),
81+
// selectedRange = Range(LocalDate.now().minusDays(4), LocalDate.now())
82+
// ) { start, end ->
83+
// date.value = end
84+
// }
85+
)
86+
87+
}
88+
}
89+
}
90+
}
91+
}
92+
93+
@Composable
94+
fun Greeting(name: String) {
95+
Text(text = "Hello $name!")
96+
}
97+
98+
@Preview(showBackground = true)
99+
@Composable
100+
fun DefaultPreview() {
101+
SheetsComposeTheme {
102+
Greeting("Android")
103+
}
104+
}

Diff for: app/src/main/java/com/mk/sheets/ui/theme/Color.kt

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.mk.sheets.ui.theme
2+
3+
import androidx.compose.ui.graphics.Color
4+
5+
val Purple80 = Color(0xFFD0BCFF)
6+
val PurpleGrey80 = Color(0xFFCCC2DC)
7+
val Pink80 = Color(0xFFEFB8C8)
8+
9+
val Purple40 = Color(0xFF6650a4)
10+
val PurpleGrey40 = Color(0xFF625b71)
11+
val Pink40 = Color(0xFF7D5260)

0 commit comments

Comments
 (0)