-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
322 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
app/src/main/java/com/eipsaferoad/owl/components/Button.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package com.eipsaferoad.owl.components | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.width | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import androidx.wear.compose.material.Text | ||
import com.eipsaferoad.owl.presentation.theme.md_theme_light_onSurfaceVariant | ||
import com.eipsaferoad.owl.presentation.theme.md_theme_light_primary | ||
import com.eipsaferoad.owl.presentation.theme.md_theme_light_secondary | ||
|
||
enum class ButtonTypeEnum() { | ||
PRIMARY, | ||
SECONDARY, | ||
REDIRECTION, | ||
} | ||
|
||
@Composable | ||
fun Button(type: ButtonTypeEnum, content: @Composable () -> Unit, action: () -> Unit) { | ||
val backgroundColor = when (type) { | ||
ButtonTypeEnum.PRIMARY -> md_theme_light_primary | ||
ButtonTypeEnum.SECONDARY -> md_theme_light_secondary | ||
ButtonTypeEnum.REDIRECTION -> md_theme_light_onSurfaceVariant | ||
else -> md_theme_light_onSurfaceVariant | ||
} | ||
|
||
Column( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.clip(shape = RoundedCornerShape(20.dp)) | ||
.background(backgroundColor) | ||
.clickable { action() }, | ||
verticalArrangement = Arrangement.Center, | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
) { | ||
content() | ||
} | ||
} | ||
|
||
@Composable | ||
fun ContentExample() { | ||
Column( | ||
modifier = Modifier.fillMaxSize(), | ||
verticalArrangement = Arrangement.Center, | ||
horizontalAlignment = Alignment.CenterHorizontally | ||
) { | ||
Text(text = "coucou") | ||
} | ||
} | ||
|
||
@Composable | ||
@Preview | ||
fun PreviewButtonPrimary() { | ||
Column( | ||
modifier = Modifier | ||
.height(50.dp) | ||
.width(100.dp), | ||
verticalArrangement = Arrangement.Center, | ||
horizontalAlignment = Alignment.CenterHorizontally | ||
) { | ||
Button(type = ButtonTypeEnum.PRIMARY, content = { ContentExample() }, action = { println("cpicpi") }) | ||
} | ||
} | ||
|
||
@Composable | ||
@Preview | ||
fun PreviewButtonSecondary() { | ||
Column( | ||
modifier = Modifier | ||
.height(50.dp) | ||
.width(100.dp), | ||
verticalArrangement = Arrangement.Center, | ||
horizontalAlignment = Alignment.CenterHorizontally | ||
) { | ||
Button(type = ButtonTypeEnum.SECONDARY, content = { ContentExample() }, action = { println("cpicpi") }) | ||
} | ||
} | ||
|
||
@Composable | ||
@Preview | ||
fun PreviewButtonRedirection() { | ||
Column( | ||
modifier = Modifier | ||
.height(50.dp) | ||
.width(100.dp), | ||
verticalArrangement = Arrangement.Center, | ||
horizontalAlignment = Alignment.CenterHorizontally | ||
) { | ||
Button(type = ButtonTypeEnum.REDIRECTION, content = { ContentExample() }, action = { println("cpicpi") }) | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
app/src/main/java/com/eipsaferoad/owl/components/Draggeable.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.eipsaferoad.owl.components | ||
|
||
import androidx.compose.foundation.gestures.detectDragGestures | ||
import androidx.compose.runtime.MutableState | ||
import androidx.compose.ui.input.pointer.pointerInput | ||
import kotlin.math.abs | ||
import androidx.compose.ui.Modifier | ||
import com.eipsaferoad.owl.models.Alarm | ||
|
||
fun Modifier.handleDraggableModifier( | ||
lastPosX: Float, | ||
vibrationVal: Float, | ||
nbrPixelToMove: Int, | ||
alarms: MutableState<Alarm>, | ||
dragLeft: (value: Float) -> Unit, | ||
dragRight: (value: Float) -> Unit, | ||
init: (value: Float) -> Unit | ||
): Modifier { | ||
return this.pointerInput(Unit) { | ||
detectDragGestures { change, dragAmount -> | ||
change.consume() | ||
if (lastPosX == 0.0f) { | ||
init(change.position.x) | ||
} | ||
if (change.previousPosition.x < change.position.x && abs(lastPosX - change.position.x) > nbrPixelToMove && vibrationVal < alarms.value.vibration.max.toFloat()) { | ||
dragRight(change.position.x) | ||
} else if (change.previousPosition.x > change.position.x && abs(lastPosX - change.position.x) > nbrPixelToMove && vibrationVal > alarms.value.vibration.min) { | ||
dragLeft(change.position.x) | ||
} | ||
println(vibrationVal) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.eipsaferoad.owl.components | ||
|
||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.rounded.Favorite | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.graphics.vector.ImageVector | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import com.eipsaferoad.owl.presentation.theme.OwlTheme | ||
|
||
@Composable | ||
fun DisplayIcon(imageVector: ImageVector, tint: Color) { | ||
Icon( | ||
imageVector, | ||
contentDescription = "Favorite Icon", | ||
tint = tint | ||
) | ||
} | ||
|
||
@Composable | ||
@Preview | ||
fun PreviewDisplayIcon() { | ||
OwlTheme { | ||
DisplayIcon(Icons.Rounded.Favorite, Color.Blue) | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
.../owl/presentation/components/TextInput.kt → ...m/eipsaferoad/owl/components/TextInput.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
app/src/main/java/com/eipsaferoad/owl/components/ToggleSwitch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.eipsaferoad.owl.components | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.width | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import androidx.wear.compose.material.Switch | ||
import androidx.wear.compose.material.SwitchDefaults | ||
import com.eipsaferoad.owl.presentation.theme.md_theme_dark_tertiary | ||
import com.eipsaferoad.owl.presentation.theme.md_theme_light_surface | ||
|
||
@Composable | ||
fun ToggleSwitch(isActivate: Boolean, action: (it: Boolean) -> Unit) { | ||
Switch( | ||
colors = SwitchDefaults.colors( | ||
checkedThumbColor = md_theme_light_surface, | ||
checkedTrackColor = md_theme_light_surface, | ||
uncheckedThumbColor = md_theme_light_surface, | ||
uncheckedTrackColor = md_theme_dark_tertiary | ||
), | ||
checked = isActivate, | ||
onCheckedChange = { | ||
action(it) | ||
} | ||
) | ||
} | ||
|
||
@Composable | ||
@Preview | ||
fun PreviewToggleSwitchDeactivated() { | ||
Column( | ||
modifier = Modifier | ||
.height(50.dp) | ||
.width(100.dp), | ||
verticalArrangement = Arrangement.Center, | ||
horizontalAlignment = Alignment.CenterHorizontally | ||
) { | ||
ToggleSwitch(false, {}) | ||
} | ||
} | ||
|
||
@Composable | ||
@Preview | ||
fun PreviewToggleSwitchActivated() { | ||
Column( | ||
modifier = Modifier | ||
.height(50.dp) | ||
.width(100.dp), | ||
verticalArrangement = Arrangement.Center, | ||
horizontalAlignment = Alignment.CenterHorizontally | ||
) { | ||
ToggleSwitch(true, {}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,7 @@ | ||
package com.eipsaferoad.owl.presentation | ||
|
||
import androidx.compose.runtime.Composable | ||
|
||
enum class PagesEnum(val value: String) { | ||
LOGIN("login"), | ||
HOME("home"), | ||
SETTINGS("settings"), | ||
ALARM("alarm") | ||
} | ||
|
||
typealias ComposableFun = @Composable () -> Unit |
55 changes: 0 additions & 55 deletions
55
app/src/main/java/com/eipsaferoad/owl/presentation/alarm/Alarm.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.