mirror of
https://github.com/hanskokx/arcane_framework.git
synced 2026-05-14 02:19:08 +02:00
Fixed a bug in the example
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
+26
-14
@@ -152,8 +152,11 @@ class _ArcaneLoggingExampleState extends State<ArcaneLoggingExample> {
|
||||
builder: (context, enabledFeatures, _) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Card(
|
||||
child: SizedBox(
|
||||
height: 200,
|
||||
height: MediaQuery.sizeOf(context).height / 2,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@@ -186,6 +189,8 @@ class _ArcaneLoggingExampleState extends State<ArcaneLoggingExample> {
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -544,6 +549,11 @@ class ArcaneServicesExample extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final FavoriteColorService? service =
|
||||
ArcaneServiceProvider.serviceOfType<FavoriteColorService>(context);
|
||||
final ValueNotifier<MaterialColor?> notifier =
|
||||
service?.notifier ?? ValueNotifier(null);
|
||||
return ValueListenableBuilder(
|
||||
valueListenable: notifier,
|
||||
builder: (context, color, _) {
|
||||
return Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
@@ -555,16 +565,8 @@ class ArcaneServicesExample extends StatelessWidget {
|
||||
"Services",
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
),
|
||||
ValueListenableBuilder(
|
||||
valueListenable: ArcaneService.ofType<FavoriteColorService>(
|
||||
context,
|
||||
)?.notifier ??
|
||||
ValueNotifier(null),
|
||||
builder: (context, color, _) {
|
||||
return Text(
|
||||
Text(
|
||||
color != null ? "Favorite color: ${color.name}" : "",
|
||||
);
|
||||
},
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
@@ -587,7 +589,9 @@ class ArcaneServicesExample extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Text('${service == null ? 'Register' : 'Remove'} service'),
|
||||
child: Text(
|
||||
'${service == null ? 'Register' : 'Remove'} service',
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
@@ -604,7 +608,14 @@ class ArcaneServicesExample extends StatelessWidget {
|
||||
itemBuilder: (context, index) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
service?.setMyFavoriteColor(colors[index]);
|
||||
if (service == null) {
|
||||
Arcane.log(
|
||||
"FavoriteColorService is not registered",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
service.setMyFavoriteColor(colors[index]);
|
||||
Arcane.log(
|
||||
"Set a color in FavoriteColorService",
|
||||
metadata: {
|
||||
@@ -615,8 +626,7 @@ class ArcaneServicesExample extends StatelessWidget {
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: colors[index],
|
||||
border: service?.myFavoriteColor?.name ==
|
||||
colors[index].name
|
||||
border: color?.name == colors[index].name
|
||||
? Border.all(width: 2)
|
||||
: null,
|
||||
),
|
||||
@@ -637,5 +647,7 @@ class ArcaneServicesExample extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user