Skip to content

Commit

Permalink
Merge pull request #348 from Aga-C/open-day-from-weekly
Browse files Browse the repository at this point in the history
Added opening daily view from weekly view (#344)
  • Loading branch information
naveensingh authored Nov 14, 2024
2 parents 2c3e481 + 79defd5 commit fbed60c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,22 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
}
}

fun openDayFromWeekly(dateTime: DateTime) {
if (currentFragments.last() is DayFragmentsHolder) {
return
}

val fragment = DayFragmentsHolder()
currentFragments.add(fragment)
val bundle = Bundle()
bundle.putString(DAY_CODE, Formatter.getDayCodeFromDateTime(dateTime))
fragment.arguments = bundle
supportFragmentManager.beginTransaction().add(R.id.fragments_holder, fragment).commitNow()
resetActionBarTitle()
binding.calendarFab.beVisible()
showBackNavigationArrow()
}

private fun getFragmentsHolder() = when (config.storedView) {
DAILY_VIEW -> DayFragmentsHolder()
MONTHLY_VIEW -> MonthFragmentsHolder()
Expand All @@ -1013,7 +1029,10 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
refreshEvents()
}

binding.calendarFab.beGoneIf(currentFragments.size == 1 && config.storedView == YEARLY_VIEW)
binding.calendarFab.beGoneIf(
currentFragments.size == 1 &&
(config.storedView == YEARLY_VIEW || config.storedView == WEEKLY_VIEW)
)
if (currentFragments.size > 1) {
showBackNavigationArrow()
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ class WeekFragment : Fragment(), WeeklyCalendar {
if (todayCode == dayCode) {
todayColumnIndex = i
}
label.setOnClickListener {
(activity as MainActivity).openDayFromWeekly(Formatter.getDateTimeFromCode(dayCode))
}

binding.weekLettersHolder.addView(label)
curDay = curDay.plusDays(1)
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/weekly_view_day_letter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="?selectableItemBackgroundBorderless"
android:gravity="center_horizontal"
android:textSize="@dimen/normal_text_size"
tools:text="@string/monday_letter" />

0 comments on commit fbed60c

Please sign in to comment.