Skip to content

Commit

Permalink
Merge pull request #330 from boostcampwm2023/AOS-feat/structural-main…
Browse files Browse the repository at this point in the history
…tenance

�노드를 이동시킬 때 구조 유지
  • Loading branch information
jaehan4707 authored Apr 6, 2024
2 parents 7a2969a + a1b3e37 commit f8ff8cc
Show file tree
Hide file tree
Showing 18 changed files with 328 additions and 278 deletions.
27 changes: 1 addition & 26 deletions AOS/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import java.io.FileInputStream
import java.util.Properties

plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
Expand All @@ -10,16 +7,11 @@ plugins {
id("kotlinx-serialization")
id("com.google.gms.google-services")
}
val keystorePropertiesFile = rootProject.file("keystore.properties")
val keystoreProperties = Properties()
keystoreProperties.load(FileInputStream(keystorePropertiesFile))

android {
namespace = "boostcamp.and07.mindsync"
compileSdk = 34

val properties = Properties()
properties.load(project.rootProject.file("local.properties").inputStream())
val url = properties["BASE_URL"] ?: ""
val googleServerClientId = properties["GOOGLE_SERVER_CLIENT_ID"] ?: ""
val kakaoClientId = properties["KAKAO_CLIENT_ID"] ?: ""
Expand All @@ -39,24 +31,7 @@ android {
buildConfigField("String", "KAKAO_CLIENT_ID", "$kakaoClientId")
manifestPlaceholders["KAKAO_CLIENT_ID"] = removeQuotationKakaoClientId
}
signingConfigs {
create("release") {
keyAlias = keystoreProperties["keyAlias"] as String
keyPassword = keystoreProperties["keyPassword"] as String
storeFile = file(keystoreProperties["storeFile"] as String)
storePassword = keystoreProperties["storePassword"] as String
}
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
)
signingConfig = signingConfigs.getByName("release")
}
}

buildFeatures {
viewBinding = true
dataBinding = true
Expand Down
25 changes: 22 additions & 3 deletions AOS/app/src/main/java/boostcamp/and07/mindsync/data/model/Node.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,39 @@ sealed class Node(
open val path: NodePath,
open val description: String,
open val children: List<String>,
) : java.io.Serializable
) : java.io.Serializable {
abstract fun adjustPosition(
horizontalSpacing: Dp,
totalHeight: Dp,
): Node
}

data class CircleNode(
override val id: String,
override val parentId: String?,
override val path: CirclePath = CirclePath(Dp(0f), Dp(0f), Dp(0f)),
override val description: String,
override val children: List<String>,
) : Node(id, parentId, path, description, children)
) : Node(id, parentId, path, description, children) {
override fun adjustPosition(
horizontalSpacing: Dp,
totalHeight: Dp,
): Node {
return this.copy(path = path.adjustPath(horizontalSpacing, totalHeight))
}
}

data class RectangleNode(
override val id: String,
override val parentId: String,
override val path: RectanglePath = RectanglePath(Dp(0f), Dp(0f), Dp(0f), Dp(0f)),
override val description: String,
override val children: List<String>,
) : Node(id, parentId, path, description, children)
) : Node(id, parentId, path, description, children) {
override fun adjustPosition(
horizontalSpacing: Dp,
totalHeight: Dp,
): Node {
return this.copy(path = path.adjustPath(horizontalSpacing, totalHeight))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,19 @@ import boostcamp.and07.mindsync.ui.util.Dp
import kotlinx.serialization.Serializable

@Serializable
sealed class NodePath(open val centerX: Dp, open val centerY: Dp)
sealed class NodePath(open val centerX: Dp, open val centerY: Dp) {
abstract fun adjustPath(
horizontalSpacing: Dp,
totalHeight: Dp,
): NodePath

protected fun calculateNewCenterY(
horizontalSpacing: Dp,
totalHeight: Dp,
): Dp {
return centerY + totalHeight / 2 + horizontalSpacing
}
}

data class RectanglePath(
override val centerX: Dp,
Expand All @@ -19,10 +31,24 @@ data class RectanglePath(
fun rightX() = centerX + (width / (Dp(2f)))

fun bottomY() = centerY + (height / (Dp(2f)))

override fun adjustPath(
horizontalSpacing: Dp,
totalHeight: Dp,
): RectanglePath {
return this.copy(centerY = calculateNewCenterY(horizontalSpacing, totalHeight))
}
}

data class CirclePath(
override val centerX: Dp,
override val centerY: Dp,
val radius: Dp,
) : NodePath(centerX, centerY)
) : NodePath(centerX, centerY) {
override fun adjustPath(
horizontalSpacing: Dp,
totalHeight: Dp,
): CirclePath {
return this.copy(centerY = calculateNewCenterY(horizontalSpacing, totalHeight))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import androidx.activity.compose.setContent
import androidx.compose.runtime.Composable

abstract class BaseComposeActivity : ComponentActivity() {

@Composable
abstract fun Content()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ fun MSButton(
modifier = modifier,
onClick = onClick,
shape = shape,
colors = ButtonDefaults.buttonColors(
containerColor = backgroundColor,
disabledContainerColor = disableColor,
),
colors =
ButtonDefaults.buttonColors(
containerColor = backgroundColor,
disabledContainerColor = disableColor,
),
enabled = isEnabled,
) {
Text(
Expand All @@ -45,8 +46,9 @@ fun MSButton(

@Preview
@Composable
fun ButtonPreview() = MSPreview {
MSButton(
onClick = { },
)
}
fun ButtonPreview() =
MSPreview {
MSButton(
onClick = { },
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ fun RefreshFloatingButton(
contentDescription = null,
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,4 @@ fun RestoreIconButton(
tint = iconColor,
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import androidx.compose.runtime.Composable
import boostcamp.and07.mindsync.ui.theme.MindSyncTheme

@Composable
fun MSPreview(isDarkTheme: Boolean = false, content: @Composable () -> Unit) {
fun MSPreview(
isDarkTheme: Boolean = false,
content: @Composable () -> Unit,
) {
MindSyncTheme(darkTheme = isDarkTheme, content = content)
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,19 @@ fun NickNameDialog(
) {
val screenWidth = LocalConfiguration.current.screenWidthDp.dp
val dialogWidth = screenWidth * 0.8f
var textFieldValue = remember {
mutableStateOf(
TextFieldValue(
text = uiState.nickname,
selection = TextRange(uiState.nickname.length),
),
)
}
val focusRequester = remember {
FocusRequester()
}
var textFieldValue =
remember {
mutableStateOf(
TextFieldValue(
text = uiState.nickname,
selection = TextRange(uiState.nickname.length),
),
)
}
val focusRequester =
remember {
FocusRequester()
}

LaunchedEffect(Unit) {
focusRequester.requestFocus()
Expand All @@ -67,10 +69,11 @@ fun NickNameDialog(
},
) {
Column(
modifier = Modifier
.background(Color.White, RoundedCornerShape(20.dp))
.width(dialogWidth)
.padding(start = 10.dp, top = 20.dp, end = 10.dp),
modifier =
Modifier
.background(Color.White, RoundedCornerShape(20.dp))
.width(dialogWidth)
.padding(start = 10.dp, top = 20.dp, end = 10.dp),
) {
Text(
text = stringResource(id = R.string.profile_nickname_modify),
Expand All @@ -80,10 +83,14 @@ fun NickNameDialog(

OutlinedTextField(
value = textFieldValue.value,
onValueChange = { textFieldValue.value = it; editNickname(it.text) },
modifier = Modifier
.padding(5.dp)
.focusRequester(focusRequester),
onValueChange = {
textFieldValue.value = it
editNickname(it.text)
},
modifier =
Modifier
.padding(5.dp)
.focusRequester(focusRequester),
placeholder = {
Text(text = stringResource(id = R.string.profile_name_limit))
},
Expand All @@ -109,12 +116,16 @@ fun NickNameDialog(
}

TextButton(
onClick = { updateNickname(uiState.editingNickname); closeDialog() },
modifier = Modifier,
enabled = when (uiState.editingNickname.length) {
in 1..20 -> true
else -> false
onClick = {
updateNickname(uiState.editingNickname)
closeDialog()
},
modifier = Modifier,
enabled =
when (uiState.editingNickname.length) {
in 1..20 -> true
else -> false
},
) {
Text(
text = stringResource(id = R.string.profile_modify),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import android.os.Bundle
import android.view.View
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.navigation.navGraphViewModels
import boostcamp.and07.mindsync.R
import boostcamp.and07.mindsync.data.repository.login.LogoutEventRepository
Expand All @@ -33,11 +32,15 @@ class ProfileFragment : BaseComposeFragment() {

private lateinit var imagePickerHandler: ImagePickerHandler

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
override fun onViewCreated(
view: View,
savedInstanceState: Bundle?,
) {
super.onViewCreated(view, savedInstanceState)
imagePickerHandler = ImagePickerHandler(requireActivity()) { uri ->
createImage(uri)
}
imagePickerHandler =
ImagePickerHandler(requireActivity()) { uri ->
createImage(uri)
}
}

@Composable
Expand Down
Loading

0 comments on commit f8ff8cc

Please sign in to comment.