Line data Source code
1 : import 'package:flutter/material.dart'; 2 : import 'package:widgetbook/src/providers/theme_provider.dart'; 3 : import '../utils/extensions.dart'; 4 : 5 : class ThemeHandle extends StatelessWidget { 6 10 : const ThemeHandle({Key? key}) : super(key: key); 7 : 8 0 : @override 9 : Widget build(BuildContext context) { 10 0 : var themeProvider = ThemeProvider.of(context)!; 11 0 : return Row( 12 0 : children: [ 13 : // TODO add an own widget for this 14 : // or style the text button.icon appropriately 15 : // TODO make sure the onPresses is triggered on the text as well 16 0 : TextButton( 17 0 : onPressed: themeProvider.toggleTheme, 18 0 : style: TextButton.styleFrom( 19 : splashFactory: InkRipple.splashFactory, 20 : shape: 21 0 : RoundedRectangleBorder(borderRadius: BorderRadius.circular(90)), 22 : minimumSize: Size.zero, 23 : padding: const EdgeInsets.all(12), 24 : ), 25 0 : child: Icon( 26 : Icons.dark_mode, 27 0 : color: themeProvider.state == ThemeMode.light 28 0 : ? context.theme.hintColor 29 0 : : context.colorScheme.primary, 30 : ), 31 : ), 32 : const SizedBox( 33 : width: 4, 34 : ), 35 : const Text('theme'), 36 : ], 37 : ); 38 : } 39 : }