-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* create ZetaSwitch * ZetaSwitch using MaterialSwitch * widgetbook for ZetaSwitch * remove hover; fix initState * add showHover parameter * add comments 'Zeta change' in material_switch.dart * remove size parameter and factory constructors * fix example and widgetbook
- Loading branch information
1 parent
5329362
commit 9c57528
Showing
7 changed files
with
1,284 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:zeta_example/widgets.dart'; | ||
import 'package:zeta_flutter/zeta_flutter.dart'; | ||
|
||
class SwitchExample extends StatefulWidget { | ||
static const String name = 'Switch'; | ||
|
||
const SwitchExample({Key? key}) : super(key: key); | ||
|
||
@override | ||
State<SwitchExample> createState() => _SwitchExampleState(); | ||
} | ||
|
||
class _SwitchExampleState extends State<SwitchExample> { | ||
bool? isOn = false; | ||
bool isEnabled = true; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return ExampleScaffold( | ||
name: 'Switch', | ||
child: Center( | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.spaceEvenly, | ||
children: [ | ||
Row( | ||
crossAxisAlignment: CrossAxisAlignment.center, | ||
mainAxisAlignment: MainAxisAlignment.spaceAround, | ||
children: [ | ||
ZetaSwitch( | ||
value: isOn, | ||
onChanged: isEnabled ? (value) => setState(() => isOn = value) : null, | ||
), | ||
ZetaButton( | ||
label: isEnabled ? 'Disable' : 'Enable', | ||
onPressed: () => setState(() => isEnabled = !isEnabled), | ||
), | ||
], | ||
), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} |
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
32 changes: 32 additions & 0 deletions
32
example/widgetbook/pages/components/switch_widgetbook.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,32 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:widgetbook/widgetbook.dart'; | ||
import 'package:zeta_flutter/zeta_flutter.dart'; | ||
|
||
import '../../test/test_components.dart'; | ||
|
||
Widget switchUseCase(BuildContext context) { | ||
bool? isOn = false; | ||
|
||
return WidgetbookTestWidget( | ||
widget: StatefulBuilder( | ||
builder: (context, setState) { | ||
ValueChanged<bool?>? onChanged = context.knobs.boolean(label: 'Enabled', initialValue: true) | ||
? (value) => setState(() => isOn = value) | ||
: null; | ||
return Padding( | ||
padding: const EdgeInsets.all(ZetaSpacing.x5), | ||
child: Column( | ||
children: [ | ||
Text('Switch'), | ||
ZetaSwitch( | ||
value: isOn, | ||
onChanged: onChanged, | ||
), | ||
Text(isOn == true ? 'On' : 'Off'), | ||
], | ||
), | ||
); | ||
}, | ||
), | ||
); | ||
} |
Oops, something went wrong.