chore: Adjust material dialog button design
This commit is contained in:
parent
dce4b36150
commit
6370c486a0
4 changed files with 48 additions and 15 deletions
|
|
@ -1,11 +1,28 @@
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'package:fluffychat/config/app_config.dart';
|
||||||
|
|
||||||
class AdaptiveDialogAction extends StatelessWidget {
|
class AdaptiveDialogAction extends StatelessWidget {
|
||||||
final VoidCallback? onPressed;
|
final VoidCallback? onPressed;
|
||||||
final bool autofocus;
|
final bool autofocus;
|
||||||
final Widget child;
|
final Widget child;
|
||||||
final bool bigButtons;
|
final bool bigButtons;
|
||||||
|
final BorderRadius? borderRadius;
|
||||||
|
|
||||||
|
static const BorderRadius topRadius = BorderRadius.only(
|
||||||
|
topLeft: Radius.circular(AppConfig.borderRadius),
|
||||||
|
topRight: Radius.circular(AppConfig.borderRadius),
|
||||||
|
bottomLeft: Radius.circular(2),
|
||||||
|
bottomRight: Radius.circular(2),
|
||||||
|
);
|
||||||
|
static const BorderRadius centerRadius = BorderRadius.all(Radius.circular(2));
|
||||||
|
static const BorderRadius bottomRadius = BorderRadius.only(
|
||||||
|
bottomLeft: Radius.circular(AppConfig.borderRadius),
|
||||||
|
bottomRight: Radius.circular(AppConfig.borderRadius),
|
||||||
|
topLeft: Radius.circular(2),
|
||||||
|
topRight: Radius.circular(2),
|
||||||
|
);
|
||||||
|
|
||||||
const AdaptiveDialogAction({
|
const AdaptiveDialogAction({
|
||||||
super.key,
|
super.key,
|
||||||
|
|
@ -13,6 +30,7 @@ class AdaptiveDialogAction extends StatelessWidget {
|
||||||
required this.child,
|
required this.child,
|
||||||
this.autofocus = false,
|
this.autofocus = false,
|
||||||
this.bigButtons = false,
|
this.bigButtons = false,
|
||||||
|
this.borderRadius,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -25,11 +43,15 @@ class AdaptiveDialogAction extends StatelessWidget {
|
||||||
case TargetPlatform.windows:
|
case TargetPlatform.windows:
|
||||||
if (bigButtons) {
|
if (bigButtons) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
padding: const EdgeInsets.symmetric(vertical: 2.0),
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: borderRadius ??
|
||||||
|
BorderRadius.circular(AppConfig.borderRadius),
|
||||||
|
),
|
||||||
backgroundColor: autofocus
|
backgroundColor: autofocus
|
||||||
? theme.colorScheme.primary
|
? theme.colorScheme.primary
|
||||||
: theme.colorScheme.surfaceBright,
|
: theme.colorScheme.surfaceBright,
|
||||||
|
|
|
||||||
|
|
@ -210,6 +210,7 @@ class PublicRoomDialog extends StatelessWidget {
|
||||||
actions: [
|
actions: [
|
||||||
AdaptiveDialogAction(
|
AdaptiveDialogAction(
|
||||||
bigButtons: true,
|
bigButtons: true,
|
||||||
|
borderRadius: AdaptiveDialogAction.topRadius,
|
||||||
onPressed: () => _joinRoom(context),
|
onPressed: () => _joinRoom(context),
|
||||||
child: Text(
|
child: Text(
|
||||||
chunk?.joinRule == 'knock' &&
|
chunk?.joinRule == 'knock' &&
|
||||||
|
|
@ -222,6 +223,7 @@ class PublicRoomDialog extends StatelessWidget {
|
||||||
),
|
),
|
||||||
AdaptiveDialogAction(
|
AdaptiveDialogAction(
|
||||||
bigButtons: true,
|
bigButtons: true,
|
||||||
|
borderRadius: AdaptiveDialogAction.bottomRadius,
|
||||||
onPressed: Navigator.of(context).pop,
|
onPressed: Navigator.of(context).pop,
|
||||||
child: Text(L10n.of(context).close),
|
child: Text(L10n.of(context).close),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,19 @@ class UserDialog extends StatelessWidget {
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
|
Center(
|
||||||
|
child: Avatar(
|
||||||
|
mxContent: avatar,
|
||||||
|
name: displayname,
|
||||||
|
size: Avatar.defaultSize * 2,
|
||||||
|
onTap: avatar != null
|
||||||
|
? () => showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (_) => MxcImageViewer(avatar),
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
),
|
||||||
HoverBuilder(
|
HoverBuilder(
|
||||||
builder: (context, hovered) => StatefulBuilder(
|
builder: (context, hovered) => StatefulBuilder(
|
||||||
builder: (context, setState) => MouseRegion(
|
builder: (context, setState) => MouseRegion(
|
||||||
|
|
@ -122,19 +135,6 @@ class UserDialog extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Center(
|
|
||||||
child: Avatar(
|
|
||||||
mxContent: avatar,
|
|
||||||
name: displayname,
|
|
||||||
size: Avatar.defaultSize * 2,
|
|
||||||
onTap: avatar != null
|
|
||||||
? () => showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (_) => MxcImageViewer(avatar),
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (presenceText != null)
|
if (presenceText != null)
|
||||||
Text(
|
Text(
|
||||||
presenceText,
|
presenceText,
|
||||||
|
|
@ -165,6 +165,7 @@ class UserDialog extends StatelessWidget {
|
||||||
actions: [
|
actions: [
|
||||||
if (client.userID != profile.userId) ...[
|
if (client.userID != profile.userId) ...[
|
||||||
AdaptiveDialogAction(
|
AdaptiveDialogAction(
|
||||||
|
borderRadius: AdaptiveDialogAction.topRadius,
|
||||||
bigButtons: true,
|
bigButtons: true,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
final router = GoRouter.of(context);
|
final router = GoRouter.of(context);
|
||||||
|
|
@ -185,6 +186,7 @@ class UserDialog extends StatelessWidget {
|
||||||
),
|
),
|
||||||
AdaptiveDialogAction(
|
AdaptiveDialogAction(
|
||||||
bigButtons: true,
|
bigButtons: true,
|
||||||
|
borderRadius: AdaptiveDialogAction.centerRadius,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
final router = GoRouter.of(context);
|
final router = GoRouter.of(context);
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
|
|
@ -201,6 +203,7 @@ class UserDialog extends StatelessWidget {
|
||||||
],
|
],
|
||||||
AdaptiveDialogAction(
|
AdaptiveDialogAction(
|
||||||
bigButtons: true,
|
bigButtons: true,
|
||||||
|
borderRadius: AdaptiveDialogAction.bottomRadius,
|
||||||
onPressed: Navigator.of(context).pop,
|
onPressed: Navigator.of(context).pop,
|
||||||
child: Text(L10n.of(context).close),
|
child: Text(L10n.of(context).close),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ Future<int?> showPermissionChooser(
|
||||||
return await showAdaptiveDialog<int>(
|
return await showAdaptiveDialog<int>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => AlertDialog.adaptive(
|
builder: (context) => AlertDialog.adaptive(
|
||||||
title: Text(L10n.of(context).chatPermissions),
|
title: Center(child: Text(L10n.of(context).chatPermissions)),
|
||||||
content: ConstrainedBox(
|
content: ConstrainedBox(
|
||||||
constraints: const BoxConstraints(maxWidth: 256, maxHeight: 256),
|
constraints: const BoxConstraints(maxWidth: 256, maxHeight: 256),
|
||||||
child: Column(
|
child: Column(
|
||||||
|
|
@ -39,6 +39,7 @@ Future<int?> showPermissionChooser(
|
||||||
actions: [
|
actions: [
|
||||||
AdaptiveDialogAction(
|
AdaptiveDialogAction(
|
||||||
bigButtons: true,
|
bigButtons: true,
|
||||||
|
borderRadius: AdaptiveDialogAction.topRadius,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
final level = int.tryParse(controller.text.trim());
|
final level = int.tryParse(controller.text.trim());
|
||||||
if (level == null) {
|
if (level == null) {
|
||||||
|
|
@ -55,18 +56,23 @@ Future<int?> showPermissionChooser(
|
||||||
),
|
),
|
||||||
if (maxLevel >= 100 && currentLevel != 100)
|
if (maxLevel >= 100 && currentLevel != 100)
|
||||||
AdaptiveDialogAction(
|
AdaptiveDialogAction(
|
||||||
|
borderRadius: AdaptiveDialogAction.centerRadius,
|
||||||
bigButtons: true,
|
bigButtons: true,
|
||||||
onPressed: () => Navigator.of(context).pop<int>(100),
|
onPressed: () => Navigator.of(context).pop<int>(100),
|
||||||
child: Text(L10n.of(context).admin),
|
child: Text(L10n.of(context).admin),
|
||||||
),
|
),
|
||||||
if (maxLevel >= 50 && currentLevel != 50)
|
if (maxLevel >= 50 && currentLevel != 50)
|
||||||
AdaptiveDialogAction(
|
AdaptiveDialogAction(
|
||||||
|
borderRadius: maxLevel != 0
|
||||||
|
? AdaptiveDialogAction.centerRadius
|
||||||
|
: AdaptiveDialogAction.bottomRadius,
|
||||||
bigButtons: true,
|
bigButtons: true,
|
||||||
onPressed: () => Navigator.of(context).pop<int>(50),
|
onPressed: () => Navigator.of(context).pop<int>(50),
|
||||||
child: Text(L10n.of(context).moderator),
|
child: Text(L10n.of(context).moderator),
|
||||||
),
|
),
|
||||||
if (currentLevel != 0)
|
if (currentLevel != 0)
|
||||||
AdaptiveDialogAction(
|
AdaptiveDialogAction(
|
||||||
|
borderRadius: AdaptiveDialogAction.bottomRadius,
|
||||||
bigButtons: true,
|
bigButtons: true,
|
||||||
onPressed: () => Navigator.of(context).pop<int>(0),
|
onPressed: () => Navigator.of(context).pop<int>(0),
|
||||||
child: Text(L10n.of(context).normalUser),
|
child: Text(L10n.of(context).normalUser),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue