Fix Up File Sharing Overlay
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
Sarah Jamie Lewis 2024-02-08 15:43:10 -08:00
parent 659c7fe75e
commit cb079c2fd3
4 changed files with 178 additions and 213 deletions

View File

@ -1,9 +1,6 @@
import 'dart:convert'; import 'dart:convert';
import 'package:cwtch/config.dart';
import 'package:cwtch/cwtch/cwtch.dart';
import 'package:cwtch/main.dart'; import 'package:cwtch/main.dart';
import 'package:cwtch/models/appstate.dart';
import 'package:cwtch/models/contact.dart'; import 'package:cwtch/models/contact.dart';
import 'package:cwtch/models/profile.dart'; import 'package:cwtch/models/profile.dart';
import 'package:cwtch/settings.dart'; import 'package:cwtch/settings.dart';

View File

@ -146,25 +146,23 @@ class FileBubbleState extends State<FileBubble> {
); );
} }
return LayoutBuilder(builder: (bcontext, constraints) {
var wdgSender = Visibility( var wdgSender = Visibility(
visible: widget.interactive, visible: widget.interactive,
child: Container( child: Container(
height: 14 * Provider.of<Settings>(context).fontScaling, height: 14 * Provider.of<Settings>(context).fontScaling, clipBehavior: Clip.hardEdge, decoration: BoxDecoration(), child: compileSenderWidget(context, null, fromMe, senderDisplayStr)));
clipBehavior: Clip.hardEdge,
decoration: BoxDecoration(),
child: compileSenderWidget(context, constraints, fromMe, senderDisplayStr)));
var isPreview = false; var isPreview = false;
var wdgMessage = !showFileSharing var wdgMessage = !showFileSharing
? Text(AppLocalizations.of(context)!.messageEnableFileSharing, style: Provider.of<Settings>(context).scaleFonts(defaultTextStyle)) ? Text(AppLocalizations.of(context)!.messageEnableFileSharing, style: Provider.of<Settings>(context).scaleFonts(defaultTextStyle))
: fromMe : fromMe
? senderFileChrome(AppLocalizations.of(context)!.messageFileSent, widget.nameSuggestion, widget.rootHash, widget.fileSize) ? senderFileChrome(AppLocalizations.of(context)!.messageFileSent, widget.nameSuggestion, widget.rootHash)
: (fileChrome(AppLocalizations.of(context)!.messageFileOffered + ":", widget.nameSuggestion, widget.rootHash, widget.fileSize, : (fileChrome(AppLocalizations.of(context)!.messageFileOffered + ":", widget.nameSuggestion, widget.rootHash, widget.fileSize,
Provider.of<ProfileInfoState>(context).downloadSpeed(widget.fileKey()))); Provider.of<ProfileInfoState>(context).downloadSpeed(widget.fileKey())));
Widget wdgDecorations; Widget wdgDecorations;
if (!showFileSharing) { if (!showFileSharing) {
wdgDecorations = Text('\u202F'); wdgDecorations = Text('\u202F');
} else if (fromMe) {
wdgDecorations = Text('\u202F');
} else if (downloadComplete && path != null) { } else if (downloadComplete && path != null) {
// in this case, whatever marked download.complete would have also set the path // in this case, whatever marked download.complete would have also set the path
if (myFile != null && Provider.of<Settings>(context).shouldPreview(path)) { if (myFile != null && Provider.of<Settings>(context).shouldPreview(path)) {
@ -176,17 +174,17 @@ class FileBubbleState extends State<FileBubble> {
child: GestureDetector( child: GestureDetector(
child: Padding(padding: EdgeInsets.all(1.0), child: getPreview(context)), child: Padding(padding: EdgeInsets.all(1.0), child: getPreview(context)),
onTap: () { onTap: () {
pop(bcontext, myFile!, widget.nameSuggestion); pop(context, myFile!, widget.nameSuggestion);
}, },
))); )));
} else { } else {
wdgDecorations = Visibility( wdgDecorations = Visibility(
visible: widget.interactive, child: Text(AppLocalizations.of(context)!.fileSavedTo + ': ' + path + '\u202F', style: Provider.of<Settings>(context).scaleFonts(defaultTextStyle))); visible: widget.interactive, child: SelectableText(AppLocalizations.of(context)!.fileSavedTo + ': ' + path + '\u202F', style: Provider.of<Settings>(context).scaleFonts(defaultTextStyle)));
} }
} else if (downloadActive) { } else if (downloadActive) {
if (!downloadGotManifest) { if (!downloadGotManifest) {
wdgDecorations = Visibility( wdgDecorations = Visibility(
visible: widget.interactive, child: Text(AppLocalizations.of(context)!.retrievingManifestMessage + '\u202F', style: Provider.of<Settings>(context).scaleFonts(defaultTextStyle))); visible: widget.interactive, child: SelectableText(AppLocalizations.of(context)!.retrievingManifestMessage + '\u202F', style: Provider.of<Settings>(context).scaleFonts(defaultTextStyle)));
} else { } else {
wdgDecorations = Visibility( wdgDecorations = Visibility(
visible: widget.interactive, visible: widget.interactive,
@ -230,7 +228,6 @@ class FileBubbleState extends State<FileBubble> {
} }
return Container( return Container(
constraints: constraints,
decoration: BoxDecoration( decoration: BoxDecoration(
color: fromMe ? Provider.of<Settings>(context).theme.messageFromMeBackgroundColor : Provider.of<Settings>(context).theme.messageFromOtherBackgroundColor, color: fromMe ? Provider.of<Settings>(context).theme.messageFromMeBackgroundColor : Provider.of<Settings>(context).theme.messageFromOtherBackgroundColor,
border: Border.all(color: fromMe ? Provider.of<Settings>(context).theme.messageFromMeBackgroundColor : Provider.of<Settings>(context).theme.messageFromOtherBackgroundColor, width: 1), border: Border.all(color: fromMe ? Provider.of<Settings>(context).theme.messageFromMeBackgroundColor : Provider.of<Settings>(context).theme.messageFromOtherBackgroundColor, width: 1),
@ -272,7 +269,6 @@ class FileBubbleState extends State<FileBubble> {
messageStatusWidget messageStatusWidget
]), ]),
))); )));
});
} }
void _btnAccept() async { void _btnAccept() async {
@ -322,41 +318,27 @@ class FileBubbleState extends State<FileBubble> {
} }
// Construct an file chrome for the sender // Construct an file chrome for the sender
Widget senderFileChrome(String chrome, String fileName, String rootHash, int fileSize) { Widget senderFileChrome(String chrome, String fileName, String rootHash) {
var settings = Provider.of<Settings>(context); var settings = Provider.of<Settings>(context);
return ListTile( return ListTile(
visualDensity: VisualDensity.compact, visualDensity: VisualDensity.compact,
title: Wrap(direction: Axis.horizontal, alignment: WrapAlignment.start, children: [ contentPadding: EdgeInsets.all(1.0),
SelectableText( title: SelectableText(
chrome + '\u202F',
style: settings.scaleFonts(defaultMessageTextStyle.copyWith(color: Provider.of<Settings>(context).theme.messageFromMeTextColor)),
textAlign: TextAlign.left,
maxLines: 2,
textWidthBasis: TextWidthBasis.longestLine,
),
SelectableText(
fileName + '\u202F', fileName + '\u202F',
style: style:
settings.scaleFonts(defaultMessageTextStyle.copyWith(overflow: TextOverflow.ellipsis, fontWeight: FontWeight.bold, color: Provider.of<Settings>(context).theme.messageFromMeTextColor)), settings.scaleFonts(defaultMessageTextStyle.copyWith(overflow: TextOverflow.ellipsis, fontWeight: FontWeight.bold, color: Provider.of<Settings>(context).theme.messageFromMeTextColor)),
textAlign: TextAlign.left, textAlign: TextAlign.left,
textWidthBasis: TextWidthBasis.parent, textWidthBasis: TextWidthBasis.longestLine,
maxLines: 2, maxLines: 2,
), ),
SelectableText(
prettyBytes(fileSize) + '\u202F' + '\n',
style: settings.scaleFonts(defaultSmallTextStyle.copyWith(color: Provider.of<Settings>(context).theme.messageFromMeTextColor)),
textAlign: TextAlign.left,
maxLines: 2,
)
]),
subtitle: SelectableText( subtitle: SelectableText(
'sha512: ' + rootHash + '\u202F', prettyBytes(widget.fileSize) + '\u202F' + '\n' + 'sha512: ' + rootHash + '\u202F',
style: settings.scaleFonts(defaultSmallTextStyle.copyWith(fontFamily: "RobotoMono", color: Provider.of<Settings>(context).theme.messageFromMeTextColor)), style: settings.scaleFonts(defaultSmallTextStyle.copyWith(fontFamily: "RobotoMono", color: Provider.of<Settings>(context).theme.messageFromMeTextColor)),
textAlign: TextAlign.left, textAlign: TextAlign.left,
maxLines: 4, maxLines: 4,
textWidthBasis: TextWidthBasis.parent, textWidthBasis: TextWidthBasis.longestLine,
), ),
leading: Icon(CwtchIcons.attached_file_3, size: 32, color: Provider.of<Settings>(context).theme.messageFromMeTextColor)); leading: FittedBox(child: Icon(CwtchIcons.attached_file_3, size: 32, color: Provider.of<Settings>(context).theme.messageFromOtherTextColor)));
} }
// Construct an file chrome // Construct an file chrome
@ -364,46 +346,33 @@ class FileBubbleState extends State<FileBubble> {
var settings = Provider.of<Settings>(context); var settings = Provider.of<Settings>(context);
return ListTile( return ListTile(
visualDensity: VisualDensity.compact, visualDensity: VisualDensity.compact,
title: Wrap(direction: Axis.horizontal, alignment: WrapAlignment.start, children: [ contentPadding: EdgeInsets.all(1.0),
SelectableText( title: SelectableText(
chrome + '\u202F',
style: settings.scaleFonts(defaultMessageTextStyle.copyWith(color: Provider.of<Settings>(context).theme.messageFromOtherTextColor)),
textAlign: TextAlign.left,
maxLines: 2,
textWidthBasis: TextWidthBasis.longestLine,
),
SelectableText(
fileName + '\u202F', fileName + '\u202F',
style: settings style:
.scaleFonts(defaultMessageTextStyle.copyWith(overflow: TextOverflow.ellipsis, fontWeight: FontWeight.bold, color: Provider.of<Settings>(context).theme.messageFromOtherTextColor)), settings.scaleFonts(defaultMessageTextStyle.copyWith(overflow: TextOverflow.ellipsis, fontWeight: FontWeight.bold, color: Provider.of<Settings>(context).theme.messageFromOtherTextColor)),
textAlign: TextAlign.left, textAlign: TextAlign.left,
textWidthBasis: TextWidthBasis.parent, textWidthBasis: TextWidthBasis.longestLine,
maxLines: 2, maxLines: 2,
), ),
SelectableText(
AppLocalizations.of(context)!.labelFilesize + ': ' + prettyBytes(fileSize) + '\u202F' + '\n',
style: settings.scaleFonts(defaultSmallTextStyle.copyWith(color: Provider.of<Settings>(context).theme.messageFromOtherTextColor)),
textAlign: TextAlign.left,
maxLines: 2,
)
]),
subtitle: SelectableText( subtitle: SelectableText(
'sha512: ' + rootHash + '\u202F', prettyBytes(widget.fileSize) + '\u202F' + '\n' + 'sha512: ' + rootHash + '\u202F',
style: settings.scaleFonts(defaultSmallTextStyle.copyWith(fontFamily: "RobotoMono", color: Provider.of<Settings>(context).theme.messageFromOtherTextColor)), style: settings.scaleFonts(defaultSmallTextStyle.copyWith(fontFamily: "RobotoMono", color: Provider.of<Settings>(context).theme.messageFromOtherTextColor)),
textAlign: TextAlign.left, textAlign: TextAlign.left,
maxLines: 4, maxLines: 4,
textWidthBasis: TextWidthBasis.parent, textWidthBasis: TextWidthBasis.longestLine,
), ),
leading: Icon(CwtchIcons.attached_file_3, size: 32, color: Provider.of<Settings>(context).theme.messageFromOtherTextColor), leading: FittedBox(child: Icon(CwtchIcons.attached_file_3, size: 32, color: Provider.of<Settings>(context).theme.messageFromOtherTextColor)),
trailing: Visibility( // Note: not using Visible here because we want to shrink this to nothing when not in use...
visible: speed != "0 B/s", trailing: speed == "0 B/s"
child: SelectableText( ? null
: SelectableText(
speed + '\u202F', speed + '\u202F',
style: settings.scaleFonts(defaultSmallTextStyle.copyWith(color: Provider.of<Settings>(context).theme.messageFromOtherTextColor)), style: settings.scaleFonts(defaultSmallTextStyle.copyWith(color: Provider.of<Settings>(context).theme.messageFromOtherTextColor)),
textAlign: TextAlign.left, textAlign: TextAlign.left,
maxLines: 1, maxLines: 1,
textWidthBasis: TextWidthBasis.longestLine, textWidthBasis: TextWidthBasis.longestLine,
)), ),
); );
} }

View File

@ -1,4 +1,5 @@
import 'dart:io'; import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@ -23,13 +24,13 @@ class _MessageBubbleDecoration extends State<MessageBubbleDecoration> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
var prettyDate = prettyDateString(context, widget.messageDate.toLocal()); var prettyDate = prettyDateString(context, widget.messageDate.toLocal());
return Center( return FittedBox(
widthFactor: 1.0,
child: Row( child: Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Text(prettyDate, Text(prettyDate,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
textWidthBasis: TextWidthBasis.longestLine,
style: TextStyle( style: TextStyle(
fontSize: 9.0 * Provider.of<Settings>(context).fontScaling, fontSize: 9.0 * Provider.of<Settings>(context).fontScaling,
fontWeight: FontWeight.w200, fontWeight: FontWeight.w200,
@ -42,12 +43,10 @@ class _MessageBubbleDecoration extends State<MessageBubbleDecoration> {
padding: EdgeInsets.all(1.0), padding: EdgeInsets.all(1.0),
child: widget.ackd == true child: widget.ackd == true
? Tooltip( ? Tooltip(
message: AppLocalizations.of(context)!.acknowledgedLabel, message: AppLocalizations.of(context)!.acknowledgedLabel, child: Icon(Icons.check_circle_outline, color: Provider.of<Settings>(context).theme.messageFromMeTextColor, size: 16))
child: Icon(Icons.check_circle_outline, color: Provider.of<Settings>(context).theme.messageFromMeTextColor, size: 16))
: (widget.errored == true : (widget.errored == true
? Tooltip( ? Tooltip(
message: AppLocalizations.of(context)!.couldNotSendMsgError, message: AppLocalizations.of(context)!.couldNotSendMsgError, child: Icon(Icons.error_outline, color: Provider.of<Settings>(context).theme.messageFromMeTextColor, size: 16))
child: Icon(Icons.error_outline, color: Provider.of<Settings>(context).theme.messageFromMeTextColor, size: 16))
: Tooltip( : Tooltip(
message: AppLocalizations.of(context)!.pendingLabel, message: AppLocalizations.of(context)!.pendingLabel,
child: Icon(Icons.hourglass_bottom_outlined, color: Provider.of<Settings>(context).theme.messageFromMeTextColor, size: 16)))) child: Icon(Icons.hourglass_bottom_outlined, color: Provider.of<Settings>(context).theme.messageFromMeTextColor, size: 16))))

View File

@ -63,7 +63,7 @@ class MessageRowState extends State<MessageRow> with SingleTickerProviderStateMi
var isContact = Provider.of<ProfileInfoState>(context).contactList.findContact(Provider.of<MessageMetadata>(context).senderHandle) != null; var isContact = Provider.of<ProfileInfoState>(context).contactList.findContact(Provider.of<MessageMetadata>(context).senderHandle) != null;
var isGroup = Provider.of<ProfileInfoState>(context).contactList.getContact(Provider.of<MessageMetadata>(context, listen: false).conversationIdentifier)!.isGroup; var isGroup = Provider.of<ProfileInfoState>(context).contactList.getContact(Provider.of<MessageMetadata>(context, listen: false).conversationIdentifier)!.isGroup;
var isBlocked = isContact ? Provider.of<ProfileInfoState>(context).contactList.findContact(Provider.of<MessageMetadata>(context).senderHandle)!.isBlocked : false; var isBlocked = isContact ? Provider.of<ProfileInfoState>(context).contactList.findContact(Provider.of<MessageMetadata>(context).senderHandle)!.isBlocked : false;
var actualMessage = Flexible(flex: 1, fit: FlexFit.loose, child: widget.child); var actualMessage = Flexible(flex: Platform.isAndroid ? 10 : 7, fit: FlexFit.loose, child: widget.child);
_dragAffinity = fromMe ? Alignment.centerRight : Alignment.centerLeft; _dragAffinity = fromMe ? Alignment.centerRight : Alignment.centerLeft;
_dragAlignment = fromMe ? Alignment.centerRight : Alignment.centerLeft; _dragAlignment = fromMe ? Alignment.centerRight : Alignment.centerLeft;