Skip to content

Commit

Permalink
Merge pull request #26 from stslex/dev
Browse files Browse the repository at this point in the history
fix logout
  • Loading branch information
stslex committed Feb 1, 2024
2 parents 96ec883 + 360625e commit 4155511
Show file tree
Hide file tree
Showing 42 changed files with 1,150 additions and 82 deletions.
1 change: 1 addition & 0 deletions composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ kotlin {
implementation(project(":feature:profile"))
implementation(project(":feature:match_feed"))
implementation(project(":feature:auth"))
implementation(project(":feature:follower"))
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions composeApp/src/commonMain/kotlin/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.stslex.core.ui.theme.AppTheme
import com.stslex.feature.auth.di.featureAuthModule
import com.stslex.feature.film.di.featureFilmModule
import com.stslex.feature.film_feed.di.featureFeedModule
import com.stslex.feature.follower.di.featureFollowerModule
import com.stslex.feature.match_feed.di.featureMatchFeedModule
import com.stslex.feature.profile.di.featureProfileModule
import di.appModule
Expand Down Expand Up @@ -42,6 +43,7 @@ private fun KoinApplication.setupCommonModules() {
featureProfileModule,
featureMatchFeedModule,
featureAuthModule,
featureFollowerModule
)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.compose.ui.graphics.vector.rememberVectorPainter
import cafe.adriel.voyager.navigator.Navigator
import cafe.adriel.voyager.navigator.tab.Tab
import cafe.adriel.voyager.navigator.tab.TabOptions
import com.stslex.feature.profile.navigation.ProfileScreenArguments
import com.stslex.feature.profile.ui.ProfileScreen

object ProfileTab : Tab {
Expand All @@ -29,6 +30,8 @@ object ProfileTab : Tab {

@Composable
override fun Content() {
Navigator(ProfileScreen)
Navigator(
ProfileScreen(args = ProfileScreenArguments.Self)
)
}
}
18 changes: 18 additions & 0 deletions composeApp/src/commonMain/kotlin/navigator/AppNavigatorImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import com.stslex.core.ui.navigation.AppNavigator
import com.stslex.core.ui.navigation.AppScreen
import com.stslex.feature.auth.ui.AuthScreen
import com.stslex.feature.film.ui.FilmScreen
import com.stslex.feature.follower.ui.FollowerScreen
import com.stslex.feature.follower.navigation.FollowerScreenArgs
import com.stslex.feature.match_feed.ui.MatchFeedScreen
import main_screen.MainScreen

Expand Down Expand Up @@ -36,6 +38,22 @@ class AppNavigatorImpl : AppNavigator {
AppScreen.Main -> navigator.replaceAll(MainScreen)
is AppScreen.Film -> navigator.push(FilmScreen(screen.id))
AppScreen.MatchFeed -> navigator.push(MatchFeedScreen)
is AppScreen.Favourite -> TODO()
is AppScreen.Followers -> navigator.push(
FollowerScreen(
args = FollowerScreenArgs.Follower(
uuid = screen.uuid
)
)
)

is AppScreen.Following -> navigator.push(
FollowerScreen(
args = FollowerScreenArgs.Following(
uuid = screen.uuid
)
)
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class AuthClientImpl(
username: String,
password: String
): LoginOkResponse = networkClient.request {
post("$AUTH_URL/register") {
post("$AUTH_URL/registration") {
setBody(
RegisterRequest(
login = login,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
package com.stslex.core.network.clients.profile.client

import com.stslex.core.network.clients.profile.model.ProfileResponse
import com.stslex.core.network.clients.profile.model.UserFavouriteResponse
import com.stslex.core.network.clients.profile.model.UserFavouriteResultResponse
import com.stslex.core.network.clients.profile.model.UserFollowerResponse
import com.stslex.core.network.clients.profile.model.UserFollowerResultResponse
import com.stslex.core.network.clients.profile.model.UserSearchResponse
import com.stslex.core.network.clients.profile.model.UserSearchResultResponse
import kotlinx.coroutines.delay

class MockProfileClientImpl : ProfileClient {
Expand All @@ -18,7 +24,76 @@ class MockProfileClientImpl : ProfileClient {
)
}

override suspend fun getProfile(): ProfileResponse {
TODO("Not yet implemented")
override suspend fun getProfile(): ProfileResponse = getProfile("uuid")

override suspend fun searchUser(
query: String,
page: Int,
pageSize: Int
): UserSearchResponse {
delay(2000)
return UserSearchResponse(
result = listOf(
UserSearchResultResponse(
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,",
followersCount = 100,
followingCount = 93,
favouritesCount = 873
),
)
)
}

override suspend fun getFavourites(
uuid: String,
page: Int,
pageSize: Int
): UserFavouriteResponse {
delay(2000)
return UserFavouriteResponse(
result = listOf(
UserFavouriteResultResponse(
uuid = "uuid",
title = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec auctor, nisl eu ultricies tincidunt, nisl nisl aliquam nisl,",
),
)
)
}

override suspend fun getFollowers(
uuid: String,
page: Int,
pageSize: Int
): UserFollowerResponse {
delay(2000)
return UserFollowerResponse(
result = listOf(
UserFollowerResultResponse(
uuid = "uuid",
username = "John Doe",
avatarUrl = "https://avatars.githubusercontent.com/u/139426?s=460&u=8f6b6e2e4e9e4b0e9b5b5e4e9b5b5e4e9b5b5e4e&v=4",
),
)
)
}

override suspend fun getFollowing(
uuid: String,
page: Int,
pageSize: Int
): UserFollowerResponse {
delay(2000)
return UserFollowerResponse(
result = listOf(
UserFollowerResultResponse(
uuid = "uuid",
username = "John Doe",
avatarUrl = "https://avatars.githubusercontent.com/u/139426?s=460&u=8f6b6e2e4e9e4b0e9b5b5e4e9b5b5e4e9b5b5e4e&v=4",
),
)
)
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,37 @@
package com.stslex.core.network.clients.profile.client

import com.stslex.core.network.clients.profile.model.ProfileResponse
import com.stslex.core.network.clients.profile.model.UserFavouriteResponse
import com.stslex.core.network.clients.profile.model.UserFollowerResponse
import com.stslex.core.network.clients.profile.model.UserSearchResponse

interface ProfileClient {

suspend fun getProfile(uuid: String): ProfileResponse

suspend fun getProfile(): ProfileResponse

suspend fun searchUser(
query: String,
page: Int,
pageSize: Int
): UserSearchResponse

suspend fun getFavourites(
uuid: String,
page: Int,
pageSize: Int
): UserFavouriteResponse

suspend fun getFollowers(
uuid: String,
page: Int,
pageSize: Int
): UserFollowerResponse

suspend fun getFollowing(
uuid: String,
page: Int,
pageSize: Int
): UserFollowerResponse
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package com.stslex.core.network.clients.profile.client

import com.stslex.core.network.api.server.client.ServerApiClient
import com.stslex.core.network.clients.profile.model.ProfileResponse
import com.stslex.core.network.clients.profile.model.UserFavouriteResponse
import com.stslex.core.network.clients.profile.model.UserFollowerResponse
import com.stslex.core.network.clients.profile.model.UserSearchResponse
import io.ktor.client.call.body
import io.ktor.client.request.get
import io.ktor.client.request.parameter
Expand All @@ -13,7 +16,7 @@ class ProfileClientImpl(
override suspend fun getProfile(
uuid: String
): ProfileResponse = client.request {
get(HOST){
get(HOST) {
parameter("uuid", uuid)
}.body()
}
Expand All @@ -22,6 +25,54 @@ class ProfileClientImpl(
get(HOST).body()
}

override suspend fun searchUser(
query: String,
page: Int,
pageSize: Int
): UserSearchResponse = client.request {
get("$HOST/search") {
parameter("query", query)
parameter("page", page)
parameter("page_size", pageSize)
}.body()
}

override suspend fun getFavourites(
uuid: String,
page: Int,
pageSize: Int
): UserFavouriteResponse = client.request {
get("$HOST/favourites") {
parameter("uuid", uuid)
parameter("page", page)
parameter("page_size", pageSize)
}.body()
}

override suspend fun getFollowers(
uuid: String,
page: Int,
pageSize: Int
): UserFollowerResponse = client.request {
get("$HOST/followers") {
parameter("uuid", uuid)
parameter("page", page)
parameter("page_size", pageSize)
}.body()
}

override suspend fun getFollowing(
uuid: String,
page: Int,
pageSize: Int
): UserFollowerResponse = client.request {
get("$HOST/following") {
parameter("uuid", uuid)
parameter("page", page)
parameter("page_size", pageSize)
}.body()
}

companion object {
private const val HOST = "user"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.stslex.core.network.clients.profile.model

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class UserFavouriteResponse(
@SerialName("result")
val result: List<UserFavouriteResultResponse>,
)

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.stslex.core.network.clients.profile.model

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class UserFavouriteResultResponse(
@SerialName("uuid")
val uuid: String,
@SerialName("title")
val title: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.stslex.core.network.clients.profile.model

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class UserFollowerResponse(
@SerialName("result")
val result: List<UserFollowerResultResponse>,
)

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.stslex.core.network.clients.profile.model

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class UserFollowerResultResponse(
@SerialName("uuid")
val uuid: String,
@SerialName("username")
val username: String,
@SerialName("avatar_url")
val avatarUrl: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.stslex.core.network.clients.profile.model

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class UserSearchResponse(
@SerialName("result")
val result: List<UserSearchResultResponse>,
)
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 UserSearchResultResponse(
@SerialName("uuid")
val uuid: String,
@SerialName("username")
val username: String,
@SerialName("avatar_url")
val avatarUrl: String,
@SerialName("bio")
val bio: String,
@SerialName("followers_count")
val followersCount: Int,
@SerialName("following_count")
val followingCount: Int,
@SerialName("favourites_count")
val favouritesCount: Int,
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ class AuthControllerImpl(
private val userStore: UserStore
) : AuthController {

init {
userStore.accessToken = "123"
}

override val isAuth: Boolean
get() = userStore.accessToken.isNotEmpty()
get() = userStore.accessToken.isNotBlank() &&
userStore.refreshToken.isNotBlank() &&
userStore.username.isNotBlank() &&
userStore.uuid.isNotBlank()

private val _isAuthFlow: MutableStateFlow<Boolean> = MutableStateFlow(isAuth)
override val isAuthFlow: StateFlow<Boolean> = _isAuthFlow.asStateFlow()
Expand Down
Loading

0 comments on commit 4155511

Please sign in to comment.