You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
107 lines
3.2 KiB
107 lines
3.2 KiB
import 'package:flutter/material.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
import 'package:teso/util/consts.dart';
|
|
import 'package:teso/providers/user_provider.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
class Gender extends StatefulWidget {
|
|
final int value;
|
|
|
|
const Gender({Key key, this.value}) : super(key: key);
|
|
@override
|
|
_GenderState createState() => _GenderState(value: this.value);
|
|
}
|
|
|
|
class _GenderState extends State<Gender> {
|
|
int value;
|
|
_GenderState({this.value});
|
|
List<String> genders = ["Male", "Female", "Other"];
|
|
bool light = true;
|
|
|
|
@override
|
|
void initState() {
|
|
SharedPreferences.getInstance().then((prefs) {
|
|
setState(() {
|
|
light = prefs.getString("theme") == "dark" ? false : true;
|
|
});
|
|
});
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: Text("Gender"),
|
|
leading: IconButton(
|
|
icon: Icon(Icons.arrow_back_ios),
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
),
|
|
actions: <Widget>[
|
|
new Container(
|
|
margin: EdgeInsets.symmetric(vertical: 0.0, horizontal: 20),
|
|
child: new Center(
|
|
child: ElevatedButton(
|
|
style: ElevatedButton.styleFrom(
|
|
primary: Theme.of(context).colorScheme.secondary,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.all(
|
|
Radius.circular(25.0),
|
|
),
|
|
),
|
|
),
|
|
onPressed: () {
|
|
Provider.of<UserProvider>(context, listen: false)
|
|
.currentUser
|
|
.gender = genders[value];
|
|
Navigator.of(context).pop(value);
|
|
},
|
|
child: Text("Done"),
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
body: Container(
|
|
child: Column(
|
|
children: <Widget>[
|
|
for (int i = 0; i < genders.length; i++)
|
|
Column(
|
|
children: [
|
|
ListTile(
|
|
title: Text(
|
|
genders[i],
|
|
style: Theme.of(context).textTheme.subtitle1.copyWith(
|
|
color: light
|
|
? i == 3
|
|
? Colors.black38
|
|
: Colors.black
|
|
: i == 3
|
|
? Colors.white10
|
|
: Colors.white,
|
|
),
|
|
),
|
|
trailing: Radio(
|
|
value: i,
|
|
groupValue: value,
|
|
activeColor: accentMain,
|
|
onChanged: i == 3
|
|
? null
|
|
: (int _value) {
|
|
setState(() {
|
|
value = _value;
|
|
});
|
|
},
|
|
),
|
|
),
|
|
Divider(),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|