Commit 0d454724 authored by Adam Barth's avatar Adam Barth Committed by GitHub

Improve DatePicker RTL (#11922)

This patch just fixes the next and previous buttons to be in the proper
place. There might be other issues with the DatePicker, but this one was
obvious.

See #11377
parent 020029ac
...@@ -10,7 +10,7 @@ import 'package:flutter/rendering.dart'; ...@@ -10,7 +10,7 @@ import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:intl/date_symbols.dart'; import 'package:intl/date_symbols.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart' hide TextDirection;
import 'button.dart'; import 'button.dart';
import 'button_bar.dart'; import 'button_bar.dart';
...@@ -533,8 +533,31 @@ class _MonthPickerState extends State<MonthPicker> { ...@@ -533,8 +533,31 @@ class _MonthPickerState extends State<MonthPicker> {
}); });
} }
Icon _getPreviousMonthIcon(TextDirection textDirection) {
assert(textDirection != null);
switch (textDirection) {
case TextDirection.rtl:
return const Icon(Icons.chevron_right);
case TextDirection.ltr:
return const Icon(Icons.chevron_left);
}
return null;
}
Icon _getNextMonthIcon(TextDirection textDirection) {
assert(textDirection != null);
switch (textDirection) {
case TextDirection.rtl:
return const Icon(Icons.chevron_left);
case TextDirection.ltr:
return const Icon(Icons.chevron_right);
}
return null;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final TextDirection textDirection = Directionality.of(context);
return new SizedBox( return new SizedBox(
width: _kMonthPickerPortraitWidth, width: _kMonthPickerPortraitWidth,
height: _kMaxDayPickerHeight, height: _kMaxDayPickerHeight,
...@@ -548,20 +571,20 @@ class _MonthPickerState extends State<MonthPicker> { ...@@ -548,20 +571,20 @@ class _MonthPickerState extends State<MonthPicker> {
itemBuilder: _buildItems, itemBuilder: _buildItems,
onPageChanged: _handleMonthPageChanged, onPageChanged: _handleMonthPageChanged,
), ),
new Positioned( new PositionedDirectional(
top: 0.0, top: 0.0,
left: 8.0, start: 8.0,
child: new IconButton( child: new IconButton(
icon: const Icon(Icons.chevron_left), icon: _getPreviousMonthIcon(textDirection),
tooltip: MaterialLocalizations.of(context).previousMonthTooltip, tooltip: MaterialLocalizations.of(context).previousMonthTooltip,
onPressed: _isDisplayingFirstMonth ? null : _handlePreviousMonth, onPressed: _isDisplayingFirstMonth ? null : _handlePreviousMonth,
), ),
), ),
new Positioned( new PositionedDirectional(
top: 0.0, top: 0.0,
right: 8.0, end: 8.0,
child: new IconButton( child: new IconButton(
icon: const Icon(Icons.chevron_right), icon: _getNextMonthIcon(textDirection),
tooltip: MaterialLocalizations.of(context).nextMonthTooltip, tooltip: MaterialLocalizations.of(context).nextMonthTooltip,
onPressed: _isDisplayingLastMonth ? null : _handleNextMonth, onPressed: _isDisplayingLastMonth ? null : _handleNextMonth,
), ),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment