chore: Adjust design of adaptive dialogs
This commit is contained in:
parent
040c2b8369
commit
fba44d9946
3 changed files with 102 additions and 70 deletions
|
|
@ -1,7 +1,9 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||||
|
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/adaptive_dialog_action.dart';
|
||||||
|
|
||||||
enum OkCancelResult { ok, cancel }
|
enum OkCancelResult { ok, cancel }
|
||||||
|
|
@ -25,7 +27,17 @@ Future<OkCancelResult?> showOkCancelAlertDialog({
|
||||||
),
|
),
|
||||||
content: ConstrainedBox(
|
content: ConstrainedBox(
|
||||||
constraints: const BoxConstraints(maxWidth: 256),
|
constraints: const BoxConstraints(maxWidth: 256),
|
||||||
child: message == null ? null : Text(message),
|
child: message == null
|
||||||
|
? null
|
||||||
|
: SelectableLinkify(
|
||||||
|
text: message,
|
||||||
|
linkStyle: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
decorationColor: Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
|
options: const LinkifyOptions(humanize: false),
|
||||||
|
onOpen: (url) => UrlLauncher(context, url.url).launchUrl(),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
AdaptiveDialogAction(
|
AdaptiveDialogAction(
|
||||||
|
|
@ -65,7 +77,17 @@ Future<OkCancelResult?> showOkAlertDialog({
|
||||||
),
|
),
|
||||||
content: ConstrainedBox(
|
content: ConstrainedBox(
|
||||||
constraints: const BoxConstraints(maxWidth: 256),
|
constraints: const BoxConstraints(maxWidth: 256),
|
||||||
child: message == null ? null : Text(message),
|
child: message == null
|
||||||
|
? null
|
||||||
|
: SelectableLinkify(
|
||||||
|
text: message,
|
||||||
|
linkStyle: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
decorationColor: Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
|
options: const LinkifyOptions(humanize: false),
|
||||||
|
onOpen: (url) => UrlLauncher(context, url.url).launchUrl(),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
AdaptiveDialogAction(
|
AdaptiveDialogAction(
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,9 @@ import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||||
|
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/adaptive_dialog_action.dart';
|
||||||
|
|
||||||
Future<String?> showTextInputDialog({
|
Future<String?> showTextInputDialog({
|
||||||
|
|
@ -40,73 +42,81 @@ Future<String?> showTextInputDialog({
|
||||||
constraints: const BoxConstraints(maxWidth: 256),
|
constraints: const BoxConstraints(maxWidth: 256),
|
||||||
child: Text(title),
|
child: Text(title),
|
||||||
),
|
),
|
||||||
content: Column(
|
content: ConstrainedBox(
|
||||||
mainAxisSize: MainAxisSize.min,
|
constraints: const BoxConstraints(maxWidth: 256),
|
||||||
children: [
|
child: Column(
|
||||||
if (message != null)
|
mainAxisSize: MainAxisSize.min,
|
||||||
ConstrainedBox(
|
children: [
|
||||||
constraints: const BoxConstraints(maxWidth: 256),
|
if (message != null)
|
||||||
child: Text(message),
|
SelectableLinkify(
|
||||||
),
|
text: message,
|
||||||
const SizedBox(height: 16),
|
linkStyle: TextStyle(
|
||||||
ValueListenableBuilder<String?>(
|
color: Theme.of(context).colorScheme.primary,
|
||||||
valueListenable: error,
|
decorationColor: Theme.of(context).colorScheme.primary,
|
||||||
builder: (context, error, _) {
|
),
|
||||||
switch (theme.platform) {
|
options: const LinkifyOptions(humanize: false),
|
||||||
case TargetPlatform.android:
|
onOpen: (url) => UrlLauncher(context, url.url).launchUrl(),
|
||||||
case TargetPlatform.fuchsia:
|
),
|
||||||
case TargetPlatform.linux:
|
const SizedBox(height: 16),
|
||||||
case TargetPlatform.windows:
|
ValueListenableBuilder<String?>(
|
||||||
return TextField(
|
valueListenable: error,
|
||||||
controller: controller,
|
builder: (context, error, _) {
|
||||||
obscureText: obscureText,
|
switch (theme.platform) {
|
||||||
minLines: minLines,
|
case TargetPlatform.android:
|
||||||
maxLines: maxLines,
|
case TargetPlatform.fuchsia:
|
||||||
maxLength: maxLength,
|
case TargetPlatform.linux:
|
||||||
keyboardType: keyboardType,
|
case TargetPlatform.windows:
|
||||||
autocorrect: autocorrect,
|
return TextField(
|
||||||
decoration: InputDecoration(
|
controller: controller,
|
||||||
errorText: error,
|
obscureText: obscureText,
|
||||||
hintText: hintText,
|
minLines: minLines,
|
||||||
labelText: labelText,
|
maxLines: maxLines,
|
||||||
prefixText: prefixText,
|
maxLength: maxLength,
|
||||||
suffixText: suffixText,
|
keyboardType: keyboardType,
|
||||||
),
|
autocorrect: autocorrect,
|
||||||
);
|
decoration: InputDecoration(
|
||||||
case TargetPlatform.iOS:
|
errorText: error,
|
||||||
case TargetPlatform.macOS:
|
hintText: hintText,
|
||||||
return Column(
|
labelText: labelText,
|
||||||
mainAxisSize: MainAxisSize.min,
|
prefixText: prefixText,
|
||||||
children: [
|
suffixText: suffixText,
|
||||||
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(
|
case TargetPlatform.iOS:
|
||||||
error,
|
case TargetPlatform.macOS:
|
||||||
style: TextStyle(
|
return Column(
|
||||||
fontSize: 11,
|
mainAxisSize: MainAxisSize.min,
|
||||||
color: theme.colorScheme.error,
|
children: [
|
||||||
),
|
CupertinoTextField(
|
||||||
textAlign: TextAlign.left,
|
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,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
AdaptiveDialogAction(
|
AdaptiveDialogAction(
|
||||||
|
|
|
||||||
|
|
@ -210,9 +210,9 @@ class PublicRoomBottomSheet extends StatelessWidget {
|
||||||
ListTile(
|
ListTile(
|
||||||
subtitle: SelectableLinkify(
|
subtitle: SelectableLinkify(
|
||||||
text: profile!.topic!,
|
text: profile!.topic!,
|
||||||
linkStyle: const TextStyle(
|
linkStyle: TextStyle(
|
||||||
color: Colors.blueAccent,
|
color: theme.colorScheme.primary,
|
||||||
decorationColor: Colors.blueAccent,
|
decorationColor: theme.colorScheme.primary,
|
||||||
),
|
),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue