refactor: New private chat

This commit is contained in:
Krille 2022-12-30 14:37:13 +01:00
parent 1e1e591d27
commit fff3dc9946
2 changed files with 82 additions and 85 deletions

View File

@ -26,78 +26,80 @@ class NewPrivateChatView extends StatelessWidget {
title: Text(L10n.of(context)!.newChat),
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
actions: [
TextButton(
onPressed: () => VRouter.of(context).to('/newgroup'),
child: Text(
L10n.of(context)!.createNewGroup,
style: TextStyle(color: Theme.of(context).colorScheme.secondary),
Padding(
padding: const EdgeInsets.all(8.0),
child: TextButton(
onPressed: () => VRouter.of(context).to('/newgroup'),
child: Text(
L10n.of(context)!.createNewGroup,
style:
TextStyle(color: Theme.of(context).colorScheme.secondary),
),
),
)
],
),
body: MaxWidthBody(
withScrolling: true,
child: Column(
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Form(
key: controller.formKey,
child: TextFormField(
controller: controller.controller,
autocorrect: false,
autofocus: !PlatformInfos.isMobile,
textInputAction: TextInputAction.go,
focusNode: controller.textFieldFocus,
onFieldSubmitted: controller.submitAction,
validator: controller.validateForm,
inputFormatters: controller.removeMatrixToFormatters,
decoration: InputDecoration(
contentPadding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 6,
),
labelText: L10n.of(context)!.typeInInviteLinkManually,
hintText: '@username',
prefixText: NewPrivateChatController.prefixNoProtocol,
suffixIcon: IconButton(
icon: const Icon(Icons.send_outlined),
onPressed: controller.submitAction,
),
),
child: Container(
margin: const EdgeInsets.all(_qrCodePadding),
alignment: Alignment.center,
padding: const EdgeInsets.all(_qrCodePadding * 2),
child: Material(
borderRadius: BorderRadius.circular(12),
elevation: 10,
color: Colors.white,
shadowColor: Theme.of(context).appBarTheme.shadowColor,
clipBehavior: Clip.hardEdge,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
QrImage(
data:
'https://matrix.to/#/${Matrix.of(context).client.userID}',
version: QrVersions.auto,
size: min(MediaQuery.of(context).size.width - 16, 200),
),
TextButton.icon(
icon: Icon(Icons.adaptive.share_outlined),
label: Text(L10n.of(context)!.shareYourInviteLink),
onPressed: controller.inviteAction,
),
const SizedBox(height: 8),
],
),
),
),
),
bottomNavigationBar: MaxWidthBody(
withScrolling: false,
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Form(
key: controller.formKey,
child: TextFormField(
controller: controller.controller,
autocorrect: false,
textInputAction: TextInputAction.go,
focusNode: controller.textFieldFocus,
onFieldSubmitted: controller.submitAction,
validator: controller.validateForm,
inputFormatters: controller.removeMatrixToFormatters,
decoration: InputDecoration(
contentPadding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 6,
),
labelText: L10n.of(context)!.typeInInviteLinkManually,
hintText: '@username',
prefixText: NewPrivateChatController.prefixNoProtocol,
suffixIcon: IconButton(
icon: const Icon(Icons.send_outlined),
onPressed: controller.submitAction,
),
),
),
Container(
margin: const EdgeInsets.all(_qrCodePadding),
alignment: Alignment.center,
padding: const EdgeInsets.all(_qrCodePadding * 2),
child: Material(
borderRadius: BorderRadius.circular(12),
elevation: 10,
color: Colors.white,
shadowColor: Theme.of(context).appBarTheme.shadowColor,
clipBehavior: Clip.hardEdge,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
QrImage(
data:
'https://matrix.to/#/${Matrix.of(context).client.userID}',
version: QrVersions.auto,
size: min(MediaQuery.of(context).size.width - 16, 200),
),
TextButton.icon(
icon: Icon(Icons.adaptive.share_outlined),
label: Text(L10n.of(context)!.shareYourInviteLink),
onPressed: controller.inviteAction,
),
const SizedBox(height: 8),
],
),
),
),
],
),
),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,

View File

@ -11,7 +11,6 @@ class ContentBanner extends StatelessWidget {
final void Function()? onEdit;
final Client? client;
final double opacity;
final String heroTag;
const ContentBanner(
{this.mxContent,
@ -20,7 +19,6 @@ class ContentBanner extends StatelessWidget {
this.onEdit,
this.client,
this.opacity = 0.75,
this.heroTag = 'content_banner',
Key? key})
: super(key: key);
@ -42,27 +40,23 @@ class ContentBanner extends StatelessWidget {
bottom: 0,
child: Opacity(
opacity: opacity,
child: Hero(
tag: heroTag,
child: mxContent == null
? Center(
child: Icon(
defaultIcon,
color: Theme.of(context)
.colorScheme
.onSecondaryContainer,
size: 128,
),
)
: MxcImage(
key: Key(mxContent?.toString() ?? 'NoKey'),
uri: mxContent,
animated: true,
fit: BoxFit.cover,
height: 400,
width: 800,
child: mxContent == null
? Center(
child: Icon(
defaultIcon,
color:
Theme.of(context).colorScheme.onSecondaryContainer,
size: 128,
),
),
)
: MxcImage(
key: Key(mxContent?.toString() ?? 'NoKey'),
uri: mxContent,
animated: true,
fit: BoxFit.cover,
height: 400,
width: 800,
),
),
),
if (onEdit != null)
@ -71,6 +65,7 @@ class ContentBanner extends StatelessWidget {
alignment: Alignment.bottomRight,
child: FloatingActionButton(
mini: true,
heroTag: null,
onPressed: onEdit,
backgroundColor: Theme.of(context).backgroundColor,
foregroundColor: Theme.of(context).textTheme.bodyText1?.color,