Skip to content

Commit

Permalink
Merge pull request #83 from aritra-tech/develop
Browse files Browse the repository at this point in the history
v1.3.1
  • Loading branch information
aritra-tech authored Sep 27, 2023
2 parents 0d8fa26 + f6d3a56 commit 86dbe95
Show file tree
Hide file tree
Showing 10 changed files with 206 additions and 300 deletions.
10 changes: 5 additions & 5 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ dependencies {

val lifecycleVersion = "2.6.2"
val roomVersion = "2.5.2"
val navVersion = "2.7.2"
val navVersion = "2.7.3"


implementation ("androidx.core:core-ktx:1.10.1")
Expand All @@ -84,12 +84,12 @@ dependencies {
implementation ("androidx.navigation:navigation-compose:$navVersion")

// Accompanist
implementation ("com.google.accompanist:accompanist-systemuicontroller:0.30.1")
implementation ("com.google.accompanist:accompanist-permissions:0.24.11-rc")
implementation ("com.google.accompanist:accompanist-systemuicontroller:0.32.0")
implementation ("com.google.accompanist:accompanist-permissions:0.28.0")

// Material 3
implementation ("androidx.compose.material3:material3:1.1.1")
implementation ("androidx.compose.material3:material3-window-size-class:1.1.1")
implementation ("androidx.compose.material3:material3:1.1.2")
implementation ("androidx.compose.material3:material3-window-size-class:1.1.2")
implementation ("androidx.compose.material:material-icons-extended:1.5.1")

// Room
Expand Down
1 change: 0 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>

<application
Expand Down
49 changes: 0 additions & 49 deletions app/src/main/java/com/aritra/notify/components/actions/NoList.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package com.aritra.notify.components.topbar


import androidx.activity.compose.BackHandler
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.BottomSheetDefaults
import androidx.compose.material3.CenterAlignedTopAppBar
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
Expand All @@ -28,25 +26,30 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import com.aritra.notify.domain.models.Note
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import com.aritra.notify.R
import com.aritra.notify.components.actions.ShareOption
import com.aritra.notify.components.dialog.TextDialog
import com.aritra.notify.ui.screens.notes.homeScreen.NoteScreenViewModel
import com.aritra.notify.utils.shareAsImage
import com.aritra.notify.utils.shareAsPdf
import com.aritra.notify.utils.shareNoteAsText


@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun AddNoteTopBar(
fun AddEditTopBar(
note: Note?,
title: String,
description: String,
modifier: Modifier = Modifier,
onBackPress: () -> Unit,
saveNote: () -> Unit,
updateNote: () -> Unit,
) {
val noteScreenViewModel = hiltViewModel<NoteScreenViewModel>()
var showSheet by remember { mutableStateOf(false) }
val context = LocalContext.current
val skipPartiallyExpanded by remember { mutableStateOf(false) }
Expand All @@ -55,15 +58,17 @@ fun AddNoteTopBar(
)
val view = LocalView.current
val bitmapSize = view.width to view.height
val deleteDialogVisible = remember { mutableStateOf(false) }

BackHandler {
if (title.isNotEmpty() && description.isNotEmpty()) {
saveNote()
} else onBackPress()
}
BackHandler(onBack = {
if (note != null) {
updateNote()
} else {
onBackPress()
}
})

CenterAlignedTopAppBar(
modifier = modifier,
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(
containerColor = MaterialTheme.colorScheme.surface
),
Expand All @@ -74,14 +79,42 @@ fun AddNoteTopBar(
)
},
navigationIcon = {
IconButton(onClick = { onBackPress() }) {
IconButton(onClick = {
if (note != null) {
updateNote()
} else {
onBackPress()
}
}) {
Icon(
painterResource(R.drawable.back),
contentDescription = stringResource(R.string.back)
)
}
},
actions = {
note?.let {
IconButton(onClick = { deleteDialogVisible.value = true }) {
Icon(
painter = painterResource(R.drawable.ic_delete),
contentDescription = "Delete",
)
}

if (deleteDialogVisible.value) {
TextDialog(
title = stringResource(R.string.warning),
description = stringResource(R.string.are_you_sure_want_to_delete_these_items_it_cannot_be_recovered),
isOpened = deleteDialogVisible.value,
onDismissCallback = { deleteDialogVisible.value = false },
onConfirmCallback = {
noteScreenViewModel.deleteNote(note)
deleteDialogVisible.value = false
onBackPress()
}
)
}
}
if (title.isNotEmpty() && description.isNotEmpty()) {
IconButton(onClick = { showSheet = true }) {
Icon(
Expand All @@ -92,8 +125,7 @@ fun AddNoteTopBar(
if (showSheet) {
ModalBottomSheet(
onDismissRequest = { showSheet = false },
sheetState = bottomSheetState,
dragHandle = { BottomSheetDefaults.DragHandle() }
sheetState = bottomSheetState
) {
Column(
modifier = Modifier
Expand Down Expand Up @@ -128,8 +160,13 @@ fun AddNoteTopBar(
}
}
}

IconButton(onClick = saveNote) {
IconButton(onClick = {
if (note != null) {
updateNote()
} else {
saveNote()
}
}) {
Icon(
painterResource(R.drawable.save),
contentDescription = stringResource(R.string.save)
Expand All @@ -139,4 +176,3 @@ fun AddNoteTopBar(
}
)
}

This file was deleted.

Loading

0 comments on commit 86dbe95

Please sign in to comment.