Skip to content

Commit

Permalink
Module SetUp Done
Browse files Browse the repository at this point in the history
  • Loading branch information
ArjunGupta08 committed Apr 4, 2024
1 parent 0562cdb commit 67b8659
Show file tree
Hide file tree
Showing 25 changed files with 331 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .idea/compiler.xml

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

6 changes: 4 additions & 2 deletions .idea/gradle.xml

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

6 changes: 6 additions & 0 deletions .idea/kotlinc.xml

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

10 changes: 10 additions & 0 deletions .idea/migrations.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 @@ -54,11 +54,11 @@ class CalendarAdapter(private val listener: (calendarDateModel: CalendarDateMode
if (position == adapterPosition){
holder.calendarDay.setTextColor(ContextCompat.getColor(holder.itemView.context, R.color.white))
holder.calendarDate.setTextColor(ContextCompat.getColor(holder.itemView.context, R.color.white))
holder.linear.background = holder.itemView.context.getDrawable(R.drawable.rectangle_fill)
holder.linear.setBackgroundResource(R.drawable.rectangle_fill)
}else {
holder.calendarDay.setTextColor(ContextCompat.getColor(holder.itemView.context, R.color.black))
holder.calendarDate.setTextColor(ContextCompat.getColor(holder.itemView.context, R.color.black))
holder.linear.background = holder.itemView.context.getDrawable(R.drawable.rectangle_outline)
holder.linear.setBackgroundResource(R.drawable.rectangle_outline)
}

}
Expand Down
1 change: 1 addition & 0 deletions horizontal_calendar_date/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
41 changes: 41 additions & 0 deletions horizontal_calendar_date/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
}

android {
namespace 'com.arjungupta08.horizontal_calendar_date'
compileSdk 34

defaultConfig {
minSdk 24

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}

dependencies {

implementation 'androidx.core:core-ktx:1.12.0'
implementation platform('org.jetbrains.kotlin:kotlin-bom:1.8.0')
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.11.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
Empty file.
21 changes: 21 additions & 0 deletions horizontal_calendar_date/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.arjungupta08.horizontal_calendar_date

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

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.arjungupta08.horizontal_calendar_date.test", appContext.packageName)
}
}
4 changes: 4 additions & 0 deletions horizontal_calendar_date/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.arjungupta08.horizontal_calendar_date

import android.os.Build
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.TextView
import androidx.annotation.RequiresApi
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import kotlin.collections.ArrayList

class CalendarAdapter(private val listener: (calendarDateModel: CalendarDateModel, position: Int) -> Unit):
RecyclerView.Adapter<CalendarAdapter.CalendarViewHolder>(){

private var list = ArrayList<CalendarDateModel>()
private var adapterPosition = -1


interface OnItemClickListener{
fun onItemClick(text: String, date: String, day: String)
}

private var mListener: OnItemClickListener? = null

fun setOnItemClickListener(listener: OnItemClickListener){
mListener = listener
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CalendarViewHolder {
val inflater : LayoutInflater = LayoutInflater.from(parent.context)
val view: View = inflater.inflate(R.layout.date_layout,parent,false)
return CalendarViewHolder(view)
}


@RequiresApi(Build.VERSION_CODES.O)
override fun onBindViewHolder(holder: CalendarViewHolder, position: Int) {
val itemList = list[position]
holder.calendarDay.text = itemList.calendarDay
holder.calendarDate.text = itemList.calendarDate

holder.itemView.setOnClickListener {
adapterPosition = position
notifyItemRangeChanged(0, list.size)

val text = itemList.calendarYear
val date = itemList.calendarDate
val day = itemList.calendarDay
mListener?.onItemClick(text,date,day)
}
if (position == adapterPosition){
holder.calendarDay.setTextColor(ContextCompat.getColor(holder.itemView.context, R.color.white))
holder.calendarDate.setTextColor(ContextCompat.getColor(holder.itemView.context, R.color.white))
holder.linear.setBackgroundResource(R.drawable.rectangle_fill)
}else {
holder.calendarDay.setTextColor(ContextCompat.getColor(holder.itemView.context, R.color.black))
holder.calendarDate.setTextColor(ContextCompat.getColor(holder.itemView.context, R.color.black))
holder.linear.setBackgroundResource(R.drawable.rectangle_outline)
}
}
override fun getItemCount(): Int {
return list.size
}

class CalendarViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val calendarDay : TextView= itemView.findViewById(R.id.tv_calendar_day)
val calendarDate : TextView= itemView.findViewById(R.id.tv_calendar_date)
val linear : LinearLayout= itemView.findViewById(R.id.linear_calendar)
}

fun setData(calendarList: ArrayList<CalendarDateModel>) {
list.clear()
list.addAll(calendarList)
notifyDataSetChanged()
}
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.arjungupta08.horizontal_calendar_date

import java.text.SimpleDateFormat
import java.util.*

data class CalendarDateModel(var data: Date, var isSelected: Boolean = true) {

val calendarDay: String
get() = SimpleDateFormat("EE", Locale.getDefault()).format(data)

val calendarYear: String
get() = SimpleDateFormat("dd MMMM yyyy", Locale.getDefault()).format(data)

val calendarDate: String
get() {
val cal = Calendar.getInstance()
cal.time = data
return cal[Calendar.DAY_OF_MONTH].toString()
}
}
5 changes: 5 additions & 0 deletions horizontal_calendar_date/src/main/res/drawable/left_arrow.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:autoMirrored="true" android:height="24dp"
android:tint="#000000" android:viewportHeight="24"
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M15.41,16.59L10.83,12l4.58,-4.59L14,6l-6,6 6,6 1.41,-1.41z"/>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<solid android:color="#4A7AF7"/>
<corners android:radius="15dp"/>

</shape>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<solid android:color="#E9F1EF"/>
<corners android:radius="15dp"/>

</shape>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:autoMirrored="true" android:height="24dp"
android:tint="#000000" android:viewportHeight="24"
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M8.59,16.59L13.17,12 8.59,7.41 10,6l6,6 -6,6 -1.41,-1.41z"/>
</vector>
27 changes: 27 additions & 0 deletions horizontal_calendar_date/src/main/res/layout/date_layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="70dp"
android:layout_height="95dp"
android:id="@+id/linear_calendar"
android:layout_margin="5dp"
android:gravity="center"
android:orientation="vertical"
android:padding="15dp"
android:background="@drawable/rectangle_outline"
xmlns:app="http://schemas.android.com/apk/res-auto">

<TextView
android:id="@+id/tv_calendar_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="11"
android:textSize="14sp" />

<TextView
android:id="@+id/tv_calendar_day"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mon"
android:textSize="14sp" />

</LinearLayout>
16 changes: 16 additions & 0 deletions horizontal_calendar_date/src/main/res/values-night/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.HorizontalCalendarDate" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_200</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/black</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_200</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
</resources>
10 changes: 10 additions & 0 deletions horizontal_calendar_date/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
</resources>
3 changes: 3 additions & 0 deletions horizontal_calendar_date/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">Horizontal CalendarDate</string>
</resources>
16 changes: 16 additions & 0 deletions horizontal_calendar_date/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.HorizontalCalendarDate" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_700</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
</resources>
Loading

0 comments on commit 67b8659

Please sign in to comment.