feat: Send optional message with images or files
This commit is contained in:
parent
00d219bae1
commit
4f67992d9e
4 changed files with 131 additions and 56 deletions
95
lib/widgets/adaptive_dialogs/dialog_text_field.dart
Normal file
95
lib/widgets/adaptive_dialogs/dialog_text_field.dart
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class DialogTextField extends StatelessWidget {
|
||||
final TextEditingController? controller;
|
||||
final String? hintText;
|
||||
final String? labelText;
|
||||
final String? initialText;
|
||||
final String? counterText;
|
||||
final String? prefixText;
|
||||
final String? suffixText;
|
||||
final String? errorText;
|
||||
final bool obscureText = false;
|
||||
final bool isDestructive = false;
|
||||
final int? minLines;
|
||||
final int? maxLines;
|
||||
final TextInputType? keyboardType;
|
||||
final int? maxLength;
|
||||
final bool autocorrect = true;
|
||||
|
||||
const DialogTextField({
|
||||
super.key,
|
||||
this.hintText,
|
||||
this.labelText,
|
||||
this.initialText,
|
||||
this.prefixText,
|
||||
this.suffixText,
|
||||
this.minLines,
|
||||
this.maxLines,
|
||||
this.keyboardType,
|
||||
this.maxLength,
|
||||
this.controller,
|
||||
this.counterText,
|
||||
this.errorText,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final prefixText = this.prefixText;
|
||||
final suffixText = this.suffixText;
|
||||
final errorText = this.errorText;
|
||||
final theme = Theme.of(context);
|
||||
switch (theme.platform) {
|
||||
case TargetPlatform.android:
|
||||
case TargetPlatform.fuchsia:
|
||||
case TargetPlatform.linux:
|
||||
case TargetPlatform.windows:
|
||||
return TextField(
|
||||
controller: controller,
|
||||
obscureText: obscureText,
|
||||
minLines: minLines,
|
||||
maxLines: maxLines,
|
||||
maxLength: maxLength,
|
||||
keyboardType: keyboardType,
|
||||
autocorrect: autocorrect,
|
||||
decoration: InputDecoration(
|
||||
errorText: errorText,
|
||||
hintText: hintText,
|
||||
labelText: labelText,
|
||||
prefixText: prefixText,
|
||||
suffixText: suffixText,
|
||||
counterText: counterText,
|
||||
),
|
||||
);
|
||||
case TargetPlatform.iOS:
|
||||
case TargetPlatform.macOS:
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CupertinoTextField(
|
||||
controller: controller,
|
||||
obscureText: obscureText,
|
||||
minLines: minLines,
|
||||
maxLines: maxLines,
|
||||
maxLength: maxLength,
|
||||
keyboardType: keyboardType,
|
||||
autocorrect: autocorrect,
|
||||
prefix: prefixText != null ? Text(prefixText) : null,
|
||||
suffix: suffixText != null ? Text(suffixText) : null,
|
||||
placeholder: labelText ?? hintText,
|
||||
),
|
||||
if (errorText != null)
|
||||
Text(
|
||||
errorText,
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: theme.colorScheme.error,
|
||||
),
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
|
@ -6,6 +5,7 @@ import 'package:flutter_linkify/flutter_linkify.dart';
|
|||
|
||||
import 'package:fluffychat/utils/url_launcher.dart';
|
||||
import 'package:fluffychat/widgets/adaptive_dialogs/adaptive_dialog_action.dart';
|
||||
import 'package:fluffychat/widgets/adaptive_dialogs/dialog_text_field.dart';
|
||||
|
||||
Future<String?> showTextInputDialog({
|
||||
required BuildContext context,
|
||||
|
|
@ -28,7 +28,6 @@ Future<String?> showTextInputDialog({
|
|||
int? maxLength,
|
||||
bool autocorrect = true,
|
||||
}) {
|
||||
final theme = Theme.of(context);
|
||||
return showAdaptiveDialog<String>(
|
||||
context: context,
|
||||
useRootNavigator: useRootNavigator,
|
||||
|
|
@ -61,58 +60,19 @@ Future<String?> showTextInputDialog({
|
|||
ValueListenableBuilder<String?>(
|
||||
valueListenable: error,
|
||||
builder: (context, error, _) {
|
||||
switch (theme.platform) {
|
||||
case TargetPlatform.android:
|
||||
case TargetPlatform.fuchsia:
|
||||
case TargetPlatform.linux:
|
||||
case TargetPlatform.windows:
|
||||
return TextField(
|
||||
controller: controller,
|
||||
obscureText: obscureText,
|
||||
minLines: minLines,
|
||||
maxLines: maxLines,
|
||||
maxLength: maxLength,
|
||||
keyboardType: keyboardType,
|
||||
autocorrect: autocorrect,
|
||||
decoration: InputDecoration(
|
||||
errorText: error,
|
||||
hintText: hintText,
|
||||
labelText: labelText,
|
||||
prefixText: prefixText,
|
||||
suffixText: suffixText,
|
||||
),
|
||||
);
|
||||
case TargetPlatform.iOS:
|
||||
case TargetPlatform.macOS:
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CupertinoTextField(
|
||||
controller: controller,
|
||||
obscureText: obscureText,
|
||||
minLines: minLines,
|
||||
maxLines: maxLines,
|
||||
maxLength: maxLength,
|
||||
keyboardType: keyboardType,
|
||||
autocorrect: autocorrect,
|
||||
prefix:
|
||||
prefixText != null ? Text(prefixText) : null,
|
||||
suffix:
|
||||
suffixText != null ? Text(suffixText) : null,
|
||||
placeholder: labelText ?? hintText,
|
||||
),
|
||||
if (error != null)
|
||||
Text(
|
||||
error,
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: theme.colorScheme.error,
|
||||
),
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
return DialogTextField(
|
||||
hintText: hintText,
|
||||
errorText: error,
|
||||
labelText: labelText,
|
||||
controller: controller,
|
||||
initialText: initialText,
|
||||
prefixText: prefixText,
|
||||
suffixText: suffixText,
|
||||
minLines: minLines,
|
||||
maxLines: maxLines,
|
||||
maxLength: maxLength,
|
||||
keyboardType: keyboardType,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue