Skip to content

added Hebrew localization, fixed rtl issues #254

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

Merged
merged 1 commit into from
Jul 8, 2021
Merged
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ you can choose date / time / date&time in multiple languages:
- English(en)
- French(fr)
- German(de)
- Hebrew(he)
- Indonesian(id)
- Italian(it)
- Japanese(jp)
Expand Down
136 changes: 70 additions & 66 deletions lib/flutter_datetime_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ library flutter_datetime_picker;
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/painting.dart';
import 'package:flutter_datetime_picker/src/datetime_picker_theme.dart';
import 'package:flutter_datetime_picker/src/date_model.dart';
import 'package:flutter_datetime_picker/src/i18n_model.dart';
Expand Down Expand Up @@ -398,70 +399,73 @@ class _DatePickerState extends State<_DatePickerComponent> {
Widget _renderItemView(DatePickerTheme theme) {
return Container(
color: theme.backgroundColor,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
child: widget.pickerModel.layoutProportions()[0] > 0
? _renderColumnView(
ValueKey(widget.pickerModel.currentLeftIndex()),
theme,
widget.pickerModel.leftStringAtIndex,
leftScrollCtrl,
widget.pickerModel.layoutProportions()[0], (index) {
widget.pickerModel.setLeftIndex(index);
}, (index) {
setState(() {
refreshScrollOffset();
_notifyDateChanged();
});
})
: null,
),
Text(
widget.pickerModel.leftDivider(),
style: theme.itemStyle,
),
Container(
child: widget.pickerModel.layoutProportions()[1] > 0
? _renderColumnView(
ValueKey(widget.pickerModel.currentLeftIndex()),
theme,
widget.pickerModel.middleStringAtIndex,
middleScrollCtrl,
widget.pickerModel.layoutProportions()[1], (index) {
widget.pickerModel.setMiddleIndex(index);
}, (index) {
setState(() {
refreshScrollOffset();
_notifyDateChanged();
});
})
: null,
),
Text(
widget.pickerModel.rightDivider(),
style: theme.itemStyle,
),
Container(
child: widget.pickerModel.layoutProportions()[2] > 0
? _renderColumnView(
ValueKey(widget.pickerModel.currentMiddleIndex() * 100 +
widget.pickerModel.currentLeftIndex()),
theme,
widget.pickerModel.rightStringAtIndex,
rightScrollCtrl,
widget.pickerModel.layoutProportions()[2], (index) {
widget.pickerModel.setRightIndex(index);
}, (index) {
setState(() {
refreshScrollOffset();
_notifyDateChanged();
});
})
: null,
),
],
child: Directionality(
textDirection: TextDirection.ltr,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
child: widget.pickerModel.layoutProportions()[0] > 0
? _renderColumnView(
ValueKey(widget.pickerModel.currentLeftIndex()),
theme,
widget.pickerModel.leftStringAtIndex,
leftScrollCtrl,
widget.pickerModel.layoutProportions()[0], (index) {
widget.pickerModel.setLeftIndex(index);
}, (index) {
setState(() {
refreshScrollOffset();
_notifyDateChanged();
});
})
: null,
),
Text(
widget.pickerModel.leftDivider(),
style: theme.itemStyle,
),
Container(
child: widget.pickerModel.layoutProportions()[1] > 0
? _renderColumnView(
ValueKey(widget.pickerModel.currentLeftIndex()),
theme,
widget.pickerModel.middleStringAtIndex,
middleScrollCtrl,
widget.pickerModel.layoutProportions()[1], (index) {
widget.pickerModel.setMiddleIndex(index);
}, (index) {
setState(() {
refreshScrollOffset();
_notifyDateChanged();
});
})
: null,
),
Text(
widget.pickerModel.rightDivider(),
style: theme.itemStyle,
),
Container(
child: widget.pickerModel.layoutProportions()[2] > 0
? _renderColumnView(
ValueKey(widget.pickerModel.currentMiddleIndex() * 100 +
widget.pickerModel.currentLeftIndex()),
theme,
widget.pickerModel.rightStringAtIndex,
rightScrollCtrl,
widget.pickerModel.layoutProportions()[2], (index) {
widget.pickerModel.setRightIndex(index);
}, (index) {
setState(() {
refreshScrollOffset();
_notifyDateChanged();
});
})
: null,
),
],
),
),
);
}
Expand All @@ -483,7 +487,7 @@ class _DatePickerState extends State<_DatePickerComponent> {
height: theme.titleHeight,
child: CupertinoButton(
pressedOpacity: 0.3,
padding: EdgeInsets.only(left: 16, top: 0),
padding: EdgeInsetsDirectional.only(start: 16, top: 0),
child: Text(
'$cancel',
style: theme.cancelStyle,
Expand All @@ -500,7 +504,7 @@ class _DatePickerState extends State<_DatePickerComponent> {
height: theme.titleHeight,
child: CupertinoButton(
pressedOpacity: 0.3,
padding: EdgeInsets.only(right: 16, top: 0),
padding: EdgeInsetsDirectional.only(end: 16, top: 0),
child: Text(
'$done',
style: theme.doneStyle,
Expand Down
39 changes: 38 additions & 1 deletion lib/src/i18n_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ enum LocaleType {
sv,
kh,
tw,
fi
fi,
he
}

final _i18nModel = <LocaleType, Map<String, Object>>{
Expand Down Expand Up @@ -1340,6 +1341,42 @@ final _i18nModel = <LocaleType, Map<String, Object>>{
'day': ['Ma', 'Ti', 'Ke', 'To', 'Pe', 'La', 'Su'],
'am': 'AM',
'pm': 'PM'
},
LocaleType.he: {
'cancel': 'ביטול',
'done': 'סיום',
'today': 'היום',
'monthShort': [
'ינו׳',
'פבר׳',
'מרץ',
'אפר׳',
'מאי',
'יוני',
'יולי',
'אוג׳',
'ספט׳',
'אוק׳',
'נוב׳',
'דצמ׳'
],
'monthLong': [
'ינואר',
'פברואר',
'מרץ',
'אפריל',
'מאי',
'יוני',
'יולי',
'אוגוסט',
'ספטמבר',
'אוקטובר',
'נובמבר',
'דצמבר'
],
'day': ['ראשון', 'שני', 'שלישי', 'רביעי', 'חמישי', 'שישי', 'שבת'],
'am': 'לפנה״צ',
'pm': 'אחה״צ',
}

};
Expand Down