mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-07-26 07:55:33 -04:00
textscale dialogs
This commit is contained in:
parent
68e8d7fd39
commit
5a6b57e8ec
7 changed files with 62 additions and 59 deletions
|
@ -7,17 +7,10 @@ import '../../theme/theme.dart';
|
|||
class ProfileWidget extends StatelessWidget {
|
||||
const ProfileWidget({
|
||||
required proto.Profile profile,
|
||||
required bool showPronouns,
|
||||
String? byline,
|
||||
super.key,
|
||||
}) : _profile = profile,
|
||||
_showPronouns = showPronouns;
|
||||
|
||||
//
|
||||
|
||||
final proto.Profile _profile;
|
||||
final bool _showPronouns;
|
||||
|
||||
//
|
||||
_byline = byline;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -44,26 +37,37 @@ class ProfileWidget extends StatelessWidget {
|
|||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(8 * scaleConfig.borderRadiusScale))),
|
||||
),
|
||||
child: Row(children: [
|
||||
const Spacer(),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 8.scaled(context),
|
||||
children: [
|
||||
Text(
|
||||
_profile.name,
|
||||
style: textTheme.titleMedium!.copyWith(
|
||||
color: scaleConfig.preferBorders
|
||||
? scale.primaryScale.border
|
||||
: scale.primaryScale.borderText),
|
||||
textAlign: TextAlign.left,
|
||||
).paddingAll(8.scaled(context)),
|
||||
if (_profile.pronouns.isNotEmpty && _showPronouns)
|
||||
Text('(${_profile.pronouns})',
|
||||
textAlign: TextAlign.right,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
maxLines: 1,
|
||||
),
|
||||
if (_byline != null)
|
||||
Text(
|
||||
_byline,
|
||||
style: textTheme.bodySmall!.copyWith(
|
||||
color: scaleConfig.preferBorders
|
||||
? scale.primaryScale.border
|
||||
: scale.primaryScale.primary))
|
||||
.paddingAll(8.scaled(context)),
|
||||
const Spacer()
|
||||
]),
|
||||
: scale.primaryScale.primary),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
maxLines: 1,
|
||||
),
|
||||
]).paddingAll(8.scaled(context)),
|
||||
);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
final proto.Profile _profile;
|
||||
final String? _byline;
|
||||
}
|
||||
|
|
|
@ -58,7 +58,6 @@ class ContactInvitationDisplayDialog extends StatelessWidget {
|
|||
}
|
||||
|
||||
@override
|
||||
// ignore: prefer_expression_function_bodies
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final textTheme = theme.textTheme;
|
||||
|
@ -131,6 +130,7 @@ class ContactInvitationDisplayDialog extends StatelessWidget {
|
|||
if (message.isNotEmpty)
|
||||
Text(message,
|
||||
softWrap: true,
|
||||
textAlign: TextAlign.center,
|
||||
maxLines: 2,
|
||||
style: textTheme.labelMedium!
|
||||
.copyWith(color: Colors.black))
|
||||
|
|
|
@ -41,7 +41,7 @@ class _CreateInvitationDialogState extends State<CreateInvitationDialog> {
|
|||
late final TextEditingController _recipientTextController;
|
||||
|
||||
EncryptionKeyType _encryptionKeyType = EncryptionKeyType.none;
|
||||
String _encryptionKey = '';
|
||||
var _encryptionKey = '';
|
||||
Timestamp? _expiration;
|
||||
|
||||
@override
|
||||
|
@ -171,24 +171,23 @@ class _CreateInvitationDialogState extends State<CreateInvitationDialog> {
|
|||
}
|
||||
|
||||
@override
|
||||
// ignore: prefer_expression_function_bodies
|
||||
Widget build(BuildContext context) {
|
||||
final windowSize = MediaQuery.of(context).size;
|
||||
final maxDialogWidth = min(windowSize.width - 64.0, 800.0 - 64.0);
|
||||
final maxDialogHeight = windowSize.height - 64.0;
|
||||
|
||||
final theme = Theme.of(context);
|
||||
//final scale = theme.extension<ScaleScheme>()!;
|
||||
final textTheme = theme.textTheme;
|
||||
|
||||
return ConstrainedBox(
|
||||
constraints:
|
||||
BoxConstraints(maxHeight: maxDialogHeight, maxWidth: maxDialogWidth),
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(8),
|
||||
padding: const EdgeInsets.all(8).scaled(context),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
spacing: 16.scaled(context),
|
||||
children: <Widget>[
|
||||
TextField(
|
||||
autofocus: true,
|
||||
|
@ -200,30 +199,29 @@ class _CreateInvitationDialogState extends State<CreateInvitationDialog> {
|
|||
LengthLimitingTextInputFormatter(128),
|
||||
],
|
||||
decoration: InputDecoration(
|
||||
contentPadding: const EdgeInsets.all(8).scaled(context),
|
||||
hintText:
|
||||
translate('create_invitation_dialog.recipient_hint'),
|
||||
labelText:
|
||||
translate('create_invitation_dialog.recipient_name'),
|
||||
helperText:
|
||||
translate('create_invitation_dialog.recipient_helper')),
|
||||
).paddingAll(8),
|
||||
const SizedBox(height: 10),
|
||||
),
|
||||
TextField(
|
||||
controller: _messageTextController,
|
||||
inputFormatters: [
|
||||
LengthLimitingTextInputFormatter(128),
|
||||
],
|
||||
decoration: InputDecoration(
|
||||
contentPadding: const EdgeInsets.all(8).scaled(context),
|
||||
hintText: translate('create_invitation_dialog.message_hint'),
|
||||
labelText:
|
||||
translate('create_invitation_dialog.message_label'),
|
||||
helperText:
|
||||
translate('create_invitation_dialog.message_helper')),
|
||||
).paddingAll(8),
|
||||
const SizedBox(height: 10),
|
||||
),
|
||||
Text(translate('create_invitation_dialog.protect_this_invitation'),
|
||||
style: textTheme.labelLarge)
|
||||
.paddingAll(8),
|
||||
style: textTheme.labelLarge),
|
||||
Wrap(
|
||||
alignment: WrapAlignment.center,
|
||||
runAlignment: WrapAlignment.center,
|
||||
|
@ -245,23 +243,23 @@ class _CreateInvitationDialogState extends State<CreateInvitationDialog> {
|
|||
selected: _encryptionKeyType == EncryptionKeyType.password,
|
||||
onSelected: _onPasswordEncryptionSelected,
|
||||
)
|
||||
]).paddingAll(8).toCenter(),
|
||||
]).toCenter(),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
padding: const EdgeInsets.all(8).scaled(context),
|
||||
child: ElevatedButton(
|
||||
onPressed: _recipientTextController.text.isNotEmpty
|
||||
? _onGenerateButtonPressed
|
||||
: null,
|
||||
child: Text(
|
||||
translate('create_invitation_dialog.generate'),
|
||||
).paddingAll(16),
|
||||
).paddingAll(16.scaled(context)),
|
||||
),
|
||||
).toCenter(),
|
||||
Text(translate('create_invitation_dialog.note')).paddingAll(8),
|
||||
Text(translate('create_invitation_dialog.note')),
|
||||
Text(
|
||||
translate('create_invitation_dialog.note_text'),
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
).paddingAll(8),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
@ -292,13 +292,10 @@ class InvitationDialogState extends State<InvitationDialog> {
|
|||
]).toCenter(),
|
||||
if (_validInvitation != null && !_isValidating)
|
||||
Column(children: [
|
||||
Container(
|
||||
constraints: const BoxConstraints(maxHeight: 64),
|
||||
width: double.infinity,
|
||||
child: ProfileWidget(
|
||||
ProfileWidget(
|
||||
profile: _validInvitation!.remoteProfile,
|
||||
showPronouns: true,
|
||||
)).paddingLTRB(0, 0, 0, 16),
|
||||
byline: _validInvitation!.remoteProfile.pronouns,
|
||||
).paddingLTRB(0, 0, 0, 16),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
|
|
|
@ -127,7 +127,6 @@ class _HomeAccountReadyState extends State<HomeAccountReady> {
|
|||
buildMenuButton().paddingLTRB(0, 0, 8, 0),
|
||||
ProfileWidget(
|
||||
profile: profile,
|
||||
showPronouns: false,
|
||||
).expanded(),
|
||||
buildContactsButton().paddingLTRB(8, 0, 0, 0),
|
||||
])).paddingAll(8),
|
||||
|
@ -169,7 +168,7 @@ class _HomeAccountReadyState extends State<HomeAccountReady> {
|
|||
final hasActiveChat = activeChat != null;
|
||||
|
||||
return LayoutBuilder(builder: (context, constraints) {
|
||||
const leftColumnSize = 300.0;
|
||||
const leftColumnSize = 320.0;
|
||||
|
||||
late final bool visibleLeft;
|
||||
late final bool visibleRight;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import 'package:awesome_extensions/awesome_extensions.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../settings/settings.dart';
|
||||
import '../../theme.dart';
|
||||
|
||||
class StyledDialog extends StatelessWidget {
|
||||
|
@ -41,17 +41,22 @@ class StyledDialog extends StatelessWidget {
|
|||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
12 * scaleConfig.borderRadiusScale))),
|
||||
child: child.paddingAll(0))));
|
||||
child: child)));
|
||||
}
|
||||
|
||||
static Future<T?> show<T>(
|
||||
{required BuildContext context,
|
||||
required String title,
|
||||
required Widget child}) async =>
|
||||
required Widget child}) =>
|
||||
showDialog<T>(
|
||||
context: context,
|
||||
useRootNavigator: false,
|
||||
builder: (context) => StyledDialog(title: title, child: child));
|
||||
builder: (context) => AsyncBlocBuilder<PreferencesCubit, Preferences>(
|
||||
builder: (context, state) => MediaQuery(
|
||||
data: MediaQuery.of(context).copyWith(
|
||||
textScaler: TextScaler.linear(
|
||||
state.themePreference.displayScale)),
|
||||
child: StyledDialog(title: title, child: child))));
|
||||
|
||||
final String title;
|
||||
final Widget child;
|
||||
|
|
|
@ -120,7 +120,7 @@ class StyledSlideTile extends StatelessWidget {
|
|||
child: Padding(
|
||||
padding: scaleTheme.config.useVisualIndicators
|
||||
? EdgeInsets.zero
|
||||
: const EdgeInsets.fromLTRB(0, 2, 0, 2).scaled(context),
|
||||
: const EdgeInsets.fromLTRB(0, 4, 0, 4).scaled(context),
|
||||
child: GestureDetector(
|
||||
onDoubleTap: onDoubleTap,
|
||||
child: ListTile(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue