Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
aartikov committed Dec 23, 2021
2 parents 46cca40 + 98ed976 commit 037fa0e
Show file tree
Hide file tree
Showing 101 changed files with 3,594 additions and 34 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ Sesame components are separate modules. Use only that you like.
## Gradle Setup
```gradle
dependencies {
implementation 'com.github.aartikov:sesame-property:1.2.0-beta1'
implementation 'com.github.aartikov:sesame-dialog:1.2.0-beta1'
implementation 'com.github.aartikov:sesame-navigation:1.2.0-beta1'
implementation 'com.github.aartikov:sesame-activable:1.2.0-beta1'
implementation 'com.github.aartikov:sesame-loading:1.2.0-beta1'
implementation 'com.github.aartikov:sesame-loop:1.2.0-beta1'
implementation 'com.github.aartikov:sesame-localized-string:1.2.0-beta1'
implementation 'com.github.aartikov:sesame-form:1.2.0-beta1'
implementation 'com.github.aartikov:sesame-property:1.3.0-beta1'
implementation 'com.github.aartikov:sesame-dialog:1.3.0-beta1'
implementation 'com.github.aartikov:sesame-navigation:1.3.0-beta1'
implementation 'com.github.aartikov:sesame-activable:1.3.0-beta1'
implementation 'com.github.aartikov:sesame-loading:1.3.0-beta1'
implementation 'com.github.aartikov:sesame-loop:1.3.0-beta1'
implementation 'com.github.aartikov:sesame-localized-string:1.3.0-beta1'
implementation 'com.github.aartikov:sesame-form:1.3.0-beta1'
}
```

Expand Down
7 changes: 3 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ apply from: "dependencies.gradle"
apply from: "androidLibraryConfig.gradle"

buildscript {
ext.kotlin_version = "1.4.31"
ext.kotlin_version = "1.5.31"
repositories {
mavenCentral()
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.2"
classpath "com.android.tools.build:gradle:7.0.1"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.google.dagger:hilt-android-gradle-plugin:2.32-alpha"
classpath "com.google.dagger:hilt-android-gradle-plugin:2.38.1"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:1.4.20"
}
}
Expand Down
1 change: 1 addition & 0 deletions compose-sample/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
12 changes: 12 additions & 0 deletions compose-sample/README.md
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.
71 changes: 71 additions & 0 deletions compose-sample/build.gradle
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
}
27 changes: 27 additions & 0 deletions compose-sample/src/main/AndroidManifest.xml
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>
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()
)
}
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()
)
}
}
}
}
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)
}
}
}
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()
}
Loading

0 comments on commit 037fa0e

Please sign in to comment.