chore: Follow up animate in
This commit is contained in:
parent
f07aba448d
commit
627f7b88d4
1 changed files with 269 additions and 259 deletions
|
|
@ -122,7 +122,22 @@ class Message extends StatelessWidget {
|
||||||
: Theme.of(context).colorScheme.primaryContainer;
|
: Theme.of(context).colorScheme.primaryContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
final row = Row(
|
final resetAnimateIn = this.resetAnimateIn;
|
||||||
|
var animateIn = this.animateIn;
|
||||||
|
|
||||||
|
final row = StatefulBuilder(
|
||||||
|
builder: (context, setState) {
|
||||||
|
if (animateIn && resetAnimateIn != null) {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||||
|
animateIn = false;
|
||||||
|
setState(resetAnimateIn);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return AnimatedSlide(
|
||||||
|
offset: Offset(0, animateIn ? 1 : 0),
|
||||||
|
duration: FluffyThemes.animationDuration,
|
||||||
|
curve: FluffyThemes.animationCurve,
|
||||||
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: rowMainAxisAlignment,
|
mainAxisAlignment: rowMainAxisAlignment,
|
||||||
children: [
|
children: [
|
||||||
|
|
@ -133,11 +148,7 @@ class Message extends StatelessWidget {
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: 16,
|
width: 16,
|
||||||
height: 16,
|
height: 16,
|
||||||
child: event.status == EventStatus.sending
|
child: event.status == EventStatus.error
|
||||||
? const CircularProgressIndicator.adaptive(
|
|
||||||
strokeWidth: 2,
|
|
||||||
)
|
|
||||||
: event.status == EventStatus.error
|
|
||||||
? const Icon(Icons.error, color: Colors.red)
|
? const Icon(Icons.error, color: Colors.red)
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
|
|
@ -147,7 +158,8 @@ class Message extends StatelessWidget {
|
||||||
FutureBuilder<User?>(
|
FutureBuilder<User?>(
|
||||||
future: event.fetchSenderUser(),
|
future: event.fetchSenderUser(),
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
final user = snapshot.data ?? event.senderFromMemoryOrFallback;
|
final user =
|
||||||
|
snapshot.data ?? event.senderFromMemoryOrFallback;
|
||||||
return Avatar(
|
return Avatar(
|
||||||
mxContent: user.avatarUrl,
|
mxContent: user.avatarUrl,
|
||||||
name: user.calcDisplayname(),
|
name: user.calcDisplayname(),
|
||||||
|
|
@ -190,6 +202,17 @@ class Message extends StatelessWidget {
|
||||||
Container(
|
Container(
|
||||||
alignment: alignment,
|
alignment: alignment,
|
||||||
padding: const EdgeInsets.only(left: 8),
|
padding: const EdgeInsets.only(left: 8),
|
||||||
|
child: AnimatedOpacity(
|
||||||
|
opacity: animateIn
|
||||||
|
? 0
|
||||||
|
: event.redacted ||
|
||||||
|
event.messageType ==
|
||||||
|
MessageTypes.BadEncrypted ||
|
||||||
|
event.status.isSending
|
||||||
|
? 0.5
|
||||||
|
: 1,
|
||||||
|
duration: FluffyThemes.animationDuration,
|
||||||
|
curve: FluffyThemes.animationCurve,
|
||||||
child: Material(
|
child: Material(
|
||||||
color: noBubble ? Colors.transparent : color,
|
color: noBubble ? Colors.transparent : color,
|
||||||
clipBehavior: Clip.antiAlias,
|
clipBehavior: Clip.antiAlias,
|
||||||
|
|
@ -223,14 +246,16 @@ class Message extends StatelessWidget {
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
if (event.relationshipType == RelationshipTypes.reply)
|
if (event.relationshipType ==
|
||||||
|
RelationshipTypes.reply)
|
||||||
FutureBuilder<Event?>(
|
FutureBuilder<Event?>(
|
||||||
future: event.getReplyEvent(timeline),
|
future: event.getReplyEvent(timeline),
|
||||||
builder: (BuildContext context, snapshot) {
|
builder: (BuildContext context, snapshot) {
|
||||||
final replyEvent = snapshot.hasData
|
final replyEvent = snapshot.hasData
|
||||||
? snapshot.data!
|
? snapshot.data!
|
||||||
: Event(
|
: Event(
|
||||||
eventId: event.relationshipEventId!,
|
eventId:
|
||||||
|
event.relationshipEventId!,
|
||||||
content: {
|
content: {
|
||||||
'msgtype': 'm.text',
|
'msgtype': 'm.text',
|
||||||
'body': '...',
|
'body': '...',
|
||||||
|
|
@ -242,11 +267,14 @@ class Message extends StatelessWidget {
|
||||||
originServerTs: DateTime.now(),
|
originServerTs: DateTime.now(),
|
||||||
);
|
);
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 4.0),
|
padding:
|
||||||
|
const EdgeInsets.only(bottom: 4.0),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
borderRadius: ReplyContent.borderRadius,
|
borderRadius:
|
||||||
onTap: () =>
|
ReplyContent.borderRadius,
|
||||||
scrollToEventId(replyEvent.eventId),
|
onTap: () => scrollToEventId(
|
||||||
|
replyEvent.eventId,
|
||||||
|
),
|
||||||
child: AbsorbPointer(
|
child: AbsorbPointer(
|
||||||
child: ReplyContent(
|
child: ReplyContent(
|
||||||
replyEvent,
|
replyEvent,
|
||||||
|
|
@ -295,10 +323,14 @@ class Message extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
Widget container;
|
Widget container;
|
||||||
if (event.hasAggregatedEvents(timeline, RelationshipTypes.reaction) ||
|
if (event.hasAggregatedEvents(timeline, RelationshipTypes.reaction) ||
|
||||||
|
|
@ -381,27 +413,9 @@ class Message extends StatelessWidget {
|
||||||
container = row;
|
container = row;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.messageType == MessageTypes.BadEncrypted) {
|
|
||||||
container = Opacity(opacity: 0.4, child: container);
|
|
||||||
}
|
|
||||||
|
|
||||||
TapDownDetails? lastTapDownDetails;
|
TapDownDetails? lastTapDownDetails;
|
||||||
final resetAnimateIn = this.resetAnimateIn;
|
|
||||||
var animateIn = this.animateIn;
|
|
||||||
|
|
||||||
return StatefulBuilder(
|
return Center(
|
||||||
builder: (context, setState) {
|
|
||||||
if (animateIn && resetAnimateIn != null) {
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
|
||||||
animateIn = false;
|
|
||||||
setState(resetAnimateIn);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return AnimatedSlide(
|
|
||||||
offset: Offset(0, animateIn ? 1 : 0),
|
|
||||||
duration: FluffyThemes.animationDuration,
|
|
||||||
curve: FluffyThemes.animationCurve,
|
|
||||||
child: Center(
|
|
||||||
child: Swipeable(
|
child: Swipeable(
|
||||||
key: ValueKey(event.eventId),
|
key: ValueKey(event.eventId),
|
||||||
background: const Padding(
|
background: const Padding(
|
||||||
|
|
@ -451,8 +465,7 @@ class Message extends StatelessWidget {
|
||||||
4,
|
4,
|
||||||
borderRadius:
|
borderRadius:
|
||||||
BorderRadius.circular(AppConfig.borderRadius),
|
BorderRadius.circular(AppConfig.borderRadius),
|
||||||
shadowColor:
|
shadowColor: Theme.of(context).appBarTheme.shadowColor,
|
||||||
Theme.of(context).appBarTheme.shadowColor,
|
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
|
|
@ -487,9 +500,6 @@ class Message extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue