pubspec + remove transition
This commit is contained in:
parent
b6142ef395
commit
92927bd1c4
@ -15,12 +15,24 @@ void main() {
|
||||
),
|
||||
),
|
||||
// Providers pour la gestion de l'état
|
||||
Provider<PageTransitionsTheme>(
|
||||
create: (_) => PageTransitionsTheme(
|
||||
builders: {
|
||||
TargetPlatform.android: NoTransitionsBuilder(),
|
||||
TargetPlatform.iOS: NoTransitionsBuilder(),
|
||||
TargetPlatform.windows: NoTransitionsBuilder(),
|
||||
TargetPlatform.linux: NoTransitionsBuilder(),
|
||||
TargetPlatform.macOS: NoTransitionsBuilder(),
|
||||
},
|
||||
),
|
||||
),
|
||||
ChangeNotifierProvider(create: (context) => CellListProvider()),
|
||||
ChangeNotifierProvider(create: (context) => ArticleListProvider()),
|
||||
ChangeNotifierProvider(create: (context) => SettingsProvider()),
|
||||
ChangeNotifierProvider(
|
||||
create: (context) =>
|
||||
UserProvider(context.read<LocalUserRepository>()),
|
||||
create: (context) => UserProvider(
|
||||
context.read<LocalUserRepository>(),
|
||||
),
|
||||
),
|
||||
],
|
||||
child: const MainApp(), // Maintenant MainApp a accès aux providers
|
||||
@ -40,7 +52,6 @@ class MainApp extends StatelessWidget {
|
||||
routes: {
|
||||
'/': (context) => const LoginScreen(),
|
||||
'/lobby': (context) => const Lobby(),
|
||||
'/settings': (context) => const Settings(),
|
||||
'/blog': (context) => const Blog(),
|
||||
},
|
||||
);
|
||||
|
@ -32,15 +32,10 @@ class SettingsProvider with ChangeNotifier {
|
||||
}
|
||||
|
||||
void changeThemeColor(Color color) {
|
||||
_state = _state.copyWith(theme: _state.theme.copyWith(primaryColor: color));
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void reset() {
|
||||
_state = _state.copyWith(theme: ThemeData.dark());
|
||||
_state = _state.copyWith(
|
||||
theme: _state.theme.copyWith(primaryColor: Colors.blue));
|
||||
theme: _state.theme.copyWith(primaryColor: color),
|
||||
);
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ class SettingsState extends Equatable {
|
||||
return SettingsState(
|
||||
theme: ThemeData.dark().copyWith(
|
||||
primaryColor: Colors.blue,
|
||||
pageTransitionsTheme: pageTransitionTheme,
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -18,9 +19,35 @@ class SettingsState extends Equatable {
|
||||
@override
|
||||
List<Object?> get props => [theme];
|
||||
|
||||
SettingsState copyWith({ThemeData? theme}) {
|
||||
SettingsState copyWith({
|
||||
ThemeData? theme,
|
||||
}) {
|
||||
return SettingsState(
|
||||
theme: theme ?? this.theme,
|
||||
theme: theme?.copyWith(pageTransitionsTheme: pageTransitionTheme) ??
|
||||
this.theme.copyWith(pageTransitionsTheme: pageTransitionTheme),
|
||||
);
|
||||
}
|
||||
|
||||
static var pageTransitionTheme = PageTransitionsTheme(
|
||||
builders: {
|
||||
TargetPlatform.android: NoTransitionsBuilder(),
|
||||
TargetPlatform.iOS: NoTransitionsBuilder(),
|
||||
TargetPlatform.windows: NoTransitionsBuilder(),
|
||||
TargetPlatform.linux: NoTransitionsBuilder(),
|
||||
TargetPlatform.macOS: NoTransitionsBuilder(),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
class NoTransitionsBuilder extends PageTransitionsBuilder {
|
||||
@override
|
||||
Widget buildTransitions<T>(
|
||||
PageRoute<T> route,
|
||||
BuildContext context,
|
||||
Animation<double> animation,
|
||||
Animation<double> secondaryAnimation,
|
||||
Widget child,
|
||||
) {
|
||||
return child;
|
||||
}
|
||||
}
|
||||
|
@ -1,261 +1,12 @@
|
||||
import 'package:board_game/src/providers/providers.dart';
|
||||
import 'package:board_game/src/widgets/color_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
enum SettingStateEnum { appearance, sound, language }
|
||||
|
||||
class Settings extends StatefulWidget {
|
||||
const Settings({super.key});
|
||||
|
||||
@override
|
||||
State<Settings> createState() => _SettingsState();
|
||||
}
|
||||
|
||||
class _SettingsState extends State<Settings> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
SettingStateEnum _state = SettingStateEnum.appearance;
|
||||
bool themeValue = true;
|
||||
bool soundNotification = true;
|
||||
bool languageRegionUS = true;
|
||||
|
||||
final TextStyle _textStyle = const TextStyle(fontSize: 16.0);
|
||||
|
||||
void _resetSettings() {
|
||||
if (!themeValue) {
|
||||
context.read<SettingsProvider>().reset();
|
||||
}
|
||||
|
||||
// setState(() {
|
||||
// themeValue = true;
|
||||
// soundNotification = true;
|
||||
// languageRegionUS = true;
|
||||
// });
|
||||
}
|
||||
class MyWidget extends StatelessWidget {
|
||||
const MyWidget({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
title: Text('Little Strategy Settings', style: _textStyle),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.save),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
),
|
||||
drawer: MediaQuery.of(context).size.width < 768 ? Drawer(child: _buildMenu()) : null,
|
||||
body: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
if (constraints.maxWidth >= 768) {
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: _buildMenu(),
|
||||
),
|
||||
const VerticalDivider(),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: _buildContentColumn(),
|
||||
),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(child: _buildContentColumn()),
|
||||
],
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMenu() {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text('Appearance',
|
||||
style: _state == SettingStateEnum.appearance
|
||||
? _textStyle.copyWith(fontWeight: FontWeight.bold)
|
||||
: _textStyle),
|
||||
onTap: () => setState(() => _state = SettingStateEnum.appearance),
|
||||
),
|
||||
ListTile(
|
||||
title: Text('Sound',
|
||||
style: _state == SettingStateEnum.sound
|
||||
? _textStyle.copyWith(fontWeight: FontWeight.bold)
|
||||
: _textStyle),
|
||||
onTap: () => setState(() => _state = SettingStateEnum.sound),
|
||||
),
|
||||
ListTile(
|
||||
title: Text('Language',
|
||||
style: _state == SettingStateEnum.language
|
||||
? _textStyle.copyWith(fontWeight: FontWeight.bold)
|
||||
: _textStyle),
|
||||
onTap: () => setState(() => _state = SettingStateEnum.language),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildContentColumn() {
|
||||
return AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
child: _state == SettingStateEnum.appearance
|
||||
? _buildAppearanceSettings()
|
||||
: _state == SettingStateEnum.sound
|
||||
? _buildSoundSettings()
|
||||
: _buildLanguageSettings(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAppearanceSettings() {
|
||||
return ListView(
|
||||
key: const ValueKey('appearance'),
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text('Theme Settings',
|
||||
style: _textStyle.copyWith(fontSize: 18.0, fontWeight: FontWeight.bold)),
|
||||
),
|
||||
SwitchListTile(
|
||||
title: const Text('Dark Mode'),
|
||||
value: context.watch<SettingsProvider>().state.theme.brightness == Brightness.dark,
|
||||
onChanged: (v) {
|
||||
context.read<SettingsProvider>().toggleTheme();
|
||||
setState(() {
|
||||
themeValue = v;
|
||||
});
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: const Text('Theme Color'),
|
||||
trailing: const Icon(Icons.color_lens, color: Colors.blue),
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const AlertDialog(
|
||||
title: Text('Choose a color'),
|
||||
content: SingleChildScrollView(
|
||||
child: ColorPicker(),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: TextButton(
|
||||
onPressed: _resetSettings,
|
||||
style: TextButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12.0, vertical: 8.0),
|
||||
backgroundColor: Colors.grey[200],
|
||||
foregroundColor: Colors.black,
|
||||
),
|
||||
child: const Text('Réinitialiser les paramètres'),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSoundSettings() {
|
||||
return ListView(
|
||||
key: const ValueKey('sound'),
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text('Sound Settings',
|
||||
style: _textStyle.copyWith(fontSize: 18.0, fontWeight: FontWeight.bold)),
|
||||
),
|
||||
ListTile(
|
||||
title: const Text('Volume'),
|
||||
trailing: const Icon(Icons.volume_up),
|
||||
onTap: () {},
|
||||
),
|
||||
SwitchListTile(
|
||||
title: const Text('Notifications'),
|
||||
value: soundNotification,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
soundNotification = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: const Text('Ringtone'),
|
||||
trailing: const Icon(Icons.music_note),
|
||||
onTap: () {},
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: TextButton(
|
||||
onPressed: _resetSettings,
|
||||
style: TextButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12.0, vertical: 8.0),
|
||||
backgroundColor: Colors.grey[200],
|
||||
foregroundColor: Colors.black,
|
||||
),
|
||||
child: const Text('Réinitialiser les paramètres'),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLanguageSettings() {
|
||||
return ListView(
|
||||
key: const ValueKey('language'),
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text('Language Settings',
|
||||
style: _textStyle.copyWith(fontSize: 18.0, fontWeight: FontWeight.bold)),
|
||||
),
|
||||
ListTile(
|
||||
title: const Text('App Language'),
|
||||
trailing: Text('English', style: _textStyle),
|
||||
onTap: () {},
|
||||
),
|
||||
SwitchListTile(
|
||||
title: const Text('Preferred Region: US'),
|
||||
value: languageRegionUS,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
languageRegionUS = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: TextButton(
|
||||
onPressed: _resetSettings,
|
||||
style: TextButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12.0, vertical: 8.0),
|
||||
backgroundColor: Colors.grey[200],
|
||||
foregroundColor: Colors.black,
|
||||
),
|
||||
child: const Text('Réinitialiser les paramètres'),
|
||||
),
|
||||
),
|
||||
],
|
||||
return Center(
|
||||
child: Text('Settings - Old'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user