Skip to content

Commit

Permalink
Updated Compose Version and made Redo, Undo and Reset functions avail…
Browse files Browse the repository at this point in the history
…able
  • Loading branch information
zeeshanali-k committed Feb 1, 2024
1 parent 87bca2c commit f2ee03d
Show file tree
Hide file tree
Showing 21 changed files with 136 additions and 81 deletions.
8 changes: 8 additions & 0 deletions .idea/artifacts/CanvasPainterCMP_desktop.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/artifacts/CanvasPainterCMP_js.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/artifacts/CanvasPainterCMP_wasm_js.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/artifacts/canvas_painter_cmp_sample_wasm_js.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/migrations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 1 addition & 8 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 6 additions & 8 deletions CanvasPainter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ plugins {
}

android {
compileSdk 33
compileSdk 34

defaultConfig {
minSdk 21
targetSdk 33
targetSdk 34

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
Expand Down Expand Up @@ -49,14 +49,12 @@ android {

dependencies {
//Compose deps
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
// Other
implementation 'com.google.android.material:material:1.6.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.google.android.material:material:1.11.0'

// Color Picker
implementation 'com.godaddy.android.colorpicker:compose-color-picker:0.5.0'
Expand All @@ -65,8 +63,8 @@ dependencies {
publishing {
repositories {
maven {
def releasesRepoUrl = "$buildDir/repos/releases"
def snapshotsRepoUrl = "$buildDir/repos/snapshots"
def releasesRepoUrl = "${layout.buildDirectory}/repos/releases"
def snapshotsRepoUrl = "${layout.buildDirectory}/repos/snapshots"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@ fun CanvasPainter(
modifier: Modifier = Modifier,
painterController: PainterController
) {
Box(modifier, contentAlignment = Alignment.TopStart) {
// Paint Section
Column(Modifier.fillMaxSize()) {
if (painterController.showToolbar)
PainterToolbar(painterController = painterController)
CanvasPainterBoard(
painterController,
Modifier.fillMaxWidth()
.weight(1f)
)
}
Column(modifier) {
if (painterController.showToolbar)
PainterToolbar(painterController = painterController)
CanvasPainterBoard(
painterController,
modifier
.fillMaxWidth()
.weight(1f)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ internal fun CanvasPainterBoard(
Canvas(Modifier
.fillMaxSize()
.clipToBounds()
.background(Color.White)
.pointerInput(Unit) {
detectDragGestures(onDragStart = { offset ->
painterController.addPath(offset)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.widget.Toast
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
Expand Down Expand Up @@ -134,7 +135,7 @@ class PainterController(
selectedColor.value = PaintBrush(-1, color)
}

internal fun undo() {
fun undo() {
paintPath.value = paintPath.value.toMutableList().apply {
undonePath.value = undonePath.value
.toMutableList().apply {
Expand All @@ -144,7 +145,7 @@ class PainterController(
}.toList()
}

internal fun redo() {
fun redo() {
paintPath.value = paintPath.value.toMutableList().apply {
add(undonePath.value.last())
undonePath.value = undonePath.value
Expand All @@ -157,7 +158,7 @@ class PainterController(
}


internal fun reset() {
fun reset() {
undonePath.value = paintPath.value
paintPath.value = listOf()
}
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ plugins {
}

android {
compileSdk 33
compileSdk 34

defaultConfig {
applicationId "com.devscion.canvaspainter"
minSdk 21
targetSdk 33
targetSdk 34
versionCode 1
versionName "1.0"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
Expand Down Expand Up @@ -41,7 +42,8 @@ class MainActivity : ComponentActivity() {
)
CanvasPainterTheme {
CanvasPainter(
Modifier.fillMaxSize(),
Modifier.fillMaxSize()
.background(Color.Black),
painterController
)
}
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
buildscript {
ext {
compose_version = '1.4.0-alpha02'
compose_compiler_version = '1.3.0'
compose_version = '1.6.0'
compose_compiler_version = '1.5.8'
}
repositories {
mavenCentral()
Expand All @@ -10,7 +10,7 @@ buildscript {
plugins {
id 'com.android.application' version '7.2.2' apply false
id 'com.android.library' version '7.2.2' apply false
id 'org.jetbrains.kotlin.android' version '1.7.10' apply false
id 'org.jetbrains.kotlin.android' version '1.9.22' apply false
id 'com.vanniktech.maven.publish' version '0.22.0' apply false
}
//
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ android.nonTransitiveRClass=true

GROUP=tech.dev-scion
POM_ARTIFACT_ID=canvaspainter
VERSION_NAME=1.0.4
VERSION_NAME=1.0.5

POM_NAME=Canvas Painter
POM_DESCRIPTION=Android Jetpack Compose Paint Library
Expand Down

0 comments on commit f2ee03d

Please sign in to comment.