Skip to content

Commit

Permalink
Merge pull request #149 from icerockdev/develop
Browse files Browse the repository at this point in the history
Release 0.1.0-dev-13
  • Loading branch information
Alex009 authored Feb 25, 2020
2 parents dca618f + 6bde6a5 commit 8291a63
Show file tree
Hide file tree
Showing 120 changed files with 2,132 additions and 1,174 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This is a Kotlin MultiPlatform library that provides declarative UI and applicat
in common code. You can implement full application for Android and iOS only from common code with it.

## Current status
Current version - `0.1.0-dev-12`. Dev version is not tested in production tasks yet, API can be changed and
Current version - `0.1.0-dev-13`. Dev version is not tested in production tasks yet, API can be changed and
bugs may be found. But dev version is chance to test limits of API and concepts to feedback and improve lib.
We open for any feedback and ideas (go to issues or #moko at [kotlinlang.slack.com](https://kotlinlang.slack.com))!

Expand Down Expand Up @@ -219,6 +219,7 @@ val loginScreen = Theme(baseTheme) {
- 0.1.0-dev-10
- 0.1.0-dev-11
- 0.1.0-dev-12
- 0.1.0-dev-13

## Installation
root build.gradle
Expand All @@ -233,7 +234,7 @@ allprojects {
project build.gradle
```groovy
dependencies {
commonMainApi("dev.icerock.moko:widgets:0.1.0-dev-12")
commonMainApi("dev.icerock.moko:widgets:0.1.0-dev-13")
}
```

Expand All @@ -251,7 +252,7 @@ buildscript {
}
dependencies {
classpath "dev.icerock.moko.widgets:gradle-plugin:0.1.0-dev-12"
classpath "dev.icerock.moko.widgets:gradle-plugin:0.1.0-dev-13"
}
}
Expand Down
8 changes: 8 additions & 0 deletions buildSrc/src/main/kotlin/Deps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ object Deps {
val appCompat = AndroidLibrary(
name = "androidx.appcompat:appcompat:${Versions.Libs.Android.appCompat}"
)
val fragment = AndroidLibrary(
name = "androidx.fragment:fragment:${Versions.Libs.Android.fragment}"
)
val swipeRefreshLayout = AndroidLibrary(
name = "androidx.swiperefreshlayout:swiperefreshlayout:${Versions.Libs.Android.swipeRefreshLayout}"
)
Expand Down Expand Up @@ -110,6 +113,11 @@ object Deps {
common = "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:${Versions.Libs.MultiPlatform.coroutines}",
ios = "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:${Versions.Libs.MultiPlatform.coroutines}"
)
val klock = MultiPlatformLibrary(
android = "com.soywiz.korlibs.klock:klock-android:${Versions.Libs.MultiPlatform.klockVersion}",
common = "com.soywiz.korlibs.klock:klock:${Versions.Libs.MultiPlatform.klockVersion}",
ios = "com.soywiz.korlibs.klock:klock:${Versions.Libs.MultiPlatform.klockVersion}"
)
}

object Jvm {
Expand Down
4 changes: 3 additions & 1 deletion buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ object Versions {
}

const val kotlin = "1.3.61"
private const val mokoWidgets = "0.1.0-dev-12"
private const val mokoWidgets = "0.1.0-dev-13"
private const val mokoResources = "0.8.0"

object Plugins {
Expand All @@ -21,6 +21,7 @@ object Versions {
object Libs {
object Android {
const val appCompat = "1.1.0"
const val fragment = "1.2.2"
const val swipeRefreshLayout = "1.0.0"
const val material = "1.1.0"
const val constraintLayout = "1.1.3"
Expand All @@ -44,6 +45,7 @@ object Versions {
const val mokoMedia = "0.2.0"
const val mokoGraphics = "0.2.0"
const val mokoParcelize = "0.2.0"
const val klockVersion = "1.8.4"
}
}
}
3 changes: 3 additions & 0 deletions publishToMavenLocal.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
./gradlew -PpluginPublish publishPluginPublicationToMavenLocal
./gradlew -PlibraryPublish :widgets:publishToMavenLocal
./gradlew -PlibraryPublish :widgets-flat:publishToMavenLocal :widgets-bottomsheet:publishToMavenLocal :widgets-sms:publishToMavenLocal
1 change: 0 additions & 1 deletion sample/ios-app/src/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class AppDelegate: NSObject, UIApplicationDelegate {

let app = App()
app.initialize()
ApplicationHolderKt.application = app

let screen = app.rootScreen.instantiate()
let rootViewController = screen.viewController
Expand Down
49 changes: 40 additions & 9 deletions sample/mpp-library/src/commonMain/kotlin/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ import dev.icerock.moko.parcelize.Parcelable
import dev.icerock.moko.parcelize.Parcelize
import dev.icerock.moko.resources.desc.desc
import dev.icerock.moko.widgets.ButtonWidget
import dev.icerock.moko.widgets.FlatAlertIds
import dev.icerock.moko.widgets.ImageWidget
import dev.icerock.moko.widgets.InputWidget
import dev.icerock.moko.widgets.TabsWidget
import dev.icerock.moko.widgets.button
import dev.icerock.moko.widgets.container
import dev.icerock.moko.widgets.core.Theme
Expand All @@ -31,8 +33,11 @@ import dev.icerock.moko.widgets.factory.IconGravity
import dev.icerock.moko.widgets.factory.LinearViewFactory
import dev.icerock.moko.widgets.factory.SystemImageViewFactory
import dev.icerock.moko.widgets.factory.SystemInputViewFactory
import dev.icerock.moko.widgets.factory.SystemTabsViewFactory
import dev.icerock.moko.widgets.factory.SystemTextViewFactory
import dev.icerock.moko.widgets.flat.FlatInputViewFactory
import dev.icerock.moko.widgets.sample.InputWidgetGalleryScreen
import dev.icerock.moko.widgets.sample.ProductsSearchScreen
import dev.icerock.moko.widgets.sample.ScrollContentScreen
import dev.icerock.moko.widgets.sample.SelectGalleryScreen
import dev.icerock.moko.widgets.screen.Args
Expand All @@ -48,20 +53,20 @@ import dev.icerock.moko.widgets.screen.navigation.NavigationItem
import dev.icerock.moko.widgets.screen.navigation.NavigationScreen
import dev.icerock.moko.widgets.screen.navigation.Resultable
import dev.icerock.moko.widgets.screen.navigation.Route
import dev.icerock.moko.widgets.screen.navigation.SelectStates
import dev.icerock.moko.widgets.screen.navigation.createPushResultRoute
import dev.icerock.moko.widgets.screen.navigation.createPushRoute
import dev.icerock.moko.widgets.screen.navigation.createReplaceRoute
import dev.icerock.moko.widgets.screen.navigation.createRouter
import dev.icerock.moko.widgets.screen.navigation.route
import dev.icerock.moko.widgets.style.background.Background
import dev.icerock.moko.widgets.style.background.Fill
import dev.icerock.moko.widgets.style.background.StateBackground
import dev.icerock.moko.widgets.style.view.CornerRadiusValue
import dev.icerock.moko.widgets.style.state.PressableState
import dev.icerock.moko.widgets.style.state.SelectableState
import dev.icerock.moko.widgets.style.view.MarginValues
import dev.icerock.moko.widgets.style.view.PaddingValues
import dev.icerock.moko.widgets.style.view.TextHorizontalAlignment
import dev.icerock.moko.widgets.style.view.TextStyle
import dev.icerock.moko.widgets.style.view.WidgetSize
import dev.icerock.moko.widgets.utils.platformSpecific

class App() : BaseApplication() {

Expand Down Expand Up @@ -100,6 +105,7 @@ class App() : BaseApplication() {
theme = theme,
routes = listOf(
buildInputGalleryRouteInfo(theme, router),
buildSearchRouteInfo(theme, router),
SelectGalleryScreen.RouteInfo(
name = "Old Demo".desc(),
route = router.createPushRoute(oldDemo(router))
Expand Down Expand Up @@ -138,7 +144,21 @@ class App() : BaseApplication() {
)
}

fun oldDemo(
private fun buildSearchRouteInfo(
theme: Theme,
router: NavigationScreen.Router
): SelectGalleryScreen.RouteInfo {
val searchScreen = registerScreen(ProductsSearchScreen::class) {
ProductsSearchScreen(theme)
}

return SelectGalleryScreen.RouteInfo(
name = "SearchScreen".desc(),
route = router.createPushRoute(searchScreen)
)
}

private fun oldDemo(
router: NavigationScreen.Router
): TypedScreenDesc<Args.Empty, LoginScreen> {
val sharedFactory = SharedFactory()
Expand All @@ -153,28 +173,39 @@ class App() : BaseApplication() {
backgroundColor = Color(0xF5F5F5FF)
)
factory[LoginScreen.Id.RegistrationButtonId] = ButtonWithIconViewFactory(
icon = MR.images.stars_black_18,
icon = PressableState(all = MR.images.stars_black_18),
iconGravity = IconGravity.TEXT_END,
iconPadding = 8.0f,
padding = PaddingValues(padding = 16f),
background = StateBackground(
background = PressableState(
normal = Background(fill = Fill.Solid(color = Color(0xAAFFFFFF))),
pressed = Background(fill = Fill.Solid(color = Color(0x88FFFFFF))),
disabled = Background(fill = Fill.Solid(color = Color(0x55FFFFFF)))
)
)
factory[ImageWidget.DefaultCategory] = SystemImageViewFactory(
cornerRadiusValue = CornerRadiusValue(16.0f)
cornerRadius = 16.0f
)
}

val widgetsTheme = Theme(theme) {
factory[FlatAlertIds.Message] = SystemTextViewFactory(
textHorizontalAlignment = TextHorizontalAlignment.CENTER
)
factory[InputWidget.DefaultCategory] = SystemInputViewFactory(
textStyle = TextStyle(
size = 16,
color = Color(0x16171AFF)
)
)
factory[TabsWidget.DefaultCategory] = SystemTabsViewFactory(
tabsTintColor = Color(0xD20C0AFF),
tabsPadding = platformSpecific(android = null, ios = PaddingValues(padding = 16f)),
titleColor = SelectableState(
selected = Color(platformSpecific(android = 0x151515FF, ios = 0xFFFFFFFF)),
unselected = platformSpecific(android = Color(0x15151599), ios = null)
)
)
}

val mainScreen = registerScreen(MainBottomNavigationScreen::class) {
Expand Down Expand Up @@ -334,7 +365,7 @@ class MainBottomNavigationScreen(
init {
bottomNavigationColor = Color(0x6518f4FF)

itemStateColors = SelectStates(
itemStateColors = SelectableState(
selected = Color(0xfdfffdFF),
unselected = Color(0xc0a3f9FF)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import dev.icerock.moko.widgets.factory.SystemTextViewFactory
import dev.icerock.moko.widgets.style.background.Background
import dev.icerock.moko.widgets.style.background.Border
import dev.icerock.moko.widgets.style.background.Fill
import dev.icerock.moko.widgets.style.background.Shape
import dev.icerock.moko.widgets.style.background.StateBackground
import dev.icerock.moko.widgets.style.state.FocusableState
import dev.icerock.moko.widgets.style.state.PressableState
import dev.icerock.moko.widgets.style.view.Colors
import dev.icerock.moko.widgets.style.view.FontStyle
import dev.icerock.moko.widgets.style.view.MarginValues
Expand Down Expand Up @@ -63,26 +63,27 @@ object AppTheme {
background = {
val normalBackground = Background(
fill = Fill.Solid(color = Color(0x1375F8FF)),
shape = Shape.Rectangle(cornerRadius = 22f)
cornerRadius = 22f
)
val disabledBackground = normalBackground.copy(
fill = Fill.Solid(color = Color(0x1375F880))
)
val pressedBackground = normalBackground.copy(
fill = Fill.Solid(color = Color(0x1375F8BB))
)
StateBackground(
PressableState(
normal = normalBackground,
disabled = disabledBackground,
pressed = pressedBackground
)
}()
}(),
textStyle = TextStyle(color = PressableState(all = Colors.white))
)
factory[CryptoProfileScreen.Id.TryDemoButton] = SystemButtonViewFactory(
background = {
val normalBackground = Background(
fill = Fill.Solid(color = Color(0x303030FF)),
shape = Shape.Rectangle(cornerRadius = 22f),
cornerRadius = 22f,
border = Border(
color = Colors.white,
width = 1f
Expand All @@ -94,12 +95,19 @@ object AppTheme {
val pressedBackground = normalBackground.copy(
fill = Fill.Solid(color = Color(0x303030BB))
)
StateBackground(
PressableState(
normal = normalBackground,
disabled = disabledBackground,
pressed = pressedBackground
)
}()
}(),
textStyle = TextStyle(
color = PressableState(
normal = Colors.white,
pressed = Color(0xAA0000FF),
disabled = Colors.white
)
)
)

factory[PostsCollection] = SystemCollectionViewFactory(
Expand All @@ -117,8 +125,10 @@ object AppTheme {

factory[InputWidget.DefaultCategory] = FloatingLabelInputViewFactory(
margins = MarginValues(bottom = 8f),
underLineColor = Color(0x000000DD),
underLineFocusedColor = Color(0x3949ABFF),
underLineColor = FocusableState(
focused = Color(0x3949ABFF),
unfocused = Color(0x000000DD)
),
labelTextStyle = TextStyle(
size = 12,
color = Color(0x3949ABFF),
Expand All @@ -141,44 +151,40 @@ object AppTheme {
factory[ButtonWidget.DefaultCategory] = SystemButtonViewFactory(
margins = MarginValues(top = 32f),
background = {
val bg: (Color) -> Background = {
val bg: (Color) -> Background<out Fill> = {
Background(
fill = Fill.Solid(it),
shape = Shape.Rectangle(
cornerRadius = corners
)
cornerRadius = corners
)
}
StateBackground(
PressableState(
normal = bg(Color(0x6770e0FF)),
pressed = bg(Color(0x6770e0EE)),
disabled = bg(Color(0x6770e0BB))
)
}.invoke(),
textStyle = TextStyle(
color = Colors.white
color = PressableState(all = Colors.white)
)
)

factory[LoginScreen.Id.RegistrationButtonId] = SystemButtonViewFactory(
background = {
val bg: (Color) -> Background = {
val bg: (Color) -> Background<out Fill> = {
Background(
fill = Fill.Solid(it),
shape = Shape.Rectangle(
cornerRadius = corners
)
cornerRadius = corners
)
}
StateBackground(
PressableState(
normal = bg(Color(0xFFFFFF00)),
pressed = bg(Color(0xE7E7EEEE)),
disabled = bg(Color(0x000000BB))
)
}.invoke(),
margins = MarginValues(top = 16f),
textStyle = TextStyle(
color = Color(0x777889FF)
color = PressableState(all = Color(0x777889FF))
),
androidElevationEnabled = false
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,12 @@ open class StateScreen(
}

private fun Theme.flatAlertWrapped(message: LiveData<StringDesc?>) =
container(size = WidgetSize.AsParent) {
center {
flatAlert(
size = WidgetSize.WrapContent,
message = message
)
}
}
flatAlert(
size = WidgetSize.AsParent,
message = message.map { it ?: "".desc() as StringDesc? },
buttonText = const("press me".desc() as StringDesc?),
onTap = { println("pressed") }
)
}

interface StateViewModelContract {
Expand Down
Loading

0 comments on commit 8291a63

Please sign in to comment.