This repository has been archived by the owner on May 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Narendra ju/feature/folders setup (#45)
* Added CODEOWNERS files (#33) * Adding CONTRIBUTING.md * Added CONTRIBUTING.md and squashed commits * Updated branch naming convention Updated branch naming convention with github-username * 1. Added database schema (entity) 2. Added database functions (dao) 3. Added how to fetch paging data 4. Added LazyColumn UI with paging data with different states like loading, success, error Signed-off-by: Rajesh Hadiya <[email protected]> * Added CODEOWNERS files. (#19) * Adding CODEOWNERS files. Still needed to add the Default reviewer for the two teams. * Update CODEOWNERS * fix the validation issues on GitHub. * updated owners for all the branches. * updated the Wrong branch combinations. Signed-off-by: Rajesh Hadiya <[email protected]> Co-authored-by: Hritik Kumar Singh <[email protected]> Co-authored-by: Abhinav Suman <[email protected]> * Create main.yml * Update main.yml * Update main.yml * Added PR template + Updated .gitignore files (#42) Added the PR Templates + .gitignore * added the groundwork for the folders section in NoteX App Signed-off-by: Rajesh Hadiya <[email protected]> Co-authored-by: Rajesh Hadiya <[email protected]> Co-authored-by: Hritik Kumar Singh <[email protected]> Co-authored-by: Abhinav Suman <[email protected]> Co-authored-by: Rajesh Hadiya <[email protected]>
- Loading branch information
1 parent
1b9e220
commit 4f6b1fe
Showing
7 changed files
with
164 additions
and
1 deletion.
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
77 changes: 77 additions & 0 deletions
77
app/src/main/java/com/hadiyarajesh/notex/ui/folders/FoldersScreen.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,77 @@ | ||
package com.hadiyarajesh.notex.ui.folders | ||
|
||
import androidx.compose.foundation.layout.* | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.Scaffold | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.rememberCoroutineScope | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.compose.ui.tooling.preview.Devices | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import androidx.navigation.NavController | ||
import androidx.paging.compose.LazyPagingItems | ||
import androidx.paging.compose.collectAsLazyPagingItems | ||
import com.hadiyarajesh.notex.database.entity.Folder | ||
import com.hadiyarajesh.notex.database.model.NoteFolder | ||
import com.hadiyarajesh.notex.database.model.ReminderFolder | ||
|
||
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun FoldersScreen( | ||
navController: NavController, | ||
foldersViewModel: FoldersViewModel | ||
) { | ||
val scope = rememberCoroutineScope() | ||
val context = LocalContext.current | ||
val notesFolders = remember { foldersViewModel.noteFolders }.collectAsLazyPagingItems() | ||
val reminderFolders = remember { foldersViewModel.reminderFolders }.collectAsLazyPagingItems() | ||
|
||
Scaffold { innerPadding -> | ||
Column( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.padding(innerPadding), | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
verticalArrangement = Arrangement.Center | ||
) { | ||
AllFoldersView(onClick = {}) | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
|
||
|
||
@Composable | ||
private fun AllFoldersView( | ||
modifier: Modifier = Modifier, | ||
noteFolders: LazyPagingItems<NoteFolder>? = null, | ||
reminderFolder: LazyPagingItems<ReminderFolder>? = null, | ||
onClick: (Folder) -> Unit | ||
) { | ||
Column(modifier = Modifier.padding(16.dp)) { | ||
Text( | ||
text = "Folders Screen", | ||
modifier = Modifier.fillMaxWidth() | ||
) | ||
|
||
} | ||
} | ||
|
||
@Preview( | ||
name = "All Folders Preview", | ||
showBackground = true, | ||
showSystemUi = true, | ||
device = Devices.PIXEL_2_XL | ||
) | ||
@Composable | ||
fun AllFoldersViewPreview(){ | ||
AllFoldersView(onClick = {}) | ||
} |
38 changes: 38 additions & 0 deletions
38
app/src/main/java/com/hadiyarajesh/notex/ui/folders/FoldersViewModel.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,38 @@ | ||
package com.hadiyarajesh.notex.ui.folders | ||
|
||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.viewModelScope | ||
import androidx.paging.PagingData | ||
import androidx.paging.cachedIn | ||
import com.hadiyarajesh.notex.database.entity.Folder | ||
import com.hadiyarajesh.notex.database.model.FolderType | ||
import com.hadiyarajesh.notex.database.model.NoteFolder | ||
import com.hadiyarajesh.notex.database.model.ReminderFolder | ||
import com.hadiyarajesh.notex.repository.folder.FolderRepository | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.launch | ||
import javax.inject.Inject | ||
|
||
@HiltViewModel | ||
class FoldersViewModel @Inject constructor( | ||
private val folderRepository: FolderRepository | ||
) : ViewModel() { | ||
|
||
val noteFolders: Flow<PagingData<NoteFolder>> = | ||
folderRepository.getAllNoteFolders().cachedIn(viewModelScope) | ||
|
||
val reminderFolders : Flow<PagingData<ReminderFolder>> = | ||
folderRepository.getAllReminderFolders().cachedIn(viewModelScope) | ||
|
||
|
||
fun createFolder( | ||
name: String, | ||
description: String?, | ||
folderType: FolderType | ||
) = viewModelScope.launch { | ||
folderRepository.createFolder( | ||
name, description, folderType | ||
) | ||
} | ||
} |
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
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
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,5 @@ | ||
<vector android:height="24dp" android:tint="#000000" | ||
android:viewportHeight="24" android:viewportWidth="24" | ||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M10,4H4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2V8c0,-1.1 -0.9,-2 -2,-2h-8l-2,-2z"/> | ||
</vector> |
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,5 @@ | ||
<vector android:height="24dp" android:tint="#000000" | ||
android:viewportHeight="24" android:viewportWidth="24" | ||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M20,6h-8l-2,-2L4,4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,8c0,-1.1 -0.9,-2 -2,-2zM20,18L4,18L4,8h16v10z"/> | ||
</vector> |