Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compose Multiplatform #89

Open
wants to merge 59 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
487261f
refactor core module to multiplatform
DatL4g Mar 29, 2024
58908fb
multiplatform core module
DatL4g Mar 29, 2024
1d38e02
fix old android targets
DatL4g Mar 29, 2024
2f65c32
prepare calendar multiplatform
DatL4g Mar 29, 2024
392641f
calendar multiplatform compatible
DatL4g Mar 29, 2024
afa6178
rating multiplatform compatible
DatL4g Mar 30, 2024
5393ed2
option multiplatform compatible
DatL4g Mar 30, 2024
50dcb48
list multiplatform compatible
DatL4g Mar 30, 2024
83dde05
multiplatform landscape check
DatL4g Mar 30, 2024
8e11b75
prepare snapshot release
DatL4g Mar 30, 2024
75d6893
fix snapshot release
DatL4g Mar 30, 2024
0cd7fa2
added release workflow
DatL4g Mar 30, 2024
da08075
api core library
DatL4g Mar 30, 2024
8ecc373
make states fully serializable
DatL4g Mar 30, 2024
14e7852
added missing java serialization
DatL4g Mar 30, 2024
981caa0
skip workflows
DatL4g Mar 30, 2024
3da43ed
fix calendar module
DatL4g Mar 30, 2024
4efdbde
fix calendar module
DatL4g Mar 30, 2024
879f669
fix calendar resources
DatL4g Mar 30, 2024
87bb4a0
fix calendar arrow size
DatL4g Mar 30, 2024
ba08232
added default selection for rating
DatL4g Apr 3, 2024
a8ba838
fix resources
DatL4g Apr 3, 2024
b795aa9
added possibility to deselect rating and rating of 0 is valid
DatL4g Apr 4, 2024
47a5cca
migrate state module
DatL4g Apr 4, 2024
8d3262e
migrate input module
DatL4g Apr 4, 2024
adeb1c0
migrate info module
DatL4g Apr 4, 2024
6f30cb1
migrate color module
DatL4g Apr 4, 2024
446bdd0
migrate emoji module
DatL4g Apr 11, 2024
37bc03c
migrate emoji module
DatL4g Apr 11, 2024
2a6a658
migrate date_time module
DatL4g Apr 11, 2024
dcc5d95
migrate date_time module
DatL4g Apr 11, 2024
7b2940a
migrate date_time module
DatL4g Apr 11, 2024
0d1f94e
migrate duration module
DatL4g Apr 12, 2024
38d3372
migrate clock module
DatL4g Apr 12, 2024
1d5bfa7
added missing configuration
DatL4g Apr 12, 2024
b29bc84
changed readme as core module is not required to add manually anymore
DatL4g Apr 12, 2024
02dbb78
added wasm target
DatL4g Apr 12, 2024
a6a90ff
added missing wasm implementations
DatL4g Apr 12, 2024
5f185b5
chore(deps): ⬆️ Upgraded Compose versions
maicol07 Apr 15, 2024
fb7d802
refactor: Moved dependency management from buildSrc to Version Catalog
maicol07 Apr 16, 2024
1c81161
Merge pull request #1 from maicol07/main
DatL4g Apr 16, 2024
da9f1f1
updated compose
DatL4g Apr 17, 2024
3886da0
ignore some fields from java serialization
DatL4g Apr 18, 2024
8c34770
roll back compose version
DatL4g Apr 18, 2024
e53bb5f
update to latest compose version
DatL4g Apr 29, 2024
cee7dbe
update to latest compose version
DatL4g Apr 30, 2024
90b23af
option invoke click listener
DatL4g Apr 30, 2024
01e57b0
option icon size
DatL4g May 12, 2024
b022d95
rating body max width
DatL4g May 12, 2024
dd2451a
revert sizing
DatL4g May 12, 2024
f16d2d3
revert LocalDate calculations and fix visual error
DatL4g May 13, 2024
dce4cd0
removed unused file
DatL4g May 13, 2024
f21cd3d
apply system locale on jvm
DatL4g May 14, 2024
24de041
added missing localization
DatL4g May 14, 2024
27692e6
added body for option
DatL4g May 14, 2024
ed2ba8c
added missing body dependency injection
DatL4g May 14, 2024
d2848f5
updated compose
DatL4g May 17, 2024
01f3361
updated dependencies
DatL4g May 22, 2024
3518cc7
fix crash on android
DatL4g May 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
migrate input module
  • Loading branch information
DatL4g committed Apr 4, 2024
commit 8d3262ecbc206ce151f6cc88d0b242e644e78323
71 changes: 52 additions & 19 deletions input/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,27 +1,60 @@
/*
* Copyright (C) 2022-2024. Maximilian Keppeler (https://www.maxkeppeler.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import com.vanniktech.maven.publish.SonatypeHost

plugins {
id(Plugins.CUSTOM_LIBRARY_MODULE.id)
alias(libs.plugins.android.library)
alias(libs.plugins.compose)
alias(libs.plugins.multiplatform)
alias(libs.plugins.serialization)
alias(libs.plugins.publish)
`maven-publish`
}

android {
namespace = Modules.INPUT.namespace
compileSdk = 34

defaultConfig {
minSdk = 21
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
}

kotlin {
androidTarget {
publishAllLibraryVariants()
}
jvm()

iosX64()
iosArm64()
iosSimulatorArm64()

macosX64()
macosArm64()

js(IR) {
browser()
binaries.executable()
}

applyDefaultHierarchyTemplate()

sourceSets {
commonMain.dependencies {
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material3)

implementation(libs.serialization)

api(project(":core"))
}
}
}

mavenPublishing {
publishToMavenCentral()
signAllPublications()
}
publishToMavenCentral(SonatypeHost.S01, automaticRelease = true)
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import com.maxkeppeler.sheets.input.models.InputSelection
* @param offset The offset of the popup.
* @param properties PopupProperties for further customization of this popup's behavior.
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun InputPopup(
state: UseCaseState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
*/
package com.maxkeppeler.sheets.input

import android.os.Bundle
import androidx.compose.runtime.*
import androidx.compose.runtime.saveable.Saver
import androidx.compose.runtime.saveable.rememberSaveable
import com.maxkeppeker.sheets.core.utils.JvmSerializable
import com.maxkeppeker.sheets.core.views.BaseTypeState
import com.maxkeppeler.sheets.input.models.Input
import com.maxkeppeler.sheets.input.models.InputSelection
import java.io.Serializable
import kotlinx.serialization.Serializable

/**
* Handles the list state.
Expand Down Expand Up @@ -61,14 +61,12 @@ internal class InputState(
}

fun onFinish() {
val bundle = Bundle()
input.forEach { input ->
if (input.isInput()) {
input.onResult()
input.putValue(bundle)
}
}
selection.onPositiveClick?.invoke(bundle)
selection.onPositiveClick?.invoke()
}

override fun reset() {
Expand All @@ -95,9 +93,10 @@ internal class InputState(
* Data class that stores the important information of the current state
* and can be used by the [Saver] to save and restore the state.
*/
@Serializable
data class InputStateData(
val input: List<Input>
) : Serializable
) : JvmSerializable
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

package com.maxkeppeler.sheets.input.models

import android.os.Bundle
import java.io.Serializable
import com.maxkeppeker.sheets.core.utils.JvmSerializable
import kotlinx.serialization.Serializable

/**
* Base input definition that can be added to the input dialog.
Expand All @@ -27,12 +27,13 @@ import java.io.Serializable
* @param header The additional [InputHeader] to add more context information to the selection.
* @param columns The columns that this input spans.
*/
@Serializable
abstract class Input(
internal open val key: String? = null,
internal open val required: Boolean = false,
internal open val header: InputHeader? = null,
internal open val columns: Int? = null,
) : Serializable {
) : JvmSerializable {

internal var position: Int = 0

Expand All @@ -58,13 +59,6 @@ abstract class Input(
*/
internal open fun onResult(): Unit? = Unit

/**
* Save the input value into the bundle.
* Takes the index as an key, if there's no unique input key available.
* @param bundle The bundle where the input data is saved.
*/
internal open fun putValue(bundle: Bundle): Unit? = Unit

/**
* Helper method that either uses the key or the index as String to assign key-value pairs
* Returns the key that is used to store input data in the bundle.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

package com.maxkeppeler.sheets.input.models

import android.os.Bundle

/**
* Represents a checkbox.
* @param text The text to the checkbox.
Expand Down Expand Up @@ -56,6 +54,4 @@ class InputCheckbox(

override fun isValid(): Boolean = (required && value) || !required

override fun putValue(bundle: Bundle) = bundle.putBoolean(getBundleKey(), value)

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

package com.maxkeppeler.sheets.input.models

import android.os.Bundle

/**
* Represents a group of checkboxes.
* @param items A list of Strings representing the individual checkbox text.
Expand Down Expand Up @@ -55,6 +53,4 @@ class InputCheckboxGroup(
override fun onResult() = resultListener?.invoke(value)

override fun isValid(): Boolean = required && value.isNotEmpty() || !required

override fun putValue(bundle: Bundle) = bundle.putIntArray(getBundleKey(), value.toIntArray())
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@
package com.maxkeppeler.sheets.input.models

import com.maxkeppeker.sheets.core.models.base.IconSource
import java.io.Serializable
import com.maxkeppeker.sheets.core.utils.JvmSerializable
import kotlinx.serialization.Serializable
import kotlinx.serialization.Transient

/**
* Represents a header that can be added to invidual input types.
* @param title The text that is used for the title.
* @param body The text that is used for the body.
* @param icon The icon that is displayed on the left side of the title.
*/
@Serializable
class InputHeader(
val title: String? = null,
val body: String? = null,
val icon: IconSource? = null,
) : Serializable
@Transient val icon: IconSource? = null,
) : JvmSerializable
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

package com.maxkeppeler.sheets.input.models

import android.os.Bundle

/**
* Represents a group of radio buttons.
* @param items A list of Strings representing the individual radio button text.
Expand Down Expand Up @@ -56,6 +54,4 @@ class InputRadioButtonGroup(

override fun isValid(): Boolean = required && value != null || !required

override fun putValue(bundle: Bundle) = value?.let { bundle.putInt(getBundleKey(), it) }

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package com.maxkeppeler.sheets.input.models

import android.os.Bundle
import com.maxkeppeker.sheets.core.models.base.BaseSelection
import com.maxkeppeker.sheets.core.models.base.SelectionButton
import com.maxkeppeker.sheets.core.utils.BaseConstants
Expand All @@ -41,5 +40,5 @@ class InputSelection(
override val negativeButton: SelectionButton? = BaseConstants.DEFAULT_NEGATIVE_BUTTON,
override val onNegativeClick: (() -> Unit)? = null,
override val positiveButton: SelectionButton = BaseConstants.DEFAULT_POSITIVE_BUTTON,
val onPositiveClick: ((result: Bundle) -> Unit)? = null,
val onPositiveClick: (() -> Unit)? = null,
) : BaseSelection()
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

package com.maxkeppeler.sheets.input.models

import android.os.Bundle
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.ExperimentalMaterial3Api
Expand Down Expand Up @@ -89,8 +88,4 @@ data class InputTextField(
val requiredValid = (required && value?.isNotEmpty() == true || !required)
return customValidationOk && requiredValid
}

override fun putValue(bundle: Bundle) {
bundle.putString(getBundleKey(), value)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.unit.dp
import com.maxkeppeker.sheets.core.utils.TestTags
import com.maxkeppeker.sheets.core.utils.testTags
import com.maxkeppeler.sheets.input.models.Input
import com.maxkeppeler.sheets.input.models.InputCheckbox
import com.maxkeppeler.sheets.core.R as RC

/**
* Checkbox component.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.unit.dp
import com.maxkeppeker.sheets.core.utils.TestTags
import com.maxkeppeker.sheets.core.utils.testTags
import com.maxkeppeler.sheets.input.models.Input
import com.maxkeppeler.sheets.input.models.InputCheckboxGroup
import com.maxkeppeler.sheets.core.R as RC

/**
* Checkbox-Group component.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.unit.dp
import com.maxkeppeker.sheets.core.utils.TestTags
import com.maxkeppeker.sheets.core.utils.testTags
import com.maxkeppeler.sheets.core.R as RC

/**
* The CheckBox item for the CheckBox-Group.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.lazy.grid.itemsIndexed
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.unit.dp
import com.maxkeppeler.sheets.input.models.Input
import com.maxkeppeler.sheets.input.models.InputConfig
import com.maxkeppeler.sheets.core.R as RC

/**
* Input component that displays the setup inputs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ import androidx.compose.material3.Divider
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.unit.dp
import com.maxkeppeker.sheets.core.utils.TestTags
import com.maxkeppeker.sheets.core.utils.testTags
import com.maxkeppeler.sheets.core.R as RC

/**
* Divider component.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.unit.dp
import com.maxkeppeker.sheets.core.utils.TestTags
import com.maxkeppeker.sheets.core.utils.testTags
import com.maxkeppeker.sheets.core.views.IconComponent
import com.maxkeppeler.sheets.input.models.InputHeader
import com.maxkeppeler.sheets.core.R as RC

/**
* The header for an input item type component.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.unit.dp
import com.maxkeppeker.sheets.core.utils.TestTags
import com.maxkeppeker.sheets.core.utils.testTags
import com.maxkeppeler.sheets.input.models.InputConfig
import com.maxkeppeler.sheets.core.R as RC

/**
* The overlay for an input item type component when the data is required.
Expand All @@ -43,7 +42,7 @@ internal fun BoxScope.InputItemOverlayComponent(
.align(Alignment.TopEnd)
.testTags(TestTags.INPUT_ITEM_OVERLAY, index)
.padding(8.dp)
.size(dimensionResource(RC.dimen.scd_size_50)),
.size(8.dp),
imageVector = config.icons.Star,
contentDescription = null,
tint = MaterialTheme.colorScheme.error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.unit.dp
import com.maxkeppeker.sheets.core.utils.TestTags
import com.maxkeppeker.sheets.core.utils.testTags
import com.maxkeppeler.sheets.input.models.Input
import com.maxkeppeler.sheets.input.models.InputRadioButtonGroup
import com.maxkeppeler.sheets.core.R as RC

/**
* RadioButton-Group component.
Expand Down
Loading