6ad143195a
- added A LOT, TLTD Settings menu, updated homepage tiles, added color settings... - TODO: - update README - update license & copyright info - cleanup code - merge code parts to server side - complete settings - fix 11/12 - add caching - muuuuuuuch more...
68 lines
2.3 KiB
Dart
68 lines
2.3 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:MeinCantor/networking.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
Future<String> getSettingsString(String key) async {
|
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
String? value = prefs.getString(key);
|
|
if (value == null || value.isEmpty) {
|
|
value = "";
|
|
}
|
|
return value;
|
|
}
|
|
|
|
class UserSettings extends StatelessWidget {
|
|
const UserSettings({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
|
|
//TextEditingController nameController = TextEditingController(text: "Denys Konovalov");
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text("Benutzereinstellungen"),
|
|
centerTitle: true,
|
|
),
|
|
body: ListView(
|
|
padding: const EdgeInsets.fromLTRB(5, 5, 5, 5),
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.fromLTRB(10, 10, 10, 10),
|
|
child: Container(
|
|
width: 128.0,
|
|
height: 128.0,
|
|
decoration: const BoxDecoration(
|
|
shape: BoxShape.circle,
|
|
image: DecorationImage(
|
|
fit: BoxFit.scaleDown,
|
|
image: AssetImage("assets/images/meincantor_r.png")
|
|
)
|
|
)
|
|
),
|
|
),
|
|
FutureBuilder(
|
|
future: getSettingsString("name"),
|
|
builder: (context, snapshot) {
|
|
if (snapshot.hasData) {
|
|
return TextField(
|
|
decoration: const InputDecoration(
|
|
border: OutlineInputBorder(),
|
|
labelText: 'Name',
|
|
),
|
|
readOnly: true,
|
|
controller: TextEditingController(text: snapshot.data as String),
|
|
);
|
|
} else {
|
|
return (const Center(child: CircularProgressIndicator()));
|
|
}
|
|
}
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.fromLTRB(5, 20, 5, 5),
|
|
child: buildClassesChooser()
|
|
),
|
|
],
|
|
));
|
|
}
|
|
} |