Skip to content

Commit

Permalink
add branding in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
simonsasse committed Jun 9, 2022
1 parent 1268576 commit 798c248
Show file tree
Hide file tree
Showing 3 changed files with 174 additions and 100 deletions.
Binary file added assets/branding_low.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
273 changes: 173 additions & 100 deletions lib/screens/main/settings_screen.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:quellenreiter_app/models/quellenreiter_app_state.dart';
import 'package:quellenreiter_app/utilities/utilities.dart';
import 'package:url_launcher/url_launcher.dart';

import '../../constants/constants.dart';

class SettingsScreen extends StatefulWidget {
const SettingsScreen({Key? key, required this.appState}) : super(key: key);
Expand Down Expand Up @@ -36,121 +40,190 @@ class _SettingsScreenState extends State<SettingsScreen> {

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(20),
child: ListView(
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
children: [
ValueListenableBuilder(
valueListenable: emojiController,
builder: (context, TextEditingValue value, __) {
return Row(
children: [
Expanded(
child: TextField(
controller: emojiController,
inputFormatters: [
FilteringTextInputFormatter.allow(Utils.regexEmoji),
],
maxLength: 1,
decoration: const InputDecoration(
hintText: "Gebe einen neuen Emoji ein.",
border: UnderlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10),
),
return ListView(
padding: const EdgeInsets.all(10),
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
children: [
ValueListenableBuilder(
valueListenable: emojiController,
builder: (context, TextEditingValue value, __) {
return Row(
children: [
Expanded(
child: TextField(
controller: emojiController,
inputFormatters: [
FilteringTextInputFormatter.allow(Utils.regexEmoji),
],
maxLength: 1,
decoration: const InputDecoration(
hintText: "Gebe einen neuen Emoji ein.",
border: UnderlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10),
),
),
filled: true,
fillColor: Colors.transparent,
contentPadding: EdgeInsets.all(10),
),
),
),
Flexible(
child: ElevatedButton.icon(
onPressed:
emojiController.text != widget.appState.player!.emoji &&
emojiController.text.isNotEmpty
? () {
HapticFeedback.selectionClick();
FocusManager.instance.primaryFocus?.unfocus();
widget.appState.player?.emoji =
emojiController.text;
widget.appState.updateUserData();
}
: null,
icon: const Icon(Icons.emoji_emotions),
label: const Text("Emoji ändern"),
),
),
],
);
},
),
ValueListenableBuilder(
valueListenable: usernameController,
builder: (context, TextEditingValue value, __) {
return Row(
children: [
Expanded(
child: TextField(
inputFormatters: [
UsernameTextFormatter(),
FilteringTextInputFormatter.allow(Utils.regexUsername),
],
enableSuggestions: false,
autocorrect: false,
textCapitalization: TextCapitalization.none,
controller: usernameController,
autofillHints: const [AutofillHints.newUsername],
decoration: const InputDecoration(
hintText: "Gebe einen neuen Username ein.",
border: UnderlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10),
),
filled: true,
fillColor: Colors.transparent,
contentPadding: EdgeInsets.all(10),
),
filled: true,
fillColor: Colors.transparent,
contentPadding: EdgeInsets.all(10),
),
),
Flexible(
child: ElevatedButton.icon(
onPressed: emojiController.text !=
widget.appState.player!.emoji &&
emojiController.text.isNotEmpty
),
ElevatedButton.icon(
onPressed:
usernameController.text != widget.appState.player!.name &&
usernameController.text.length >=
Utils.usernameMinLength
? () {
HapticFeedback.selectionClick();
FocusManager.instance.primaryFocus?.unfocus();
widget.appState.player?.emoji =
emojiController.text;
widget.appState.updateUserData();
widget.appState.player?.name =
usernameController.text;
widget.appState.updateUser();
}
: null,
icon: const Icon(Icons.emoji_emotions),
label: const Text("Emoji ändern"),
icon: const Icon(Icons.switch_access_shortcut),
label: const Text("Username ändern."),
),
],
);
},
),
ElevatedButton.icon(
onPressed: () {
HapticFeedback.heavyImpact();
widget.appState.logout();
},
icon: const Icon(Icons.logout),
label: const Text("Abmelden"),
),
ElevatedButton.icon(
onPressed: () {
HapticFeedback.heavyImpact();
showModalBottomSheet(
backgroundColor: Colors.transparent,
context: context,
builder: (BuildContext context) {
return Container(
padding: const EdgeInsets.only(top: 50),
height: MediaQuery.of(context).size.height * 0.75,
decoration: BoxDecoration(
color: Colors.grey[800],
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(15),
topRight: Radius.circular(15),
),
),
),
],
);
},
),
ValueListenableBuilder(
valueListenable: usernameController,
builder: (context, TextEditingValue value, __) {
return Row(
children: [
Expanded(
child: TextField(
inputFormatters: [
UsernameTextFormatter(),
FilteringTextInputFormatter.allow(Utils.regexUsername),
],
enableSuggestions: false,
autocorrect: false,
textCapitalization: TextCapitalization.none,
controller: usernameController,
autofillHints: const [AutofillHints.newUsername],
decoration: const InputDecoration(
hintText: "Gebe einen neuen Username ein.",
border: UnderlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10),
child: Column(
children: [
const Icon(
Icons.warning_amber_rounded,
color: DesignColors.red,
size: 200,
),
Text(
"Willst du deinen Account wirklich für immer löschen?",
style: Theme.of(context).textTheme.subtitle1,
),
ElevatedButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color>(
DesignColors.red),
),
onPressed: () {},
child: Text("Ich bin sicher."),
),
filled: true,
fillColor: Colors.transparent,
contentPadding: EdgeInsets.all(10),
),
],
),
),
ElevatedButton.icon(
onPressed: usernameController.text !=
widget.appState.player!.name &&
usernameController.text.length >=
Utils.usernameMinLength
? () {
HapticFeedback.selectionClick();
FocusManager.instance.primaryFocus?.unfocus();
widget.appState.player?.name =
usernameController.text;
widget.appState.updateUser();
}
: null,
icon: const Icon(Icons.switch_access_shortcut),
label: const Text("Username ändern."),
),
],
);
},
),
ElevatedButton.icon(
onPressed: () {
HapticFeedback.heavyImpact();
widget.appState.logout();
},
icon: const Icon(Icons.logout),
label: const Text("Abmelden"),
);
});
},
icon: const Icon(Icons.delete_forever),
label: const Text("Account löschen"),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color>(DesignColors.red),
),
ElevatedButton.icon(
onPressed: () => {},
icon: const Icon(Icons.delete_forever),
label: const Text("Account löschen"),
),
Padding(padding: const EdgeInsets.only(top: 30), child: Divider()),
Padding(
padding: const EdgeInsets.all(30),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Image(
image: AssetImage("assets/branding_low.png"),
),
Padding(
padding: const EdgeInsets.all(10),
child: Text(
"Made in Berlin with ❤️ and ☕.",
style: Theme.of(context).textTheme.subtitle1,
),
),
TextButton(
onPressed: () async {
HapticFeedback.mediumImpact();
if (!await launch("https://quellenreiter.app")) {
throw 'could not launch';
}
},
child: Text("QuellenReiter.app"),
),
],
),
],
),
),
],
);
}
}
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ flutter:
assets:
- assets/logo-pink.png
- assets/branding.png
- assets/branding_low.png

# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
Expand Down

0 comments on commit 798c248

Please sign in to comment.