Skip to content

Commit

Permalink
New design (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealPad committed Jul 13, 2024
2 parents 3d63067 + e6e28db commit d6dd4a1
Show file tree
Hide file tree
Showing 8 changed files with 171 additions and 83 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/com/eipsaferoad/owl/components/Button.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fun Button(type: ButtonTypeEnum, content: @Composable () -> Unit, action: () ->
Column(
modifier = Modifier
.fillMaxSize()
.clip(shape = RoundedCornerShape(20.dp))
.clip(shape = RoundedCornerShape(100.dp))
.background(backgroundColor)
.clickable { action() },
verticalArrangement = Arrangement.Center,
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/java/com/eipsaferoad/owl/components/Draggeable.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import androidx.compose.ui.Modifier
import com.eipsaferoad.owl.models.Alarm

fun Modifier.handleDraggableModifier(
lastPosX: Float,
vibrationVal: Float,
nbrPixelToMove: Int,
lastPosX: MutableState<Float>,
vibrationVal: MutableState<Float>,
nbrPixelToMove: MutableState<Int>,
alarms: MutableState<Alarm>,
dragLeft: (value: Float) -> Unit,
dragRight: (value: Float) -> Unit,
Expand All @@ -19,12 +19,12 @@ fun Modifier.handleDraggableModifier(
return this.pointerInput(Unit) {
detectDragGestures { change, dragAmount ->
change.consume()
if (lastPosX == 0.0f) {
if (lastPosX.value == 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()) {
if (change.previousPosition.x < change.position.x && abs(lastPosX.value - change.position.x) > nbrPixelToMove.value && vibrationVal.value < 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) {
} else if (change.previousPosition.x > change.position.x && abs(lastPosX.value - change.position.x) > nbrPixelToMove.value && vibrationVal.value > alarms.value.vibration.min) {
dragLeft(change.position.x)
}
println(vibrationVal)
Expand Down
10 changes: 6 additions & 4 deletions app/src/main/java/com/eipsaferoad/owl/components/ToggleSwitch.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ 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_primary
import com.eipsaferoad.owl.presentation.theme.md_theme_light_secondary
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
checkedThumbColor = md_theme_light_primary,
checkedTrackColor = md_theme_light_secondary,
uncheckedThumbColor = md_theme_light_primary,
uncheckedTrackColor = md_theme_light_secondary
),
checked = isActivate,
onCheckedChange = {
Expand Down
109 changes: 64 additions & 45 deletions app/src/main/java/com/eipsaferoad/owl/presentation/home/Home.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.infiniteRepeatable
import androidx.compose.animation.core.rememberInfiniteTransition
import androidx.compose.animation.core.tween
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.gestures.detectDragGestures
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand All @@ -19,16 +21,20 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Clear
import androidx.compose.material.icons.rounded.Favorite
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.snapshotFlow
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Brush
Expand Down Expand Up @@ -58,6 +64,11 @@ import com.eipsaferoad.owl.utils.LocalStorage
import com.eipsaferoad.owl.utils.getVibrationEffects
import com.eipsaferoad.owl.utils.soundPlayer
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.filter
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.platform.LocalWindowInfo
import androidx.compose.ui.res.painterResource

@Composable
fun Home(currentHeartRate: MutableState<String>, context: Context, navController: NavHostController, alarms: MutableState<Alarm>, mVibrator: Vibrator) {
Expand All @@ -70,16 +81,51 @@ fun Home(currentHeartRate: MutableState<String>, context: Context, navController

@Composable
fun NoAlarm(currentHeartRate: String, context: Context, navController: NavHostController) {
val lazyListState = rememberLazyListState(
initialFirstVisibleItemIndex = 1
)

Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
LazyColumn(
state = lazyListState,
modifier = Modifier.height(200.dp),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
item {
Column(
modifier = Modifier.padding(top = 80.dp, start = 10.dp, end = 10.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
Button(
type = ButtonTypeEnum.REDIRECTION,
content = {
Text(
fontSize = 17.sp,
text = "DISCONNECTION",
fontWeight = FontWeight.Bold,
modifier = Modifier.padding(vertical = 10.dp)
)
},
action = {
LocalStorage.deleteData(context, EnvEnum.EMAIL.value)
LocalStorage.deleteData(context, EnvEnum.PASSWORD.value)
navController.navigate(PagesEnum.LOGIN.value)
}
)
Image(
painter = painterResource(id = R.drawable.logout),
contentDescription = "logout",
modifier = Modifier
.size(30.dp)
.padding(top = 10.dp)
)
}
}
item {
Column(
modifier = Modifier.padding(bottom = 100.dp, top = 70.dp),
Expand All @@ -98,47 +144,29 @@ fun NoAlarm(currentHeartRate: String, context: Context, navController: NavHostCo
}
}
item {
Buttons(context = context, navController = navController)
Column(
modifier = Modifier.padding(bottom = 60.dp, start = 10.dp, end = 10.dp)
) {
Button(
type = ButtonTypeEnum.PRIMARY,
content = {
Text(
fontSize = 30.sp,
text = "ALARM",
fontWeight = FontWeight.Bold,
modifier = Modifier.padding(vertical = 15.dp)
)
},
action = {
navController.navigate(PagesEnum.SETTINGS.value)
}
)
}
}
}
}
}

@Composable
fun Buttons(context: Context, navController: NavHostController) {
Column(
modifier = Modifier.padding(bottom = 40.dp),
verticalArrangement = Arrangement.spacedBy(10.dp)
) {
Button(
type = ButtonTypeEnum.PRIMARY,
content = {
Text(
fontSize = 30.sp,
text = "ALARM"
)
},
action = {
navController.navigate(PagesEnum.SETTINGS.value)
}
)
Button(
type = ButtonTypeEnum.REDIRECTION,
content = {
Text(
fontSize = 17.sp,
text = "DISCONNECTION",
)
},
action = {
LocalStorage.deleteData(context, EnvEnum.EMAIL.value)
LocalStorage.deleteData(context, EnvEnum.PASSWORD.value)
navController.navigate(PagesEnum.LOGIN.value)
}
)
}
}

@Composable
fun MultiColorBorderCircularColumn(
borderColors: List<Color>,
Expand Down Expand Up @@ -301,15 +329,6 @@ fun PreviewHome() {
}*/
}

@Composable
@Preview
fun PreviewButtons() {
val navController = rememberSwipeDismissableNavController()
OwlTheme {
Buttons(LocalContext.current, navController)
}
}

@Composable
@Preview(device = Devices.WEAR_OS_LARGE_ROUND, showSystemUi = true)
fun PreviewAlarm() {
Expand Down
Loading

0 comments on commit d6dd4a1

Please sign in to comment.