Compare commits

...

1 Commits

Author SHA1 Message Date
Leptopoda-GitHub 367c8377a8
fix directionality fixes #406 2021-11-25 13:31:33 +01:00
4 changed files with 28 additions and 42 deletions

View File

@ -234,9 +234,7 @@ class Board extends StatelessWidget {
1
];
final bool ltr = Directionality.of(context) == TextDirection.ltr;
if (ltr) {
if (Directionality.of(context) == TextDirection.ltr) {
for (final file in ['a', 'b', 'c', 'd', 'e', 'f', 'g']) {
for (final rank in ['7', '6', '5', '4', '3', '2', '1']) {
coordinates.add("$file$rank");

View File

@ -71,7 +71,6 @@ class _GamePageState extends State<GamePage>
late AnimationController _animationController;
late Animation<double> animation;
bool disposed = false;
late bool ltr;
late double boardWidth;
static const String _tag = "[game_page]";
@ -1237,15 +1236,18 @@ class _GamePageState extends State<GamePage>
EngineType.testViaLAN: FluentIcons.wifi_1_24_filled,
};
final iconColor = LocalDatabaseService.colorSettings.messageColor;
final iconRow = Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(engineTypeToIconLeft[widget.engineType], color: iconColor),
Icon(iconArrow, color: iconColor),
Icon(engineTypeToIconRight[widget.engineType], color: iconColor),
],
final iconRow = IconTheme(
data: IconThemeData(
color: LocalDatabaseService.colorSettings.messageColor,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(engineTypeToIconLeft[widget.engineType]),
Icon(iconArrow),
Icon(engineTypeToIconRight[widget.engineType]),
],
),
);
return Container(
@ -1284,13 +1286,9 @@ class _GamePageState extends State<GamePage>
if (gameInstance.position.phase == Phase.gameOver) {
switch (gameInstance.position.winner) {
case PieceColor.white:
return ltr
? FluentIcons.toggle_left_24_regular
: FluentIcons.toggle_right_24_regular;
return FluentIcons.toggle_left_24_regular;
case PieceColor.black:
return ltr
? FluentIcons.toggle_right_24_regular
: FluentIcons.toggle_left_24_regular;
return FluentIcons.toggle_right_24_regular;
default:
return FluentIcons.handshake_24_regular;
}
@ -1456,9 +1454,7 @@ class _GamePageState extends State<GamePage>
List<Widget> get historyNavToolbar {
final takeBackAllButton = ToolbarItem(
child: Icon(
ltr
? FluentIcons.arrow_previous_24_regular
: FluentIcons.arrow_next_24_regular,
FluentIcons.arrow_previous_24_regular,
semanticLabel: S.of(context).takeBackAll,
),
onPressed: () => onTakeBackAllButtonPressed(false),
@ -1466,9 +1462,7 @@ class _GamePageState extends State<GamePage>
final takeBackButton = ToolbarItem(
child: Icon(
ltr
? FluentIcons.chevron_left_24_regular
: FluentIcons.chevron_right_24_regular,
FluentIcons.chevron_left_24_regular,
semanticLabel: S.of(context).takeBack,
),
onPressed: () async => onTakeBackButtonPressed(false),
@ -1476,9 +1470,7 @@ class _GamePageState extends State<GamePage>
final stepForwardButton = ToolbarItem(
child: Icon(
ltr
? FluentIcons.chevron_right_24_regular
: FluentIcons.chevron_left_24_regular,
FluentIcons.chevron_right_24_regular,
semanticLabel: S.of(context).stepForward,
),
onPressed: () async => onStepForwardButtonPressed(false),
@ -1486,9 +1478,7 @@ class _GamePageState extends State<GamePage>
final stepForwardAllButton = ToolbarItem(
child: Icon(
ltr
? FluentIcons.arrow_next_24_regular
: FluentIcons.arrow_previous_24_regular,
FluentIcons.arrow_next_24_regular,
semanticLabel: S.of(context).stepForwardAll,
),
onPressed: () async => onStepForwardAllButtonPressed(false),
@ -1531,7 +1521,6 @@ class _GamePageState extends State<GamePage>
void didChangeDependencies() {
super.didChangeDependencies();
screenPaddingH = _screenPaddingH;
ltr = Directionality.of(context) == TextDirection.ltr;
_tip = S.of(context).welcome;
}

View File

@ -235,14 +235,14 @@ class _CustomDrawerState extends State<CustomDrawer>
if (!_captured) return;
final screenSize = MediaQuery.of(context).size;
final rtl = Directionality.of(context) == TextDirection.rtl;
final ltr = Directionality.of(context) == TextDirection.ltr;
_freshPosition = details.globalPosition;
final diff = (_freshPosition - _startPosition).dx;
_animationController.value = _offsetValue +
(diff / (screenSize.width * _openRatio)) * (rtl ? -1 : 1);
(diff / (screenSize.width * _openRatio)) * (ltr ? 1 : -1);
}
void _handleDragEnd(DragEndDetails details) {

View File

@ -38,8 +38,6 @@ class SettingsListTile extends StatelessWidget {
@override
Widget build(BuildContext context) {
final bool ltr = Directionality.of(context) == TextDirection.ltr;
return ListTile(
title: Text(
titleString,
@ -56,12 +54,13 @@ class SettingsListTile extends StatelessWidget {
trailingColor?.value.toRadixString(16) ?? trailingString ?? '',
style: TextStyle(backgroundColor: trailingColor),
),
Icon(
ltr
? FluentIcons.chevron_right_24_regular
: FluentIcons.chevron_left_24_regular,
color: AppTheme.listTileSubtitleColor,
)
const Directionality(
textDirection: TextDirection.ltr,
child: Icon(
FluentIcons.chevron_right_24_regular,
color: AppTheme.listTileSubtitleColor,
),
),
],
),
onTap: onTap,