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

Interface #132

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .idea/gradle.xml

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

2 changes: 1 addition & 1 deletion .idea/misc.xml

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

Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@

package com.himanshoe.kalendarsample

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.*
import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
Expand Down
71 changes: 20 additions & 51 deletions app/src/main/java/com/himanshoe/kalendarsample/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,67 +14,36 @@

package com.himanshoe.kalendarsample

import android.os.Build
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.ui.Modifier
import com.himanshoe.kalendar.endlos.KalendarEarthy
import androidx.annotation.RequiresApi
import androidx.compose.ui.graphics.Color
import com.himanshoe.kalendar.color.KalendarColor
import com.himanshoe.kalendar.color.KalendarColors
import com.himanshoe.kalendarsample.ui.theme.KalendarTheme
import kotlinx.datetime.toKotlinLocalDate

class MainActivity : ComponentActivity() {
@OptIn(ExperimentalFoundationApi::class)
@RequiresApi(Build.VERSION_CODES.O)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
KalendarTheme {
Column {
// val events = (0..5).map {
// KalendarEvent(
// date = Clock.System.todayIn(
// TimeZone.currentSystemDefault()
// ).plus(it, DateTimeUnit.DAY),
// eventName = it.toString(),
// )
// }
// val events1 = (0..5).map {
// com.himanshoe.kalendar.KalendarEvent(
// date = Clock.System.todayIn(
// TimeZone.currentSystemDefault()
// ).plus(it, DateTimeUnit.DAY),
// eventName = it.toString(),
// )
// }
// com.himanshoe.kalendar.Kalendar(
// currentDay = Clock.System.todayIn(
// TimeZone.currentSystemDefault()
// ),
// kalendarType = KalendarType.Oceanic,
// events = com.himanshoe.kalendar.KalendarEvents(events1 + events1 + events1)
//
// )
// Spacer(modifier = Modifier.padding(vertical = 8.dp))
// com.himanshoe.kalendar.Kalendar(
// currentDay = Clock.System.todayIn(
// TimeZone.currentSystemDefault()
// ),
// kalendarType = KalendarType.Firey,
// daySelectionMode = DaySelectionMode.Range,
// events = com.himanshoe.kalendar.KalendarEvents(events1 + events1 + events1),
// onRangeSelected = { range, rangeEvents ->
// Log.d(":SDfsdfsdfdsfsdfsdf",range.toString())
// Log.d(":SDfsdfsdfdsfsdfsdf",rangeEvents.toString())
// }
// )
// Spacer(modifier = Modifier.padding(vertical = 8.dp))
KalendarEarthy(modifier = Modifier.fillMaxWidth())
// Kalendar(
// modifier = Modifier.fillMaxSize(),
// events = KalendarEvents(events + events)
// )
}
com.himanshoe.kalendar.Kalendar(
currentDay = java.time.LocalDate.now().toKotlinLocalDate(),
kalendarType = com.himanshoe.kalendar.KalendarType.Firey,
kalendarColors = KalendarColors(
color = listOf(
KalendarColor(
backgroundColor = Color.Black,
dayBackgroundColor = Color.Blue,
headerTextColor = Color.Red
)
)
)
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@

package com.himanshoe.kalendarsample

import org.junit.Assert.assertEquals
import org.junit.Test

import org.junit.Assert.*

/**
* Example local unit test, which will execute on the development machine (host).
*
Expand Down
1 change: 1 addition & 0 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
jdk: openjdk17
16 changes: 8 additions & 8 deletions kalendar-endlos/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
# Maven
POM_ARTIFACT_ID=kalendar-endlos
POM_NAME=Kalendar Endlos
POM_DESCRIPTION=An Elementary Compose Calendar for Scrolling Calendar.
POM_DESCRIPTION=An Elementary Compose Calenda for Scrolling Calendar.
POM_PACKAGING=aar
POM_INCEPTION_YEAR=2022
GROUP=com.himanshoe
VERSION_NAME=1.3.1
GROUP=com.morganesoula
VERSION_NAME=1.3.2-SNAPSHOT
VERSION_CODE=1
POM_URL=https://github.com/hi-manshu
POM_URL=https://github.com/morganesoula
POM_LICENCE_NAME=The Apache Software License, Version 2.0
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENCE_DIST=repo
POM_SCM_URL=https://github.com/hi-manshu
POM_DEVELOPER_ID=hi-manshu
POM_DEVELOPER_NAME=Himanshu Singh
POM_DEVELOPER_URL=https://github.com/hi-manshu
POM_SCM_URL=https://github.com/morganesoula
POM_DEVELOPER_ID=morganesoula
POM_DEVELOPER_NAME=Morgane Soula
POM_DEVELOPER_URL=https://github.com/morganesoula
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ import kotlinx.datetime.LocalDate
* @param eventDescription The description or additional details of the event (optional).
*/
@Immutable
data class KalendarEvent(
val date: LocalDate,
val eventName: String,
val eventDescription: String? = null
)
interface KalendarEvent {
val date: LocalDate
val eventName: String
val eventDescription: String?
}

/**
* Represents a collection of calendar events.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.Text
Expand All @@ -42,13 +40,9 @@ import com.himanshoe.kalendar.endlos.ui.KalendarIndicator
import com.himanshoe.kalendar.endlos.ui.color.KalendarColor
import com.himanshoe.kalendar.endlos.ui.modifier.circleLayout
import com.himanshoe.kalendar.endlos.ui.modifier.dayBackgroundColor
import com.himanshoe.kalendar.endlos.util.MultiplePreviews
import kotlinx.datetime.Clock
import kotlinx.datetime.DateTimeUnit
import kotlinx.datetime.LocalDate
import kotlinx.datetime.TimeZone
import kotlinx.datetime.minus
import kotlinx.datetime.plus
import kotlinx.datetime.todayIn

/**
Expand Down Expand Up @@ -137,7 +131,10 @@ private fun getBorder(currentDay: Boolean, color: Color, selected: Boolean): Bor
}
}

@Composable
/**
* Since KalendarEvent is an interface, you should implement your own KalendarEvent class and use this new one
*/
/* @Composable
@MultiplePreviews
private fun KalendarDayPreview() {
val date = Clock.System.todayIn(TimeZone.currentSystemDefault())
Expand Down Expand Up @@ -176,4 +173,4 @@ private fun KalendarDayPreview() {
selectedRange = null
)
}
}
} */
14 changes: 7 additions & 7 deletions kalendar/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ POM_NAME=kalendar
POM_DESCRIPTION=An Elementary Compose Calendar.
POM_PACKAGING=aar
POM_INCEPTION_YEAR=2022
GROUP=com.himanshoe
VERSION_NAME=1.3.1
GROUP=com.morganesoula
VERSION_NAME=1.3.2-SNAPSHOT
VERSION_CODE=1
POM_URL=https://github.com/hi-manshu
POM_URL=https://github.com/morganesoula
POM_LICENCE_NAME=The Apache Software License, Version 2.0
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENCE_DIST=repo
POM_SCM_URL=https://github.com/hi-manshu
POM_DEVELOPER_ID=hi-manshu
POM_DEVELOPER_NAME=Himanshu Singh
POM_DEVELOPER_URL=https://github.com/hi-manshu
POM_SCM_URL=https://github.com/morganesoula
POM_DEVELOPER_ID=morganesoula
POM_DEVELOPER_NAME=Morgane Soula
POM_DEVELOPER_URL=https://github.com/morganesoula
2 changes: 1 addition & 1 deletion kalendar/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
~
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>

</manifest>
12 changes: 6 additions & 6 deletions kalendar/src/main/java/com/himanshoe/kalendar/KalendarEvents.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ import kotlinx.datetime.LocalDate
/**
* Represents a calendar event.
*
* @param date The date of the event.
* @param The date of the event.
* @param eventName The name or title of the event.
* @param eventDescription The description or additional details of the event (optional).
*/
@Immutable
data class KalendarEvent(
val date: LocalDate,
val eventName: String,
val eventDescription: String? = null
)
interface KalendarEvent {
val date: LocalDate
val eventName: String
val eventDescription: String?
}

/**
* Represents a collection of calendar events.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.Text
Expand All @@ -42,13 +40,9 @@ import com.himanshoe.kalendar.ui.component.day.modifier.circleLayout
import com.himanshoe.kalendar.ui.component.day.modifier.dayBackgroundColor
import com.himanshoe.kalendar.ui.component.indicator.KalendarIndicator
import com.himanshoe.kalendar.ui.firey.KalendarSelectedDayRange
import com.himanshoe.kalendar.util.MultiplePreviews
import kotlinx.datetime.Clock
import kotlinx.datetime.DateTimeUnit
import kotlinx.datetime.LocalDate
import kotlinx.datetime.TimeZone
import kotlinx.datetime.minus
import kotlinx.datetime.plus
import kotlinx.datetime.todayIn

/**
Expand Down Expand Up @@ -141,7 +135,10 @@ private fun getBorder(currentDay: Boolean, color: Color, selected: Boolean): Bor
}
}

@MultiplePreviews
/**
* Since KalendarEvent is an interface, you should implement your own KalendarEvent class and use this new one
*/
/* @MultiplePreviews
@Composable
private fun KalendarDayPreview() {
val date = Clock.System.todayIn(TimeZone.currentSystemDefault())
Expand Down Expand Up @@ -181,4 +178,4 @@ private fun KalendarDayPreview() {
selectedRange = null
)
}
}
} */
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ internal fun KalendarFirey(
val displayedYear = remember { mutableStateOf(today.year) }
val currentMonth = displayedMonth.value
val currentYear = displayedYear.value
val currentMonthIndex = currentMonth.value.minus(1)

val defaultHeaderColor = KalendarTextKonfig.default(
color = kalendarColors.color[currentMonthIndex].headerTextColor,
color = kalendarColors.color[0].headerTextColor
)

val newHeaderTextKonfig = kalendarHeaderTextKonfig ?: defaultHeaderColor

val daysInMonth = currentMonth.length(currentYear.isLeapYear())
Expand All @@ -106,7 +106,7 @@ internal fun KalendarFirey(
Column(
modifier = modifier
.background(
color = kalendarColors.color[currentMonthIndex].backgroundColor
color = kalendarColors.color[0].backgroundColor
)
.wrapContentHeight()
.fillMaxWidth()
Expand Down Expand Up @@ -156,7 +156,7 @@ internal fun KalendarFirey(
KalendarDay(
date = day,
selectedDate = selectedDate.value,
kalendarColors = kalendarColors.color[currentMonthIndex],
kalendarColors = kalendarColors.color[0],
kalendarEvents = events,
kalendarDayKonfig = kalendarDayKonfig,
selectedRange = selectedRange.value,
Expand Down