Skip to content

Commit bfc4686

Browse files
committed
fix: update the app to work with the new progres APIs
closes #5
1 parent cde4d18 commit bfc4686

File tree

83 files changed

+254
-1064
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+254
-1064
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ jobs:
1515
# with:
1616
# xcode-version: "15.2.0"
1717

18-
- name: Setup JDK 17
18+
- name: Setup JDK 21
1919
uses: actions/setup-java@v4
2020
with:
2121
distribution: 'adopt'
22-
java-version: 17
22+
java-version: 21
2323
cache: 'gradle'
2424

2525
- name: Make gradlew executable

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ jobs:
1717
- name: Checkout repo
1818
uses: actions/checkout@v4
1919

20-
- name: Setup JDK 17
20+
- name: Setup JDK 21
2121
uses: actions/setup-java@v4
2222
with:
2323
distribution: 'adopt'
24-
java-version: 17
24+
java-version: 21
2525

2626
- name: Make gradlew executable
2727
run: chmod +x ./gradlew

composeApp/build.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ plugins {
1818
kotlin {
1919
androidTarget {
2020
compilerOptions {
21-
jvmTarget.set(JvmTarget.JVM_17)
21+
jvmTarget.set(JvmTarget.JVM_21)
2222
}
2323
}
2424

@@ -76,7 +76,7 @@ kotlin {
7676
implementation(libs.bundles.connectivity)
7777
implementation(libs.sonner)
7878
implementation(libs.placeholder)
79-
implementation(libs.qrscan)
79+
// implementation(libs.qrscan)
8080
implementation(libs.compottie)
8181
implementation(libs.bundles.aboutlibraries)
8282

@@ -124,8 +124,8 @@ android {
124124
}
125125
}
126126
compileOptions {
127-
sourceCompatibility = JavaVersion.VERSION_17
128-
targetCompatibility = JavaVersion.VERSION_17
127+
sourceCompatibility = JavaVersion.VERSION_21
128+
targetCompatibility = JavaVersion.VERSION_21
129129
isCoreLibraryDesugaringEnabled = true
130130
}
131131
buildFeatures {

composeApp/src/commonMain/kotlin/presentation/ErrorScreenContent.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ fun ErrorScreenContent(
5353
style = MaterialTheme.typography.headlineMedium
5454
)
5555
Text(
56-
throwable.message!!,
56+
throwable.message ?: "ffs",
5757
style = MaterialTheme.typography.bodyLarge
5858
)
5959
LogsContainer(throwable.stackTraceToString())

composeApp/src/commonMain/kotlin/presentation/StudentCard.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ import io.github.alexzhirkevich.qrose.toByteArray
6565
import kotlinx.coroutines.Dispatchers
6666
import kotlinx.coroutines.IO
6767
import kotlinx.coroutines.launch
68-
import kotlinx.datetime.LocalDateTime
68+
import kotlinx.datetime.LocalDate
6969
import kotlinx.datetime.format
7070
import kotlinx.datetime.format.FormatStringsInDatetimeFormats
7171
import kotlinx.datetime.format.byUnicodePattern
@@ -364,7 +364,7 @@ fun CardHeader(
364364
text = if (type == CardType.ACCOMMODATION && accommodationState != null) {
365365
accommodationState.providerStringArabic
366366
} else {
367-
card.establishment.nameArabic
367+
card.establishmentStringArabic
368368
},
369369
color = Color.Black,
370370
fontSize = scaledFontSize(2.4.em),
@@ -388,7 +388,7 @@ fun CardHeader(
388388
contentAlignment = Alignment.Center,
389389
) {
390390
if (type == CardType.FRONT) {
391-
AsyncImage(model = card.establishment.photo, null)
391+
AsyncImage(model = card.establishmentLogo, null)
392392
} else {
393393
Image(painter = painterResource(Res.drawable.onou), null)
394394
}
@@ -502,7 +502,7 @@ fun CardInformationRow(
502502
horizontalArrangement = Arrangement.SpaceBetween,
503503
) {
504504
Text(
505-
text = card.individualDateOfBirth.format(LocalDateTime.Format { byUnicodePattern("dd/MM/yyyy") }),
505+
text = card.individualDateOfBirth.format(LocalDate.Format { byUnicodePattern("dd/MM/yyyy") }),
506506
color = Color.DarkGray,
507507
fontSize = scaledFontSize(2.em),
508508
lineHeight = 1.sp,
@@ -555,7 +555,7 @@ fun CardInformationRow(
555555
lineHeight = 1.sp,
556556
)
557557
Text(
558-
text = card.ofDomainStringArabic,
558+
text = (card.ofDomainStringArabic ?: card.ofFieldStringArabic ?: card.ofSpecialtyStringArabic)!!,
559559
color = Color.DarkGray,
560560
fontSize = scaledFontSize(2.em),
561561
lineHeight = 1.sp,

composeApp/src/commonMain/kotlin/ui/home/HomeScreen.kt

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
package ui.home
22

3-
import androidx.compose.animation.AnimatedVisibility
43
import androidx.compose.animation.animateContentSize
54
import androidx.compose.animation.core.animateDpAsState
6-
import androidx.compose.animation.core.tween
7-
import androidx.compose.animation.expandVertically
8-
import androidx.compose.animation.shrinkVertically
95
import androidx.compose.foundation.background
106
import androidx.compose.foundation.basicMarquee
117
import androidx.compose.foundation.clickable
@@ -69,15 +65,12 @@ import androidx.compose.ui.text.style.TextOverflow
6965
import androidx.compose.ui.unit.dp
7066
import androidx.compose.ui.window.Dialog
7167
import androidx.compose.ui.window.DialogProperties
72-
import androidx.compose.ui.zIndex
7368
import androidx.constraintlayout.compose.ConstraintLayout
74-
import cafe.adriel.voyager.core.annotation.InternalVoyagerApi
7569
import cafe.adriel.voyager.core.model.screenModelScope
7670
import cafe.adriel.voyager.core.screen.Screen
7771
import cafe.adriel.voyager.koin.koinScreenModel
7872
import cafe.adriel.voyager.navigator.LocalNavigator
7973
import cafe.adriel.voyager.navigator.currentOrThrow
80-
import cafe.adriel.voyager.navigator.internal.BackHandler
8174
import coil3.compose.AsyncImage
8275
import com.dokar.sonner.Toast
8376
import com.dokar.sonner.ToasterState
@@ -195,7 +188,6 @@ object HomeScreen : Screen {
195188
}
196189
}
197190

198-
@OptIn(InternalVoyagerApi::class)
199191
@Composable
200192
fun HomeScreenContent(
201193
homeScreenUIData: HomeScreenUIData?,
@@ -218,7 +210,7 @@ object HomeScreen : Screen {
218210
ProfileTile(
219211
homeScreenUIData?.studentCard,
220212
onClick = { isStudentBacInfoShown = !isStudentBacInfoShown },
221-
isExpanded = isStudentBacInfoShown,
213+
isExpanded = false,
222214
onCardClick = if (homeScreenUIData?.studentCard == null) null else showStudentCard,
223215
onPhotoClick = { isStudentPhotoShown = true },
224216
modifier = Modifier.constrainAs(profileCard) {
@@ -235,13 +227,14 @@ object HomeScreen : Screen {
235227
canShare = true,
236228
canSave = platformUtils.platform == Platform.Android && platformUtils.platformVersion >= 29,
237229
onSave = {
238-
platformUtils.downloadByteArray(it, "${homeScreenUIData.studentCard.nationalIdNumber}.jpg", "image/jpeg")
230+
platformUtils.downloadByteArray(it, "${homeScreenUIData.studentCard.registrationNumber}.jpg", "image/jpeg")
239231
},
240232
onShare = {
241-
platformUtils.shareByteArray(it, "${homeScreenUIData.studentCard.nationalIdNumber}.jpg", "image/jpeg")
233+
platformUtils.shareByteArray(it, "${homeScreenUIData.studentCard.registrationNumber}.jpg", "image/jpeg")
242234
},
243235
)
244236
}
237+
/*
245238
AnimatedVisibility(
246239
isStudentBacInfoShown,
247240
enter = expandVertically { -it },
@@ -270,6 +263,7 @@ object HomeScreen : Screen {
270263
}
271264
BacInfoCard(homeScreenUIData.bacInfo)
272265
}
266+
*/
273267
if (isStudentPhotoShown && homeScreenUIData != null) {
274268
StudentPhotoDialog(
275269
photo = homeScreenUIData.studentCard.photo,
@@ -279,14 +273,14 @@ object HomeScreen : Screen {
279273
onSave = {
280274
platformUtils.downloadByteArray(
281275
homeScreenUIData.studentCard.photo!!,
282-
fileName = "${homeScreenUIData.studentCard.nationalIdNumber}.jpg",
276+
fileName = "${homeScreenUIData.studentCard.registrationNumber}.jpg",
283277
"image/jpeg",
284278
)
285279
},
286280
onShare = {
287281
platformUtils.shareByteArray(
288282
homeScreenUIData.studentCard.photo!!,
289-
fileName = "${homeScreenUIData.studentCard.nationalIdNumber}.jpg",
283+
fileName = "${homeScreenUIData.studentCard.registrationNumber}.jpg",
290284
"image/jpeg",
291285
)
292286
},

composeApp/src/commonMain/kotlin/ui/home/HomeScreenModel.kt

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,23 @@ import kotlinx.datetime.TimeZone
1414
import kotlinx.datetime.toLocalDateTime
1515
import mehiz.abdallah.progres.core.TAG
1616
import mehiz.abdallah.progres.domain.AccommodationUseCase
17-
import mehiz.abdallah.progres.domain.BacInfoUseCase
1817
import mehiz.abdallah.progres.domain.StudentCardUseCase
1918
import mehiz.abdallah.progres.domain.SubjectScheduleUseCase
2019
import mehiz.abdallah.progres.domain.UserAuthUseCase
2120
import mehiz.abdallah.progres.domain.models.AccommodationModel
22-
import mehiz.abdallah.progres.domain.models.BacInfoModel
2321
import mehiz.abdallah.progres.domain.models.StudentCardModel
2422
import mehiz.abdallah.progres.domain.models.SubjectScheduleModel
2523
import presentation.utils.RequestState
2624

2725
data class HomeScreenUIData(
2826
val studentCard: StudentCardModel,
29-
val bacInfo: BacInfoModel,
27+
// val bacInfo: BacInfoModel,
3028
val accommodationStateModel: AccommodationModel? = null,
3129
)
3230

3331
class HomeScreenModel(
3432
private val studentCardUseCase: StudentCardUseCase,
35-
private val bacInfoUseCase: BacInfoUseCase,
33+
// private val bacInfoUseCase: BacInfoUseCase,
3634
private val subjectScheduleUseCase: SubjectScheduleUseCase,
3735
private val accommodationUseCase: AccommodationUseCase,
3836
private val authUseCase: UserAuthUseCase,
@@ -64,7 +62,7 @@ class HomeScreenModel(
6462
_data.value.getSuccessDataOrNull()?.let {
6563
try {
6664
_data.update { _ ->
67-
getAccommodationState(it.studentCard.id)?.let { state ->
65+
getAccommodationState(it.studentCard.academicYearId)?.let { state ->
6866
RequestState.Success(it.copy(accommodationStateModel = state))
6967
} ?: return@let
7068
}
@@ -80,7 +78,7 @@ class HomeScreenModel(
8078
_data.value.getSuccessDataOrNull()?.let {
8179
runCatching {
8280
_data.update { _ ->
83-
RequestState.Success(it.copy(accommodationStateModel = getAccommodationState(it.studentCard.id)))
81+
RequestState.Success(it.copy(accommodationStateModel = getAccommodationState(it.studentCard.academicYearId)))
8482
}
8583
}
8684
}
@@ -91,14 +89,14 @@ class HomeScreenModel(
9189
return subjectScheduleUseCase.getNextSubjectSchedule()
9290
}
9391

94-
private suspend fun getAccommodationState(cardId: Long): AccommodationModel? {
95-
return accommodationUseCase.getAccommodationStateForCard(cardId)
92+
private suspend fun getAccommodationState(academicYearId: Long): AccommodationModel? {
93+
return accommodationUseCase.getAccommodationStateForCard(academicYearId)
9694
}
9795

9896
private suspend fun getData(refresh: Boolean): HomeScreenUIData {
9997
return HomeScreenUIData(
10098
studentCard = studentCardUseCase.getLatestStudentCard(refresh),
101-
bacInfo = bacInfoUseCase.getBacInfoWithGrades(refresh),
99+
// bacInfo = bacInfoUseCase.getBacInfoWithGrades(refresh),
102100
)
103101
}
104102

composeApp/src/commonMain/kotlin/ui/home/Subscreen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ val screens = listOf(
4949
SubScreen(Icons.Rounded.EditNote, MR.strings.home_exams_results, ExamGradesScreen),
5050
SubScreen(Icons.Rounded.DoneAll, MR.strings.home_continuous_eval, CCGradesScreen),
5151
SubScreen(Icons.Rounded.FolderCopy, MR.strings.home_academic_transcripts, TranscriptScreen),
52+
SubScreen(Icons.Rounded.Inventory2, MR.strings.home_enrollments, EnrollmentsScreen),
5253
SubScreen(Icons.Rounded.Calculate, MR.strings.home_debts, enabled = false),
5354
SubScreen(Icons.AutoMirrored.Rounded.Note, MR.strings.home_academic_vacations, enabled = false),
54-
SubScreen(Icons.Rounded.Inventory2, MR.strings.home_enrollments, EnrollmentsScreen),
5555
// SubScreen(Icons.AutoMirrored.Rounded.FactCheck, MR.strings.home_bac_results, BacInfoScreen),
56-
SubScreen(Icons.Rounded.Restaurant, MR.strings.home_restaurant, RestaurantScreen, isBeta = true),
56+
SubScreen(Icons.Rounded.Restaurant, MR.strings.home_restaurant, RestaurantScreen, isBeta = true, enabled = false),
5757
SubScreen(Icons.Rounded.MoreHoriz, MR.strings.home_more_services, enabled = false),
5858
)

0 commit comments

Comments
 (0)