From f09c40d7dd7790d5b9741a62f016cd8e89365f09 Mon Sep 17 00:00:00 2001 From: "Matthew van Eerde (^_^)" Date: Thu, 26 Aug 2021 09:51:03 -0700 Subject: [PATCH 1/3] Bandaid fix - update the Tor tarball to fetch for Windows builds to a more recent version --- fetch-tor-win.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fetch-tor-win.ps1 b/fetch-tor-win.ps1 index c293f26a..08aff100 100644 --- a/fetch-tor-win.ps1 +++ b/fetch-tor-win.ps1 @@ -1,6 +1,6 @@ -Invoke-WebRequest -Uri https://dist.torproject.org/torbrowser/10.0.18/tor-win64-0.4.5.9.zip -OutFile tor.zip +Invoke-WebRequest -Uri https://dist.torproject.org/torbrowser/10.5.5/tor-win64-0.4.5.10.zip -OutFile tor.zip -if ((Get-FileHash tor.zip -Algorithm sha512).Hash -ne '72764eb07ad8ab511603aba0734951ca003989f5f4686af91ba220217b4a8a4bcc5f571b59f52c847932f6efedf847b111621983050fcddbb8099d43ca66fb07' ) { Write-Error 'tor.zip sha512sum mismatch' } +if ((Get-FileHash tor.zip -Algorithm sha512).Hash -ne 'E5DA5899D9F4DDFBD33A8D4AB659659EBC1B47FDFE7BD27681D615792E6B9CB2EBA0BF381E8A7C8D89A3B011523786679883C4ECE492452F5F26E537149999D7' ) { Write-Error 'tor.zip sha512sum mismatch' } Expand-Archive -Path tor.zip -DestinationPath Tor From 7d15c41aedaf8970898c81cde718d145a55108cb Mon Sep 17 00:00:00 2001 From: "Matthew van Eerde (^_^)" Date: Thu, 26 Aug 2021 10:41:06 -0700 Subject: [PATCH 2/3] Pull the old version from the Cwtch archive rather than the new version from Tor directly --- fetch-tor-win.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fetch-tor-win.ps1 b/fetch-tor-win.ps1 index 08aff100..ba275cbc 100644 --- a/fetch-tor-win.ps1 +++ b/fetch-tor-win.ps1 @@ -1,6 +1,6 @@ -Invoke-WebRequest -Uri https://dist.torproject.org/torbrowser/10.5.5/tor-win64-0.4.5.10.zip -OutFile tor.zip +Invoke-WebRequest -Uri https://git.openprivacy.ca/openprivacy/buildfiles/raw/branch/master/tor/tor-win64-0.4.6.5.zip -OutFile tor.zip -if ((Get-FileHash tor.zip -Algorithm sha512).Hash -ne 'E5DA5899D9F4DDFBD33A8D4AB659659EBC1B47FDFE7BD27681D615792E6B9CB2EBA0BF381E8A7C8D89A3B011523786679883C4ECE492452F5F26E537149999D7' ) { Write-Error 'tor.zip sha512sum mismatch' } +if ((Get-FileHash tor.zip -Algorithm sha512).Hash -ne '7917561a7a063440a1ddfa9cb544ab9ffd09de84cea3dd66e3cc9cd349dd9f85b74a522ec390d7a974bc19b424c4d53af60e57bbc47e763d13cab6a203c4592f' ) { Write-Error 'tor.zip sha512sum mismatch' } Expand-Archive -Path tor.zip -DestinationPath Tor From 1a80b4b80862b1f072dc0dd8d5e02ebbd1e8fde3 Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Thu, 26 Aug 2021 14:11:10 -0700 Subject: [PATCH 3/3] Add Physics to Message Row. Fixes: #132 --- lib/widgets/messagerow.dart | 91 ++++++++++++++++++++++++++++++++----- 1 file changed, 80 insertions(+), 11 deletions(-) diff --git a/lib/widgets/messagerow.dart b/lib/widgets/messagerow.dart index 8a94837c..df9d3568 100644 --- a/lib/widgets/messagerow.dart +++ b/lib/widgets/messagerow.dart @@ -5,6 +5,7 @@ import 'package:cwtch/models/message.dart'; import 'package:cwtch/views/contactsview.dart'; import 'package:flutter/material.dart'; import 'package:cwtch/widgets/profileimage.dart'; +import 'package:flutter/physics.dart'; import 'package:provider/provider.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; @@ -20,9 +21,31 @@ class MessageRow extends StatefulWidget { MessageRowState createState() => MessageRowState(); } -class MessageRowState extends State { +class MessageRowState extends State with SingleTickerProviderStateMixin { bool showMenu = false; bool showBlockedMessage = false; + late AnimationController _controller; + late Animation _animation; + late Alignment _dragAlignment = Alignment.center; + Alignment _dragAffinity = Alignment.center; + + @override + void initState() { + super.initState(); + _controller = AnimationController(vsync: this); + _controller.addListener(() { + setState(() { + _dragAlignment = _animation.value; + }); + }); + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { var fromMe = Provider.of(context).senderHandle == Provider.of(context).onion; @@ -30,6 +53,12 @@ class MessageRowState extends State { var isBlocked = isContact ? Provider.of(context).contactList.getContact(Provider.of(context).senderHandle)!.isBlocked : false; var actualMessage = Flexible(flex: 3, fit: FlexFit.loose, child: widget.child); + _dragAffinity = fromMe ? Alignment.centerRight : Alignment.centerLeft; + + if (_dragAlignment == Alignment.center) { + _dragAlignment = fromMe ? Alignment.centerRight : Alignment.centerLeft; + } + var senderDisplayStr = ""; if (!fromMe) { ContactInfoState? contact = Provider.of(context).contactList.getContact(Provider.of(context).senderHandle); @@ -52,7 +81,7 @@ class MessageRowState extends State { Provider.of(context, listen: false).selectedIndex = Provider.of(context, listen: false).messageIndex; }, icon: Icon(Icons.reply, color: Provider.of(context).theme.dropShadowColor()))); - Widget wdgSpacer = Expanded(child: SizedBox(width: 60, height: 10)); + Widget wdgSpacer = Flexible(child: SizedBox(width: 60, height: 10)); var widgetRow = []; if (fromMe) { @@ -131,10 +160,9 @@ class MessageRowState extends State { wdgSpacer, ]; } - + var size = MediaQuery.of(context).size; return MouseRegion( // For desktop... - onHover: (event) { setState(() { this.showMenu = true; @@ -146,14 +174,55 @@ class MessageRowState extends State { }); }, child: GestureDetector( + onPanUpdate: (details) { + setState(() { + _dragAlignment += Alignment( + details.delta.dx / (size.width * 0.5), + 0, + ); + }); + }, + onPanDown: (details) { + _controller.stop(); + }, + onPanEnd: (details) { + _runAnimation(details.velocity.pixelsPerSecond, size); + Provider.of(context, listen: false).selectedIndex = Provider.of(context, listen: false).messageIndex; + }, + child: Padding( + padding: EdgeInsets.all(2), + child: Align( + widthFactor: 1, + alignment: _dragAlignment, + child: Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + children: widgetRow, + ))))); + } - // Swipe to quote on Android - onHorizontalDragEnd: Platform.isAndroid - ? (details) { - Provider.of(context, listen: false).selectedIndex = Provider.of(context, listen: false).messageIndex; - } - : null, - child: Padding(padding: EdgeInsets.all(2), child: Row(mainAxisAlignment: fromMe ? MainAxisAlignment.end : MainAxisAlignment.start, children: widgetRow)))); + void _runAnimation(Offset pixelsPerSecond, Size size) { + _animation = _controller.drive( + AlignmentTween( + begin: _dragAlignment, + end: _dragAffinity, + ), + ); + // Calculate the velocity relative to the unit interval, [0,1], + // used by the animation controller. + final unitsPerSecondX = pixelsPerSecond.dx / size.width; + final unitsPerSecondY = pixelsPerSecond.dy / size.height; + final unitsPerSecond = Offset(unitsPerSecondX, unitsPerSecondY); + final unitVelocity = unitsPerSecond.distance; + + const spring = SpringDescription( + mass: 30, + stiffness: 1, + damping: 1, + ); + + final simulation = SpringSimulation(spring, 0, 1, -unitVelocity); + _controller.animateWith(simulation); } void _btnGoto() {