Skip to content

Commit 7507ada

Browse files
RD-972: Add reference style and variants (#15)
1 parent 86ae5cc commit 7507ada

File tree

15 files changed

+390
-84
lines changed

15 files changed

+390
-84
lines changed

Examples/MapTilerMobileDemo/MapTilerSDK/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ android {
1919
isMinifyEnabled = false
2020
proguardFiles(
2121
getDefaultProguardFile("proguard-android-optimize.txt"),
22-
"proguard-rules.pro"
22+
"proguard-rules.pro",
2323
)
2424
}
2525
}
@@ -39,4 +39,4 @@ dependencies {
3939
testImplementation("junit:junit:4.13.2")
4040
androidTestImplementation("androidx.test.ext:junit:1.2.1")
4141
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
42-
}
42+
}

Examples/MapTilerMobileDemo/app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ android {
2323
isMinifyEnabled = false
2424
proguardFiles(
2525
getDefaultProguardFile("proguard-android-optimize.txt"),
26-
"proguard-rules.pro"
26+
"proguard-rules.pro",
2727
)
2828
}
2929
}
@@ -58,4 +58,4 @@ dependencies {
5858
debugImplementation(libs.androidx.ui.tooling)
5959
debugImplementation(libs.androidx.ui.test.manifest)
6060
// implementation(libs.maptilersdk)
61-
}
61+
}

Examples/MapTilerMobileDemo/app/src/main/java/com/maptilerdemo/maptilermobiledemo/MainActivity.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class MainActivity : ComponentActivity() {
2222
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
2323
Greeting(
2424
name = "Android",
25-
modifier = Modifier.padding(innerPadding)
25+
modifier = Modifier.padding(innerPadding),
2626
)
2727
}
2828
}
@@ -31,10 +31,13 @@ class MainActivity : ComponentActivity() {
3131
}
3232

3333
@Composable
34-
fun Greeting(name: String, modifier: Modifier = Modifier) {
34+
fun Greeting(
35+
name: String,
36+
modifier: Modifier = Modifier,
37+
) {
3538
Text(
3639
text = "Hello $name!",
37-
modifier = modifier
40+
modifier = modifier,
3841
)
3942
}
4043

@@ -44,4 +47,4 @@ fun GreetingPreview() {
4447
MapTilerMobileDemoTheme {
4548
Greeting("Android")
4649
}
47-
}
50+
}

Examples/MapTilerMobileDemo/app/src/main/java/com/maptilerdemo/maptilermobiledemo/ui/theme/Color.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ val Pink80 = Color(0xFFEFB8C8)
88

99
val Purple40 = Color(0xFF6650a4)
1010
val PurpleGrey40 = Color(0xFF625b71)
11-
val Pink40 = Color(0xFF7D5260)
11+
val Pink40 = Color(0xFF7D5260)
Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.maptilerdemo.maptilermobiledemo.ui.theme
22

3-
import android.app.Activity
43
import android.os.Build
54
import androidx.compose.foundation.isSystemInDarkTheme
65
import androidx.compose.material3.MaterialTheme
@@ -11,17 +10,18 @@ import androidx.compose.material3.lightColorScheme
1110
import androidx.compose.runtime.Composable
1211
import androidx.compose.ui.platform.LocalContext
1312

14-
private val DarkColorScheme = darkColorScheme(
15-
primary = Purple80,
16-
secondary = PurpleGrey80,
17-
tertiary = Pink80
18-
)
19-
20-
private val LightColorScheme = lightColorScheme(
21-
primary = Purple40,
22-
secondary = PurpleGrey40,
23-
tertiary = Pink40
13+
private val DarkColorScheme =
14+
darkColorScheme(
15+
primary = Purple80,
16+
secondary = PurpleGrey80,
17+
tertiary = Pink80,
18+
)
2419

20+
private val LightColorScheme =
21+
lightColorScheme(
22+
primary = Purple40,
23+
secondary = PurpleGrey40,
24+
tertiary = Pink40,
2525
/* Other default colors to override
2626
background = Color(0xFFFFFBFE),
2727
surface = Color(0xFFFFFBFE),
@@ -30,29 +30,30 @@ private val LightColorScheme = lightColorScheme(
3030
onTertiary = Color.White,
3131
onBackground = Color(0xFF1C1B1F),
3232
onSurface = Color(0xFF1C1B1F),
33-
*/
34-
)
33+
*/
34+
)
3535

3636
@Composable
3737
fun MapTilerMobileDemoTheme(
3838
darkTheme: Boolean = isSystemInDarkTheme(),
3939
// Dynamic color is available on Android 12+
4040
dynamicColor: Boolean = true,
41-
content: @Composable () -> Unit
41+
content: @Composable () -> Unit,
4242
) {
43-
val colorScheme = when {
44-
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
45-
val context = LocalContext.current
46-
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
47-
}
43+
val colorScheme =
44+
when {
45+
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
46+
val context = LocalContext.current
47+
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
48+
}
4849

49-
darkTheme -> DarkColorScheme
50-
else -> LightColorScheme
51-
}
50+
darkTheme -> DarkColorScheme
51+
else -> LightColorScheme
52+
}
5253

5354
MaterialTheme(
5455
colorScheme = colorScheme,
5556
typography = Typography,
56-
content = content
57+
content = content,
5758
)
58-
}
59+
}

Examples/MapTilerMobileDemo/app/src/main/java/com/maptilerdemo/maptilermobiledemo/ui/theme/Type.kt

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@ import androidx.compose.ui.text.font.FontWeight
77
import androidx.compose.ui.unit.sp
88

99
// Set of Material typography styles to start with
10-
val Typography = Typography(
11-
bodyLarge = TextStyle(
12-
fontFamily = FontFamily.Default,
13-
fontWeight = FontWeight.Normal,
14-
fontSize = 16.sp,
15-
lineHeight = 24.sp,
16-
letterSpacing = 0.5.sp
17-
)
10+
val Typography =
11+
Typography(
12+
bodyLarge =
13+
TextStyle(
14+
fontFamily = FontFamily.Default,
15+
fontWeight = FontWeight.Normal,
16+
fontSize = 16.sp,
17+
lineHeight = 24.sp,
18+
letterSpacing = 0.5.sp,
19+
),
1820
/* Other default text styles to override
1921
titleLarge = TextStyle(
2022
fontFamily = FontFamily.Default,
@@ -30,5 +32,5 @@ val Typography = Typography(
3032
lineHeight = 16.sp,
3133
letterSpacing = 0.5.sp
3234
)
33-
*/
34-
)
35+
*/
36+
)

Examples/MapTilerMobileDemo/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ plugins {
33
alias(libs.plugins.android.application) apply false
44
alias(libs.plugins.kotlin.android) apply false
55
alias(libs.plugins.kotlin.compose) apply false
6-
}
6+
}

MapTilerSDK/src/main/java/com/maptiler/maptilersdk/MTConfig.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ object MTConfig {
6767
/**
6868
* Returns the MapTiler API key.
6969
*/
70-
fun getAPIKey(): String {
71-
return this.apiKey
72-
}
70+
fun getAPIKey(): String = this.apiKey
7371

7472
/**
7573
* Sets the caching mechanism.
@@ -108,9 +106,7 @@ object MTConfig {
108106
/**
109107
* Returns the unit of measurement.
110108
*/
111-
fun getUnit(): MTUnit {
112-
return this.unit
113-
}
109+
fun getUnit(): MTUnit = this.unit
114110

115111
/**
116112
* Sets the telemetry.

MapTilerSDK/src/main/java/com/maptiler/maptilersdk/bridge/MTBridge.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,5 @@ internal sealed class MTBridge(
2020
const val STYLE_OBJECT: JSString = "MapStyle"
2121
}
2222

23-
suspend fun execute(command: MTCommand): MTBridgeReturnType? {
24-
return executor?.execute(command)
25-
}
23+
suspend fun execute(command: MTCommand): MTBridgeReturnType? = executor?.execute(command)
2624
}

MapTilerSDK/src/main/java/com/maptiler/maptilersdk/bridge/MTBridgeReturnType.kt

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,30 @@
77
package com.maptiler.maptilersdk.bridge
88

99
internal sealed class MTBridgeReturnType {
10-
data class StringValue(val value: String) : MTBridgeReturnType()
10+
data class StringValue(
11+
val value: String,
12+
) : MTBridgeReturnType()
1113

12-
data class DoubleValue(val value: Double) : MTBridgeReturnType()
14+
data class DoubleValue(
15+
val value: Double,
16+
) : MTBridgeReturnType()
1317

14-
data class BoolValue(val value: Boolean) : MTBridgeReturnType()
18+
data class BoolValue(
19+
val value: Boolean,
20+
) : MTBridgeReturnType()
1521

16-
data class StringDoubleDict(val value: Map<String, Double>) : MTBridgeReturnType()
22+
data class StringDoubleDict(
23+
val value: Map<String, Double>,
24+
) : MTBridgeReturnType()
1725

1826
data object UnsupportedType : MTBridgeReturnType()
1927

2028
data object Null : MTBridgeReturnType()
2129

2230
companion object {
2331
@Throws(MTError.InvalidResultType::class)
24-
fun from(value: Any?): MTBridgeReturnType {
25-
return when (value) {
32+
fun from(value: Any?): MTBridgeReturnType =
33+
when (value) {
2634
is String -> StringValue(value)
2735
is Double -> DoubleValue(value)
2836
is Boolean -> BoolValue(value)
@@ -40,6 +48,5 @@ internal sealed class MTBridgeReturnType {
4048
null -> Null
4149
else -> throw MTError.InvalidResultType(description = value.toString())
4250
}
43-
}
4451
}
4552
}

0 commit comments

Comments
 (0)