Skip to content
This repository has been archived by the owner on May 19, 2023. It is now read-only.

Commit

Permalink
Branch hadiyarajesh (#55)
Browse files Browse the repository at this point in the history
* Added new line in Constants.kt

* Note card ui component added which will be inflated in lazy column to show all notes (#35)

* 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]>

* NoteCardView for all notes ui made

* Create main.yml

* Update main.yml

* Update main.yml

* Some improvements done generalised the code

* Some ui improvements and code to inflate all card views added

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]>

Signed-off-by: Rajesh Hadiya <[email protected]>
Co-authored-by: Swapnil bhojwani <[email protected]>
Co-authored-by: Hritik Kumar Singh <[email protected]>
Co-authored-by: Abhinav Suman <[email protected]>
  • Loading branch information
4 people authored Sep 10, 2022
1 parent f0e708c commit 7d3e5fd
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 9 deletions.
3 changes: 0 additions & 3 deletions .idea/.gitignore

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ package com.hadiyarajesh.notex.database.converter

import androidx.room.TypeConverter
import java.time.Instant
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.ZoneOffset
import java.time.format.DateTimeFormatter

object InstantConverter {
@JvmStatic
Expand All @@ -11,4 +15,14 @@ object InstantConverter {
@JvmStatic
@TypeConverter
fun toInstant(value: String?): Instant? = value?.let { Instant.parse(value) }


@JvmStatic
@TypeConverter
fun getLocalDate(instant: Instant): LocalDate {
val localDateTime: LocalDateTime =
LocalDateTime.ofInstant(instant, ZoneOffset.systemDefault())
val formatter = DateTimeFormatter.ofPattern("yyyyMMdd")
return LocalDate.parse(localDateTime.format(formatter), formatter)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package com.hadiyarajesh.notex.ui.component

import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.Divider
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.hadiyarajesh.notex.database.converter.InstantConverter
import com.hadiyarajesh.notex.database.entity.Note
import java.time.Instant

@Composable
fun NoteCard(note: Note) {
Card(
elevation = CardDefaults.cardElevation(),
modifier = Modifier
.fillMaxWidth()
.padding(start = 16.dp, end = 16.dp, top = 16.dp),
shape = RoundedCornerShape(16.dp)
) {
Column(
verticalArrangement = Arrangement.Center,
modifier = Modifier.padding(16.dp)
) {
note.title?.let {
TextSemiBold(
content = it,
null,
MaterialTheme.typography.titleLarge, Color.Black
)
}
Row(
Modifier
.fillMaxWidth()
.padding(top = 16.dp)
) {
Row(
modifier = Modifier
.fillMaxWidth()
.height(IntrinsicSize.Min)
.weight(1f)
) {
TextSemiBold(
content = "Succeed", Modifier.padding(end = 8.dp)
)
Divider(
color = Color.Gray, modifier = Modifier
.fillMaxHeight()
.width(1.dp)
)
TextSemiBold(content = "Goal", Modifier.padding(start = 8.dp))
}
Row(
Modifier
.fillMaxWidth()
.weight(1f), horizontalArrangement = Arrangement.End
) {
TextSemiBold(
content = InstantConverter.getLocalDate(note.createdOn).toString()
)
}

}
}
}

}

@Preview
@Composable
fun NoteCardPrev() {
NoteCard(
Note(
noteId = 12345,
title = "Note title",
content = "Note content",
archived = false,
createdOn = Instant.now(),
updatedOn = Instant.now()
)
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.hadiyarajesh.notex.ui.component

import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight


@Composable
fun TextSemiBold(
content: String,
modifier: Modifier? = Modifier,
textStyle: TextStyle? = null,
color: Color? = null
) {
Text(
text = content, fontWeight = FontWeight.SemiBold,
color = color ?: Color.Gray,
modifier = modifier ?: Modifier,
style = textStyle ?: TextStyle.Default
)
}
11 changes: 6 additions & 5 deletions app/src/main/java/com/hadiyarajesh/notex/ui/note/NotesScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import com.hadiyarajesh.notex.R
import com.hadiyarajesh.notex.database.entity.Note
import com.hadiyarajesh.notex.ui.component.EmptyView
import com.hadiyarajesh.notex.ui.component.LoadingProgressBar
import com.hadiyarajesh.notex.ui.component.NoteCard
import com.hadiyarajesh.notex.ui.component.RetryItem
import java.time.Instant

Expand All @@ -43,7 +44,10 @@ fun NotesScreen(
.fillMaxSize()
.padding(innerPadding),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
verticalArrangement = if (notesViewModel.notes == null) {
Arrangement.Center
} else
Arrangement.Top
) {
AllNotesView(
notes = notes,
Expand All @@ -64,10 +68,7 @@ private fun AllNotesView(
LazyColumn(modifier = modifier) {
items(notes) { item ->
item?.let { note ->
NoteItem(
note = note,
onClick = onClick
)
NoteCard(note = note)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ object Constants {
}
}

const val TAG = Constants.App.APP_NAME
const val TAG = Constants.App.APP_NAME

0 comments on commit 7d3e5fd

Please sign in to comment.