Skip to content

Commit

Permalink
Merge pull request #32 from Lite-Weight/feat/fix_ui
Browse files Browse the repository at this point in the history
히스토리, 내 정보, 직접 입력 UI 변경
  • Loading branch information
yonghanJu authored Nov 4, 2023
2 parents 3818a53 + 1cf63ce commit 412f1dc
Show file tree
Hide file tree
Showing 52 changed files with 1,634 additions and 167 deletions.
5 changes: 3 additions & 2 deletions app/src/main/res/menu/nav_items.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
android:id="@id/personal_nav_graph"
android:icon="@drawable/baseline_person_outline_24"
android:title="@string/personal_nav_title"
app:showAsAction="ifRoom"/>
app:showAsAction="ifRoom" />

<item
android:id="@+id/placeholder"
android:enabled="false"
android:title="" />

<item
android:id="@id/history_nav_graph"
android:icon="@drawable/baseline_favorite_border_24"
android:title="@string/history_nav_title"
app:showAsAction="ifRoom"/>
app:showAsAction="ifRoom" />
</menu>
6 changes: 6 additions & 0 deletions buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ object Versions {
const val RETROFIT = "2.9.0"
const val OKHTTP = "4.10.0"
const val SERIALIZATION_CONVERTER = "0.8.0"

// DataStore
const val DATASTORE = "1.0.0"
}

object Kotlin {
Expand Down Expand Up @@ -72,6 +75,9 @@ object AndroidX {

// Pagging
const val PAGING3 = "androidx.paging:paging-runtime:${Versions.PAGING3}"

// DataStore
const val DATASTORE = "androidx.datastore:datastore-preferences:${Versions.DATASTORE}"
}

object Material {
Expand Down
3 changes: 3 additions & 0 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,7 @@ dependencies {
// DI
implementation(DI.HILT)
kapt(DI.HILT_COMPLIER)

// DataStore
implementation(AndroidX.DATASTORE)
}
61 changes: 61 additions & 0 deletions common/src/main/java/com/konkuk/common/data/UserRepository.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.konkuk.common.data

import android.content.Context
import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.core.booleanPreferencesKey
import androidx.datastore.preferences.core.edit
import androidx.datastore.preferences.core.intPreferencesKey
import androidx.datastore.preferences.core.stringPreferencesKey
import androidx.datastore.preferences.preferencesDataStore
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map

class UserRepository(private val context: Context) {

private val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name = DATASTORE_NAME)

private val nameKey = stringPreferencesKey(NAME_KEY)
private val ageKey = intPreferencesKey(AGE_KEY)
private val genderKey = booleanPreferencesKey(GENDER_KEY)

val nameFlow: Flow<String?> = context.dataStore.data
.map { preferences ->
preferences[nameKey]
}

suspend fun setName(name: String) {
context.dataStore.edit { settings ->
settings[nameKey] = name
}
}

val ageFlow: Flow<Int?> = context.dataStore.data
.map { preferences ->
preferences[ageKey]
}

suspend fun setAge(age: Int) {
context.dataStore.edit { settings ->
settings[ageKey] = age
}
}

val genderFlow: Flow<Boolean?> = context.dataStore.data
.map { preferences ->
preferences[genderKey]
}

suspend fun setGender(gender: Boolean) {
context.dataStore.edit { settings ->
settings[genderKey] = gender
}
}

companion object {
const val DATASTORE_NAME = "settings"
const val NAME_KEY = "nameKey"
const val AGE_KEY = "ageKey"
const val GENDER_KEY = "genderKey"
}
}
7 changes: 7 additions & 0 deletions common/src/main/java/com/konkuk/common/di/DatabaseModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import androidx.room.Room
import com.konkuk.common.data.AppDatabase
import com.konkuk.common.data.FoodInfoDao
import com.konkuk.common.data.UserRepository
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
Expand All @@ -29,4 +30,10 @@ class DatabaseModule {
fun provideFoodInfoDao(db: AppDatabase): FoodInfoDao {
return db.foodInfoDao()
}

@Provides
@Singleton
fun provideUserRepository(@ApplicationContext context: Context): UserRepository {
return UserRepository(context)
}
}
5 changes: 5 additions & 0 deletions common/src/main/res/color/button_color_selector.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/main_blue" android:state_enabled="true" />
<item android:color="@android:color/darker_gray" android:state_enabled="false" />
</selector>
5 changes: 5 additions & 0 deletions common/src/main/res/drawable/baseline_female_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
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="M17.5,9.5C17.5,6.46 15.04,4 12,4S6.5,6.46 6.5,9.5c0,2.7 1.94,4.93 4.5,5.4V17H9v2h2v2h2v-2h2v-2h-2v-2.1C15.56,14.43 17.5,12.2 17.5,9.5zM8.5,9.5C8.5,7.57 10.07,6 12,6s3.5,1.57 3.5,3.5S13.93,13 12,13S8.5,11.43 8.5,9.5z"/>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:autoMirrored="true" android:height="24dp"
android:tint="#FFFFFF" 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="M8.59,16.59L13.17,12 8.59,7.41 10,6l6,6 -6,6 -1.41,-1.41z"/>
</vector>
5 changes: 5 additions & 0 deletions common/src/main/res/drawable/baseline_male_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
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="M9.5,11c1.93,0 3.5,1.57 3.5,3.5S11.43,18 9.5,18S6,16.43 6,14.5S7.57,11 9.5,11zM9.5,9C6.46,9 4,11.46 4,14.5S6.46,20 9.5,20s5.5,-2.46 5.5,-5.5c0,-1.16 -0.36,-2.23 -0.97,-3.12L18,7.42V10h2V4h-6v2h2.58l-3.97,3.97C11.73,9.36 10.66,9 9.5,9z"/>
</vector>
14 changes: 14 additions & 0 deletions common/src/main/res/drawable/btn_customfull.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">


<size
android:width="441dp"
android:height="48dp" />



<corners android:radius="14dp" />

</shape>
9 changes: 9 additions & 0 deletions common/src/main/res/drawable/camera_pressed.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

<solid android:color="@color/back_white" />
<stroke
android:width="1dp"
android:color="@color/stroke_deepblue" />
<corners android:radius="20dp" />
</shape>
7 changes: 7 additions & 0 deletions common/src/main/res/drawable/camera_unpressed.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

<solid android:color="@color/back_white" />

<corners android:radius="20dp" />
</shape>
9 changes: 9 additions & 0 deletions common/src/main/res/drawable/female_pressed.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

<solid android:color="@color/back_white" />
<stroke
android:width="1dp"
android:color="@color/stroke_yello" />
<corners android:radius="20dp" />
</shape>
165 changes: 165 additions & 0 deletions common/src/main/res/drawable/fragment_bottom_sheet_enroll.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bottom_sheet_backgournd"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingHorizontal="55dp">

<ImageView
android:layout_width="40dp"
android:layout_height="5dp"
android:layout_marginTop="10dp"
android:src="@drawable/rectanglesmall4x" />

<TextView
android:id="@+id/bottomSheetTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="40dp"
android:text="등록 방법을 선택해 주세요"
android:textColor="@android:color/black"
android:textSize="21sp"
android:textStyle="bold" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:gravity="center"
android:text="영양성분표를 카메라로 촬영하거나\n
직접 입력해주세요"
android:textColor="#4A545E"
android:textSize="13sp" />

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="168sp"
android:layout_marginTop="29dp"
android:background="@drawable/rectangle_roundfull"
android:backgroundTint="@color/light_blue">

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="32dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/right"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/selectorCamera"
android:layout_width="72dp"
android:layout_height="72dp"
android:background="@drawable/selector_camera"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<ImageView
android:layout_width="24sp"
android:layout_height="24sp"
android:src="@drawable/camera3x"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center"
android:text="카메라"
android:textColor="#4A545E"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/selectorCamera" />


</androidx.constraintlayout.widget.ConstraintLayout>


<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/left"
app:layout_constraintTop_toTopOf="parent">

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/selectorPen"
android:layout_width="72dp"
android:layout_height="72dp"
android:background="@drawable/selector_pen"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<ImageView
android:layout_width="24sp"
android:layout_height="24sp"
android:src="@drawable/ic_search"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center"
android:text="검색 하기"
android:textColor="#4A545E"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/selectorPen" />


</androidx.constraintlayout.widget.ConstraintLayout>


</androidx.constraintlayout.widget.ConstraintLayout>


<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btnContinue"
android:layout_width="match_parent"
android:layout_height="58sp"
android:layout_marginTop="29dp"
android:background="@drawable/btn_customfull"
android:backgroundTint="@color/main_blue"
android:clickable="true"
android:focusable="true"
android:foreground="?attr/selectableItemBackground"
android:text="Continue"
android:textAlignment="center"
android:textAllCaps="false"
android:textColor="@color/white"
android:textSize="14sp" />

<View
android:layout_width="match_parent"
android:layout_height="37dp" />


</LinearLayout>
</layout>
5 changes: 5 additions & 0 deletions common/src/main/res/drawable/outline_calendar_month_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
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="M19,4h-1V2h-2v2H8V2H6v2H5C3.89,4 3.01,4.9 3.01,6L3,20c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2V6C21,4.9 20.1,4 19,4zM19,20H5V10h14V20zM19,8H5V6h14V8zM9,14H7v-2h2V14zM13,14h-2v-2h2V14zM17,14h-2v-2h2V14zM9,18H7v-2h2V18zM13,18h-2v-2h2V18zM17,18h-2v-2h2V18z"/>
</vector>
14 changes: 14 additions & 0 deletions common/src/main/res/drawable/rectangle_roundfull.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">


<size
android:width="441dp"
android:height="48dp" />



<corners android:radius="24dp" />

</shape>
Binary file added common/src/main/res/drawable/rectanglesmall4x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions common/src/main/res/drawable/selector_female.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item android:state_selected="true" android:drawable="@drawable/female_pressed"/>
<item android:state_selected="false" android:drawable="@drawable/camera_unpressed"/>
</selector>
Loading

0 comments on commit 412f1dc

Please sign in to comment.