Skip to content

Commit

Permalink
Merge pull request #27 from everymeals/feature/select_screen
Browse files Browse the repository at this point in the history
[feature/select_screen] 학교 선택화면 뷰 구현
  • Loading branch information
SsongSik authored Jul 25, 2023
2 parents 12ca0b8 + d974832 commit bd84b1a
Show file tree
Hide file tree
Showing 17 changed files with 349 additions and 17 deletions.
8 changes: 6 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
tools:targetApi="31">
<activity
android:name="com.everymeal.presentation.MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.EveryMeal_Android">

</activity>
<activity
android:name="com.everymeal.presentation.splash.SplashActivity"
android:name="com.everymeal.presentation.ui.splash.SplashActivity"
android:exported="true"
android:theme="@style/Theme.EveryMeal_Android">
<intent-filter>
Expand All @@ -33,6 +32,11 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.everymeal.presentation.ui.signup.UnivSelectActivity"
android:theme="@style/Theme.EveryMeal_Android">

</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package com.everymeal.presentation

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.everymeal.domain.usecase.GetWeekFoodUseCase
import com.everymeal.domain.model.Result
import com.everymeal.domain.usecase.GetWeekFoodUseCase
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.everymeal.presentation

import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
Expand Down Expand Up @@ -29,6 +31,13 @@ class MainActivity : ComponentActivity() {
}
}
}

companion object {
fun startActivity(context: Context) {
val intent = Intent(context, MainActivity::class.java)
context.startActivity(intent)
}
}
}

@Composable
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.everymeal.presentation.components

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
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.res.stringResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.everymeal.presentation.R
import com.everymeal.presentation.ui.theme.Gray200
import com.everymeal.presentation.ui.theme.Main100

@Composable
fun EveryMealMainButton(
text: String,
enabled: Boolean = true,
onClick: () -> Unit,
) {
Button(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 16.dp),
shape = RoundedCornerShape(12.dp),
colors = ButtonDefaults.buttonColors(containerColor = if(enabled) Main100 else Gray200),
enabled = enabled,
onClick = onClick,
) {
Text(
text = text,
style = TextStyle(
color = Color.White,
fontWeight = FontWeight.Medium,
),
fontSize = 16.sp,
modifier = Modifier.padding(vertical = 8.dp)
)
}
}

@Preview
@Composable
fun PreviewDisableButton() {
EveryMealMainButton(
text = stringResource(R.string.select),
) { }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.everymeal.presentation.ui.signup

import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import com.everymeal.presentation.MainActivity
import com.everymeal.presentation.ui.theme.EveryMeal_AndroidTheme
import dagger.hilt.android.AndroidEntryPoint


@AndroidEntryPoint
class UnivSelectActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

setUnivSelectScreen()
}

private fun setUnivSelectScreen() {
setContent {
EveryMeal_AndroidTheme {
UnivSelectScreen{
MainActivity.startActivity(this)
finish()
}
}
}
}

companion object {
fun startActivity(context: Context) {
val intent = Intent(context, UnivSelectActivity::class.java)
context.startActivity(intent)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
package com.everymeal.presentation.ui.signup

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
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.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Icon
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.vector.ImageVector
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.everymeal.presentation.R
import com.everymeal.presentation.components.EveryMealMainButton
import com.everymeal.presentation.ui.theme.EveryMeal_AndroidTheme
import com.everymeal.presentation.ui.theme.Gray100
import com.everymeal.presentation.ui.theme.Gray300
import com.everymeal.presentation.ui.theme.Gray500
import com.everymeal.presentation.ui.theme.Gray800

data class Item(
val Image: Int,
val name: String,
)

@Composable
fun UnivSelectScreen(
onSelectClick : () -> Unit
) {
val items = listOf(
Item(Image = R.drawable.image_myongji, name = "명지대"),
Item(Image = R.drawable.image_sungsin, name = "성신여대"),
Item(Image = R.drawable.image_seoulwoman, name = "서울여대"),
Item(Image = R.drawable.image_konkuk, name = "건국대"),
)

Box(
modifier = Modifier
.fillMaxSize()
.background(Color.White)
) {
Column(
modifier = Modifier
.fillMaxSize()
.padding(horizontal = 24.dp)
) {
Spacer(modifier = Modifier.padding(58.dp))
Text(
text = stringResource(R.string.univ_select_title),
style = TextStyle(
fontSize = 24.sp,
fontWeight = FontWeight.Bold
),
)
Spacer(modifier = Modifier.padding(10.dp))
LazyVerticalGrid(
columns = GridCells.Fixed(3),
modifier = Modifier.weight(1f),
) {
items(items.size) { index ->
UnivSelectItem(item = items[index])
}
}
Row(
modifier = Modifier
.fillMaxWidth()
.background(Gray300, RoundedCornerShape(100.dp))
.padding(horizontal = 24.dp, vertical = 14.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Icon(
imageVector = ImageVector.vectorResource(id = R.drawable.icon_chat),
contentDescription = stringResource(id = R.string.icon_chat_description),
tint = Gray500
)
Spacer(modifier = Modifier.padding(14.dp))
Column {
Text(
text = stringResource(id = R.string.univ_select_not_univ),
fontSize = 15.sp,
color = Gray800
)
Text(
text = stringResource(id = R.string.univ_select_apply),
fontSize = 14.sp,
color = Gray500
)
}
Spacer(modifier = Modifier.weight(1f))
Icon(
imageVector = ImageVector.vectorResource(id = R.drawable.icon_arrow_right),
contentDescription = stringResource(id = R.string.icon_arrow_right),
tint = Gray500
)
}
EveryMealMainButton(
text = stringResource(R.string.select),
enabled = false,
) {
onSelectClick()
}
}
}
}

@Composable
fun UnivSelectItem(item: Item) {
Column(
modifier = Modifier
.padding(8.dp)
.clip(RoundedCornerShape(8.dp))
.background(Gray100)
.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
Spacer(modifier = Modifier.padding(bottom = 10.dp))
Image(
painter = painterResource(item.Image),
contentDescription = item.name,
Modifier.size(36.dp)
)
Text(
text = item.name,
fontSize = 14.sp,
modifier = Modifier.padding(10.dp)
)
}
}

@Preview(showBackground = true)
@Composable
fun UnivSelectScreenPreview() {
EveryMeal_AndroidTheme {
UnivSelectScreen{ }
}
}

@Preview(showBackground = true)
@Composable
fun UnivSelectScreenItemPreview() {
EveryMeal_AndroidTheme {
UnivSelectItem(item = Item(
Image = R.drawable.image_myongji,
name = "명지대학교"
))
}
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
package com.everymeal.presentation.splash
package com.everymeal.presentation.ui.splash

import android.annotation.SuppressLint
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.ui.Modifier
import com.everymeal.presentation.ui.theme.EveryMeal_AndroidTheme
import com.everymeal.presentation.ui.signup.UnivSelectActivity
import dagger.hilt.android.AndroidEntryPoint

@SuppressLint("CustomSplashScreen")
@AndroidEntryPoint
class SplashActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

setSplashScreen()
}

private fun setSplashScreen() {
setContent {
EveryMeal_AndroidTheme {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
SplashScreen()
}
SplashScreen(onFinishSplash = {
UnivSelectActivity.startActivity(this)
finish()
})
}
}
}
Expand Down
Loading

0 comments on commit bd84b1a

Please sign in to comment.