95 lines
2.3 KiB
Dart
95 lines
2.3 KiB
Dart
import 'package:fast_network_navigation/structs/preferences.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
class ProfilePage extends StatefulWidget {
|
|
@override
|
|
_ProfilePageState createState() => _ProfilePageState();
|
|
}
|
|
|
|
class _ProfilePageState extends State<ProfilePage> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ListView(
|
|
children: [
|
|
// First a round, centered image
|
|
Center(
|
|
child: CircleAvatar(
|
|
radius: 100,
|
|
child: Icon(Icons.person, size: 100),
|
|
)
|
|
),
|
|
Center(
|
|
child: Text('Curious traveler', style: TextStyle(fontSize: 24))
|
|
),
|
|
|
|
Padding(padding: EdgeInsets.all(10)),
|
|
Divider(indent: 25, endIndent: 25),
|
|
Padding(padding: EdgeInsets.all(10)),
|
|
|
|
Padding(
|
|
padding: EdgeInsets.only(left: 10, right: 10, top: 0, bottom: 10),
|
|
child: Text('Please rate your personal preferences so that we can taylor your experience.', style: TextStyle(fontSize: 18))
|
|
),
|
|
|
|
// Now the sliders
|
|
ImportanceSliders()
|
|
]
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
class ImportanceSliders extends StatefulWidget {
|
|
|
|
@override
|
|
State<ImportanceSliders> createState() => _ImportanceSlidersState();
|
|
}
|
|
|
|
|
|
class _ImportanceSlidersState extends State<ImportanceSliders> {
|
|
|
|
final UserPreferences _prefs = UserPreferences();
|
|
|
|
@override
|
|
void initState() {
|
|
_prefs.load();
|
|
super.initState();
|
|
}
|
|
|
|
List<Card> _createSliders() {
|
|
List<Card> sliders = [];
|
|
for (SinglePreference pref in _prefs.preferences) {
|
|
sliders.add(Card(
|
|
child: ListTile(
|
|
leading: pref.icon,
|
|
title: Text(pref.name),
|
|
subtitle: Slider(
|
|
value: pref.value.toDouble(),
|
|
min: 0,
|
|
max: 10,
|
|
divisions: 10,
|
|
label: pref.value.toString(),
|
|
onChanged: (double newValue) {
|
|
setState(() {
|
|
pref.value = newValue.toInt();
|
|
_prefs.save();
|
|
});
|
|
},
|
|
)
|
|
),
|
|
margin: const EdgeInsets.only(left: 10, right: 10, top: 10, bottom: 0),
|
|
shadowColor: Colors.grey,
|
|
));
|
|
}
|
|
return sliders;
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(children: _createSliders());
|
|
}
|
|
}
|