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