Skip to content

Commit

Permalink
#6 mypage_fragment/설정 화면 : 1 뎁스 화면
Browse files Browse the repository at this point in the history
 - 설정 화면의 가장 첫번째 화면 구현
  • Loading branch information
likppi10 committed Aug 18, 2022
1 parent 62f2f49 commit 28d61a8
Show file tree
Hide file tree
Showing 14 changed files with 571 additions and 46 deletions.
58 changes: 32 additions & 26 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.ftw.hometerview">
package="com.ftw.hometerview"
>

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Expand All @@ -19,60 +20,63 @@
android:supportsRtl="true"
android:theme="@style/Theme.Hometerview"
android:usesCleartextTraffic="true"
tools:targetApi="31">
tools:targetApi="31"
>
<activity
android:name=".ui.updatenickname.UpdateNicknameActivity"
android:exported="false"
/>
<activity
android:name=".ui.buildinglist.BuildingListActivity"
android:exported="false" />

android:exported="false"
/>
<activity
android:name=".ui.searchaddressbuilding.SearchAddressBuildingActivity"
android:exported="false" />

android:exported="false"
/>
<activity
android:name=".ui.loading.LoadingActivity"
android:exported="false" />

android:exported="false"
/>
<activity
android:name=".ui.searchcompanynonresult.SearchCompanyNonResultActivity"
android:exported="false" />

android:exported="false"
/>
<activity
android:name=".ui.searchcompanyresult.SearchCompanyResultActivity"
android:exported="false" />

android:exported="false"
/>
<activity
android:name=".ui.searchcompany.SearchCompanyActivity"
android:exported="false" />

android:exported="false"
/>
<activity
android:name=".ui.splash.SplashActivity"
android:exported="true"
tools:ignore="Instantiatable" />

tools:ignore="Instantiatable"
/>
<activity
android:name=".ui.main.MainActivity"
android:exported="true" >
android:exported="true"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name=".ui.login.LoginActivity"
android:exported="true"
/>

<activity
android:name=".ui.buildingreview.BuildingReviewActivity"
android:exported="true"
/>

<!-- kakao 로그인 창 -->
/> <!-- kakao 로그인 창 -->
<activity
android:name="com.kakao.sdk.auth.AuthCodeHandlerActivity"
android:exported="true">
android:exported="true"
>
<intent-filter>
<action android:name="android.intent.action.VIEW" />

Expand All @@ -81,13 +85,15 @@

<data
android:host="oauth"
android:scheme="@string/kakao_scheme" />
android:scheme="@string/kakao_scheme"
/>
</intent-filter>
</activity>

<meta-data
android:name="com.kakao.sdk.AppKey"
android:value="@string/kakao_api_key" />
android:value="@string/kakao_api_key"
/>
</application>

</manifest>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,5 @@ class ActivityViewModelModule {
getBuildingReviewsUseCase
)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.ftw.hometerview.ui.main.favorite.favoritelist.FavoriteBuildingsViewMo
import com.ftw.hometerview.ui.main.favorite.favoritelist.FavoriteReviewsViewModel
import com.ftw.hometerview.ui.main.home.HomeViewModel
import com.ftw.hometerview.ui.main.home.review.LocationReviewListViewModel
import com.ftw.hometerview.ui.main.mypage.MyPageViewModel
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
Expand Down Expand Up @@ -47,6 +48,18 @@ class MainFragmentViewModelModule {
)
}

@Provides
@FragmentScoped
fun provideUpdateNicknameViewModel(
dispatcher: Dispatcher,
getCachedUserUseCase: GetCachedUserUseCase
): MyPageViewModel {
return MyPageViewModel(
dispatcher,
getCachedUserUseCase
)
}


@Provides
@FragmentScoped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class HomeViewModel(
flow {
emit(getCachedUserUseCase())
}
.catch { emit(User(Company.NONE)) }
.catch { emit(User("", Company.NONE)) }
.collect {
_user.value = it
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,46 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
import com.ftw.hometerview.R
import com.ftw.hometerview.databinding.FragmentHomeBinding
import com.ftw.hometerview.databinding.FragmentMyPageBinding
import com.ftw.hometerview.ui.main.home.HomeViewModel
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject

@AndroidEntryPoint
class MyPageFragment : Fragment() {

companion object {
fun newInstance() = MyPageFragment()
}

private lateinit var viewModel: MyPageViewModel
private var _binding: FragmentMyPageBinding? = null
private val binding get() = _binding!!

@Inject
lateinit var viewModel: MyPageViewModel

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_my_page, container, false)
_binding = DataBindingUtil.inflate<FragmentMyPageBinding?>(
inflater,
R.layout.fragment_my_page,
container,
false
).apply {
viewModel = this@MyPageFragment.viewModel
}
return binding.root
}

override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
viewModel = ViewModelProvider(this).get(MyPageViewModel::class.java)
// TODO: Use the ViewModel
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,31 @@
package com.ftw.hometerview.ui.main.mypage

import androidx.lifecycle.ViewModel
import com.ftw.domain.entity.Company
import com.ftw.domain.entity.User
import com.ftw.domain.usecase.user.GetCachedUserUseCase
import com.ftw.hometerview.dispatcher.Dispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.launch

class MyPageViewModel : ViewModel() {
// TODO: Implement the ViewModel
}
class MyPageViewModel (
dispatcher: Dispatcher,
private val getCachedUserUseCase: GetCachedUserUseCase
) {

private val _user: MutableStateFlow<User> = MutableStateFlow(User.NONE)
val user: StateFlow<User> = _user.asStateFlow()

init {
CoroutineScope(dispatcher.ui()).launch {
flow {
emit(getCachedUserUseCase())
}
.catch { emit(User("", Company.NONE)) }
.collect {
_user.value = it
}

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.ftw.hometerview.ui.updatenickname

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.ftw.hometerview.R

class UpdateNicknameActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_update_nick_name)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.ftw.hometerview.ui.updatenickname

import com.ftw.domain.entity.Company
import com.ftw.domain.entity.LocationReview
import com.ftw.domain.entity.User
import com.ftw.domain.usecase.review.GetLocationReviewsUseCase
import com.ftw.domain.usecase.user.GetCachedUserUseCase
import com.ftw.hometerview.dispatcher.Dispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.launch

class UpdateNicknameViewModel(
dispatcher: Dispatcher,
private val getCachedUserUseCase: GetCachedUserUseCase
) {

private val _user: MutableStateFlow<User> = MutableStateFlow(User.NONE)
val user: StateFlow<User> = _user.asStateFlow()

init {
CoroutineScope(dispatcher.ui()).launch {
flow {
emit(getCachedUserUseCase())
}
.catch { emit(User("", Company.NONE)) }
.collect {
_user.value = it
}

}
}
}
13 changes: 13 additions & 0 deletions app/src/main/res/layout/activity_update_nick_name.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
>

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.updatenickname.UpdateNicknameActivity"
>

</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
Loading

0 comments on commit 28d61a8

Please sign in to comment.