-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #207 from hellokitty-coding-club/ui/suggestion-detail
[UI] 미션 제안 상세 화면 UI 작업(compose 활용) (#206)
- Loading branch information
Showing
28 changed files
with
782 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
common-ui/src/main/java/com/lgtm/android/common_ui/base/BaseComposeActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.lgtm.android.common_ui.base | ||
|
||
import android.os.Bundle | ||
import android.widget.Toast | ||
import androidx.activity.ComponentActivity | ||
import androidx.activity.compose.setContent | ||
import androidx.compose.runtime.Composable | ||
import com.lgtm.android.common_ui.navigator.LgtmInjector | ||
import com.lgtm.android.common_ui.navigator.LgtmNavigator | ||
import dagger.hilt.android.EntryPointAccessors | ||
|
||
abstract class BaseComposeActivity: ComponentActivity() { | ||
var viewModel: BaseViewModel? = null | ||
|
||
val lgtmNavigator: LgtmNavigator by lazy { | ||
EntryPointAccessors.fromActivity( | ||
this, LgtmInjector.LgtmNavigatorInjector::class.java | ||
).lgtmNavigator() | ||
} | ||
|
||
abstract fun initializeViewModel() | ||
|
||
@Composable | ||
abstract fun content() | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
initializeViewModel() | ||
setContent { | ||
content() | ||
} | ||
} | ||
|
||
fun moveToSignInActivity() { | ||
viewModel?.moveToSignIn?.observe(this) { | ||
lgtmNavigator.navigateToSignIn(this) | ||
finishAffinity() | ||
} | ||
} | ||
|
||
fun makeToast() { | ||
viewModel?.unknownError?.observe(this) { | ||
Toast.makeText(this, it, Toast.LENGTH_SHORT).show() | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
common-ui/src/main/java/com/lgtm/android/common_ui/components/buttons/BackButton.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.lgtm.android.common_ui.components.buttons | ||
|
||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.border | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.res.colorResource | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.unit.dp | ||
import com.lgtm.android.common_ui.R | ||
|
||
@Composable | ||
fun BackButton( | ||
modifier: Modifier = Modifier | ||
) { | ||
Box( | ||
modifier = modifier | ||
.border( | ||
width = 1.dp, | ||
color = colorResource(id = R.color.gray_3), | ||
shape = RoundedCornerShape(10.dp) | ||
) | ||
.background( | ||
color = Color.White, | ||
shape = RoundedCornerShape(10.dp) | ||
) | ||
.padding(7.dp) | ||
) { | ||
Image( | ||
painter = painterResource(id = R.drawable.ic_back), | ||
contentDescription = null | ||
) | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
common-ui/src/main/java/com/lgtm/android/common_ui/components/buttons/LikeButton.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package com.lgtm.android.common_ui.components.buttons | ||
|
||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.border | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.requiredWidth | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material.MaterialTheme | ||
import androidx.compose.material.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.graphics.vector.ImageVector | ||
import androidx.compose.ui.res.colorResource | ||
import androidx.compose.ui.res.vectorResource | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import com.lgtm.android.common_ui.R | ||
import com.lgtm.android.common_ui.theme.body3R | ||
|
||
@Composable | ||
fun LikeButton( | ||
likeNum: String, | ||
isLiked: Boolean, | ||
modifier: Modifier = Modifier | ||
) { | ||
Row( | ||
verticalAlignment = Alignment.CenterVertically, | ||
modifier = modifier | ||
.border( | ||
width = 1.dp, | ||
color = colorResource(id = R.color.gray_2), | ||
shape = RoundedCornerShape(10.dp) | ||
) | ||
.background( | ||
color = Color.White, | ||
shape = RoundedCornerShape(10.dp) | ||
) | ||
.padding( | ||
horizontal = 6.dp, | ||
vertical = 9.dp | ||
) | ||
) { | ||
|
||
Text( | ||
modifier = Modifier | ||
.requiredWidth(30.dp), | ||
text = likeNum, | ||
textAlign = TextAlign.Center, | ||
style = Typography.body3R | ||
) | ||
|
||
Image( | ||
modifier = Modifier.padding(start = 2.dp), | ||
imageVector = ImageVector.vectorResource(id = R.drawable.ic_like_selected), | ||
contentDescription = null | ||
) | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
fun LikeButtonPreview() { | ||
MaterialTheme { | ||
LikeButton( | ||
likeNum = "22", | ||
isLiked = true | ||
) | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
common-ui/src/main/java/com/lgtm/android/common_ui/components/buttons/MenuButton.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.lgtm.android.common_ui.components.buttons | ||
|
||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.border | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.wrapContentSize | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.res.colorResource | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.unit.dp | ||
import com.lgtm.android.common_ui.R | ||
|
||
@Composable | ||
fun MenuButton( | ||
modifier: Modifier = Modifier | ||
) { | ||
Box( | ||
modifier = modifier | ||
.wrapContentSize() | ||
.border( | ||
width = 1.dp, | ||
color = colorResource(id = R.color.gray_3), | ||
shape = RoundedCornerShape(10.dp) | ||
) | ||
.background( | ||
color = Color.White, | ||
shape = RoundedCornerShape(10.dp) | ||
) | ||
.padding(3.dp) | ||
) { | ||
Image( | ||
painter = painterResource(id = R.drawable.ic_menu_black), | ||
contentDescription = null | ||
) | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
common-ui/src/main/java/com/lgtm/android/common_ui/components/texts/DateTimeText.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.lgtm.android.common_ui.components.texts | ||
|
||
import androidx.compose.foundation.layout.IntrinsicSize | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.fillMaxHeight | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.width | ||
import androidx.compose.material.Divider | ||
import androidx.compose.material.MaterialTheme | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.colorResource | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import com.lgtm.android.common_ui.R | ||
import com.lgtm.android.common_ui.theme.description | ||
|
||
@Composable | ||
fun DateTimeText( | ||
date: String, | ||
time: String, | ||
modifier: Modifier = Modifier | ||
) { | ||
Row( | ||
modifier = modifier | ||
.height(IntrinsicSize.Min), | ||
verticalAlignment = Alignment.CenterVertically | ||
) { | ||
Text( | ||
modifier = Modifier.padding(end = 3.dp), | ||
text = date, | ||
style = Typography.description, | ||
color = colorResource(id = R.color.gray_5), | ||
) | ||
|
||
Divider( | ||
color = colorResource(id = R.color.gray_3), | ||
modifier = Modifier | ||
.width(1.dp) | ||
.fillMaxHeight() | ||
.padding( | ||
vertical = 2.dp | ||
) | ||
) | ||
|
||
Text( | ||
modifier = Modifier.padding(start = 3.dp), | ||
text = time, | ||
style = Typography.description, | ||
color = colorResource(id = R.color.gray_5) | ||
) | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
fun DateTimePreview() { | ||
MaterialTheme { | ||
DateTimeText( | ||
date = "2021.09.01", | ||
time = "오후 12:00" | ||
) | ||
} | ||
} |
Oops, something went wrong.