Skip to content

Commit

Permalink
feat: add OceanTag to OceanShortcut (#682)
Browse files Browse the repository at this point in the history
* fix: baseline profiles

* feat: remove unused enum for OceanBadge

* fix: adjust ocean tag spacings

* feat: organize badge and tag for ocean shortcut
  • Loading branch information
fernandozblu authored Jul 24, 2024
1 parent 4932f6b commit 61bafc6
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 86 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/baselineprofile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Generate baseline profiles
run: |
./gradlew cleanManagedDevices --unused-only
./gradlew clean :ocean-components:generateBaselineProfile -Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect" -Pandroid.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules=BaselineProfile -Pandroid.experimental.testOptions.managedDevices.setupTimeoutMinutes=20 -Dorg.gradle.workers.max=4
./gradlew :ocean-components:generateBaselineProfile -Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect" -Pandroid.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules=BaselineProfile -Pandroid.experimental.testOptions.managedDevices.setupTimeoutMinutes=20 -Dorg.gradle.workers.max=4
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
Expand Down
12 changes: 6 additions & 6 deletions baselineprofile/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import com.android.build.api.dsl.ManagedVirtualDevice
import com.android.build.gradle.internal.dsl.ManagedVirtualDevice

plugins {
id("com.android.test")
Expand All @@ -11,12 +11,12 @@ android {
compileSdk = 34

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "17"
}

defaultConfig {
Expand All @@ -29,11 +29,11 @@ android {
targetProjectPath = ":app"

testOptions.managedDevices.devices {
create<ManagedVirtualDevice>("pixel7Api30") {
add(ManagedVirtualDevice("pixel7Api30").apply {
device = "Pixel 7"
apiLevel = 30
systemImageSource = "aosp"
}
})
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
gradle = "8.3.2"
gradle = "8.3.0"
junitVersion = "4.13.2"
kotlinGradlePlugin = "2.0.0"
benchmarkBaselineProfileGradlePlugin = "1.2.4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ fun setBadgeType(view: View, badgeType: OceanBadgeType?) {
OceanBadgeType.PRIMARY_INVERTED -> R.drawable.ocean_badge_primary_inverted
OceanBadgeType.WARNING -> R.drawable.ocean_badge_warning
OceanBadgeType.DISABLED -> R.drawable.ocean_badge_disabled
OceanBadgeType.CHIP_HOVER -> R.drawable.ocean_badge_primary_inverted
null -> R.drawable.ocean_badge_highlight
}
view.background = ContextCompat.getDrawable(view.context, background)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ fun OceanBadge(
OceanBadgeType.PRIMARY_INVERTED -> OceanColors.interfaceLightPure
OceanBadgeType.WARNING -> OceanColors.statusWarningDeep
OceanBadgeType.DISABLED -> OceanColors.interfaceDarkUp
OceanBadgeType.CHIP_HOVER -> OceanColors.interfaceLightPure
}

val formattedText = text.toIntOrNull()?.let {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import br.com.useblu.oceands.model.OceanBadgeType
import br.com.useblu.oceands.model.OceanTagType
import br.com.useblu.oceands.ui.compose.OceanColors
import br.com.useblu.oceands.ui.compose.OceanSpacing
import br.com.useblu.oceands.ui.compose.OceanTextStyle
Expand All @@ -36,14 +37,12 @@ fun OceanShortcutPreview() {
label = "TinyVertical",
icon = OceanIcons.ACADEMIC_CAP_SOLID,
action = {},
badgeType = OceanBadgeType.HIGHLIGHT,
count = "Novo"
tag = OceanShortcutTag("Novo", OceanTagType.Important)
),
OceanShortcutModel(
label = "TinyVertical",
icon = OceanIcons.ACADEMIC_CAP_SOLID,
badgeType = OceanBadgeType.WARNING,
count = "120"
badge = OceanShortcutBadge(count = 120, type = OceanBadgeType.WARNING)
),

OceanShortcutModel(
Expand Down Expand Up @@ -73,15 +72,13 @@ fun OceanShortcutPreview() {
label = "Small",
icon = OceanIcons.ACADEMIC_CAP_SOLID,
layout = OceanShortcutLayout.Small,
badgeType = OceanBadgeType.WARNING,
count = "120"
badge = OceanShortcutBadge(count = 120, type = OceanBadgeType.WARNING)
),
OceanShortcutModel(
label = "Small",
icon = OceanIcons.ACADEMIC_CAP_SOLID,
layout = OceanShortcutLayout.Small,
badgeType = OceanBadgeType.HIGHLIGHT,
count = "Novo"
tag = OceanShortcutTag("Novo", OceanTagType.Highlight)
),

OceanShortcutModel(
Expand Down Expand Up @@ -171,23 +168,33 @@ fun OceanShortcut(
icon = model.icon,
modifier = modifier,
description = model.description,
count = model.count,
badgeType = model.badgeType,
badge = model.badge,
tag = model.tag,
action = model.action,
layout = model.layout,
blocked = model.blocked,
disabled = model.disabled
)
}

data class OceanShortcutBadge(
val count: Int,
val type: OceanBadgeType
)

data class OceanShortcutTag(
val text: String,
val type: OceanTagType
)

@Composable
fun OceanShortcut(
label: String,
icon: OceanIcons,
modifier: Modifier = Modifier,
description: String? = null,
count: String? = null,
badgeType: OceanBadgeType? = null,
badge: OceanShortcutBadge? = null,
tag: OceanShortcutTag? = null,
action: (() -> Unit)? = null,
layout: OceanShortcutLayout = OceanShortcutLayout.TinyVertical,
blocked: Boolean = false,
Expand Down Expand Up @@ -237,15 +244,27 @@ fun OceanShortcut(
)
}

if (count != null && badgeType != null) {
OceanBadge(
text = count,
type = badgeType,
size = OceanBadgeSize.Small,
modifier = Modifier
.padding(top = OceanSpacing.xxs, end = OceanSpacing.xxs)
.align(Alignment.TopEnd)
)
when {
tag != null -> {
OceanTag(
label = tag.text,
type = tag.type,
isSmall = true,
modifier = Modifier
.padding(top = OceanSpacing.xxs, end = OceanSpacing.xxs)
.align(Alignment.TopEnd)
)
}
badge != null -> {
OceanBadge(
text = badge.count.toString(),
type = badge.type,
size = OceanBadgeSize.Small,
modifier = Modifier
.padding(top = OceanSpacing.xxs, end = OceanSpacing.xxs)
.align(Alignment.TopEnd)
)
}
}

Column(
Expand Down Expand Up @@ -336,8 +355,8 @@ data class OceanShortcutModel(
val label: String,
val description: String? = null,
val icon: OceanIcons,
val count: String? = null,
val badgeType: OceanBadgeType? = null,
val badge: OceanShortcutBadge? = null,
val tag: OceanShortcutTag? = null,
val action: (() -> Unit)? = null,
val layout: OceanShortcutLayout = OceanShortcutLayout.TinyVertical,
val blocked: Boolean = false,
Expand Down
Loading

0 comments on commit 61bafc6

Please sign in to comment.