Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/form styling #189

Open
wants to merge 3 commits into
base: develop-whitelabel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,32 +1,23 @@
package org.secfirst.umbrella.whitelabel.feature.form.view


import android.content.res.ColorStateList
import android.graphics.drawable.ColorDrawable
import android.os.Build
import android.support.v4.content.ContextCompat
import android.support.v4.graphics.drawable.DrawableCompat
import android.support.v4.view.ViewCompat
import android.support.v7.widget.AppCompatCheckBox
import android.view.Gravity
import android.view.ViewManager
import android.widget.CheckBox
import android.widget.EditText
import android.widget.RadioButton
import com.stepstone.stepper.Step
import com.stepstone.stepper.VerificationError
import org.jetbrains.anko.*
import org.jetbrains.anko.appcompat.v7.linearLayoutCompat
import org.jetbrains.anko.appcompat.v7.tintedCheckBox
import org.jetbrains.anko.appcompat.v7.tintedRadioButton
import org.jetbrains.anko.custom.ankoView
import org.secfirst.umbrella.whitelabel.R
import org.secfirst.umbrella.whitelabel.data.database.form.Answer
import org.secfirst.umbrella.whitelabel.data.database.form.Screen
import org.secfirst.umbrella.whitelabel.feature.form.FieldType
import org.secfirst.umbrella.whitelabel.feature.form.hasAnswer
import org.secfirst.umbrella.whitelabel.feature.form.view.controller.FormController
import java.util.logging.Logger


class FormUI(private val screen: Screen, private val answers: List<Answer>?) : AnkoComponent<FormController>, Step {
Expand All @@ -39,6 +30,11 @@ class FormUI(private val screen: Screen, private val answers: List<Answer>?) : A
background = ColorDrawable(ContextCompat.getColor(context, R.color.form_background))
verticalLayout {
padding = dip(20)
textView(screen.title){
textSize = 20f
textColor = R.color.umbrella_purple
}.lparams{gravity = Gravity.CENTER_HORIZONTAL}

screen.items.forEach { item ->
when (item.type) {

Expand All @@ -61,9 +57,9 @@ class FormUI(private val screen: Screen, private val answers: List<Answer>?) : A
textColor = formTextColor

}.lparams(width = matchParent)
if (Build.VERSION.SDK_INT < 24) {
editText.backgroundTintList = ColorStateList.valueOf(formTextColor)
}
// if (Build.VERSION.SDK_INT < 24) {
// editText.backgroundTintList = ColorStateList.valueOf(formTextColor)
// }
answer.itemId = item.id
bindEditText(answer, editText, ui)
}
Expand All @@ -79,9 +75,9 @@ class FormUI(private val screen: Screen, private val answers: List<Answer>?) : A
hintTextColor = R.color.immersive_background
textColor = formTextColor
}.lparams(width = matchParent)
if (Build.VERSION.SDK_INT < 24) {
editText.backgroundTintList = ColorStateList.valueOf(formTextColor)
}
// if (Build.VERSION.SDK_INT < 24) {
// editText.backgroundTintList = ColorStateList.valueOf(formTextColor)
// }
answer.itemId = item.id
answer.run { bindEditText(answer, editText, ui) }
}
Expand All @@ -98,9 +94,9 @@ class FormUI(private val screen: Screen, private val answers: List<Answer>?) : A
isChecked = answer.choiceInput
}
answer.optionId = formOption.id
if (Build.VERSION.SDK_INT < 24) {
checkBox.buttonTintList = ColorStateList.valueOf(formTextColor)
}
// if (Build.VERSION.SDK_INT < 24) {
// checkBox.buttonTintList = ColorStateList.valueOf(formTextColor)
// }
bindCheckBox(answer, checkBox, ui)
}
}
Expand All @@ -118,9 +114,9 @@ class FormUI(private val screen: Screen, private val answers: List<Answer>?) : A
textColor = formTextColor
}
answer.optionId = formOption.id
if (Build.VERSION.SDK_INT < 24) {
radioButton.buttonTintList = ColorStateList.valueOf(formTextColor)
}
// if (Build.VERSION.SDK_INT < 24) {
// radioButton.buttonTintList = ColorStateList.valueOf(formTextColor)
// }
bindRadioButton(answer, radioButton, ui)
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/drawable/nav_item_color_state.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@android:color/white" android:state_enabled="true" />
<item android:color="@color/colorPrimaryDark" android:state_enabled="false" />
<item android:color="@android:color/darker_gray" android:state_checked="false"/>
<item android:color="@color/avocado" android:state_checked="true" />
</selector>
4 changes: 4 additions & 0 deletions app/src/main/res/layout/form_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
app:ms_showErrorState="true"
app:ms_showErrorStateOnBack="true"
app:ms_stepperType="tabs"
app:ms_activeStepColor="@color/avocado"
app:ms_bottomNavigationBackground="@color/avocado"
app:ms_backButtonColor="@color/light_white"
app:ms_nextButtonColor="@color/light_white"
tools:theme="@style/AppTheme" />

<include
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/layout/main_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@
android:layout_height="wrap_content"
android:background="?android:attr/windowBackground"
android:fitsSystemWindows="true"
app:itemIconTint="@drawable/nav_item_color_state"
app:itemTextColor="@drawable/nav_item_color_state"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_insetEdge="bottom"
app:layout_scrollFlags="scroll|enterAlways"
app:menu="@menu/navigation" />

</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>