This repository has been archived by the owner on Jan 10, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Provisional month view * Deleted unnecessary import statement * Update calendar_month_view.xml * New approach for the month view * improved the desingn * Apply suggestions from code review * Applyed formatting suggestions from code review * renamed some functions * implemented the swithcing behaviour via an enum instead of two bools * renamed another function * Clarifed that monday is the first day of the Week * Apply suggestions from code review Co-authored-by: Marius Wagner <[email protected]> * formatting fixes * formatting fix --------- Co-authored-by: ge78fug <[email protected]> Co-authored-by: Marius Wagner <[email protected]>
- Loading branch information
1 parent
d0b4cab
commit 1912fc2
Showing
17 changed files
with
458 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
app/src/main/java/de/tum/in/tumcampusapp/component/tumui/calendar/MonthViewAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package de.tum.`in`.tumcampusapp.component.tumui.calendar | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.LinearLayoutManager | ||
import androidx.recyclerview.widget.RecyclerView | ||
import de.tum.`in`.tumcampusapp.R | ||
import de.tum.`in`.tumcampusapp.component.tumui.calendar.model.CalendarItem | ||
|
||
class MonthViewAdapter(private var daysOfMonth: ArrayList<String>, private var eventMap: Map<String, List<CalendarItem>>) : | ||
RecyclerView.Adapter<MonthViewHolder>() { | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MonthViewHolder { | ||
val inflater = LayoutInflater.from(parent.context) | ||
val view = inflater.inflate(R.layout.calendar_month_view_cell, parent, false) | ||
val layoutParams = view.layoutParams | ||
layoutParams.height = (parent.height * 1 / 6) | ||
return MonthViewHolder(view) | ||
} | ||
|
||
override fun onBindViewHolder(holder: MonthViewHolder, position: Int) { | ||
val events = eventMap[daysOfMonth[position]] | ||
|
||
holder.dayOfMonth.text = daysOfMonth[position] | ||
holder.eventsContainer.adapter = events?.let { MonthViewEventAdapter(it) } | ||
holder.eventsContainer.layoutManager = LinearLayoutManager(holder.itemView.context) | ||
} | ||
|
||
override fun getItemCount(): Int { | ||
return daysOfMonth.size | ||
} | ||
|
||
fun updateData(daysOfMonth: ArrayList<String>, eventMap: Map<String, List<CalendarItem>>) { | ||
this.daysOfMonth = daysOfMonth | ||
this.eventMap = eventMap | ||
notifyDataSetChanged() | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
app/src/main/java/de/tum/in/tumcampusapp/component/tumui/calendar/MonthViewEventAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package de.tum.`in`.tumcampusapp.component.tumui.calendar | ||
|
||
import android.graphics.drawable.GradientDrawable | ||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.RecyclerView | ||
import de.tum.`in`.tumcampusapp.R | ||
import de.tum.`in`.tumcampusapp.component.tumui.calendar.model.CalendarItem | ||
|
||
class MonthViewEventAdapter(private val events: List<CalendarItem>) : RecyclerView.Adapter<MonthViewEventViewHolder>() { | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MonthViewEventViewHolder { | ||
val view = LayoutInflater.from(parent.context).inflate(R.layout.calendar_month_event_view, parent, false) | ||
return MonthViewEventViewHolder(view) | ||
} | ||
|
||
override fun onBindViewHolder(holder: MonthViewEventViewHolder, position: Int) { | ||
val event = events[position] | ||
holder.title.text = event.title | ||
val background = holder.title.background as GradientDrawable | ||
background.setColor(event.color!!) | ||
} | ||
|
||
override fun getItemCount(): Int { | ||
return events.size | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...src/main/java/de/tum/in/tumcampusapp/component/tumui/calendar/MonthViewEventViewHolder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package de.tum.`in`.tumcampusapp.component.tumui.calendar | ||
|
||
import android.view.View | ||
import android.widget.TextView | ||
import androidx.recyclerview.widget.RecyclerView | ||
import de.tum.`in`.tumcampusapp.R | ||
|
||
class MonthViewEventViewHolder(view: View) : RecyclerView.ViewHolder(view) { | ||
val title: TextView = view.findViewById(R.id.eventTitle) | ||
} |
13 changes: 13 additions & 0 deletions
13
app/src/main/java/de/tum/in/tumcampusapp/component/tumui/calendar/MonthViewHolder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package de.tum.`in`.tumcampusapp.component.tumui.calendar | ||
|
||
import android.view.View | ||
import android.widget.TextView | ||
import androidx.recyclerview.widget.RecyclerView | ||
import de.tum.`in`.tumcampusapp.R | ||
|
||
class MonthViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { | ||
|
||
val dayOfMonth: TextView = itemView.findViewById(R.id.cellDayNumber) | ||
|
||
val eventsContainer: RecyclerView = itemView.findViewById(R.id.eventsContainer) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
<stroke | ||
android:width="0.5dp" | ||
android:color="@color/navigation_bar_divider" /> | ||
</shape> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:tint="?attr/colorControlNormal" | ||
android:viewportHeight="24" | ||
android:viewportWidth="24"> | ||
<path | ||
android:fillColor="@color/color_primary" | ||
android:pathData="M12,4l-1.41,1.41L16.17,11H4v2h12.17l-5.58,5.59L12,20l8,-8z" /> | ||
</vector> |
13 changes: 13 additions & 0 deletions
13
app/src/main/res/drawable/ic_outline_calendar_view_month_24px.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:autoMirrored="true" | ||
android:viewportHeight="24" | ||
android:viewportWidth="24"> | ||
<path | ||
android:fillColor="@color/text_primary" | ||
android:pathData="M4,5v13h17V5H4zM14,7v9h-3V7H14zM6,7h3v9H6V7zM19,16h-3V7h3V16z" /> | ||
<path | ||
android:fillColor="@color/text_primary" | ||
android:pathData="M4,10.5h17v2h-15z" /> | ||
</vector> |
12 changes: 12 additions & 0 deletions
12
app/src/main/res/drawable/rounded_corners_monthly_calendar.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
<corners android:radius="10px" /> | ||
|
||
<padding | ||
android:bottom="2dp" | ||
android:left="2dp" | ||
android:right="2dp" | ||
android:top="2dp" /> | ||
<solid android:color="@color/white" /> | ||
</shape> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical"> | ||
|
||
<TextView | ||
android:id="@+id/eventTitle" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginLeft="0.5dp" | ||
android:layout_marginRight="2dp" | ||
android:layout_marginVertical="0.5dp" | ||
android:background="@drawable/rounded_corners_monthly_calendar" | ||
android:maxLines="2" | ||
android:text="Event Title" | ||
android:textColor="@color/white" | ||
android:textSize="8sp" /> | ||
|
||
</LinearLayout> | ||
|
Oops, something went wrong.