This repository has been archived on 2023-06-24. You can view files and clone it, but cannot push or open issues or pull requests.
meincantor-app/lib/Settings/Pages/user_settings.dart
Denys Konovalov 6ad143195a ==0.7.5==
- 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...
2021-11-06 11:01:44 +01:00

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