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