-
Notifications
You must be signed in to change notification settings - Fork 4
Feature splash and onboarding #39
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
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
07a5e8e
move splash screen to new package
HendSayed25 b8ae948
move bottomSheet to to new package
HendSayed25 d5a8afc
add dependencies for coil and ktor
HendSayed25 8e1d30d
add onboarding repo and entity
HendSayed25 0cf480f
add onboarding repo implementation , dto and response
HendSayed25 c996d1b
add safe call function , constants object and ktor setup
HendSayed25 1daa939
add state management for onboarding screen
HendSayed25 dcbf8aa
update screen and OnBoardingItem with view model
HendSayed25 a992b37
Fix: Add base URL and remove comment in NetworkConstants
HendSayed25 a3e82db
Merge remote-tracking branch 'origin/development' into feature/splash…
HendSayed25 49159d8
Refactor: Remove unused dependencies and versions
HendSayed25 b961839
Merge remote-tracking branch 'origin/development' into feature/splash…
HendSayed25 1a4e562
feat: Integrate NetworkModule and dependencies
HendSayed25 2e4af5f
feat: Update Ktor and add new dependencies
HendSayed25 8a893c6
feat: Implement platform-specific Ktor HTTP engines
HendSayed25 0d1871d
Chore: Update base URL and HttpClient engine
HendSayed25 1060f35
Refactor: Remove OnboardingResponse wrapper
HendSayed25 51367f1
feat: Replace AccountSetupCategoryScreen with OnBoardingScreen
HendSayed25 0a24af5
Refactor: Improve Onboarding screen UI and structure
HendSayed25 eb306ff
Apply consistent naming and updates to Onboarding feature
HendSayed25 31d12d0
Fix: Rename OnBoardingScreen to OnboardingScreen
HendSayed25 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
6 changes: 6 additions & 0 deletions
6
composeApp/src/androidMain/kotlin/org/example/project/di/getHttpEngine.android.kt
This file contains hidden or 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,6 @@ | ||
| package org.example.project.di | ||
|
|
||
| import io.ktor.client.engine.HttpClientEngine | ||
| import io.ktor.client.engine.cio.CIO | ||
|
|
||
| actual fun getHttpEngine(): HttpClientEngine = CIO.create() |
This file contains hidden or 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
16 changes: 16 additions & 0 deletions
16
composeApp/src/commonMain/kotlin/org/example/project/data/dto/OnboardingDto.kt
This file contains hidden or 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,16 @@ | ||
| package org.example.project.data.dto | ||
|
|
||
| import kotlinx.serialization.SerialName | ||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class OnboardingDto( | ||
| @SerialName("id") | ||
| val id : String, | ||
| @SerialName("title") | ||
| val title : String, | ||
| @SerialName("imageRes") | ||
| val imageUrl : String, | ||
| @SerialName("description") | ||
| val description : String | ||
| ) |
11 changes: 11 additions & 0 deletions
11
composeApp/src/commonMain/kotlin/org/example/project/data/mapper/OnboardingMapper.kt
This file contains hidden or 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,11 @@ | ||
| package org.example.project.data.mapper | ||
|
|
||
| import org.example.project.data.dto.OnboardingDto | ||
| import org.example.project.domain.entity.OnboardingItem | ||
|
|
||
| fun OnboardingDto.toEntity() : OnboardingItem = | ||
| OnboardingItem( | ||
| imageRes = imageUrl, | ||
| title = title, | ||
| description = description | ||
| ) |
25 changes: 25 additions & 0 deletions
25
...eApp/src/commonMain/kotlin/org/example/project/data/repository/OnboardingRepositoryImp.kt
This file contains hidden or 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,25 @@ | ||
| package org.example.project.data.repository | ||
|
|
||
| import io.ktor.client.HttpClient | ||
| import io.ktor.client.request.get | ||
| import org.example.project.data.dto.OnboardingDto | ||
| import org.example.project.data.mapper.toEntity | ||
| import org.example.project.data.utils.NetworkConstants.ONBOARDING_END_POINT | ||
| import org.example.project.data.utils.safeApiCall | ||
| import org.example.project.domain.entity.OnboardingItem | ||
| import org.example.project.domain.repository.OnboardingRepository | ||
| import org.koin.core.annotation.Provided | ||
| import org.koin.core.annotation.Single | ||
|
|
||
|
|
||
| @Single(binds = [OnboardingRepository::class]) | ||
| class OnboardingRepositoryImp( | ||
| @Provided private val httpClient: HttpClient | ||
| ) : OnboardingRepository { | ||
|
|
||
| override suspend fun getOnboardingData(): List<OnboardingItem> { | ||
| return safeApiCall<List<OnboardingDto>> { | ||
| httpClient.get(ONBOARDING_END_POINT) | ||
| }.map { it.toEntity() } | ||
| } | ||
| } | ||
5 changes: 5 additions & 0 deletions
5
composeApp/src/commonMain/kotlin/org/example/project/data/utils/NetworkConstants.kt
This file contains hidden or 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,5 @@ | ||
| package org.example.project.data.utils | ||
|
|
||
| object NetworkConstants { | ||
| const val ONBOARDING_END_POINT = "/onboarding" | ||
| } |
92 changes: 92 additions & 0 deletions
92
composeApp/src/commonMain/kotlin/org/example/project/data/utils/safeApiCall.kt
This file contains hidden or 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,92 @@ | ||
| package org.example.project.data.utils | ||
|
|
||
| import io.ktor.client.call.body | ||
| import io.ktor.client.statement.HttpResponse | ||
| import io.ktor.http.HttpStatusCode | ||
| import io.ktor.util.network.UnresolvedAddressException | ||
| import kotlinx.io.IOException | ||
|
|
||
| internal suspend inline fun <reified T> safeApiCall( | ||
| execute: suspend () -> HttpResponse | ||
| ): T { | ||
| val result = try { | ||
| execute() | ||
| } catch (exception: IOException) { | ||
| logError(SAFE_API_CALL_TAG, "IOException", exception.message.toString()) | ||
|
|
||
| } catch (exception: UnresolvedAddressException) { | ||
| logError(SAFE_API_CALL_TAG, "UnresolvedAddressException", exception.message.toString()) | ||
| } catch (exception: Exception) { | ||
| logError(SAFE_API_CALL_TAG, "Unknown exception", exception.message.toString()) | ||
| } | ||
|
|
||
| return handleResponseStatusCode(result as HttpResponse) | ||
| } | ||
|
|
||
| private suspend inline fun <reified T> handleResponseStatusCode(result: HttpResponse): T { | ||
| return when (result.status.value) { | ||
| in 200..299 -> { | ||
| result.body<T>() | ||
| } | ||
|
|
||
| in 400..499 -> { | ||
| when (result.status) { | ||
| HttpStatusCode.Unauthorized -> { | ||
| logError( | ||
| HANDLE_ERROR_STATUS_TAG, | ||
| "Unauthorized", | ||
| "Not authorized to do this action" | ||
| ) | ||
| throw Exception() | ||
| } | ||
|
|
||
| HttpStatusCode.NotFound -> { | ||
| logError( | ||
| HANDLE_ERROR_STATUS_TAG, | ||
| "Not found", | ||
| "the resource you requested could not be found" | ||
| ) | ||
| throw Exception() | ||
| } | ||
|
|
||
| else -> { | ||
| logError( | ||
| HANDLE_ERROR_STATUS_TAG, | ||
| "Unknown 400s status code ${result.status.value}", | ||
| "An error with status code ${result.status.value} happened" | ||
| ) | ||
| throw Exception() | ||
| } | ||
| } | ||
| } | ||
|
|
||
| in 500..599 -> { | ||
| logError( | ||
| HANDLE_ERROR_STATUS_TAG, | ||
| "Server error", | ||
| "An error occurred on the server side" | ||
| ) | ||
| throw Exception() | ||
| } | ||
|
|
||
| else -> { | ||
| logError( | ||
| HANDLE_ERROR_STATUS_TAG, | ||
| "Unknown status code ${result.status.value}", | ||
| "An error with status code ${result.status.value} happened" | ||
| ) | ||
| throw Exception() | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private fun logError( | ||
| tag: String, | ||
| type: String, | ||
| message: String | ||
| ) { | ||
| println("$tag----------- : $type $message") | ||
| } | ||
|
|
||
| private const val SAFE_API_CALL_TAG = "safeApiCall" | ||
| private const val HANDLE_ERROR_STATUS_TAG = "handleErrorStatus" |
53 changes: 53 additions & 0 deletions
53
composeApp/src/commonMain/kotlin/org/example/project/di/NetworkModule.kt
This file contains hidden or 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,53 @@ | ||
| package org.example.project.di | ||
|
|
||
| import io.ktor.client.HttpClient | ||
| import io.ktor.client.plugins.HttpTimeout | ||
| import io.ktor.client.plugins.contentnegotiation.ContentNegotiation | ||
| import io.ktor.client.plugins.defaultRequest | ||
| import io.ktor.client.plugins.logging.LogLevel | ||
| import io.ktor.client.plugins.logging.Logger | ||
| import io.ktor.client.plugins.logging.Logging | ||
| import io.ktor.serialization.kotlinx.json.json | ||
| import kotlinx.serialization.json.Json | ||
| import org.koin.core.annotation.Module | ||
| import org.koin.core.annotation.Single | ||
|
|
||
| //192.168.1.15 | ||
| @Module | ||
| class NetworkModule { | ||
| @Single | ||
| fun provideHttpClient(): HttpClient { | ||
| return HttpClient(engine = getHttpEngine()) { | ||
| defaultRequest { | ||
| url("http://10.0.2.2:8085/") | ||
| } | ||
|
|
||
| install(Logging) { | ||
| level = LogLevel.ALL | ||
| logger = object : Logger { | ||
| override fun log(message: String) { | ||
| println(message) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| install(HttpTimeout) { | ||
| connectTimeoutMillis = TIME_OUT_INTERVAL_MILLI | ||
| requestTimeoutMillis = TIME_OUT_INTERVAL_MILLI | ||
| } | ||
|
|
||
| install(ContentNegotiation) { | ||
| json( | ||
| Json { | ||
| isLenient = true | ||
| ignoreUnknownKeys = true | ||
| } | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private companion object { | ||
| const val TIME_OUT_INTERVAL_MILLI = 10_000L | ||
| } | ||
| } |
5 changes: 5 additions & 0 deletions
5
composeApp/src/commonMain/kotlin/org/example/project/di/getHttpEngine.kt
This file contains hidden or 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,5 @@ | ||
| package org.example.project.di | ||
|
|
||
| import io.ktor.client.engine.HttpClientEngine | ||
|
|
||
| expect fun getHttpEngine(): HttpClientEngine |
This file contains hidden or 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
7 changes: 7 additions & 0 deletions
7
composeApp/src/commonMain/kotlin/org/example/project/domain/entity/OnboardingItem.kt
This file contains hidden or 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 @@ | ||
| package org.example.project.domain.entity | ||
|
|
||
| data class OnboardingItem( | ||
| val imageRes : String, | ||
| val title : String, | ||
| val description : String | ||
| ) |
7 changes: 7 additions & 0 deletions
7
...seApp/src/commonMain/kotlin/org/example/project/domain/repository/OnboardingRepository.kt
This file contains hidden or 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 @@ | ||
| package org.example.project.domain.repository | ||
|
|
||
| import org.example.project.domain.entity.OnboardingItem | ||
|
|
||
| interface OnboardingRepository { | ||
| suspend fun getOnboardingData(): List<OnboardingItem> | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.