Skip to content

Commit

Permalink
Merge pull request #327 from PatilShreyas/v1.3.1-dev
Browse files Browse the repository at this point in the history
Release NotyKT v1.3.1
  • Loading branch information
PatilShreyas authored Nov 16, 2021
2 parents e07e2e1 + de0df87 commit b85a447
Show file tree
Hide file tree
Showing 14 changed files with 257 additions and 93 deletions.
28 changes: 28 additions & 0 deletions docs/pages/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,34 @@ You can see [GitHub releases](https://github.com/PatilShreyas/NotyKT/releases) w

---

## _v1.3.1_ (2021-11-16)

This release includes few improvements and fixes in the Jetpack Compose Application to make it better.

### 🐛 Bug Fixes

- [[#281](https://github.com/PatilShreyas/NotyKT/issues/281)] Earlier, After signup, navigating back takes to log in screen. Now it closes the app.
- [[#282](https://github.com/PatilShreyas/NotyKT/issues/282)] Show proper cards with proper shadow in About screen. (_Contributed by [@yogeshpaliyal](https://github.com/yogeshpaliyal)_)
- [[#284](https://github.com/PatilShreyas/NotyKT/issues/284)] Removed focus (cursor) from fields while sharing image of a note. (_Contributed by [@yogeshpaliyal](https://github.com/yogeshpaliyal)_)
- [[#286](https://github.com/PatilShreyas/NotyKT/issues/286)] Improved dark mode visibility. (_Contributed by [@yogeshpaliyal](https://github.com/yogeshpaliyal)_)
- [[#294](https://github.com/PatilShreyas/NotyKT/issues/294)] Earlier, flickering (recompositions) were happening after performing navigation through screens.

### ✅ Improvements

- [[#280](https://github.com/PatilShreyas/NotyKT/issues/280)] Provided helper message for input fields like username and password for better UX in Login/Signup screens.
- [[#283](https://github.com/PatilShreyas/NotyKT/issues/283)] Improved touch region area of note input fields. (_Contributed by [@yogeshpaliyal](https://github.com/yogeshpaliyal)_)
- [[#287](https://github.com/PatilShreyas/NotyKT/issues/287)] Show confirmation dialog before deleting a note.
- [[#297](https://github.com/PatilShreyas/NotyKT/issues/297)] Show confirmation dialog before logging out.

### 🎯 Codebase Improvements

- Used `decorationBox` property of Composable TextField to show/hide placeholder instead of manually handling in a box.
- Removed `jcenter()` from Gradle repositories (_Contributed by [@sairajsawant](https://github.com/sairajsawant)_)

_**Many Thanks to superstar ⭐ contributors [@yogeshpaliyal](https://github.com/yogeshpaliyal), [@sairajsawant](https://github.com/sairajsawant) for contributing PRs and [@kasem-sm](https://github.com/kasem-sm) for raising issues**_

---

## _v1.3.0_ (2021-10-24)

This release includes new feature and some fixes in the Jetpack Compose Application.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,23 @@

package dev.shreyaspatil.noty.composeapp.component.dialog

import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.Button
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.material.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
Expand Down Expand Up @@ -87,3 +96,82 @@ fun FailureDialog(failureMessage: String, onDismissed: () -> Unit = {}) {
}
}
}

@Composable
fun ConfirmationDialog(
title: String,
message: String,
onConfirmedYes: () -> Unit,
onConfirmedNo: () -> Unit,
onDismissed: () -> Unit
) {
var isDismissed by remember { mutableStateOf(false) }

if (!isDismissed) {
Dialog(onDismissRequest = {}) {
Surface {
Column(
horizontalAlignment = Alignment.Start,
modifier = Modifier.padding(
top = 16.dp,
bottom = 8.dp,
start = 16.dp,
end = 16.dp
)
) {
Text(
text = title,
color = MaterialTheme.colors.onSurface,
style = MaterialTheme.typography.body1,
fontWeight = FontWeight.Bold
)

Text(
text = message,
color = MaterialTheme.colors.onSurface,
style = MaterialTheme.typography.body2,
fontWeight = FontWeight.Normal,
modifier = Modifier.padding(vertical = 8.dp)
)

Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.End,
verticalAlignment = Alignment.CenterVertically
) {
TextButton(
onClick = {
onConfirmedYes()
isDismissed = true
},
modifier = Modifier
.padding(horizontal = 4.dp),

) {
Text(
style = typography.button,
color = MaterialTheme.colors.primary,
text = "Yes"
)
}
TextButton(
onClick = {
onConfirmedNo()
isDismissed = true
},
modifier = Modifier
.padding(horizontal = 4.dp),

) {
Text(
style = typography.button,
color = MaterialTheme.colors.primary,
text = "No"
)
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ package dev.shreyaspatil.noty.composeapp.component.text

import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.material.MaterialTheme
import androidx.compose.material.OutlinedTextField
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
Expand All @@ -46,18 +50,28 @@ fun NotyTextField(
color: Color = MaterialTheme.colors.onPrimary,
leadingIcon: @Composable() (() -> Unit)? = null,
isError: Boolean = false,
helperText: String = "",
visualTransformation: VisualTransformation = VisualTransformation.None
) {
OutlinedTextField(
value = value,
label = { Text(text = label) },
modifier = modifier,
onValueChange = onValueChange,
leadingIcon = leadingIcon,
textStyle = TextStyle(color, fontSize = fontSize),
isError = isError,
visualTransformation = visualTransformation
)
Surface(modifier) {
Column {
OutlinedTextField(
value = value,
label = { Text(text = label) },
modifier = Modifier.fillMaxWidth(),
onValueChange = onValueChange,
leadingIcon = leadingIcon,
textStyle = TextStyle(color, fontSize = fontSize),
isError = isError,
visualTransformation = visualTransformation,
shape = RoundedCornerShape(8.dp)
)
if (helperText.isNotEmpty()) {
Spacer(modifier = Modifier.padding(2.dp))
Text(text = helperText, style = MaterialTheme.typography.caption)
}
}
}
}

@ExperimentalAnimationApi
Expand All @@ -68,24 +82,25 @@ fun BasicNotyTextField(
label: String = "",
textStyle: TextStyle = TextStyle(fontSize = 16.sp, fontWeight = FontWeight.Normal),
onTextChange: (String) -> Unit,
maxLines: Int = Int.MAX_VALUE
maxLines: Int = Int.MAX_VALUE,
) {

Box(modifier = modifier.padding(4.dp)) {
AnimatedVisibility(visible = value.isBlank()) {
Text(
text = label,
color = getTextFieldHintColor(),
fontSize = textStyle.fontSize,
fontWeight = textStyle.fontWeight
)
BasicTextField(
modifier = modifier,
value = value,
onValueChange = onTextChange,
textStyle = textStyle.copy(color = MaterialTheme.colors.onPrimary),
maxLines = maxLines,
cursorBrush = SolidColor(MaterialTheme.colors.primary),
decorationBox = { inlineTextField ->
AnimatedVisibility(visible = value.isBlank()) {
Text(
text = label,
color = getTextFieldHintColor(),
fontSize = textStyle.fontSize,
fontWeight = textStyle.fontWeight
)
}
inlineTextField()
}
BasicTextField(
value = value,
onValueChange = onTextChange,
textStyle = textStyle.copy(color = MaterialTheme.colors.onPrimary),
maxLines = maxLines,
cursorBrush = SolidColor(MaterialTheme.colors.primary)
)
}
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ fun PasswordTextField(
modifier = modifier,
leadingIcon = { Icon(Icons.Outlined.Password, "Password") },
visualTransformation = PasswordVisualTransformation(),
isError = !isValid && startedTyping
isError = !isValid && startedTyping,
helperText = "Minimum 8 characters required"
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ fun UsernameTextField(
},
modifier = modifier,
leadingIcon = { Icon(Icons.Outlined.Person, "User") },
isError = !isValid && startedTyping
isError = !isValid && startedTyping,
helperText = "Minimum 4 characters required"
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
Expand Down Expand Up @@ -71,7 +70,7 @@ class MainActivity : AppCompatActivity() {
val darkMode by preferenceManager.uiModeFlow.collectAsState(initial = isSystemInDarkTheme())

NotyTheme(darkTheme = darkMode) {
Surface(color = MaterialTheme.colors.background) {
Surface {
NotyNavigation()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
Expand Down Expand Up @@ -106,7 +107,7 @@ fun AboutAppBar(navController: NavController) {
@Composable
fun AboutColumn() {
LazyColumn(
modifier = Modifier.padding(8.dp),
modifier = Modifier.padding(8.dp).fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally
) {
item {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.sizeIn
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.Button
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand All @@ -49,6 +50,7 @@ import dev.shreyaspatil.noty.composeapp.component.dialog.LoaderDialog
import dev.shreyaspatil.noty.composeapp.component.text.PasswordTextField
import dev.shreyaspatil.noty.composeapp.component.text.TextFieldValue
import dev.shreyaspatil.noty.composeapp.component.text.UsernameTextField
import dev.shreyaspatil.noty.composeapp.navigation.NOTY_NAV_HOST_ROUTE
import dev.shreyaspatil.noty.composeapp.ui.Screen
import dev.shreyaspatil.noty.composeapp.ui.theme.typography
import dev.shreyaspatil.noty.core.ui.UIDataState
Expand All @@ -64,21 +66,15 @@ fun LoginScreen(navController: NavHostController, loginViewModel: LoginViewModel
when (viewState) {
is UIDataState.Loading -> LoaderDialog()
is UIDataState.Failed -> FailureDialog(viewState.message)
is UIDataState.Success -> {
navController.navigate(Screen.Notes.route) {
launchSingleTop = true
popUpTo(Screen.Login.route) { inclusive = true }
}
}
}

LazyColumn {
LazyColumn(
modifier = Modifier
.fillMaxSize()
.background(MaterialTheme.colors.surface)
) {
item {
ConstraintLayout(
Modifier
.fillMaxSize()
.background(MaterialTheme.colors.surface)
) {
ConstraintLayout() {
val (
logoRef,
titleRef,
Expand All @@ -91,14 +87,13 @@ fun LoginScreen(navController: NavHostController, loginViewModel: LoginViewModel
Image(
contentDescription = "App Logo",
painter = painterResource(id = noty_app_logo),
modifier = Modifier
.sizeIn(100.dp, 100.dp)
modifier = Modifier.size(92.dp)
.constrainAs(logoRef) {
top.linkTo(parent.top, margin = 60.dp)
start.linkTo(parent.start, 16.dp)
end.linkTo(parent.end, 16.dp)
},
contentScale = ContentScale.Inside
contentScale = ContentScale.FillBounds
)

Text(
Expand Down Expand Up @@ -184,4 +179,13 @@ fun LoginScreen(navController: NavHostController, loginViewModel: LoginViewModel
}
}
}

LaunchedEffect(viewState?.isSuccess) {
if (viewState?.isSuccess == true) {
navController.navigate(Screen.Notes.route) {
launchSingleTop = true
popUpTo(NOTY_NAV_HOST_ROUTE)
}
}
}
}
Loading

0 comments on commit b85a447

Please sign in to comment.