Skip to content

Commit b3f7ba9

Browse files
committed
Compose desktop support
1 parent b7962d0 commit b3f7ba9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+967
-732
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
/.idea/workspace.xml
88
/.idea/navEditor.xml
99
/.idea/assetWizardSettings.xml
10+
.idea/artifacts/
1011
.idea/deploymentTargetDropDown.xml
1112
.DS_Store
1213
/build

.idea/.name

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/compiler.xml

+10-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+3-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.

android/build.gradle.kts

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import org.jetbrains.compose.compose
2+
3+
plugins {
4+
id("org.jetbrains.compose")
5+
id("com.android.application")
6+
kotlin("android")
7+
}
8+
9+
dependencies {
10+
implementation(project(":reorderable"))
11+
implementation(compose.runtime)
12+
implementation(compose.material)
13+
implementation("androidx.activity:activity-compose:1.3.1")
14+
implementation("com.google.android.material:material:1.4.0")
15+
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1")
16+
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha07")
17+
}
18+
19+
android {
20+
compileSdk = rootProject.extra.get("compileSdk") as Int
21+
defaultConfig {
22+
minSdk = rootProject.extra.get("minVersion") as Int
23+
targetSdk = rootProject.extra.get("targetSdk") as Int
24+
versionCode = 1
25+
versionName = "1.0"
26+
}
27+
28+
compileOptions {
29+
sourceCompatibility = JavaVersion.VERSION_1_8
30+
targetCompatibility = JavaVersion.VERSION_1_8
31+
}
32+
33+
kotlinOptions {
34+
jvmTarget = "1.8"
35+
}
36+
}

android/src/main/AndroidManifest.xml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.burnoutcrew.android">
3+
<application
4+
android:icon="@mipmap/ic_launcher"
5+
android:label="@string/app_name"
6+
android:roundIcon="@mipmap/ic_launcher_round"
7+
android:supportsRtl="true"
8+
android:theme="@style/Theme.LazyReorderList">
9+
<activity android:name=".ui.MainActivity">
10+
<intent-filter>
11+
<action android:name="android.intent.action.MAIN"/>
12+
<category android:name="android.intent.category.LAUNCHER"/>
13+
</intent-filter>
14+
</activity>
15+
</application>
16+
</manifest>

app/src/main/kotlin/io/burnoutcrew/lazyreorderlist/ui/MainActivity.kt renamed to android/src/main/kotlin/org/burnoutcrew/android/ui/MainActivity.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package io.burnoutcrew.lazyreorderlist.ui
16+
package org.burnoutcrew.android.ui
1717

1818
import android.os.Bundle
1919
import androidx.activity.ComponentActivity

app/src/main/kotlin/io/burnoutcrew/lazyreorderlist/ui/Root.kt renamed to android/src/main/kotlin/org/burnoutcrew/android/ui/Root.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package io.burnoutcrew.lazyreorderlist.ui
16+
package org.burnoutcrew.android.ui
1717

1818
import androidx.compose.material.Scaffold
1919
import androidx.compose.material.Text
2020
import androidx.compose.material.TopAppBar
2121
import androidx.compose.runtime.Composable
2222
import androidx.compose.ui.res.stringResource
23-
import io.burnoutcrew.lazyreorderlist.R
24-
import io.burnoutcrew.lazyreorderlist.ui.reorderlist.ReorderList
25-
import io.burnoutcrew.lazyreorderlist.ui.theme.ReorderListTheme
23+
import org.burnoutcrew.android.R
24+
import org.burnoutcrew.android.ui.reorderlist.ReorderList
25+
import org.burnoutcrew.android.ui.theme.ReorderListTheme
2626

2727
@Composable
2828
fun Root() {

app/src/main/kotlin/io/burnoutcrew/lazyreorderlist/ui/reorderlist/ItemData.kt renamed to android/src/main/kotlin/org/burnoutcrew/android/ui/reorderlist/ItemData.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package io.burnoutcrew.lazyreorderlist.ui.reorderlist
16+
package org.burnoutcrew.android.ui.reorderlist
1717

1818
import androidx.compose.runtime.Stable
1919

app/src/main/kotlin/io/burnoutcrew/lazyreorderlist/ui/reorderlist/ReorderList.kt renamed to android/src/main/kotlin/org/burnoutcrew/android/ui/reorderlist/ReorderList.kt

+11-20
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package io.burnoutcrew.lazyreorderlist.ui.reorderlist
16+
package org.burnoutcrew.android.ui.reorderlist
1717

1818

1919
import androidx.compose.foundation.Image
@@ -38,7 +38,8 @@ import androidx.compose.ui.draw.scale
3838
import androidx.compose.ui.graphics.Color
3939
import androidx.compose.ui.unit.dp
4040
import androidx.lifecycle.viewmodel.compose.viewModel
41-
import io.burnoutcrew.reorderable.*
41+
import org.burnoutcrew.reorderable.*
42+
4243

4344
@Composable
4445
fun ReorderList(vm: ReorderListViewModel = viewModel()) {
@@ -63,13 +64,11 @@ fun HorizontalReorderList(
6364
state: ReorderableState = rememberReorderState(),
6465
onMove: (fromPos: Int, toPos: Int) -> (Unit),
6566
) {
66-
Reorderable(state, onMove)
6767
LazyRow(
6868
state = state.listState,
6969
horizontalArrangement = Arrangement.spacedBy(8.dp),
70-
modifier = Modifier
71-
.detectListReorder(state, Orientation.Horizontal)
72-
.then(modifier),
70+
modifier = modifier
71+
.then(Modifier.reorderable(state, onMove = onMove, orientation = Orientation.Horizontal)),
7372
) {
7473
itemsIndexed(items) { idx, item ->
7574
Box(
@@ -83,6 +82,7 @@ fun HorizontalReorderList(
8382
.scale(if (state.draggedIndex == null || state.draggedIndex == idx) 1f else .9f)
8483
.clip(RoundedCornerShape(8.dp))
8584
.background(MaterialTheme.colors.primary)
85+
.detectReorderAfterLongPress(state)
8686
) {
8787
Text(item.title)
8888
}
@@ -98,10 +98,10 @@ fun VerticalReorderList(
9898
onMove: (fromPos: Int, toPos: Int) -> (Unit),
9999
canDragOver: ((index: Int) -> Boolean),
100100
) {
101-
Reorderable(state, onMove, canDragOver)
102101
LazyColumn(
103102
state = state.listState,
104103
modifier = modifier
104+
.then(Modifier.reorderable(state, onMove = onMove, canDragOver = canDragOver))
105105
) {
106106
items(items, { it.key }) { item ->
107107
if (item.isLocked) {
@@ -121,21 +121,12 @@ fun VerticalReorderList(
121121
.fillMaxWidth()
122122
.draggedItem(state.offsetOf(item.key))
123123
.background(MaterialTheme.colors.surface)
124+
.detectReorderAfterLongPress(state)
124125
) {
125-
Row(
126-
verticalAlignment = Alignment.CenterVertically,
126+
Text(
127+
text = item.title,
127128
modifier = Modifier.padding(16.dp)
128-
) {
129-
Image(
130-
imageVector = Icons.Filled.Menu,
131-
contentDescription = "",
132-
modifier = Modifier.detectReorder(state, { item.key })
133-
)
134-
Text(
135-
text = item.title,
136-
modifier = Modifier.padding(start = 8.dp)
137-
)
138-
}
129+
)
139130
Divider()
140131
}
141132
}

app/src/main/kotlin/io/burnoutcrew/lazyreorderlist/ui/reorderlist/ReorderListViewModel.kt renamed to android/src/main/kotlin/org/burnoutcrew/android/ui/reorderlist/ReorderListViewModel.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package io.burnoutcrew.lazyreorderlist.ui.reorderlist
16+
package org.burnoutcrew.android.ui.reorderlist
1717

1818
import androidx.compose.runtime.toMutableStateList
1919
import androidx.lifecycle.ViewModel
20-
import io.burnoutcrew.reorderable.move
20+
import org.burnoutcrew.reorderable.move
21+
2122

2223
class ReorderListViewModel : ViewModel() {
2324
val cats = List(500) { ItemData("Cat $it", "") }.toMutableStateList()

app/src/main/kotlin/io/burnoutcrew/lazyreorderlist/ui/theme/Color.kt renamed to android/src/main/kotlin/org/burnoutcrew/android/ui/theme/Color.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.burnoutcrew.lazyreorderlist.ui.theme
1+
package org.burnoutcrew.android.ui.theme
22

33
import androidx.compose.ui.graphics.Color
44

app/src/main/kotlin/io/burnoutcrew/lazyreorderlist/ui/theme/Shape.kt renamed to android/src/main/kotlin/org/burnoutcrew/android/ui/theme/Shape.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.burnoutcrew.lazyreorderlist.ui.theme
1+
package org.burnoutcrew.android.ui.theme
22

33
import androidx.compose.foundation.shape.RoundedCornerShape
44
import androidx.compose.material.Shapes

app/src/main/kotlin/io/burnoutcrew/lazyreorderlist/ui/theme/Theme.kt renamed to android/src/main/kotlin/org/burnoutcrew/android/ui/theme/Theme.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.burnoutcrew.lazyreorderlist.ui.theme
1+
package org.burnoutcrew.android.ui.theme
22

33
import androidx.compose.foundation.isSystemInDarkTheme
44
import androidx.compose.material.MaterialTheme

app/src/main/kotlin/io/burnoutcrew/lazyreorderlist/ui/theme/Type.kt renamed to android/src/main/kotlin/org/burnoutcrew/android/ui/theme/Type.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.burnoutcrew.lazyreorderlist.ui.theme
1+
package org.burnoutcrew.android.ui.theme
22

33
import androidx.compose.material.Typography
44
import androidx.compose.ui.text.TextStyle

app/build.gradle.kts

-53
This file was deleted.

app/proguard-rules.pro

-21
This file was deleted.

app/src/androidTest/kotlin/io/burnoutcrew/lazyreorderlist/ExampleInstrumentedTest.kt

-24
This file was deleted.

0 commit comments

Comments
 (0)