Skip to content

Commit

Permalink
chore(Example): add RTL mode settings (#894)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jupi007 authored May 8, 2024
1 parent e442fc9 commit 0bbdf7c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
16 changes: 13 additions & 3 deletions example/lib/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ class _ExampleState extends State<Example> {
Widget build(BuildContext context) {
final model = context.watch<ExampleModel>();

return model.compactMode
? _CompactPage(pageItems: examplePageItems)
: _MasterDetailPage(pageItems: examplePageItems);
return Directionality(
textDirection: !model.rtl ? TextDirection.ltr : TextDirection.rtl,
child: model.compactMode
? _CompactPage(pageItems: examplePageItems)
: _MasterDetailPage(pageItems: examplePageItems),
);
}
}

Expand Down Expand Up @@ -208,6 +211,13 @@ Future<void> showSettingsDialog(BuildContext context) {
onChanged: (v) => model.compactMode = v,
),
),
YaruTile(
title: const Text('RTL mode'),
trailing: YaruSwitch(
value: model.rtl,
onChanged: (v) => model.rtl = v,
),
),
],
),
actions: [
Expand Down
8 changes: 8 additions & 0 deletions example/lib/example_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ class ExampleModel extends SafeChangeNotifier {
notifyListeners();
}

bool _rtl = false;
bool get rtl => _rtl;
set rtl(bool value) {
if (value == _rtl) return;
_rtl = value;
notifyListeners();
}

Future<void> init() async {
await initConnectivity();
}
Expand Down

0 comments on commit 0bbdf7c

Please sign in to comment.