Browse Source

fix picker width and wheel spacing (#234)

master
Henning Hall 5 years ago
committed by GitHub
parent
commit
69ca7de49b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 48 additions and 7 deletions
  1. +17
    -1
      android/src/main/java/com/henninghall/date_picker/ui/Wheels.java
  2. +1
    -1
      android/src/main/java/com/henninghall/date_picker/wheels/AmPmWheel.java
  3. +1
    -1
      android/src/main/java/com/henninghall/date_picker/wheels/MinutesWheel.java
  4. +4
    -3
      android/src/main/java/com/henninghall/date_picker/wheels/Wheel.java
  5. +25
    -1
      android/src/main/res/layout/ios_clone.xml

+ 17
- 1
android/src/main/java/com/henninghall/date_picker/ui/Wheels.java View File

@ -2,6 +2,7 @@ package com.henninghall.date_picker.ui;
import android.view.View;
import com.henninghall.date_picker.models.Variant;
import com.henninghall.date_picker.pickers.Picker;
import com.henninghall.date_picker.R;
import com.henninghall.date_picker.State;
@ -25,9 +26,13 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import cn.carbswang.android.numberpickerview.library.NumberPickerView;
public class Wheels {
private final State state;
private final NumberPickerView emptyStart;
private final NumberPickerView emptyEnd;
private HourWheel hourWheel;
private DayWheel dayWheel;
private MinutesWheel minutesWheel;
@ -52,8 +57,9 @@ public class Wheels {
minutesWheel = new MinutesWheel(getPickerWithId(R.id.minutes), state);
ampmWheel = new AmPmWheel(getPickerWithId(R.id.ampm), state);
hourWheel = new HourWheel(getPickerWithId(R.id.hour), state);
emptyStart = rootView.findViewById(R.id.empty_start);
emptyEnd = rootView.findViewById(R.id.empty_end);
wheelPerWheelType = getWheelPerType();
changeAmPmWhenPassingMidnightOrNoon();
}
@ -80,16 +86,26 @@ public class Wheels {
void updateHeight() {
int shownCount = state.derived.getShownCount();
applyOnAll(new SetShowCount(shownCount));
if(state.getVariant() == Variant.iosClone) {
emptyStart.setShownCount(shownCount);
emptyEnd.setShownCount(shownCount);
}
}
void updateDividerHeight() {
int height = state.getDividerHeight();
applyOnAll(new SetDividerHeight(height));
if(state.getVariant() == Variant.iosClone) {
emptyStart.setDividerHeight(height);
emptyEnd.setDividerHeight(height);
}
}
void updateWheelOrder() {
pickerWrapper.removeAll();
if(state.getVariant() == Variant.iosClone) pickerWrapper.addPicker(emptyStart);
addInOrder();
if(state.getVariant() == Variant.iosClone) pickerWrapper.addPicker(emptyEnd);
}
Wheel getWheel(WheelType type){

+ 1
- 1
android/src/main/java/com/henninghall/date_picker/wheels/AmPmWheel.java View File

@ -47,7 +47,7 @@ public class AmPmWheel extends Wheel {
@Override
public Paint.Align getTextAlign() {
return Paint.Align.LEFT;
return Paint.Align.RIGHT;
}
}

+ 1
- 1
android/src/main/java/com/henninghall/date_picker/wheels/MinutesWheel.java View File

@ -47,7 +47,7 @@ public class MinutesWheel extends Wheel {
@Override
public Paint.Align getTextAlign() {
return state.derived.usesAmPm() ? Paint.Align.RIGHT: Paint.Align.LEFT;
return Paint.Align.RIGHT;
}
}

+ 4
- 3
android/src/main/java/com/henninghall/date_picker/wheels/Wheel.java View File

@ -123,10 +123,11 @@ public abstract class Wheel {
public int getHorizontalPadding() {
Mode mode = state.getMode();
switch (mode){
case time: return 15;
case date: return 10;
case date: return 15;
case time:
case datetime:
default: return 5;
default:
return 5;
}
}
}

+ 25
- 1
android/src/main/res/layout/ios_clone.xml View File

@ -13,9 +13,18 @@
android:orientation="horizontal"
android:gravity="center_horizontal"
>
<com.henninghall.date_picker.pickers.IosClone
android:id="@+id/empty_start"
android:tag="empty_start"
android:layout_weight="4"
custom:npv_ShownCount="5"
android:layout_width="0dp"
android:layout_height="match_parent"
custom:npv_DividerColor="#cccccc"
/>
<com.henninghall.date_picker.pickers.IosClone
android:id="@+id/year"
android:layout_weight="1"
android:tag="year"
android:layout_width="wrap_content"
android:layout_height="match_parent"
@ -29,6 +38,7 @@
<com.henninghall.date_picker.pickers.IosClone
android:id="@+id/month"
android:layout_weight="1"
android:tag="month"
android:layout_width="wrap_content"
android:layout_height="match_parent"
@ -44,6 +54,7 @@
<com.henninghall.date_picker.pickers.IosClone
android:id="@+id/date"
android:tag="date"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
custom:npv_ShownCount="5"
@ -72,6 +83,7 @@
android:tag="hour"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_weight="1"
custom:npv_DividerColor="#cccccc"
custom:npv_RespondChangeOnDetached="false"
custom:npv_ShownCount="5"
@ -83,6 +95,7 @@
<com.henninghall.date_picker.pickers.IosClone
android:id="@+id/minutes"
android:tag="minutes"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
custom:npv_DividerColor="#cccccc"
@ -97,6 +110,7 @@
<com.henninghall.date_picker.pickers.IosClone
android:id="@+id/ampm"
android:tag="ampm"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
custom:npv_DividerColor="#cccccc"
@ -107,6 +121,16 @@
custom:npv_TextSizeNormal="18dp"
custom:npv_TextSizeSelected="21dp"
/>
<com.henninghall.date_picker.pickers.IosClone
android:id="@+id/empty_end"
android:tag="empty_end"
android:layout_weight="4"
custom:npv_ShownCount="5"
android:layout_width="0dp"
android:layout_height="match_parent"
custom:npv_DividerColor="#cccccc"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"

Loading…
Cancel
Save