-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add profile scree, refactor navigation
- Loading branch information
Showing
38 changed files
with
497 additions
and
58 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
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
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
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
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
20 changes: 20 additions & 0 deletions
20
...commonMain/kotlin/com/stslex/core/network/clients/profile/client/MockProfileClientImpl.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,20 @@ | ||
package com.stslex.core.network.clients.profile.client | ||
|
||
import com.stslex.core.network.clients.profile.model.ProfileResponse | ||
import kotlinx.coroutines.delay | ||
|
||
class MockProfileClientImpl : ProfileClient { | ||
|
||
override suspend fun getProfile(uuid: String): ProfileResponse { | ||
delay(2000) | ||
return ProfileResponse( | ||
uuid = "uuid", | ||
username = "John Doe", | ||
avatarUrl = "https://avatars.githubusercontent.com/u/139426?s=460&u=8f6b6e2e4e9e4b0e9b5b5e4e9b5b5e4e9b5b5e4e&v=4", | ||
bio = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec auctor, nisl eu ultricies tincidunt, nisl nisl aliquam nisl,", | ||
followers = 100, | ||
following = 93, | ||
favouriteCount = 873 | ||
) | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...ork/src/commonMain/kotlin/com/stslex/core/network/clients/profile/client/ProfileClient.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,8 @@ | ||
package com.stslex.core.network.clients.profile.client | ||
|
||
import com.stslex.core.network.clients.profile.model.ProfileResponse | ||
|
||
interface ProfileClient { | ||
|
||
suspend fun getProfile(uuid: String): ProfileResponse | ||
} |
20 changes: 20 additions & 0 deletions
20
...src/commonMain/kotlin/com/stslex/core/network/clients/profile/client/ProfileClientImpl.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,20 @@ | ||
package com.stslex.core.network.clients.profile.client | ||
|
||
import com.stslex.core.network.client.NetworkClient | ||
import com.stslex.core.network.clients.profile.model.ProfileResponse | ||
import io.ktor.client.call.body | ||
import io.ktor.client.request.get | ||
import io.ktor.client.request.parameter | ||
|
||
class ProfileClientImpl( | ||
private val client: NetworkClient | ||
) : ProfileClient { | ||
|
||
override suspend fun getProfile( | ||
uuid: String | ||
): ProfileResponse = client.request { | ||
get("profile") { | ||
parameter("uuid", uuid) | ||
}.body() | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...rk/src/commonMain/kotlin/com/stslex/core/network/clients/profile/model/ProfileResponse.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,22 @@ | ||
package com.stslex.core.network.clients.profile.model | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ProfileResponse( | ||
@SerialName("uuid") | ||
val uuid: String, | ||
@SerialName("username") | ||
val username: String, | ||
@SerialName("avatar_url") | ||
val avatarUrl: String, | ||
@SerialName("bio") | ||
val bio: String, | ||
@SerialName("followers") | ||
val followers: Int, | ||
@SerialName("following") | ||
val following: Int, | ||
@SerialName("favourite_count") | ||
val favouriteCount: Int | ||
) |
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
10 changes: 3 additions & 7 deletions
10
core/ui/src/commonMain/kotlin/com/stslex/core/ui/mvi/StoreExt.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 |
---|---|---|
@@ -1,21 +1,17 @@ | ||
package com.stslex.core.ui.mvi | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
import cafe.adriel.voyager.core.model.ScreenModel | ||
import cafe.adriel.voyager.core.screen.Screen | ||
import cafe.adriel.voyager.koin.getScreenModel | ||
import androidx.compose.runtime.LaunchedEffect | ||
import cafe.adriel.voyager.navigator.LocalNavigator | ||
import cafe.adriel.voyager.navigator.currentOrThrow | ||
import com.stslex.core.ui.navigation.AppNavigator | ||
import org.koin.compose.getKoin | ||
|
||
@Composable | ||
inline fun <reified S : ScreenModel> Screen.getScreenStore(): S { | ||
fun setupNavigator() { | ||
val navigator = LocalNavigator.currentOrThrow | ||
val koin = getKoin() | ||
remember(navigator) { | ||
LaunchedEffect(navigator.hashCode()) { | ||
koin.get<AppNavigator>().setNavigator(navigator) | ||
} | ||
return getScreenModel<S>() | ||
} |
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
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
Oops, something went wrong.