Select Git revision
settings.dart
settings.dart 2.82 KiB
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../provider/data.dart';
import '../utils/constants.dart';
class Settings extends StatelessWidget {
static const String id = 'settings';
@override
Widget build(BuildContext context) {
Data _myProvider = Provider.of<Data>(context);
return Scaffold(
appBar: AppBar(title: Text('Réglages')),
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.only(top: 30.0, left: 30.0, right: 30.0),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('Mode en ligne'),
Switch(
value: _myProvider.gameModeValue,
onChanged: (bool value) => _myProvider.updateGameMode = value,
activeTrackColor: Color(board),
activeColor: Colors.greenAccent[400],
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('Niveau'),
DropdownButton<String>(
value: _myProvider.levelValue ?? onlineGameMode[_myProvider.gameModeValue].first,
items: onlineGameMode[_myProvider.gameModeValue]
.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
onChanged: (String value) => _myProvider.updateLevel = value,
),
],
),
Divider(color: Colors.grey),
Padding(
padding: const EdgeInsets.only(top: 20.0),
child: RaisedButton.icon(
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(10.0))),
color: Color(board),
padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0),
onPressed: () {
_myProvider.setPrefGameMode = _myProvider.gameModeValue;
_myProvider.setPrefLevel = _myProvider.levelValue;
Navigator.pop(context);
},
icon: Icon(Icons.save, color: Colors.white),
label: Text(
'Enregistrer',
style: TextStyle(
color: Colors.white,
fontSize: 18.0,
),
),
),
)
],
),
),
),
);
}
}