Erweiterungen

This commit is contained in:
Sven committed 2023-11-14 14:57:57 +01:00
1 parent cb4525a774
commit 5c3cee2d92
10 files changed
+466 -54

No files matched your search

+4 -3
View File
@@ -1,11 +1,12 @@
import 'dart:ui';
class Constants {
static const Color colorPrimary = Color(0xff0095DB);
static const String messageTopicConnectionStatusChanged = "connection_status_changed";
static const String messageTopicPushContentView = "push_content_view";
static const String messageTopicPopContentView = "pop_content_view";
static const String messageTopicReplaceContentView = "replace_content_view";
static const String messageTopicHideRightButton = "hide_right_button";
static const String messageShowPopup = "show_popup";
//static const String topicToServer = "/app/100/2/208738/to_server";
//static const String topicFromServer = "/app/100/2/208738/from_server";
}
+59 -17
View File
@@ -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;