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

Android #17/toggling bookmark crashes app #24

Open
wants to merge 42 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
c0b29ec
moved appearence type for string resource implementation
SvenLindstrom Sep 10, 2024
1bba02d
added string resources
SvenLindstrom Sep 30, 2024
4e3d1d9
string resources
SvenLindstrom Oct 8, 2024
cb5ebed
refactor events
SvenLindstrom Oct 8, 2024
c83522b
resource fetching and event registration
SvenLindstrom Oct 8, 2024
a7998bb
get accurate number of availabilitys
SvenLindstrom Oct 8, 2024
db3ea0a
ui fixes
SvenLindstrom Oct 8, 2024
c6b49cd
api calls for fetching resource and booking events
SvenLindstrom Oct 8, 2024
9fa3417
fixed location id being null
SvenLindstrom Oct 8, 2024
703fcce
string resources
SvenLindstrom Oct 8, 2024
0fced16
merger
SvenLindstrom Oct 8, 2024
f5f3168
api calls for resource booking
SvenLindstrom Oct 8, 2024
1e48bc5
minor refactor
SvenLindstrom Oct 8, 2024
58d371f
added api for resources
SvenLindstrom Oct 25, 2024
8fdf62a
fixed bug with reciving data from backend
SvenLindstrom Oct 25, 2024
a113edd
added function that returns first time slot with availability
SvenLindstrom Oct 25, 2024
55dd47c
navigation for account
SvenLindstrom Oct 25, 2024
fed7bba
added sheed header and miner ui updates
SvenLindstrom Oct 25, 2024
8c38405
event and resource sheets
SvenLindstrom Oct 25, 2024
a9b92e0
updated view models
SvenLindstrom Oct 26, 2024
516db56
event and resource sheets now display
SvenLindstrom Oct 26, 2024
032fc3e
event screen ui
SvenLindstrom Oct 26, 2024
045ca85
resource booking UI
SvenLindstrom Oct 26, 2024
cc06109
added selected resource modle to app controller
SvenLindstrom Oct 26, 2024
6fc05ac
user over view resources UI
SvenLindstrom Oct 26, 2024
12809ef
changed data formating
SvenLindstrom Oct 26, 2024
574cbf2
user banner UI
SvenLindstrom Oct 26, 2024
2bcd155
string resources
SvenLindstrom Oct 26, 2024
cb9468d
misc
SvenLindstrom Oct 26, 2024
1f89497
merged with main
SvenLindstrom Oct 26, 2024
923a8bc
miner clean up
SvenLindstrom Oct 26, 2024
4a16eef
updated resource and event scaffolding
SvenLindstrom Oct 26, 2024
d52d13f
added string resources
SvenLindstrom Oct 26, 2024
5b6f0bc
renamed function
SvenLindstrom Oct 27, 2024
c9de000
past days not electable anymore
SvenLindstrom Oct 27, 2024
a485195
button state now updates
SvenLindstrom Oct 27, 2024
fcc47b4
updated how resources are fetched
SvenLindstrom Oct 27, 2024
0b3ccf2
updated reasource details top bar
SvenLindstrom Oct 27, 2024
76b632e
merged with main
SvenLindstrom Oct 29, 2024
351eafc
updates to be in line with new topbar handeling
SvenLindstrom Oct 29, 2024
81b1fe7
fixed bug no longer crashes when toggling bookmarks
SvenLindstrom Nov 9, 2024
33ba338
Merge branch 'main' of https://github.com/tumble-for-kronox/Tumble-An…
SvenLindstrom Nov 11, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ class RealmManager {
}
}

suspend fun updateScheduleVisibility(scheduleId: String, visibility: Boolean){
realm.write {
val schedule: Schedule? = this.query<Schedule>("scheduleId == $0", scheduleId).first().find()
schedule?.toggled = visibility
}
}

fun getCourseColors(): MutableMap<String, String> {
val courses: RealmResults<Course> = realm.query<Course>().find()
val courseColors = mutableMapOf<String, String>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@ package tumble.app.tumble.presentation.viewmodels
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import io.realm.kotlin.ext.copyFromRealm
import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.launch
import tumble.app.tumble.data.api.Endpoint
import tumble.app.tumble.data.notifications.NotificationManager
import tumble.app.tumble.data.repository.preferences.CombinedData
import tumble.app.tumble.data.repository.preferences.DataStoreManager
import tumble.app.tumble.data.repository.realm.RealmManager
import tumble.app.tumble.datasource.SchoolManager
import tumble.app.tumble.domain.enums.Types.AppearanceType
import tumble.app.tumble.domain.enums.ViewType
import tumble.app.tumble.domain.models.realm.Event
import tumble.app.tumble.domain.models.realm.Schedule
import tumble.app.tumble.presentation.views.Settings.Notifications.NotificationOffset
Expand Down Expand Up @@ -110,6 +109,12 @@ class SettingsViewModel @Inject constructor(
//TODO
}

fun updateBookmarkVisibility(visibility: Boolean, schedule: Schedule){
viewModelScope.launch {
realmManager.updateScheduleVisibility(schedule.scheduleId, visibility)
}
}

fun deleteAllSchedules(){
//TODO
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ fun BookmarksSettings(

if (schedules.value.isNotEmpty()) {
SettingsList {
schedules.value.forEachIndexed { index, schedule ->
schedules.value.forEach{ schedule ->
BookmarkSettingsRow(
schedule = schedule,
index = index,
onDelete = { offsets, id ->
onDelete = { offsets ->
parentViewModel.deleteBookmark(schedule)
},
onToggle = {visibility ->
parentViewModel.updateBookmarkVisibility(visibility, schedule)
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ import tumble.app.tumble.domain.models.realm.Schedule
@Composable
fun BookmarkSettingsRow(
schedule: Schedule,
index: Int,
onDelete: (Int, String) -> Unit
onDelete: (String) -> Unit,
onToggle: (Boolean) -> Unit,
) {
val scope = rememberCoroutineScope()

Expand All @@ -60,15 +60,12 @@ fun BookmarkSettingsRow(
checked = isToggled,
onCheckedChange = { checked ->
isToggled = checked
schedule.toggled = checked
onToggle(checked)
// Trigger the widget update when the toggle changes
},
colors = SwitchDefaults.colors(checkedThumbColor = MaterialTheme.colors.primary),
modifier = Modifier.scale(2f)
)



}
}