mirror of
https://github.com/hanskokx/arcane_framework.git
synced 2026-05-14 10:29:06 +02:00
+44
-25
@@ -81,17 +81,37 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final bool isSignedIn = Arcane.auth.isSignedIn.value;
|
final bool isSignedIn = Arcane.auth.isSignedIn.value;
|
||||||
return Center(
|
return GridView.extent(
|
||||||
child: SingleChildScrollView(
|
maxCrossAxisExtent: 300,
|
||||||
child: Column(
|
padding: const EdgeInsets.all(16),
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
children: [
|
||||||
Card(
|
Card(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
|
Text(
|
||||||
|
"Theme",
|
||||||
|
style: Theme.of(context).textTheme.headlineSmall,
|
||||||
|
),
|
||||||
Column(
|
Column(
|
||||||
|
children: [
|
||||||
|
Switch(
|
||||||
|
value: Arcane.theme.currentTheme == ThemeMode.dark,
|
||||||
|
thumbIcon: WidgetStateProperty.resolveWith((states) {
|
||||||
|
if (states.contains(WidgetState.selected)) {
|
||||||
|
return const Icon(Icons.dark_mode);
|
||||||
|
}
|
||||||
|
return const Icon(Icons.light_mode);
|
||||||
|
}),
|
||||||
|
onChanged: (_) {
|
||||||
|
Arcane.theme.switchTheme();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Checkbox(
|
Checkbox(
|
||||||
value: Arcane.theme.isFollowingSystemTheme,
|
value: Arcane.theme.isFollowingSystemTheme,
|
||||||
@@ -105,20 +125,10 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const Text("Use system theme"),
|
const Text("Follow system"),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Switch(
|
],
|
||||||
value: Arcane.theme.currentTheme == ThemeMode.dark,
|
|
||||||
thumbIcon: WidgetStateProperty.resolveWith((states) {
|
|
||||||
if (states.contains(WidgetState.selected)) {
|
|
||||||
return const Icon(Icons.dark_mode);
|
|
||||||
}
|
|
||||||
return const Icon(Icons.light_mode);
|
|
||||||
}),
|
|
||||||
onChanged: (_) {
|
|
||||||
Arcane.theme.switchTheme();
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
"The current theme mode is ${context.themeMode.name} and\n"
|
"The current theme mode is ${context.themeMode.name} and\n"
|
||||||
@@ -129,24 +139,27 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Card(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Authentication status: ${Arcane.auth.status.name}",
|
"Authentication",
|
||||||
|
style: Theme.of(context).textTheme.headlineSmall,
|
||||||
),
|
),
|
||||||
if (isSignedIn)
|
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
child: const Text("Sign out"),
|
child: Text(isSignedIn ? "Sign out" : "Sign in"),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
|
if (isSignedIn) {
|
||||||
await Arcane.auth.logOut(
|
await Arcane.auth.logOut(
|
||||||
onLoggedOut: () async {
|
onLoggedOut: () async {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
} else {
|
||||||
),
|
|
||||||
if (!isSignedIn)
|
|
||||||
ElevatedButton(
|
|
||||||
child: const Text("Sign in"),
|
|
||||||
onPressed: () async {
|
|
||||||
await Arcane.auth.login<Credentials>(
|
await Arcane.auth.login<Credentials>(
|
||||||
input: (
|
input: (
|
||||||
email: "email",
|
email: "email",
|
||||||
@@ -156,11 +169,17 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
setState(() {});
|
setState(() {});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
Center(
|
||||||
|
child: Text("Status: ${Arcane.auth.status.name}"),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user