Skip to content

Commit d05be33

Browse files
authored
Fix showcase position (#18)
* Fix showcase popup position * Fix publish script * Fix build job
1 parent 086f7c6 commit d05be33

File tree

13 files changed

+265
-179
lines changed

13 files changed

+265
-179
lines changed

.github/workflows/app-build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@v2
10-
- name: set up JDK 11
10+
- name: set up JDK 17
1111
uses: actions/setup-java@v2
1212
with:
1313
distribution: adopt
14-
java-version: 11
14+
java-version: 17
1515
- name: Build with Gradle
1616
run: ./gradlew build

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ jobs:
1111
steps:
1212
- name: Check out code
1313
uses: actions/checkout@v2
14-
- name: Set up JDK 11
14+
- name: Set up JDK 17
1515
uses: actions/setup-java@v2
1616
with:
1717
distribution: adopt
18-
java-version: 11
18+
java-version: 17
1919

2020
- name: Publish to MavenCentral
2121
run: ./gradlew showcase:publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository

app/build.gradle

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ plugins {
44
}
55

66
android {
7-
compileSdk 31
7+
namespace = "com.canopas.campose.showcase"
8+
compileSdk 34
89

910
defaultConfig {
1011
applicationId "com.canopas.campose.jettaptarget"
1112
minSdk 21
12-
targetSdk 31
13+
targetSdk 34
1314
versionCode 1
1415
versionName "1.0"
1516

@@ -26,17 +27,17 @@ android {
2627
}
2728
}
2829
compileOptions {
29-
sourceCompatibility JavaVersion.VERSION_11
30-
targetCompatibility JavaVersion.VERSION_11
30+
sourceCompatibility JavaVersion.VERSION_17
31+
targetCompatibility JavaVersion.VERSION_17
3132
}
3233
kotlinOptions {
33-
jvmTarget = '11'
34+
jvmTarget = '17'
3435
}
3536
buildFeatures {
3637
compose true
3738
}
3839
composeOptions {
39-
kotlinCompilerExtensionVersion compose_version
40+
kotlinCompilerExtensionVersion compose_compiler_version
4041
}
4142
packagingOptions {
4243
resources {
@@ -48,15 +49,17 @@ android {
4849
dependencies {
4950
implementation project(path: ':showcase')
5051

51-
implementation 'androidx.core:core-ktx:1.7.0'
52-
implementation "androidx.compose.ui:ui:$compose_version"
53-
implementation "androidx.compose.material:material:$compose_version"
54-
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
55-
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
56-
implementation 'androidx.activity:activity-compose:1.3.1'
52+
implementation platform("androidx.compose:compose-bom:$compose_bom_version")
53+
54+
implementation 'androidx.core:core-ktx:1.12.0'
55+
implementation "androidx.compose.ui:ui"
56+
implementation "androidx.compose.material:material"
57+
implementation "androidx.compose.ui:ui-tooling-preview"
58+
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2'
59+
implementation 'androidx.activity:activity-compose:1.8.2'
5760
testImplementation 'junit:junit:4.13.2'
58-
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
59-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
60-
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
61-
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
61+
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
62+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
63+
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.5.4"
64+
debugImplementation "androidx.compose.ui:ui-tooling"
6265
}

app/src/main/java/com/canopas/campose/showcase/MainActivity.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ import androidx.compose.ui.unit.dp
4646
import androidx.compose.ui.unit.sp
4747
import com.canopas.campose.showcase.ui.theme.JetTapTargetTheme
4848
import com.canopas.campose.showcase.ui.theme.ThemeColor
49-
import com.canopas.lib.showcase.IntroShowCase
50-
import com.canopas.lib.showcase.IntroShowCaseScope
51-
import com.canopas.lib.showcase.ShowcaseStyle
49+
import com.canopas.lib.showcase.IntroShowcase
50+
import com.canopas.lib.showcase.IntroShowcaseScope
51+
import com.canopas.lib.showcase.component.ShowcaseStyle
5252

5353
class MainActivity : ComponentActivity() {
5454
override fun onCreate(savedInstanceState: Bundle?) {
@@ -75,7 +75,7 @@ fun ShowcaseSample() {
7575
mutableStateOf(true)
7676
}
7777

78-
IntroShowCase(
78+
IntroShowcase(
7979
showIntroShowCase = showAppIntro,
8080
dismissOnClickOutside = false,
8181
onShowCaseCompleted = {
@@ -142,7 +142,7 @@ fun ShowcaseSample() {
142142

143143

144144
@Composable
145-
fun IntroShowCaseScope.FloatingMailButton() {
145+
fun IntroShowcaseScope.FloatingMailButton() {
146146
FloatingActionButton(
147147
onClick = {},
148148
modifier = Modifier.introShowCaseTarget(
@@ -191,7 +191,7 @@ fun IntroShowCaseScope.FloatingMailButton() {
191191
}
192192

193193
@Composable
194-
fun IntroShowCaseScope.BackButton() {
194+
fun IntroShowcaseScope.BackButton() {
195195
IconButton(
196196
onClick = {},
197197
modifier = Modifier.introShowCaseTarget(
@@ -232,7 +232,7 @@ fun IntroShowCaseScope.BackButton() {
232232
}
233233

234234
@Composable
235-
fun IntroShowCaseScope.Content(modifier: Modifier) {
235+
fun IntroShowcaseScope.Content(modifier: Modifier) {
236236
Box(modifier = modifier.fillMaxSize()) {
237237
Box(modifier = Modifier.fillMaxHeight(0.3f)) {
238238

build.gradle

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
buildscript {
22
ext {
33
compose_version = '1.1.0-beta04'
4+
compose_bom_version = "2023.10.01"
5+
compose_compiler_version = "1.5.3"
46
}
57

68
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
79
plugins {
8-
id 'com.android.application' version '7.1.0' apply false
9-
id 'com.android.library' version '7.1.0' apply false
10-
id 'org.jetbrains.kotlin.android' version '1.6.0' apply false
11-
id 'io.github.gradle-nexus.publish-plugin' version "1.1.0"
10+
id 'com.android.application' version '8.1.1' apply false
11+
id 'com.android.library' version '8.1.1' apply false
12+
id 'org.jetbrains.kotlin.android' version '1.9.10' apply false
13+
id 'io.github.gradle-nexus.publish-plugin' version "1.3.0"
1214
}
1315

1416
apply from: "${rootDir}/scripts/publish-root.gradle"
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Mon Jan 31 09:43:16 IST 2022
1+
#Thu Dec 14 16:33:00 IST 2023
22
distributionBase=GRADLE_USER_HOME
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
43
distributionPath=wrapper/dists
5-
zipStorePath=wrapper/dists
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
65
zipStoreBase=GRADLE_USER_HOME
6+
zipStorePath=wrapper/dists

scripts/publish-module.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apply plugin: 'maven-publish'
22
apply plugin: 'signing'
33

4-
task androidSourcesJar(type: Jar) {
4+
tasks.register('androidSourcesJar', Jar) {
55
archiveClassifier.set('sources')
66
if (project.plugins.findPlugin("com.android.library")) {
77
from android.sourceSets.main.java.srcDirs
@@ -10,6 +10,7 @@ task androidSourcesJar(type: Jar) {
1010
}
1111
}
1212

13+
1314
artifacts {
1415
archives androidSourcesJar
1516
}
@@ -20,6 +21,8 @@ afterEvaluate {
2021
publishing {
2122
publications {
2223
release(MavenPublication) {
24+
tasks.named("generateMetadataFileForReleasePublication").configure { dependsOn("androidSourcesJar") }
25+
2326
// The coordinates of the library, being set from variables that
2427
// we'll set up later
2528
groupId PUBLISH_GROUP_ID

showcase/build.gradle

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ ext {
1111
apply from: "${rootDir}/scripts/publish-module.gradle"
1212

1313
android {
14-
compileSdk 31
14+
namespace = "com.canopas.lib.showcase"
15+
16+
compileSdk 34
1517

1618
defaultConfig {
1719
minSdk 21
18-
targetSdk 31
20+
targetSdk 34
1921

2022
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2123
consumerProguardFiles "consumer-rules.pro"
@@ -29,32 +31,39 @@ android {
2931
}
3032

3133
compileOptions {
32-
sourceCompatibility JavaVersion.VERSION_11
33-
targetCompatibility JavaVersion.VERSION_11
34+
sourceCompatibility JavaVersion.VERSION_17
35+
targetCompatibility JavaVersion.VERSION_17
3436
}
3537
kotlinOptions {
36-
jvmTarget = '11'
38+
jvmTarget = '17'
3739
}
3840
buildFeatures {
3941
compose true
4042
}
4143
composeOptions {
42-
kotlinCompilerExtensionVersion compose_version
44+
kotlinCompilerExtensionVersion compose_compiler_version
45+
}
46+
publishing {
47+
singleVariant("release") {
48+
withSourcesJar()
49+
}
4350
}
4451
}
4552

4653
dependencies {
4754

48-
implementation 'androidx.core:core-ktx:1.7.0'
49-
implementation 'androidx.appcompat:appcompat:1.4.1'
50-
implementation 'com.google.android.material:material:1.5.0'
51-
implementation 'androidx.compose.ui:ui:1.0.5'
55+
implementation platform("androidx.compose:compose-bom:$compose_bom_version")
56+
57+
implementation 'androidx.core:core-ktx:1.12.0'
58+
implementation 'androidx.appcompat:appcompat:1.6.1'
59+
implementation 'com.google.android.material:material:1.11.0'
60+
implementation 'androidx.compose.ui:ui:'
5261
testImplementation 'junit:junit:4.13.2'
53-
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
54-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
62+
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
63+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
5564

56-
implementation "androidx.compose.ui:ui:$compose_version"
57-
implementation "androidx.compose.material:material:$compose_version"
58-
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
59-
implementation "androidx.compose.material:material-icons-extended:$compose_version"
65+
implementation "androidx.compose.ui:ui"
66+
implementation "androidx.compose.material:material"
67+
implementation "androidx.compose.ui:ui-tooling-preview"
68+
implementation "androidx.compose.material:material-icons-extended"
6069
}

showcase/src/main/java/com/canopas/lib/showcase/IntroShowCase.kt

Lines changed: 0 additions & 53 deletions
This file was deleted.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package com.canopas.lib.showcase
2+
3+
import androidx.compose.foundation.layout.BoxScope
4+
import androidx.compose.runtime.Composable
5+
import androidx.compose.runtime.remember
6+
import androidx.compose.ui.Modifier
7+
import com.canopas.lib.showcase.component.IntroShowcaseState
8+
import com.canopas.lib.showcase.component.ShowcasePopup
9+
import com.canopas.lib.showcase.component.ShowcaseStyle
10+
import com.canopas.lib.showcase.component.introShowcaseTarget
11+
import com.canopas.lib.showcase.component.rememberIntroShowcaseState
12+
13+
@Composable
14+
fun IntroShowcase(
15+
showIntroShowCase: Boolean,
16+
onShowCaseCompleted: () -> Unit,
17+
state: IntroShowcaseState = rememberIntroShowcaseState(),
18+
dismissOnClickOutside: Boolean = false,
19+
content: @Composable IntroShowcaseScope.() -> Unit,
20+
) {
21+
val scope = remember(state) {
22+
IntroShowcaseScope(state)
23+
}
24+
25+
scope.content()
26+
27+
if (showIntroShowCase) {
28+
ShowcasePopup(
29+
state = state,
30+
dismissOnClickOutside = dismissOnClickOutside,
31+
onShowCaseCompleted = onShowCaseCompleted,
32+
)
33+
}
34+
}
35+
36+
37+
class IntroShowcaseScope(
38+
private val state: IntroShowcaseState,
39+
) {
40+
41+
/**
42+
* Modifier that marks Compose UI element as a target for [IntroShowcase]
43+
*/
44+
fun Modifier.introShowCaseTarget(
45+
index: Int,
46+
style: ShowcaseStyle = ShowcaseStyle.Default,
47+
content: @Composable BoxScope.() -> Unit,
48+
): Modifier = introShowcaseTarget(
49+
state = state,
50+
index = index,
51+
style = style,
52+
content = content,
53+
)
54+
}

0 commit comments

Comments
 (0)