102 lines
2.9 KiB
Dart
102 lines
2.9 KiB
Dart
import 'package:adaptive_theme/adaptive_theme.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:gap/gap.dart';
|
|
import 'package:wyatt_ui_kit_example/buttons/buttons.dart';
|
|
import 'package:wyatt_ui_kit_example/cards/cards.dart';
|
|
import 'package:wyatt_ui_kit_example/theme/themes.dart';
|
|
|
|
const String title = 'Wyatt UIKit Example';
|
|
|
|
class Home extends StatefulWidget {
|
|
const Home({super.key, this.forceIndex = 0});
|
|
|
|
final int forceIndex;
|
|
|
|
@override
|
|
State<Home> createState() => _HomeState();
|
|
}
|
|
|
|
class _HomeState extends State<Home> {
|
|
final List<Widget> pages = const [Cards(), Buttons()];
|
|
|
|
int currentIndex = 0;
|
|
|
|
@override
|
|
void initState() {
|
|
currentIndex = widget.forceIndex;
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) => Scaffold(
|
|
drawer: Drawer(
|
|
child: ListView(
|
|
padding: EdgeInsets.zero,
|
|
children: [
|
|
ListTile(
|
|
title: const Text('Cards'),
|
|
onTap: () {
|
|
if (currentIndex != 0) {
|
|
setState(() {
|
|
currentIndex = 0;
|
|
});
|
|
Navigator.pop(context);
|
|
}
|
|
},
|
|
),
|
|
ListTile(
|
|
title: const Text('Buttons'),
|
|
onTap: () {
|
|
if (currentIndex != 1) {
|
|
setState(() {
|
|
currentIndex = 1;
|
|
});
|
|
Navigator.pop(context);
|
|
}
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
appBar: AppBar(
|
|
title: const Text(title),
|
|
actions: [
|
|
Row(
|
|
children: [
|
|
const Text('Mode'),
|
|
Switch.adaptive(
|
|
value:
|
|
AdaptiveTheme.of(context).brightness == Brightness.dark,
|
|
onChanged: (_) {
|
|
AdaptiveTheme.of(context).brightness == Brightness.light
|
|
? AdaptiveTheme.of(context).setDark()
|
|
: AdaptiveTheme.of(context).setLight();
|
|
},
|
|
),
|
|
],
|
|
),
|
|
const Gap(30),
|
|
Row(
|
|
children: [
|
|
const Text('Studio'),
|
|
Switch.adaptive(
|
|
value: Themes.currentThemeIndex == 1,
|
|
onChanged: (_) {
|
|
setState(() {
|
|
Themes.currentThemeIndex =
|
|
(Themes.currentThemeIndex == 1) ? 0 : 1;
|
|
});
|
|
Themes.auto(context);
|
|
},
|
|
),
|
|
],
|
|
)
|
|
],
|
|
),
|
|
body: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
|
child: pages[currentIndex],
|
|
),
|
|
);
|
|
}
|