-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
101 changed files
with
3,594 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
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,12 @@ | ||
# Sample | ||
The sample application consists of several screens. Each screen demonstrates certain Sesame feature. | ||
|
||
COUNTER - shows how to use properties and commands from [property](https://github.com/aartikov/Sesame/tree/master/sesame-property). | ||
PROFILE - loads ordinary data with [loading](https://github.com/aartikov/Sesame/tree/master/sesame-loading). | ||
DIALOGS - shows how to use [dialog](https://github.com/aartikov/Sesame/tree/master/sesame-dialog) and [localized string](https://github.com/aartikov/Sesame/tree/master/sesame-localized-string). | ||
MOVIES - loads paged data with [loading](https://github.com/aartikov/Sesame/tree/master/sesame-loading). | ||
CLOCK - shows how to use [activable](https://github.com/aartikov/Sesame/tree/master/sesame-activable). | ||
FORM - validates input fields with [form](https://github.com/aartikov/Sesame/tree/master/sesame-form). | ||
The whole app - demonstrates [navigation](https://github.com/aartikov/Sesame/tree/master/sesame-navigation). | ||
|
||
There is no sample for [loop](https://github.com/aartikov/Sesame/tree/master/sesame-loop). See [LoadingLoop](https://github.com/aartikov/Sesame/blob/master/sesame-loading/src/main/kotlin/me/aartikov/sesame/loading/simple/internal/LoadingLoop.kt) and [PagedLoadingLoop](https://github.com/aartikov/Sesame/blob/master/sesame-loading/src/main/kotlin/me/aartikov/sesame/loading/paged/internal/PagedLoadingLoop.kt) as good examples how to use it. |
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,71 @@ | ||
apply plugin: "com.android.application" | ||
apply plugin: "kotlin-android" | ||
apply plugin: "kotlin-parcelize" | ||
|
||
android { | ||
compileSdkVersion 31 | ||
|
||
defaultConfig { | ||
applicationId "me.aartikov.sesamecomposesample" | ||
minSdkVersion 21 | ||
targetSdkVersion 31 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
|
||
compileOptions { | ||
coreLibraryDesugaringEnabled true | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
|
||
kotlinOptions { | ||
jvmTarget = '1.8' | ||
useIR = true | ||
freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn" | ||
} | ||
buildFeatures { | ||
compose true | ||
} | ||
composeOptions { | ||
kotlinCompilerExtensionVersion versions.compose | ||
} | ||
|
||
sourceSets { | ||
main.java.srcDirs += "src/main/kotlin" | ||
} | ||
} | ||
|
||
dependencies { | ||
coreLibraryDesugaring desugaring | ||
|
||
implementation project(":sesame-activable") | ||
implementation project(":sesame-dialog") | ||
implementation project(":sesame-form") | ||
implementation project(":sesame-loading") | ||
implementation project(":sesame-localized-string") | ||
implementation project(":sesame-compose-form") | ||
|
||
implementation androidx.appCompat | ||
implementation androidx.activityCompose | ||
|
||
implementation compose.ui | ||
implementation compose.material | ||
implementation compose.uiTooling | ||
implementation "androidx.compose.material:material-icons-extended:1.0.1" | ||
|
||
implementation decompose.core | ||
implementation decompose.compose | ||
|
||
implementation coroutines.core | ||
implementation coroutines.android | ||
implementation dateTime | ||
|
||
implementation coil | ||
|
||
implementation koin | ||
|
||
implementation accompanist.swiperefresh | ||
|
||
implementation konfetti | ||
} |
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,27 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="me.aartikov.sesamecomposesample"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET"/> | ||
|
||
<application | ||
android:allowBackup="false" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity | ||
android:name="me.aartikov.sesamecomposesample.MainActivity" | ||
android:windowSoftInputMode="adjustResize" | ||
android:configChanges="density|fontScale|keyboard|keyboardHidden|layoutDirection|locale|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
|
||
<category android:name="android.intent.category.LAUNCHER"/> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
42 changes: 42 additions & 0 deletions
42
compose-sample/src/main/kotlin/me/aartikov/sesamecomposesample/MainActivity.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,42 @@ | ||
package me.aartikov.sesamecomposesample | ||
|
||
import android.os.Bundle | ||
import androidx.activity.compose.setContent | ||
import androidx.appcompat.app.AppCompatActivity | ||
import com.arkivanov.decompose.defaultComponentContext | ||
import me.aartikov.sesamecomposesample.di.* | ||
import me.aartikov.sesamecomposesample.root.RootUi | ||
import me.aartikov.sesamecomposesample.theme.AppTheme | ||
import org.koin.android.ext.koin.androidContext | ||
import org.koin.core.module.Module | ||
import org.koin.dsl.koinApplication | ||
|
||
class MainActivity : AppCompatActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
val koin = koinApplication { | ||
androidContext(this@MainActivity) | ||
modules(getAllModules()) | ||
}.koin | ||
|
||
koin.declare(ComponentFactory(koin)) | ||
|
||
val rootComponent = koin.get<ComponentFactory>().createRootComponent( | ||
defaultComponentContext() | ||
) | ||
|
||
setContent { | ||
AppTheme { | ||
RootUi(rootComponent) | ||
} | ||
} | ||
} | ||
|
||
private fun getAllModules(): List<Module> = listOf( | ||
GatewayModule.create(), | ||
InteractorModule.create(), | ||
ServiceModule.create() | ||
) | ||
} |
58 changes: 58 additions & 0 deletions
58
compose-sample/src/main/kotlin/me/aartikov/sesamecomposesample/base/widget/ComposeWidget.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,58 @@ | ||
package me.aartikov.sesamecomposesample.base.widget | ||
|
||
import androidx.compose.foundation.layout.* | ||
import androidx.compose.material.CircularProgressIndicator | ||
import androidx.compose.material.MaterialTheme | ||
import androidx.compose.material.Text | ||
import androidx.compose.material.TextButton | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.unit.dp | ||
import me.aartikov.sesamecomposesample.R | ||
|
||
@Composable | ||
fun ProgressWidget() { | ||
Row( | ||
modifier = Modifier.fillMaxSize(), | ||
verticalAlignment = Alignment.CenterVertically, | ||
horizontalArrangement = Arrangement.Center | ||
) { | ||
CircularProgressIndicator( | ||
color = MaterialTheme.colors.secondary | ||
) | ||
} | ||
} | ||
|
||
@Composable | ||
fun PlaceholderWidget( | ||
message: String, | ||
onRetry: () -> Unit | ||
) { | ||
Box { | ||
Column( | ||
verticalArrangement = Arrangement.spacedBy(18.dp), | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
modifier = Modifier | ||
.padding(horizontal = 18.dp) | ||
.align(Alignment.Center) | ||
.fillMaxWidth() | ||
) { | ||
Text( | ||
text = message, | ||
textAlign = TextAlign.Center, | ||
modifier = Modifier.fillMaxWidth(), | ||
style = MaterialTheme.typography.body2 | ||
) | ||
TextButton( | ||
onClick = onRetry | ||
) { | ||
Text( | ||
text = stringResource(R.string.common_retry).uppercase() | ||
) | ||
} | ||
} | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
compose-sample/src/main/kotlin/me/aartikov/sesamecomposesample/counter/CounterButton.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,52 @@ | ||
package me.aartikov.sesamecomposesample.counter | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.shape.CircleShape | ||
import androidx.compose.material.Button | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import me.aartikov.sesamecomposesample.theme.AppTheme | ||
|
||
enum class CounterIcon(val symbol: Char) { | ||
Minus('–'), | ||
Plus('+') | ||
} | ||
|
||
@Composable | ||
fun CounterButton( | ||
icon: CounterIcon, | ||
onClick: () -> Unit, | ||
modifier: Modifier = Modifier, | ||
enabled: Boolean = true | ||
) { | ||
Button( | ||
onClick = onClick, | ||
enabled = enabled, | ||
shape = CircleShape, | ||
modifier = modifier.size(42.dp), | ||
contentPadding = PaddingValues(0.dp) | ||
) { | ||
Text( | ||
text = icon.symbol.toString(), | ||
fontSize = 24.sp | ||
) | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
fun CounterButtonsPreview() { | ||
AppTheme { | ||
Row(horizontalArrangement = Arrangement.spacedBy(16.dp)) { | ||
CounterButton(CounterIcon.Minus, onClick = {}, enabled = false) | ||
CounterButton(CounterIcon.Plus, onClick = {}, enabled = true) | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
compose-sample/src/main/kotlin/me/aartikov/sesamecomposesample/counter/CounterComponent.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,14 @@ | ||
package me.aartikov.sesamecomposesample.counter | ||
|
||
interface CounterComponent { | ||
|
||
val count: Int | ||
|
||
val minusButtonEnabled: Boolean | ||
|
||
val plusButtonEnabled: Boolean | ||
|
||
fun onMinusButtonClick() | ||
|
||
fun onPlusButtonClick() | ||
} |
Oops, something went wrong.