Erweiterungen
This commit is contained in:
1 parent
cb4525a774
commit
5c3cee2d92
10 files changed
+466
-54
No files matched your search
+59
-17
@@ -1,6 +1,8 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:stadtbote/tools/constants.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
import '../Tools/colored_safe_area.dart';
|
||||
@@ -16,8 +18,7 @@ class Util {
|
||||
await prefs.setString(key, value);
|
||||
}
|
||||
|
||||
static Future<String?> preferencesGetString(
|
||||
String key, String? defaultValue) async {
|
||||
static Future<String?> preferencesGetString(String key, String? defaultValue) async {
|
||||
if (await preferencesContainsKey(key)) {
|
||||
var prefs = await SharedPreferences.getInstance();
|
||||
return prefs.getString(key);
|
||||
@@ -109,11 +110,61 @@ class Util {
|
||||
return icon;
|
||||
});
|
||||
}
|
||||
|
||||
static TextField getDefaultTextField(String hint,
|
||||
{TextEditingController? controller,
|
||||
FocusNode? focusNode,
|
||||
IconButton? iconButton,
|
||||
int? maxLines = 1,
|
||||
TextInputType? type,
|
||||
List<TextInputFormatter>? formatter,
|
||||
Function()? onTap,
|
||||
bool? autofocus}) {
|
||||
iconButton ??= IconButton(
|
||||
icon: const Icon(Icons.clear),
|
||||
onPressed: () {
|
||||
if (controller != null) {
|
||||
controller.text = "";
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
return TextField(
|
||||
controller: controller,
|
||||
focusNode: focusNode,
|
||||
maxLines: maxLines,
|
||||
onTap: onTap,
|
||||
keyboardType: type,
|
||||
inputFormatters: formatter,
|
||||
autofocus: (autofocus != null) ? autofocus : false,
|
||||
decoration: InputDecoration(
|
||||
hintText: hint,
|
||||
contentPadding: const EdgeInsets.all(10),
|
||||
border: Util.getDefaultBorder(),
|
||||
errorBorder: Util.getDefaultBorder(),
|
||||
disabledBorder: Util.getDefaultBorder(),
|
||||
focusedBorder: Util.getDefaultFocusedBorder(),
|
||||
focusedErrorBorder: Util.getDefaultBorder(),
|
||||
suffixIcon: iconButton,
|
||||
labelText: hint),
|
||||
);
|
||||
}
|
||||
|
||||
static OutlineInputBorder getDefaultBorder() {
|
||||
return const OutlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(20.0)));
|
||||
}
|
||||
|
||||
static OutlineInputBorder getDefaultFocusedBorder() {
|
||||
return const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Constants.colorPrimary),
|
||||
borderRadius: BorderRadius.all(Radius.circular(20.0)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget getDefaultButton(String text, Function() onPressed, {Image? image}) {
|
||||
Widget getDefaultButton(String text, Function() onPressed, {Image? image, double? buttonHeight}) {
|
||||
return SizedBox(
|
||||
height: 60,
|
||||
height: buttonHeight ?? 60,
|
||||
child: Stack(
|
||||
children: [
|
||||
Row(
|
||||
@@ -137,30 +188,21 @@ Widget getDefaultButton(String text, Function() onPressed, {Image? image}) {
|
||||
onPressed: () {
|
||||
onPressed();
|
||||
},
|
||||
child: Text(text)
|
||||
),
|
||||
child: Text(text)),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Positioned(
|
||||
left: 20,
|
||||
top: 15,
|
||||
child: Center(
|
||||
child: image
|
||||
)
|
||||
)
|
||||
Positioned(left: 20, top: 15, child: Center(child: image))
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String mapTourMode(String mode)
|
||||
{
|
||||
String mapTourMode(String mode) {
|
||||
var text = "";
|
||||
switch (mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case "pu":
|
||||
text += "/ Abholung";
|
||||
break;
|
||||
|
||||
Reference in new issue
Block a user