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

[Feature] 공유/좋아요/온보딩 추가 #339

Merged
merged 25 commits into from
Jul 31, 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,46 @@
package `in`.koreatech.koin.core.dialog

import android.app.Dialog
import android.content.Context
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.view.ViewGroup
import `in`.koreatech.koin.core.databinding.AlertModalDialogBinding

class AlertModalDialog(
private val context: Context,
private val data: AlertModalDialogData,
private val onPositiveButtonClicked: () -> Unit,
private val onNegativeButtonClicked: (Dialog) -> Unit
) : Dialog(context) {

private lateinit var binding: AlertModalDialogBinding

override fun onStart() {
super.onStart()
window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = AlertModalDialogBinding.inflate(layoutInflater)
setContentView(binding.root)

binding.apply {
textViewAlertModalTitle.text = context.getString(data.title)
textViewAlertModalMessage.text = context.getString(data.message)
buttonPositive.text = context.getString(data.positiveButtonText)
buttonNegative.text = context.getString(data.negativeButtonText)

buttonPositive.setOnClickListener {
onPositiveButtonClicked()
}

buttonNegative.setOnClickListener {
onNegativeButtonClicked(this@AlertModalDialog)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package `in`.koreatech.koin.core.dialog

import androidx.annotation.StringRes
import `in`.koreatech.koin.core.R

data class AlertModalDialogData(
@StringRes val title: Int,
@StringRes val message: Int,
@StringRes val positiveButtonText: Int,
@StringRes val negativeButtonText: Int = R.string.close,
)
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ class NotificationRow @JvmOverloads constructor(
attributeSet, R.styleable.Notification, 0, 0
).apply {
binding.tvTitle.text = getString(R.styleable.Notification_text)
val pt = getDimensionPixelSize(R.styleable.Notification_paddingTop, 0)
val pb = getDimensionPixelSize(R.styleable.Notification_paddingBottom, 0)
val ps = getDimensionPixelSize(R.styleable.Notification_paddingStart, 0)
val pe = getDimensionPixelSize(R.styleable.Notification_paddingEnd, 0)
[email protected](ps, pt, pe, pb)
recycle()
}

Expand Down
8 changes: 8 additions & 0 deletions core/src/main/res/drawable/bg_rect_white_radius_20dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:topLeftRadius="20dp"
android:topRightRadius="20dp" />
<solid android:color="@color/white" />
</shape>
11 changes: 11 additions & 0 deletions core/src/main/res/drawable/bg_white_radius_18dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dp"
android:shape="rectangle">
<solid android:color="@color/white" />
<corners
android:bottomLeftRadius="18dp"
android:bottomRightRadius="18dp"
android:topLeftRadius="18dp"
android:topRightRadius="18dp" />
</shape>
70 changes: 70 additions & 0 deletions core/src/main/res/layout/alert_modal_dialog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/bg_white_radius_18dp"
android:paddingHorizontal="32dp"
android:paddingVertical="24dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<TextView
android:id="@+id/text_view_alert_modal_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="@string/recommend_login_to_like_dining" />

<TextView
android:id="@+id/text_view_alert_modal_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center"
android:textAlignment="center"
android:textColor="@color/gray18"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="@id/text_view_alert_modal_title"
app:layout_constraintStart_toStartOf="@id/text_view_alert_modal_title"
app:layout_constraintTop_toBottomOf="@id/text_view_alert_modal_title"
tools:text="@string/recommend_like_dining" />

<Button
android:id="@+id/button_negative"
style="?attr/materialButtonOutlinedStyle"
android:layout_width="0dp"
android:layout_height="60dp"
android:layout_marginTop="24dp"
android:text="@string/close"
android:textColor="@color/black"
app:layout_constraintEnd_toStartOf="@+id/button_positive"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/text_view_alert_modal_message" />

<Button
android:id="@+id/button_positive"
android:layout_width="0dp"
android:layout_height="60dp"
android:layout_marginStart="8dp"
app:layout_constraintBottom_toBottomOf="@id/button_negative"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/button_negative"
app:layout_constraintTop_toTopOf="@id/button_negative"
tools:text="@string/action_login" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
4 changes: 1 addition & 3 deletions core/src/main/res/layout/notification_row.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="24dp"
android:paddingVertical="16dp">
android:layout_height="wrap_content">

<TextView
android:id="@+id/tv_title"
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,9 @@
<declare-styleable name="Notification">
<attr name="text" format="reference|string"/>
<attr name="description" format="reference|string"/>
<attr name="paddingTop" format="dimension"/>
<attr name="paddingBottom" format="dimension"/>
<attr name="paddingStart" format="dimension"/>
<attr name="paddingEnd" format="dimension"/>
</declare-styleable>
</resources>
1 change: 1 addition & 0 deletions core/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<color name="gray15">#cacaca</color>
<color name="gray16">#e1e1e1</color>
<color name="gray17">#eeeeee</color>
<color name="gray18">#8e8e8e</color>


<color name="black_alpha12">#1f252525</color>
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,7 @@
<string name="close">닫기</string>
<string name="back">뒤로가기</string>
<string name="my_shop">내 상점</string>
<string name="recommend_login_to_like_dining">더 맛있는 학식을 먹는 방법,\n로그인하고 좋아요를 남겨주세요!</string>
<string name="recommend_like_dining">여러분의 좋아요가 영양사님이 더 나은\n식단을 제공할 수 있도록 도와줍니다.</string>
<string name="action_login">로그인하기</string>
</resources>
8 changes: 8 additions & 0 deletions core/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,12 @@
<item name="cornerSizeBottomLeft">@dimen/toolbar_main_corner_raduis</item>
<item name="cornerSizeBottomRight">@dimen/toolbar_main_corner_raduis</item>
</style>

<style name="CustomBottomSheetDialog" parent="Theme.MaterialComponents.Light.BottomSheetDialog">
<item name="bottomSheetStyle">@style/CustomBottomSheet</item>
</style>

<style name="CustomBottomSheet" parent="Widget.Design.BottomSheet.Modal">
<item name="android:background">@drawable/bg_rect_white_radius_20dp</item>
</style>
</resources>
1 change: 1 addition & 0 deletions data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@ dependencies {
implementation(libs.okhttp.logging.interceptor)

implementation(libs.androidx.security.crypto)
implementation(libs.dataStore)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ import retrofit2.http.GET
import retrofit2.http.Query

interface DiningApi {
@GET(URLConstant.DINING)
@GET(URLConstant.DINING.DININGS)
suspend fun getDining(@Query("date") date: String): List<DiningResponse>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package `in`.koreatech.koin.data.api.auth

import `in`.koreatech.koin.data.constant.URLConstant
import `in`.koreatech.koin.data.response.DiningResponse
import retrofit2.http.GET
import retrofit2.http.PATCH
import retrofit2.http.Query

interface DiningAuthApi {
@PATCH(URLConstant.DINING.LIKE)
suspend fun likeDining(@Query("diningId") id: Int)

@PATCH(URLConstant.DINING.UNLIKE)
suspend fun unlikeDining(@Query("diningId") id: Int)

@GET(URLConstant.DINING.DININGS)
suspend fun getDining(@Query("date") date: String): List<DiningResponse>
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ object URLConstant {

const val ADMIN = "admin/"
const val VERSION = "versions"
const val DINING = "dinings"
const val FAQ = "faqs"
const val LECTURE = "lectures"
const val TIMETABLE = "timetable"
Expand All @@ -23,6 +22,13 @@ object URLConstant {
const val LAND = "lands"
const val TERM = "term"

object DINING {
const val DINING = "dining"
const val DININGS = "dinings"
const val LIKE = "${DINING}/like"
const val UNLIKE = "${LIKE}/cancel"
}

object SHOPS{
const val OWNERSHOPS= "owner/shops"
const val SHOPS = "shops"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,12 @@ object RepositoryModule {
): OwnerShopRepository {
return OwnerShopRepositoryImpl(ownerRemoteDataSource)
}

@Provides
@Singleton
fun provideOnBoardingRepository(
onBoardingLocalDataSource: OnBoardingLocalDataSource
): OnBoardingRepository {
return OnBoardingRepositoryImpl(onBoardingLocalDataSource)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import `in`.koreatech.koin.data.api.*
import `in`.koreatech.koin.data.api.auth.DiningAuthApi
import `in`.koreatech.koin.data.api.auth.OwnerAuthApi
import `in`.koreatech.koin.data.api.auth.UserAuthApi
import `in`.koreatech.koin.data.source.remote.*
Expand Down Expand Up @@ -67,8 +68,9 @@ object RemoteDataSourceModule {
@Singleton
fun provideDiningRemoteDataSource(
diningApi: DiningApi,
diningAuthApi: DiningAuthApi
): DiningRemoteDataSource {
return DiningRemoteDataSource(diningApi)
return DiningRemoteDataSource(diningApi, diningAuthApi)
}

@Provides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ fun DiningResponse.toDining() = Dining(
this.updatedAt,
this.soldoutAt ?: "",
this.changedAt ?: "",
this.error ?: ""
this.likes ?: 0,
this.isLiked ?: false
)

fun List<String>.toLineChangingString(): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ fun SubscribeDetailResponse.toSubscribesDetail() = SubscribesDetail(
fun String.toSubscribesType(): SubscribesType = when (this) {
Subscribes.SHOP_EVENT -> SubscribesType.SHOP_EVENT
Subscribes.DINING_SOLD_OUT -> SubscribesType.DINING_SOLD_OUT
Subscribes.DINING_IMAGE_UPLOAD -> SubscribesType.DINING_IMAGE_UPLOAD
else -> SubscribesType.NOTHING
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package `in`.koreatech.koin.data.repository

import `in`.koreatech.koin.data.mapper.toDining
import `in`.koreatech.koin.data.response.DiningResponse
import `in`.koreatech.koin.data.source.remote.DiningRemoteDataSource
import `in`.koreatech.koin.domain.model.dining.Dining
import `in`.koreatech.koin.domain.repository.DiningRepository
Expand All @@ -10,8 +11,18 @@ class DiningRepositoryImpl @Inject constructor(
private val diningRemoteDataSource: DiningRemoteDataSource
) : DiningRepository {
override suspend fun getDining(date: String): List<Dining> {
return diningRemoteDataSource.getDining(date).map {
it.toDining()
}
return diningRemoteDataSource.getDining(date).map(DiningResponse::toDining)
}

override suspend fun getAuthDining(date: String): List<Dining> {
return diningRemoteDataSource.getAuthDining(date).map(DiningResponse::toDining)
}

override suspend fun likeDining(id: Int) {
diningRemoteDataSource.likeDining(id)
}

override suspend fun unlikeDining(id: Int) {
diningRemoteDataSource.unlikeDining(id)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package `in`.koreatech.koin.data.repository

import `in`.koreatech.koin.data.source.local.OnBoardingLocalDataSource
import `in`.koreatech.koin.domain.repository.OnBoardingRepository
import javax.inject.Inject

class OnBoardingRepositoryImpl @Inject constructor(
private val onBoardingLocalDataSource: OnBoardingLocalDataSource
) : OnBoardingRepository {

override suspend fun updateShouldShowDiningTooltip(shouldShow: Boolean) {
onBoardingLocalDataSource.updateShouldShowDiningTooltip(shouldShow)
}

override suspend fun getShouldShowDiningTooltip(): Result<Boolean> {
return onBoardingLocalDataSource.getShouldShowDiningTooltip()
}

override suspend fun updateShouldShowNotificationOnBoarding(shouldShow: Boolean) {
onBoardingLocalDataSource.updateShouldShowNotificationOnBoarding(shouldShow)
}

override suspend fun getShouldShowNotificationOnBoarding(): Result<Boolean> {
return onBoardingLocalDataSource.getShouldShowNotificationOnBoarding()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ data class DiningResponse(
@SerializedName("updated_at") val updatedAt: String,
@SerializedName("soldout_at") val soldoutAt: String?,
@SerializedName("changed_at") val changedAt: String?,
@SerializedName("error") val error: String?
@SerializedName("likes") val likes: Int?,
@SerializedName("is_liked") val isLiked: Boolean?
)
Loading