Skip to content

Commit

Permalink
(#2) fix login ui
Browse files Browse the repository at this point in the history
  • Loading branch information
myung jun Hyun committed Nov 27, 2019
1 parent 65c5da6 commit 7f1c31d
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 136 deletions.
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".app.login.LoginActivity" />
<activity android:name=".app.login.LoginActivity"
android:windowSoftInputMode="adjustResize" />
<activity android:name=".app.attendees.AttendeesActivity" />
</application>

Expand Down
15 changes: 14 additions & 1 deletion app/src/main/java/com/mashup/app/login/LoginFragment.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.mashup.app.login

import android.content.Context.INPUT_METHOD_SERVICE
import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.InputMethodManager
import androidx.fragment.app.Fragment
import com.google.android.material.snackbar.Snackbar
import com.mashup.app.main.MainActivity
Expand Down Expand Up @@ -45,12 +47,23 @@ class LoginFragment : Fragment() {
}

private fun setupEventObserver() {
viewModel.isLoginSuccess.observe(this, EventObserver {
viewModel.isLoginSuccess.observe(viewLifecycleOwner, EventObserver {
if (it) {
activity?.finishAffinity()
val intent = Intent(this.context, MainActivity::class.java)
startActivity(intent)
}
})

viewModel.hideKeyboard.observe(viewLifecycleOwner, EventObserver {
if (it) {
hideSoftKeyBoard()
}
})
}

private fun hideSoftKeyBoard() {
val imm = context?.getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(viewDataBinding.layoutForm.windowToken, 0)
}
}
4 changes: 4 additions & 0 deletions app/src/main/java/com/mashup/app/login/LoginViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class LoginViewModel(
private val _snackbarText = MutableLiveData<Event<Any>>()
val snackbarText: LiveData<Event<Any>> = _snackbarText

private val _hideKeyboard = MutableLiveData<Event<Boolean>>()
val hideKeyboard: LiveData<Event<Boolean>> = _hideKeyboard

val email = MutableLiveData<String>()
val password = MutableLiveData<String>()

Expand Down Expand Up @@ -52,6 +55,7 @@ class LoginViewModel(
}

fun onClickLoginButton() {
_hideKeyboard.value = Event(true)
getAuthToken()
}

Expand Down
272 changes: 143 additions & 129 deletions app/src/main/res/layout/login_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,145 +10,159 @@
type="com.mashup.app.login.LoginViewModel" />
</data>

<androidx.constraintlayout.widget.ConstraintLayout
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorBaseBg"
android:orientation="vertical">
android:fillViewport="true">

<TextView
android:id="@+id/tvLoginScreenTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/login_margin_start_tv_layout"
android:layout_marginTop="60dp"
android:text="@string/login_tv_screen_title"
android:textColor="@color/colorPrimary"
android:textSize="13sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/tvLoginMainTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/login_margin_start_tv_layout"
android:text="@string/login_tv_main_title"
android:textColor="@color/colorPrimary"
android:textSize="30sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvLoginScreenTitle" />

<LinearLayout
android:id="@+id/layoutOval"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="@+id/tvLoginMainTitle"
app:layout_constraintEnd_toEndOf="parent">

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/circle_shape_color_primary" />

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:background="@drawable/circle_shape_color_accent" />
</LinearLayout>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layoutForm"
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="290dp"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:background="@color/colorWhite"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.45">
android:layout_height="wrap_content"
android:background="@color/colorBaseBg"
android:orientation="vertical">

<TextView
android:id="@+id/tvEmail"
android:layout_width="wrap_content"
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/login_margin_start_tv_layout"
android:layout_marginTop="@dimen/login_margin_top_tv_layout"
android:text="@string/login_tv_email"
android:textColor="@color/textGrayNormal"
android:textSize="13sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<EditText
android:id="@+id/etEmail"
android:layout_above="@+id/layoutForm"
android:layout_alignParentTop="true">

<LinearLayout
android:id="@+id/title_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="vertical">

<TextView
android:id="@+id/tvLoginScreenTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/login_margin_start_tv_layout"
android:text="@string/login_tv_screen_title"
android:textColor="@color/colorPrimary"
android:textSize="13sp" />

<TextView
android:id="@+id/tvLoginMainTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/login_margin_start_tv_layout"
android:text="@string/login_tv_main_title"
android:textColor="@color/colorPrimary"
android:textSize="30sp" />
</LinearLayout>

<LinearLayout
android:id="@+id/layoutOval"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/title_container"
android:layout_alignParentEnd="true"
android:layout_marginEnd="20dp"
android:orientation="horizontal">

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/circle_shape_color_primary" />

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:background="@drawable/circle_shape_color_accent" />
</LinearLayout>

</RelativeLayout>

<androidx.cardview.widget.CardView
android:id="@+id/layoutForm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/login_margin_start_et_layout"
android:layout_marginEnd="@dimen/login_margin_end_et_layout"
android:hint="@string/login_et_email"
android:inputType="textEmailAddress"
android:text="@={viewmodel.email}"
android:textColorHint="@color/colorEtHint"
android:textSize="14sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvEmail" />
android:layout_centerVertical="true"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
app:cardCornerRadius="@dimen/card_radius"
app:cardElevation="@dimen/card_elevation">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorWhite"
android:orientation="vertical">

<TextView
android:id="@+id/tvEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/login_margin_start_tv_layout"
android:layout_marginTop="@dimen/login_margin_top_tv_layout"
android:text="@string/login_tv_email"
android:textColor="@color/textGrayNormal"
android:textSize="13sp" />

<EditText
android:id="@+id/etEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/login_margin_start_et_layout"
android:layout_marginEnd="@dimen/login_margin_end_et_layout"
android:hint="@string/login_et_email"
android:inputType="textEmailAddress"
android:text="@={viewmodel.email}"
android:textColorHint="@color/colorEtHint"
android:textSize="14sp" />

<TextView
android:id="@+id/tvPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/login_margin_start_tv_layout"
android:layout_marginTop="30dp"
android:text="@string/login_tv_password"
android:textColor="@color/textGrayNormal"
android:textSize="13sp" />

<EditText
android:id="@+id/etPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/login_margin_start_et_layout"
android:layout_marginEnd="@dimen/login_margin_end_et_layout"
android:hint="@string/login_et_password"
android:inputType="textPassword"
android:text="@={viewmodel.password}"
android:textColorHint="@color/colorEtHint"
android:textSize="14sp" />

<Button
android:id="@+id/btnLogin"
android:layout_width="260dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginTop="30dp"
android:layout_marginBottom="30dp"
android:background="@drawable/btn_radius_main"
android:onClick="@{() -> viewmodel.onClickLoginButton()}"
android:text="@string/login_btn"
android:textColor="@color/colorWhite"
android:textSize="20sp" />
</LinearLayout>
</androidx.cardview.widget.CardView>

<TextView
android:id="@+id/tvPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/login_margin_start_tv_layout"
android:layout_marginTop="30dp"
android:text="@string/login_tv_password"
android:textColor="@color/textGrayNormal"
android:textSize="13sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etEmail" />

<EditText
android:id="@+id/etPassword"
android:id="@+id/tvWelcomeMsg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/login_margin_start_et_layout"
android:layout_marginEnd="@dimen/login_margin_end_et_layout"
android:hint="@string/login_et_password"
android:inputType="textPassword"
android:text="@={viewmodel.password}"
android:textColorHint="@color/colorEtHint"
android:textSize="14sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvPassword" />

<Button
android:id="@+id/btnLogin"
android:layout_width="260dp"
android:layout_height="50dp"
android:layout_marginTop="30dp"
android:background="@drawable/btn_radius_main"
android:onClick="@{() -> viewmodel.onClickLoginButton()}"
android:text="@string/login_btn"
android:textColor="@color/colorWhite"
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etPassword" />
</androidx.constraintlayout.widget.ConstraintLayout>

<TextView
android:id="@+id/tvWelcomeMsg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="25dp"
android:text="@string/login_tv_welcome_msg"
android:textSize="15sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />


</androidx.constraintlayout.widget.ConstraintLayout>
android:layout_below="@+id/layoutForm"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:gravity="bottom|center"
android:paddingBottom="10dp"
android:text="@string/login_tv_welcome_msg"
android:textSize="15sp" />

</RelativeLayout>
</ScrollView>
</layout>
4 changes: 2 additions & 2 deletions app/src/main/res/layout/notice_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
android:layout_marginEnd="30dp"
android:layout_marginBottom="50dp"
android:onClick="@{() -> viewmodel.onClickItem(notice)}"
app:cardElevation="8dp"
app:cardCornerRadius="8dp">
app:cardElevation="@dimen/card_elevation"
app:cardCornerRadius="@dimen/card_radius">

<LinearLayout
android:layout_width="match_parent"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/setting_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
android:layout_marginStart="30dp"
android:layout_marginTop="74dp"
android:layout_marginEnd="30dp"
app:cardCornerRadius="8dp"
app:cardElevation="8dp">
app:cardCornerRadius="@dimen/card_radius"
app:cardElevation="@dimen/card_elevation">

<LinearLayout
android:layout_width="match_parent"
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@
<dimen name="login_width_btn">260dp</dimen>
<dimen name="login_height_btn">50dp</dimen>
<dimen name="login_margin_start_tv_layout">30dp</dimen>
<dimen name="login_margin_top_tv_layout">48dp</dimen>
<dimen name="login_margin_top_tv_layout">30dp</dimen>
<dimen name="login_margin_start_et_layout">30dp</dimen>
<dimen name="login_margin_end_et_layout">30dp</dimen>
<dimen name="text_small">12sp</dimen>
<dimen name="text_normal">14sp</dimen>
<dimen name="text_head">22sp</dimen>
<dimen name="card_elevation">3dp</dimen>
<dimen name="card_radius">8dp</dimen>
</resources>

0 comments on commit 7f1c31d

Please sign in to comment.