Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/home-screen #12

Merged
merged 18 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package com.pwhs.quickmem.presentation.homescreen.components

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
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
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Notifications
import androidx.compose.material.icons.filled.Search
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.pwhs.quickmem.presentation.app.home.component.home.SearchTextField

@Composable
fun HomeHeader(
Onclick: () -> Unit
) {
Box(
modifier = Modifier
.background(
Color(0xFF5E8DF5),
shape = RoundedCornerShape(bottomStart = 32.dp, bottomEnd = 32.dp)
)
.padding(16.dp)
) {
Column(
verticalArrangement = Arrangement.spacedBy(16.dp)
) {
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween
) {
Text(
text = "QuickMem",
color = Color.White,
fontWeight = FontWeight.Bold,
fontSize = 32.sp
)

Row(
verticalAlignment = Alignment.CenterVertically
) {
Button(
onClick = Onclick,
modifier = Modifier.padding(end = 8.dp),
shape = RoundedCornerShape(8.dp),
colors = ButtonDefaults.buttonColors(containerColor = Color(0xFFCBB237))
) {
Text("Free trial")
}

IconButton(
onClick = {

}
) {
Icon(
imageVector = Icons.Default.Notifications,
contentDescription = "Notifications",
tint = Color.White
)
}
}
}
SearchTextField()
}
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,59 @@
package com.pwhs.quickmem.presentation.app.home

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.compose.foundation.rememberScrollState
import com.pwhs.quickmem.presentation.app.home.component.achiverment.AchievementsSection
import com.pwhs.quickmem.presentation.app.home.component.categories.CategoriesSection
import com.pwhs.quickmem.presentation.app.home.component.classes.ClassesSection
import com.pwhs.quickmem.presentation.app.home.component.folder.FoldersSections
import com.pwhs.quickmem.presentation.app.home.component.sets.SetsSections
import com.pwhs.quickmem.presentation.homescreen.components.HomeHeader
import com.ramcosta.composedestinations.annotation.Destination
import com.ramcosta.composedestinations.annotation.RootGraph
import com.ramcosta.composedestinations.generated.destinations.SearchScreenDestination
import com.ramcosta.composedestinations.navigation.DestinationsNavigator

@Composable
@Destination<RootGraph>
fun HomeScreen(modifier: Modifier = Modifier) {
fun HomeScreen(
modifier: Modifier = Modifier,
navigator: DestinationsNavigator,
viewModel: HomeViewModel = hiltViewModel()
) {
Scaffold { innerPadding ->
Column(
modifier = modifier.padding(innerPadding),
modifier = Modifier
.fillMaxSize()
.background(Color.White)
.verticalScroll(rememberScrollState())
.padding(innerPadding),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(16.dp)
) {
Text("Home Screen")
HomeHeader(
Onclick = {
navigator.navigate(SearchScreenDestination)
}
)
SetsSections()
FoldersSections()
ClassesSection()
AchievementsSection()
CategoriesSection()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.pwhs.quickmem.presentation.app.home

import androidx.lifecycle.ViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class HomeViewModel @Inject constructor(

) : ViewModel() {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package com.pwhs.quickmem.presentation.app.home.component

import androidx.annotation.DrawableRes
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
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
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.MaterialTheme.typography
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.pwhs.quickmem.R

@Composable
fun StartForBegin() {
Column(
modifier = Modifier
.fillMaxSize()
.padding(16.dp),
) {
Text(
text = "Start for begin",
style = typography.titleMedium.copy(
fontWeight = FontWeight.Bold,
fontSize = 20.sp
),
modifier = Modifier.padding(bottom = 24.dp),
textAlign = TextAlign.Start
)

ActionButton(
title = "Create a flashcard for yourself",
iconResId = R.drawable.onboarding1,
onClick = { }
)

Spacer(modifier = Modifier.height(16.dp))

ActionButton(
title = "Find a topic, class",
iconResId = R.drawable.ic_launcher_foreground,
onClick = { }
)
}
}

@Composable
fun ActionButton(
title: String,
@DrawableRes iconResId: Int,
onClick: () -> Unit
) {
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.fillMaxWidth()
.height(60.dp)
.clip(RoundedCornerShape(8.dp))
.background(Color(0xFFF0F0F0))
.clickable(onClick = onClick)
.padding(horizontal = 16.dp)
) {
Image(
painter = painterResource(id = iconResId),
contentDescription = null,
contentScale = ContentScale.Fit,
modifier = Modifier.size(40.dp)
)
Spacer(modifier = Modifier.width(16.dp))
Text(
text = title,
style = typography.bodyMedium.copy(
fontWeight = FontWeight.Medium,
fontSize = 16.sp
)
)
}
}
Loading