-
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.
Merge pull request #24 from stslex/dev
dev
- Loading branch information
Showing
28 changed files
with
418 additions
and
70 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
17 changes: 17 additions & 0 deletions
17
composeApp/src/androidMain/res/xml/network_security_config.xml
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,17 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<network-security-config> | ||
<debug-overrides> | ||
<trust-anchors> | ||
<!-- Trust user added CAs while debuggable only --> | ||
<certificates src="user" /> | ||
<certificates src="system" /> | ||
</trust-anchors> | ||
</debug-overrides> | ||
|
||
<base-config cleartextTrafficPermitted="true"> | ||
<trust-anchors> | ||
<certificates src="system" /> | ||
<certificates src="user" /> | ||
</trust-anchors> | ||
</base-config> | ||
</network-security-config> |
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
14 changes: 11 additions & 3 deletions
14
...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 |
---|---|---|
@@ -1,20 +1,28 @@ | ||
package com.stslex.core.network.clients.profile.client | ||
|
||
import com.stslex.core.network.api.base.NetworkClient | ||
import com.stslex.core.network.api.server.ServerApiClient | ||
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 | ||
private val client: ServerApiClient | ||
) : ProfileClient { | ||
|
||
override suspend fun getProfile( | ||
uuid: String | ||
): ProfileResponse = client.request { | ||
get("profile") { | ||
get(HOST){ | ||
parameter("uuid", uuid) | ||
}.body() | ||
} | ||
|
||
override suspend fun getProfile(): ProfileResponse = client.request { | ||
get(HOST).body() | ||
} | ||
|
||
companion object { | ||
private const val HOST = "user" | ||
} | ||
} |
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
83 changes: 83 additions & 0 deletions
83
core/ui/src/commonMain/kotlin/com/stslex/core/ui/components/AppSnackbar.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,83 @@ | ||
package com.stslex.core.ui.components | ||
|
||
import androidx.compose.foundation.gestures.Orientation | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.material.ExperimentalMaterialApi | ||
import androidx.compose.material.Snackbar | ||
import androidx.compose.material.Text | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.Info | ||
import androidx.compose.material.rememberSwipeableState | ||
import androidx.compose.material.swipeable | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.layout.onGloballyPositioned | ||
|
||
@OptIn(ExperimentalMaterialApi::class) | ||
@Composable | ||
fun AppSnackbar( | ||
type: SnackbarType, | ||
modifier: Modifier = Modifier, | ||
) { | ||
val swipeableState = rememberSwipeableState(SnackbarSwipeState.NONE) | ||
var width by remember { mutableStateOf(0f) } | ||
|
||
Snackbar( | ||
modifier = modifier | ||
.swipeable( | ||
state = swipeableState, | ||
orientation = Orientation.Horizontal, | ||
anchors = mapOf( | ||
0f to SnackbarSwipeState.LEFT, | ||
width * 0.5f to SnackbarSwipeState.RIGHT, | ||
width to SnackbarSwipeState.RIGHT | ||
), | ||
) | ||
.onGloballyPositioned { | ||
width = it.size.width.toFloat() | ||
}, | ||
action = { | ||
Text(text = "OK") | ||
} | ||
) { | ||
Row { | ||
Icon( | ||
imageVector = Icons.Default.Info, | ||
contentDescription = "info" | ||
) | ||
Text( | ||
modifier = Modifier, | ||
text = type.message, | ||
color = MaterialTheme.colorScheme.onBackground | ||
) | ||
} | ||
} | ||
} | ||
|
||
enum class SnackbarSwipeState { | ||
LEFT, | ||
RIGHT, | ||
NONE | ||
} | ||
|
||
sealed class SnackbarType( | ||
val message: String | ||
) { | ||
data class Error( | ||
private val mes: String | ||
) : SnackbarType(mes) | ||
|
||
data class Success( | ||
private val mes: String | ||
) : SnackbarType(mes) | ||
|
||
data class Info( | ||
private val mes: String | ||
) : SnackbarType(mes) | ||
} |
Oops, something went wrong.