Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

added extra layer to edit is_member status #172

Open
wants to merge 1 commit into
base: development
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
Expand Up @@ -3,9 +3,11 @@
import android.app.Activity;
import android.app.DatePickerDialog;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.google.android.material.textfield.TextInputLayout;
import android.text.Editable;
import android.text.TextUtils;
Expand All @@ -16,6 +18,8 @@
import android.widget.CheckBox;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.stepstone.stepper.Step;
import com.stepstone.stepper.VerificationError;
Expand All @@ -33,6 +37,7 @@

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnCheckedChanged;
import butterknife.OnClick;

/**
Expand Down Expand Up @@ -76,6 +81,12 @@ public class FormCustomerDetailsFragment extends FineractBaseFragment implements
@BindView(R.id.cb_is_member)
CheckBox cbIsmember;

@BindView(R.id.tv_member_status)
TextView tvMemberStatus;

@BindView(R.id.iv_edit_is_member)
ImageView ivEditIsMember;

View rootView;

private Calendar calendar = Calendar.getInstance();
Expand Down Expand Up @@ -144,6 +155,9 @@ public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth
}

public void showPreviousCustomerDetails() {
tvMemberStatus.setVisibility(View.VISIBLE);
ivEditIsMember.setVisibility(View.VISIBLE);
cbIsmember.setVisibility(View.GONE);
etAccount.setText(customer.getIdentifier());
etAccount.setEnabled(false);
etFirstName.setText(customer.getGivenName());
Expand All @@ -152,6 +166,7 @@ public void showPreviousCustomerDetails() {
}
etLastName.setText(customer.getSurname());
cbIsmember.setChecked(customer.getMember());
setIsMemberStatus();
dateOfBirth = customer.getDateOfBirth();

calendar.set(Calendar.YEAR, dateOfBirth.getYear());
Expand Down Expand Up @@ -298,4 +313,46 @@ public void onAttach(Context context) {
+ " must implement OnNavigationBarListener.CustomerDetails");
}
}

@OnClick(R.id.iv_edit_is_member)
void editIsMember() {
if (tvMemberStatus.getVisibility() == View.VISIBLE) {
tvMemberStatus.setVisibility(View.GONE);
cbIsmember.setVisibility(View.VISIBLE);
ivEditIsMember.setImageResource(R.drawable.ms_ic_check);
} else {
tvMemberStatus.setVisibility(View.VISIBLE);
cbIsmember.setVisibility(View.GONE);
ivEditIsMember.setImageResource(R.drawable.ic_edit_black_24dp);
}
}

@OnCheckedChanged(R.id.cb_is_member)
void setIsMemberStatus() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
if (cbIsmember.isChecked()) {
tvMemberStatus.
setCompoundDrawablesRelativeWithIntrinsicBounds(
R.drawable.ic_check_circle_black_24dp, 0, 0, 0);
} else {
tvMemberStatus.
setCompoundDrawablesRelativeWithIntrinsicBounds(
R.drawable.ic_cross_cricle_red_24dp, 0, 0, 0);
}
} else {
if (cbIsmember.isChecked()) {
tvMemberStatus.setCompoundDrawables(
getResources().getDrawable(R.drawable.ic_check_circle_black_24dp),
getResources().getDrawable(0),
getResources().getDrawable(0),
getResources().getDrawable(0));
} else {
tvMemberStatus.setCompoundDrawables(
getResources().getDrawable(R.drawable.ic_cross_cricle_red_24dp),
getResources().getDrawable(0),
getResources().getDrawable(0),
getResources().getDrawable(0));
}
}
}
}
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_cross_cricle_red_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="@color/red_dark"
android:pathData="M12,2C6.47,2 2,6.47 2,12s4.47,10 10,10 10,-4.47 10,-10S17.53,2 12,2zM17,15.59L15.59,17 12,13.41 8.41,17 7,15.59 10.59,12 7,8.41 8.41,7 12,10.59 15.59,7 17,8.41 13.41,12 17,15.59z"/>
</vector>
23 changes: 21 additions & 2 deletions app/src/main/res/layout/fragment_form_customer_details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@
android:orientation="horizontal"
android:paddingBottom="@dimen/layout_padding_16dp"
android:paddingLeft="@dimen/layout_padding_16dp"
android:paddingRight="@dimen/layout_padding_16dp">
android:paddingRight="@dimen/layout_padding_16dp"
android:gravity="center_vertical">

<CheckBox
android:id="@+id/cb_is_member"
Expand All @@ -133,7 +134,25 @@
android:paddingRight="@dimen/layout_padding_16dp"
android:checked="true"
android:layout_width="wrap_content"
android:paddingLeft="@dimen/layout_padding_16dp"/>
android:paddingLeft="@dimen/layout_padding_16dp"
android:layout_weight="1"/>

<TextView
android:id="@+id/tv_member_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/is_member"
android:drawablePadding="@dimen/layout_padding_5dp"
android:visibility="gone"
android:layout_weight="1"/>

<ImageView
android:id="@+id/iv_edit_is_member"
android:layout_width="@dimen/layout_padding_24dp"
android:layout_height="@dimen/layout_padding_24dp"
app:srcCompat="@drawable/ic_edit_black_24dp"
android:tint="@color/black"
android:visibility="gone"/>

</LinearLayout>

Expand Down