Skip to content

Commit

Permalink
Merge pull request #23 from aritra-tech/develop
Browse files Browse the repository at this point in the history
UI changes and Optimization 🪓
  • Loading branch information
aritra-tech committed Jul 25, 2023
2 parents ad59e2a + 1f386ff commit ffcaec0
Show file tree
Hide file tree
Showing 28 changed files with 249 additions and 145 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
android:theme="@style/Theme.Notify"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:name=".ui.screens.MainActivity"
android:exported="true"
android:theme="@style/Theme.MyApp.Splash">
<intent-filter>
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/com/aritra/notify/NotifyApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ import android.app.Application
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class NotifyApplication: Application() {
}
class NotifyApplication: Application()
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
Expand All @@ -22,6 +20,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -74,7 +73,7 @@ fun SettingsComponent(
}
Icon(
painter = painterResource(painterResourceID),
contentDescription = "icon",
contentDescription = stringResource(R.string.icon),
modifier = modifier
.size(35.dp),
tint = MaterialTheme.colorScheme.primary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ import androidx.compose.ui.unit.sp
import com.aritra.notify.R
import com.aritra.notify.components.actions.ShareOption
import com.aritra.notify.data.models.Note
import com.aritra.notify.screens.notes.addNoteScreen.AddNoteViewModel
import eu.wewox.modalsheet.ExperimentalSheetApi
import com.aritra.notify.ui.screens.notes.addNoteScreen.AddNoteViewModel
import com.aritra.notify.utils.shareNoteAsText
import java.util.Date


@OptIn(ExperimentalMaterial3Api::class, ExperimentalSheetApi::class)
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun AddNoteTopBar(
viewModel: AddNoteViewModel,
Expand Down Expand Up @@ -72,21 +72,21 @@ fun AddNoteTopBar(
IconButton(onClick = { onBackPress() }) {
Icon(
painterResource(R.drawable.back),
contentDescription = "back"
contentDescription = stringResource(R.string.back)
)
}
},
actions = {
if (title.isNotEmpty() && description.isNotEmpty()) {
IconButton(onClick = { showSheet = true }) {
Icon(
painterResource(R.drawable.share),
contentDescription = "share"
painterResource(R.drawable.ic_share),
contentDescription = stringResource(R.string.share)
)
}
if (showSheet){
if (showSheet) {
ModalBottomSheet(
onDismissRequest = {showSheet = false},
onDismissRequest = { showSheet = false },
sheetState = bottomSheetState
) {
Column(
Expand All @@ -99,16 +99,13 @@ fun AddNoteTopBar(
ShareOption(
text = stringResource(R.string.share_note_as_text),
onClick = {
val sharingIntent = Intent(Intent.ACTION_SEND)
sharingIntent.type = "text/plain"

sharingIntent.putExtra(Intent.EXTRA_TEXT, "${"Title: $title"}\n${"Note: $description"}")
context.startActivity(Intent.createChooser(sharingIntent, "Share via"))
shareNoteAsText(context, title, description)
showSheet = false
}
)
Spacer(modifier = Modifier.height(14.dp))
Button(onClick = { showSheet = false },
Button(
onClick = { showSheet = false },
modifier = Modifier
.fillMaxWidth()
.padding(10.dp),
Expand All @@ -125,15 +122,16 @@ fun AddNoteTopBar(
}

IconButton(onClick = {
val noteDB = Note(id = 0, title = title,note = description, dateTime = dateTime)
val noteDB =
Note(id = 0, title = title, note = description, dateTime = dateTime)
viewModel.insertNote(noteDB)
onSave()
Toast.makeText(context, "Successfully Saved!", Toast.LENGTH_SHORT).show()

}) {
Icon(
painterResource(R.drawable.save),
contentDescription = "save"
contentDescription = stringResource(R.string.save)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ import androidx.compose.ui.unit.sp
import com.aritra.notify.R
import com.aritra.notify.components.actions.ShareOption
import com.aritra.notify.data.models.Note
import com.aritra.notify.screens.notes.editNoteScreen.EditScreenViewModel
import eu.wewox.modalsheet.ExperimentalSheetApi
import com.aritra.notify.ui.screens.notes.editNoteScreen.EditScreenViewModel
import com.aritra.notify.utils.shareNoteAsText
import java.util.Date

@OptIn(ExperimentalMaterial3Api::class, ExperimentalSheetApi::class)
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun EditNoteTopBar(
viewModel: EditScreenViewModel,
Expand All @@ -48,7 +48,7 @@ fun EditNoteTopBar(
title: String,
description: String,
dateTime: Date,
){
) {
var showSheet by remember { mutableStateOf(false) }
val context = LocalContext.current
val skipPartiallyExpanded by remember { mutableStateOf(false) }
Expand All @@ -70,20 +70,20 @@ fun EditNoteTopBar(
IconButton(onClick = { navigateBack() }) {
Icon(
painterResource(R.drawable.back),
contentDescription = "back"
contentDescription = stringResource(R.string.back)
)
}
},
actions = {
IconButton(onClick = { showSheet = true }) {
Icon(
painterResource(R.drawable.share),
contentDescription = "share"
painterResource(R.drawable.ic_share),
contentDescription = stringResource(R.string.share)
)
}
if (showSheet){
if (showSheet) {
ModalBottomSheet(
onDismissRequest = {showSheet = false},
onDismissRequest = { showSheet = false },
sheetState = bottomSheetState
) {
Column(
Expand All @@ -96,16 +96,13 @@ fun EditNoteTopBar(
ShareOption(
text = stringResource(R.string.share_note_as_text),
onClick = {
val sharingIntent = Intent(Intent.ACTION_SEND)
sharingIntent.type = "text/plain"

sharingIntent.putExtra(Intent.EXTRA_TEXT, "${"Title: $title"}\n${"Note: $description"}")
context.startActivity(Intent.createChooser(sharingIntent, "Share via"))
shareNoteAsText(context, title, description)
showSheet = false
}
)
Spacer(modifier = Modifier.height(14.dp))
Button(onClick = { showSheet = false },
Button(
onClick = { showSheet = false },
modifier = Modifier
.fillMaxWidth()
.padding(10.dp),
Expand All @@ -122,14 +119,14 @@ fun EditNoteTopBar(
}
IconButton(onClick = {
val currentDateTime = Date()
val updateNote = Note(noteId,title,description,currentDateTime)
val updateNote = Note(noteId, title, description, currentDateTime)
viewModel.updateNotes(updateNote)
navigateBack()
Toast.makeText(context, "Successfully Updated!", Toast.LENGTH_SHORT).show()
}) {
Icon(
painterResource(R.drawable.save),
contentDescription = "save"
contentDescription = stringResource(R.string.save)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,5 @@ fun TopBar() {
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(
containerColor = Color.Transparent,
)
// actions = {
// IconButton(onClick = { /*TODO*/ }) {
// Icon(
// painterResource(R.drawable.notification),
// contentDescription = "notification"
// )
// }
// },
)
}
4 changes: 2 additions & 2 deletions app/src/main/java/com/aritra/notify/data/db/NoteDatabase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import com.aritra.notify.data.dao.NoteDao
import com.aritra.notify.data.models.Note

@Database(entities = [Note::class], version = 2)
abstract class NoteDatabase : RoomDatabase() {
abstract class NoteDatabase : RoomDatabase() {

abstract fun noteDao() : NoteDao
abstract fun noteDao(): NoteDao

companion object {
private var INSTANCE: NoteDatabase? = null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.aritra.notify.screens.settingsScreen
package com.aritra.notify.data.repository

import android.content.Context
import android.net.Uri
Expand Down
29 changes: 12 additions & 17 deletions app/src/main/java/com/aritra/notify/navigation/NotifyApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,16 @@ import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import androidx.navigation.navArgument
import com.aritra.notify.R
import com.aritra.notify.screens.notes.addNoteScreen.AddNotesScreen
import com.aritra.notify.screens.notes.editNoteScreen.EditNotesScreen
import com.aritra.notify.screens.notes.homeScreen.HomeScreen
import com.aritra.notify.screens.settingsScreen.SettingsScreen
import com.aritra.notify.screens.todo.todoHomeScreen.TodoHomeScreen
import com.aritra.notify.ui.screens.notes.addNoteScreen.AddNotesScreen
import com.aritra.notify.ui.screens.notes.editNoteScreen.EditNotesScreen
import com.aritra.notify.ui.screens.notes.homeScreen.HomeScreen
import com.aritra.notify.ui.screens.settingsScreen.SettingsScreen
import kotlinx.coroutines.delay

@Composable
fun NotifyApp(navController: NavHostController = rememberNavController(),onLoaded: () -> Unit){
fun NotifyApp(navController: NavHostController = rememberNavController(), onLoaded: () -> Unit) {

LaunchedEffect(key1 = Unit){
LaunchedEffect(key1 = Unit) {
delay(2000)
onLoaded()
}
Expand Down Expand Up @@ -89,32 +88,28 @@ fun NotifyApp(navController: NavHostController = rememberNavController(),onLoade
) {
composable(route = NotifyScreens.Home.name) {
HomeScreen(
onFabClicked = { navController.navigate(NotifyScreens.AddNotes.name)},
onFabClicked = { navController.navigate(NotifyScreens.AddNotes.name) },
navigateToUpdateNoteScreen = { noteId ->
navController.navigate("${NotifyScreens.UpdateNotes.name}/$noteId")
}
)
}
composable(route = "${NotifyScreens.UpdateNotes.name}/{noteId}",
arguments = listOf(navArgument("noteId") { type = IntType})
composable(
route = "${NotifyScreens.UpdateNotes.name}/{noteId}",
arguments = listOf(navArgument("noteId") { type = IntType })
) { backStack ->
val noteId = backStack.arguments?.getInt("noteId") ?: 0
EditNotesScreen(
noteId = noteId,
navigateBack = {navController.popBackStack()}
navigateBack = { navController.popBackStack() }
)
}
composable(NotifyScreens.TodoHome.name) {
TodoHomeScreen()
}
composable(NotifyScreens.AddNotes.name) {
AddNotesScreen(navigateBack = {navController.popBackStack()})
AddNotesScreen(navigateBack = { navController.popBackStack() })
}
composable(NotifyScreens.Settings.name) {
SettingsScreen()
}
}
}


}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.aritra.notify
package com.aritra.notify.ui.screens

import android.os.Bundle
import androidx.activity.ComponentActivity
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.aritra.notify.screens.notes.addNoteScreen
package com.aritra.notify.ui.screens.notes.addNoteScreen

import android.app.Application
import androidx.lifecycle.AndroidViewModel
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.aritra.notify.screens.notes.addNoteScreen
package com.aritra.notify.ui.screens.notes.addNoteScreen


import androidx.compose.foundation.layout.Column
Expand Down Expand Up @@ -91,8 +91,8 @@ fun AddNotesScreen(
modifier = Modifier
.fillMaxWidth(),
value = title,
onValueChange = {
title = it
onValueChange = { newTitle ->
title = newTitle
characterCount = title.length + description.length
},
placeholder = {
Expand Down Expand Up @@ -148,8 +148,8 @@ fun AddNotesScreen(
TextField(
modifier = Modifier.fillMaxSize(),
value = description,
onValueChange = {
description = it
onValueChange = { newDescription ->
description = newDescription
characterCount = title.length + description.length
},
placeholder = {
Expand Down
Loading

0 comments on commit ffcaec0

Please sign in to comment.