petitspas/frontend/lib/screens/home/home_screen.dart

54 lines
1.5 KiB
Dart

import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../../theme/theme_provider.dart';
import '../../theme/app_theme.dart';
class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
String _getThemeName(ThemeType type) {
switch (type) {
case ThemeType.defaultTheme:
return "P'titsPas";
case ThemeType.pastelTheme:
return "Pastel";
case ThemeType.darkTheme:
return "Sombre";
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Accueil'),
actions: [
Consumer<ThemeProvider>(
builder: (context, themeProvider, child) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: DropdownButton<ThemeType>(
value: themeProvider.currentTheme,
items: ThemeType.values.map((ThemeType type) {
return DropdownMenuItem<ThemeType>(
value: type,
child: Text(_getThemeName(type)),
);
}).toList(),
onChanged: (ThemeType? newValue) {
if (newValue != null) {
themeProvider.setTheme(newValue);
}
},
),
);
},
),
],
),
body: const Center(
child: Text('Bienvenue sur P\'titsPas !'),
),
);
}
}