Skip to content

Commit

Permalink
Change FAB Color and shape (#323)
Browse files Browse the repository at this point in the history
* Change FAB Color and shape
Fixes #294
Fixes #282

* Example: fix onPressed
  • Loading branch information
Feichtmeier committed Mar 15, 2023
1 parent be03ce8 commit c1377fd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
18 changes: 16 additions & 2 deletions example/lib/view/controls_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,24 @@ class _ControlsViewState extends State<ControlsView>
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
child: Wrap(
spacing: 10,
runSpacing: 10,
children: [
FloatingActionButton(
onPressed: () => {incrementCounter()},
onPressed: incrementCounter,
child: const Icon(Icons.plus_one),
),
FloatingActionButton.extended(
onPressed: incrementCounter,
label: const Text('Yay! +1 ❤️ for Yaru'),
),
FloatingActionButton.small(
onPressed: incrementCounter,
child: const Icon(Icons.plus_one),
),
FloatingActionButton.large(
onPressed: incrementCounter,
child: const Icon(Icons.plus_one),
),
],
Expand Down
17 changes: 10 additions & 7 deletions lib/src/themes/common_themes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -329,15 +329,17 @@ ProgressIndicatorThemeData _createProgressIndicatorTheme(
}

FloatingActionButtonThemeData _getFloatingActionButtonThemeData(
ColorScheme colorScheme,
) {
ColorScheme colorScheme, [
Color? buttonColor,
]) {
const elevation = 3.0;
final bg = buttonColor ?? colorScheme.primary;

return FloatingActionButtonThemeData(
backgroundColor: colorScheme.surface
.scale(lightness: colorScheme.isLight ? -0.10 : 0.20),
foregroundColor: colorScheme.onSurface,
shape: CircleBorder(
backgroundColor: bg,
foregroundColor: contrastColor(bg),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30),
side: colorScheme.isHighContrast
? BorderSide(color: colorScheme.outlineVariant)
: BorderSide.none,
Expand Down Expand Up @@ -404,7 +406,8 @@ ThemeData createYaruTheme({
radioTheme: _getRadioThemeData(colorScheme),
primaryColorDark: colorScheme.isDark ? colorScheme.primary : null,
appBarTheme: _createAppBarTheme(colorScheme),
floatingActionButtonTheme: _getFloatingActionButtonThemeData(colorScheme),
floatingActionButtonTheme:
_getFloatingActionButtonThemeData(colorScheme, elevatedButtonColor),
bottomNavigationBarTheme: BottomNavigationBarThemeData(
selectedItemColor: colorScheme.primary,
unselectedItemColor: colorScheme.onSurface.withOpacity(0.8),
Expand Down

0 comments on commit c1377fd

Please sign in to comment.