-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(widgetbook): added textScaleFactors for font accessibility
- Loading branch information
Jens Horstmann
committed
Feb 9, 2022
1 parent
b1f404c
commit 19c3f93
Showing
21 changed files
with
475 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
packages/widgetbook/lib/src/rendering/builders/text_scale_builder.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
TextScaleBuilder get defaultTextScaleBuilder => | ||
(BuildContext context, double textScaleFactor, Widget child) { | ||
return MediaQuery( | ||
data: MediaQuery.of(context).copyWith( | ||
textScaleFactor: textScaleFactor, | ||
), | ||
child: child, | ||
); | ||
}; | ||
|
||
typedef TextScaleBuilder = Widget Function( | ||
BuildContext context, | ||
double textScaleFactor, | ||
Widget child, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
packages/widgetbook/lib/src/text_scale/text_scale_handle.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:provider/provider.dart'; | ||
import 'package:widgetbook/src/workbench/comparison_handle.dart'; | ||
import 'package:widgetbook/src/workbench/comparison_setting.dart'; | ||
import 'package:widgetbook/src/workbench/selection_item.dart'; | ||
import 'package:widgetbook/src/workbench/workbench_provider.dart'; | ||
|
||
class TextScaleHandle<CustomTheme> extends StatelessWidget { | ||
const TextScaleHandle({Key? key}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final workbenchProvider = context.watch<WorkbenchProvider<CustomTheme>>(); | ||
final workbenchState = workbenchProvider.state; | ||
return ComparisonHandle<double, CustomTheme>( | ||
multiRender: ComparisonSetting.textScale, | ||
items: workbenchState.textScaleFactors, | ||
buildItem: (double e) => SelectionItem( | ||
name: e.toStringAsFixed(2), | ||
selectedItem: workbenchState.textScaleFactor, | ||
item: e, | ||
onPressed: () { | ||
workbenchProvider.changedTextScaleFactor(e); | ||
}, | ||
), | ||
onPreviousPressed: workbenchProvider.previousTextScaleFactor, | ||
onNextPressed: workbenchProvider.nextTextScaleFactor, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.