makes toolbar have dynamic width to fit around content

This commit is contained in:
ggurdin 2024-10-10 15:59:28 -04:00
parent 2bc421e6e7
commit 4ddd28b7fe
No known key found for this signature in database
GPG key ID: A01CB41737CBB478
3 changed files with 47 additions and 46 deletions

View file

@ -373,24 +373,16 @@ class MessageOverlayController extends State<MessageSelectionOverlay>
// the default spacing between the side of the screen and the message bubble
final double messageMargin =
pangeaMessageEvent.ownMessage ? Avatar.defaultSize + 16 : 8;
// the actual spacing between the side of the screen and
// the message bubble, accounts for wide screen
double extraChatSpace = FluffyThemes.isColumnMode(context)
? ((screenWidth -
(FluffyThemes.columnWidth * 3.5) -
FluffyThemes.navRailWidth) /
2) +
messageMargin
: messageMargin;
if (extraChatSpace < messageMargin) {
extraChatSpace = messageMargin;
}
final horizontalPadding = FluffyThemes.isColumnMode(context) ? 8.0 : 0.0;
final chatViewWidth = screenWidth -
(FluffyThemes.isColumnMode(context)
? (FluffyThemes.columnWidth + FluffyThemes.navRailWidth)
: 0);
final maxWidth = chatViewWidth - (2 * horizontalPadding) - messageMargin;
final overlayMessage = Container(
constraints: const BoxConstraints(
maxWidth: FluffyThemes.columnWidth * 2.5,
constraints: BoxConstraints(
maxWidth: maxWidth,
),
child: Material(
type: MaterialType.transparency,
@ -439,21 +431,20 @@ class MessageOverlayController extends State<MessageSelectionOverlay>
),
);
final horizontalPadding = FluffyThemes.isColumnMode(context) ? 8.0 : 0.0;
final columnOffset = FluffyThemes.isColumnMode(context)
? FluffyThemes.columnWidth + FluffyThemes.navRailWidth
: 0;
final double leftPadding = widget._pangeaMessageEvent.ownMessage
? extraChatSpace
final double? leftPadding = widget._pangeaMessageEvent.ownMessage
? null
: messageOffset!.dx - horizontalPadding - columnOffset;
final double rightPadding = widget._pangeaMessageEvent.ownMessage
final double? rightPadding = widget._pangeaMessageEvent.ownMessage
? screenWidth -
messageOffset!.dx -
messageSize!.width -
horizontalPadding
: extraChatSpace;
: null;
final positionedOverlayMessage = _overlayPositionAnimation == null
? Positioned(

View file

@ -120,34 +120,40 @@ class MessageToolbarState extends State<MessageToolbar> {
.layerLinkAndKey('${widget.pangeaMessageEvent.eventId}-toolbar')
.key,
type: MaterialType.transparency,
child: Column(
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Container(
decoration: BoxDecoration(
color: Theme.of(context).cardColor,
border: Border.all(
width: 2,
color: Theme.of(context).colorScheme.primary.withOpacity(0.5),
),
borderRadius: const BorderRadius.all(
Radius.circular(AppConfig.borderRadius),
),
),
constraints: const BoxConstraints(
maxHeight: AppConfig.toolbarMaxHeight,
),
child: Row(
children: [
Expanded(
child: SingleChildScrollView(
child: AnimatedSize(
duration: FluffyThemes.animationDuration,
child: toolbarContent,
),
Column(
children: [
Container(
decoration: BoxDecoration(
color: Theme.of(context).cardColor,
border: Border.all(
width: 2,
color:
Theme.of(context).colorScheme.primary.withOpacity(0.5),
),
borderRadius: const BorderRadius.all(
Radius.circular(AppConfig.borderRadius),
),
),
],
),
constraints: const BoxConstraints(
maxHeight: AppConfig.toolbarMaxHeight,
),
// child: Row(
// children: [
// Expanded(
child: SingleChildScrollView(
child: AnimatedSize(
duration: FluffyThemes.animationDuration,
child: toolbarContent,
),
),
// ),
// ],
// ),
),
],
),
],
),

View file

@ -1,4 +1,5 @@
import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/pages/chat/chat.dart';
import 'package:fluffychat/pangea/utils/bot_style.dart';
import 'package:fluffychat/pangea/widgets/common/bot_face_svg.dart';
import 'package:fluffychat/pangea/widgets/igc/card_header.dart';
@ -7,8 +8,10 @@ import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
class PaywallCard extends StatelessWidget {
final ChatController chatController;
const PaywallCard({
super.key,
required this.chatController,
});
@override
@ -69,6 +72,7 @@ class PaywallCard extends StatelessWidget {
width: double.infinity,
child: TextButton(
onPressed: () {
chatController.clearSelectedEvents();
MatrixState.pangeaController.subscriptionController
.showPaywall(context);
},