Skip to content

Commit

Permalink
Merge pull request #34 from Team-Walkie/compose/mypage
Browse files Browse the repository at this point in the history
마이페이지 이름 수정 불가 및 ui 수정
  • Loading branch information
yonghanJu authored Sep 1, 2023
2 parents f8fb931 + 79d75c5 commit 9524070
Show file tree
Hide file tree
Showing 15 changed files with 125 additions and 99 deletions.
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat"
android:screenOrientation="portrait"
tools:targetApi="31">
<activity
android:name=".MainActivity"
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/whyranoid/walkie/KoinModules.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import com.whyranoid.domain.usecase.running.GetRunningFollowerUseCase
import com.whyranoid.domain.usecase.running.RunningFinishUseCase
import com.whyranoid.domain.usecase.running.RunningPauseOrResumeUseCase
import com.whyranoid.domain.usecase.running.RunningStartUseCase
import com.whyranoid.presentation.screens.mypage.editprofile.EditProfileViewModel
import com.whyranoid.presentation.viewmodel.ChallengeDetailViewModel
import com.whyranoid.presentation.viewmodel.ChallengeExitViewModel
import com.whyranoid.presentation.viewmodel.ChallengeMainViewModel
Expand Down Expand Up @@ -70,6 +71,7 @@ val viewModelModule = module {
factory { SplashViewModel(get()) }
factory { SignInViewModel(get()) }
factory { SelectHistoryViewModel(get()) }
factory { EditProfileViewModel(get()) }
}

val repositoryModule = module {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/whyranoid/walkie/RunningWorker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class RunningWorker(
const val WORKER_NAME = "RunningWorker"
const val NOTIFICATION_ID = 2000
const val CHANNEL_ID = "Walkie Channel"
const val UPDATE_INTERVAL_MS = 2000L
const val UPDATE_INTERVAL_MS = 1000L
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package com.whyranoid.data.datasource.runninghistory

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.whyranoid.data.model.RunningHistoryEntity

@Dao
interface RunningHistoryDao {
@Insert
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(runningHistoryEntity: RunningHistoryEntity)

@Query("SELECT * FROM running_history")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class AccountRepositoryImpl(

override val authId: Flow<String?> = accountDataStore.authId
override val uId: Flow<Long?> = accountDataStore.uId
override val userName: Flow<String?> = accountDataStore.userName
override val nickName: Flow<String?> = accountDataStore.nickName

// TODO API Call
override suspend fun signUp(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ class RunningRepositoryImpl(context: Context) : RunningRepository {
private val fusedLocationClient = LocationServices.getFusedLocationProviderClient(context)
private val locationRequest =
LocationRequest.Builder(Priority.PRIORITY_HIGH_ACCURACY, 1000L).build()
private lateinit var locationCallback: LocationCallback
private var locationCallback: LocationCallback? = null

override val userLocationState: MutableStateFlow<UserLocation> =
MutableStateFlow(UserLocation.NotTracking)

private var isTrackingUserLocation = true

override suspend fun startRunning() {
}

Expand All @@ -40,13 +42,16 @@ class RunningRepositoryImpl(context: Context) : RunningRepository {
}

override fun listenLocation() {
isTrackingUserLocation = true
if (userLocationState.value is UserLocation.Tracking) return
if ((runningDataManager.runningState.value is RunningState.NotRunning).not()) return
locationCallback = object : LocationCallback() {
override fun onLocationResult(locationResult: LocationResult) {
locationResult.lastLocation?.let { location ->
userLocationState.value =
UserLocation.Tracking(location.latitude, location.longitude)
if (isTrackingUserLocation) {
userLocationState.value =
UserLocation.Tracking(location.latitude, location.longitude)
}
} ?: run {
removeListener()
}
Expand All @@ -55,7 +60,7 @@ class RunningRepositoryImpl(context: Context) : RunningRepository {
try {
fusedLocationClient.requestLocationUpdates(
locationRequest,
locationCallback,
requireNotNull(locationCallback),
Looper.getMainLooper(),
)
} catch (e: SecurityException) {
Expand All @@ -66,7 +71,10 @@ class RunningRepositoryImpl(context: Context) : RunningRepository {
}

override fun removeListener() {
fusedLocationClient.removeLocationUpdates(locationCallback)
isTrackingUserLocation = false
userLocationState.value = UserLocation.NotTracking
fusedLocationClient.removeLocationUpdates(requireNotNull(locationCallback))
locationCallback = null
}

override fun removeUserLocation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ interface AccountRepository {

val authId: Flow<String?>
val uId: Flow<Long?>
val userName: Flow<String?>
val nickName: Flow<String?>

suspend fun signUp(
authId: String,
userName: String,
Expand Down
3 changes: 3 additions & 0 deletions domain/src/main/java/com/whyranoid/domain/util/Extensions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.whyranoid.domain.util

val String.Companion.EMPTY: String get() = ""
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ import com.whyranoid.presentation.screens.Screen.Companion.bottomNavigationItems
import com.whyranoid.presentation.screens.challenge.ChallengeDetailScreen
import com.whyranoid.presentation.screens.challenge.ChallengeExitScreen
import com.whyranoid.presentation.screens.challenge.ChallengeMainScreen
import com.whyranoid.presentation.screens.mypage.EditProfileScreen
import com.whyranoid.presentation.screens.mypage.MyPageScreen
import com.whyranoid.presentation.screens.mypage.addpost.AddPostScreen
import com.whyranoid.presentation.screens.mypage.editprofile.EditProfileScreen
import com.whyranoid.presentation.screens.running.RunningScreen
import com.whyranoid.presentation.screens.signin.SignInScreen
import com.whyranoid.presentation.screens.splash.SplashScreen
import com.whyranoid.presentation.theme.WalkieColor
import com.whyranoid.presentation.viewmodel.SplashState
import com.whyranoid.presentation.viewmodel.SplashViewModel
import org.koin.androidx.compose.koinViewModel

Expand Down Expand Up @@ -87,11 +90,11 @@ fun AppScreen(startWorker: () -> Unit) {
val splashState = splashViewModel.splashState.collectAsStateWithLifecycle()
AppScreenContent(startWorker, navController)
// TODO Splash 적용
// when (splashState.value) {
// SplashState.InitialState -> SplashScreen()
// SplashState.SignInState -> SignInScreen { splashViewModel.finishSignIn() }
// SplashState.SignedInState -> AppScreenContent(startWorker, navController)
// }
when (splashState.value) {
SplashState.InitialState -> SplashScreen()
SplashState.SignInState -> SignInScreen { splashViewModel.finishSignIn() }
SplashState.SignedInState -> AppScreenContent(startWorker, navController)
}
}

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.foundation.text.KeyboardActions
Expand Down Expand Up @@ -70,27 +71,20 @@ import java.util.*
@SuppressLint("SimpleDateFormat")
@Composable
fun PostingScreen(runningHistory: RunningHistory) {
var textVisibleState by remember { mutableStateOf(true) }
var textVisibleState by remember { mutableStateOf(TextVisibleState.WHITE) }
var photoEditState by remember { mutableStateOf(false) }

Column(
modifier = Modifier
.fillMaxWidth()
.wrapContentHeight(),
modifier = Modifier.fillMaxWidth().wrapContentHeight(),
verticalArrangement = Arrangement.Top,
) {
Box(
Modifier
.fillMaxWidth()
.padding(horizontal = 20.dp)
.padding(top = 20.dp),
Modifier.fillMaxWidth().padding(horizontal = 20.dp).padding(top = 20.dp),
) {
Text(
style = WalkieTypography.Title,
text = "새 게시물",
modifier = Modifier
.align(Alignment.Center)
.padding(bottom = 24.dp),
modifier = Modifier.align(Alignment.Center).padding(bottom = 24.dp),
)
}

Expand All @@ -103,12 +97,8 @@ fun PostingScreen(runningHistory: RunningHistory) {
Row(
horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.padding(bottom = 12.dp)
.weight(1f)
.height(40.dp)
.clip(RoundedCornerShape(12.dp))
.background(WalkieColor.GrayDefault),
modifier = Modifier.padding(bottom = 12.dp).weight(1f).height(40.dp)
.clip(RoundedCornerShape(12.dp)).background(WalkieColor.GrayDefault),
) {
Text(text = it, style = WalkieTypography.SubTitle)
}
Expand All @@ -122,33 +112,28 @@ fun PostingScreen(runningHistory: RunningHistory) {
Row(
horizontalArrangement = Arrangement.SpaceAround,
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.padding(horizontal = 20.dp)
.align(Alignment.End)
.wrapContentSize(),
modifier = Modifier.padding(horizontal = 20.dp).align(Alignment.End).wrapContentSize(),
) {
if (photoEditState) {
Text("앨범", style = WalkieTypography.SubTitle)
Spacer(Modifier.weight(1f))
}
Icon(
modifier = Modifier
.clickable {
textVisibleState = textVisibleState.not()
modifier = Modifier.clickable {
textVisibleState = when (textVisibleState) {
TextVisibleState.WHITE -> TextVisibleState.BLACK
TextVisibleState.BLACK -> TextVisibleState.HIDE
TextVisibleState.HIDE -> TextVisibleState.WHITE
}
.size(48.dp)
.padding(12.dp),
}.size(48.dp).clip(CircleShape).padding(12.dp),
painter = painterResource(id = R.drawable.ic_timer),
contentDescription = "textVisible",
tint = WalkieColor.GrayDefault,
)
Icon(
modifier = Modifier
.clickable {
photoEditState = photoEditState.not()
}
.size(48.dp)
.padding(12.dp),
modifier = Modifier.clickable {
photoEditState = photoEditState.not()
}.size(48.dp).clip(CircleShape).padding(12.dp),
painter = painterResource(id = R.drawable.ic_gallery),
contentDescription = "gallery",
tint = WalkieColor.GrayDefault,
Expand All @@ -166,13 +151,9 @@ fun PostingScreen(runningHistory: RunningHistory) {
BasicTextField(
keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus() }),
keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Done),
modifier = Modifier
.padding(horizontal = 20.dp)
.fillMaxWidth()
.height(92.dp)
modifier = Modifier.padding(horizontal = 20.dp).fillMaxWidth().height(92.dp)
.background(Color.White)
.border(1.dp, WalkieColor.GrayDefault, RoundedCornerShape(12.dp))
.padding(8.dp),
.border(1.dp, WalkieColor.GrayDefault, RoundedCornerShape(12.dp)).padding(8.dp),
value = text,
onValueChange = {
text = it
Expand All @@ -184,16 +165,12 @@ fun PostingScreen(runningHistory: RunningHistory) {
}

Box(
modifier = Modifier
.fillMaxSize()
.padding(20.dp),
modifier = Modifier.fillMaxSize().padding(20.dp),
contentAlignment = Alignment.BottomCenter,
) {
Button(
shape = RoundedCornerShape(12.dp),
modifier = Modifier
.fillMaxWidth()
.height(48.dp),
modifier = Modifier.fillMaxWidth().height(48.dp),
onClick = {
if (photoEditState) {
photoEditState = false
Expand All @@ -213,7 +190,7 @@ fun PostingScreen(runningHistory: RunningHistory) {
@Composable
fun Map(
runningHistory: RunningHistory,
textVisibleState: Boolean,
textVisibleState: TextVisibleState,
) {
val runningHistoryUiModel = runningHistory.toRunningHistoryUiModel(LocalContext.current)

Expand Down Expand Up @@ -261,9 +238,7 @@ fun Map(

Box {
NaverMap(
modifier = Modifier
.padding(horizontal = 20.dp)
.aspectRatio(1f),
modifier = Modifier.padding(horizontal = 20.dp).aspectRatio(1f),
cameraPositionState = cameraPositionState,
uiSettings = mapUiSettings,
properties = mapProperties,
Expand All @@ -289,20 +264,19 @@ fun Map(
}
}

Text(
text = SimpleDateFormat("yyyy.MM.dd HH:mm").format(Date(runningHistory.finishedAt)),
modifier = Modifier.padding(top = 12.dp).align(Alignment.TopCenter),
style = WalkieTypography.Body2,
)

// 지도 하단 정보
if (textVisibleState) {
if (textVisibleState != TextVisibleState.HIDE) {
val textColor = if (textVisibleState == TextVisibleState.WHITE) Color.White else Color.Black

Text(
text = SimpleDateFormat("yyyy.MM.dd HH:mm").format(Date(runningHistory.finishedAt)),
modifier = Modifier.padding(top = 12.dp).align(Alignment.TopCenter),
style = WalkieTypography.Body2.copy(color = textColor),
)

Row(
modifier = Modifier
.padding(horizontal = 20.dp)
.fillMaxWidth()
.align(Alignment.BottomCenter)
.padding(bottom = 12.dp)
modifier = Modifier.padding(horizontal = 20.dp).fillMaxWidth()
.align(Alignment.BottomCenter).padding(bottom = 12.dp)
.padding(horizontal = 20.dp),
horizontalArrangement = Arrangement.SpaceBetween,
) {
Expand All @@ -313,10 +287,14 @@ fun Map(
).forEach {
Text(
it,
style = WalkieTypography.Title,
style = WalkieTypography.Title.copy(color = textColor),
)
}
}
}
}
}

enum class TextVisibleState {
WHITE, BLACK, HIDE
}
Loading

0 comments on commit 9524070

Please sign in to comment.