Browse Source

fix: modal theming (android) (#606)

master
Henning Hall 2 years ago
committed by GitHub
parent
commit
11a41642f5
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 1 deletions
  1. +12
    -1
      android/src/main/java/com/henninghall/date_picker/DatePickerModule.java

+ 12
- 1
android/src/main/java/com/henninghall/date_picker/DatePickerModule.java View File

@ -55,7 +55,7 @@ public class DatePickerModule extends ReactContextBaseJavaModule {
final String cancelText = props.getString("cancelText");
final View pickerWithMargin = withTopMargin(picker);
return new AlertDialog.Builder(DatePickerPackage.context.getCurrentActivity())
return new AlertDialog.Builder(DatePickerPackage.context.getCurrentActivity(), getTheme(props))
.setTitle(title)
.setCancelable(true)
.setView(pickerWithMargin)
@ -80,6 +80,17 @@ public class DatePickerModule extends ReactContextBaseJavaModule {
.create();
}
private int getTheme(ReadableMap props) {
int defaultTheme = 0;
String theme = props.getString("theme");
if(theme == null) return defaultTheme;
switch (theme){
case "light": return AlertDialog.THEME_DEVICE_DEFAULT_LIGHT;
case "dark": return AlertDialog.THEME_DEVICE_DEFAULT_DARK;
default: return defaultTheme;
}
}
private PickerView createPicker(ReadableMap props){
int height = 180;
LinearLayout.LayoutParams rootLayoutParams = new LinearLayout.LayoutParams(

Loading…
Cancel
Save