Skip to content
Snippets Groups Projects
Select Git revision
  • 5db87aa928ee22f3b881497b79efb53d06369dd8
  • master default protected
  • 42-improve-app-metadata
  • 17-improve-and-complete-offline-words-list-and-tips
  • 6-allow-translate-application
  • 9-improve-documentation
  • Release_1.10.1_45 protected
  • Release_1.10.0_44 protected
  • Release_1.9.2_43 protected
  • Release_1.9.1_42 protected
  • Release_1.9.0_41 protected
  • Release_1.8.0_40 protected
  • Release_1.7.0_39 protected
  • Release_1.6.0_38 protected
  • Release_1.5.2_37 protected
  • Release_1.5.1_36 protected
  • Release_1.5.0_35 protected
  • Release_1.4.1_34 protected
  • Release_1.4.0_33 protected
  • Release_1.3.2_32 protected
  • Release_1.3.1_31 protected
  • Release_1.3.0_30 protected
  • Release_1.2.18_29 protected
  • Release_1.2.17_28 protected
  • Release_1.2.16_27 protected
  • Release_1.2.15_26 protected
26 results

settings.dart

Blame
  • 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,
                        ),
                      ),
                    ),
                  )
                ],
              ),
            ),
          ),
        );
      }
    }