mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-18 02:42:34 +01:00
Merge branch 'krille/fix-chatview-safearea' into 'main'
fix: ChatView safearea on iPad See merge request famedly/fluffychat!588
This commit is contained in:
commit
afc9afb391
@ -177,172 +177,177 @@ class ChatView extends StatelessWidget {
|
|||||||
height: double.infinity,
|
height: double.infinity,
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
),
|
),
|
||||||
Column(
|
SafeArea(
|
||||||
children: <Widget>[
|
child: Column(
|
||||||
TombstoneDisplay(controller),
|
children: <Widget>[
|
||||||
Expanded(
|
TombstoneDisplay(controller),
|
||||||
child: FutureBuilder<bool>(
|
Expanded(
|
||||||
future: controller.getTimeline(),
|
child: FutureBuilder<bool>(
|
||||||
builder: (BuildContext context, snapshot) {
|
future: controller.getTimeline(),
|
||||||
if (snapshot.hasError) {
|
builder: (BuildContext context, snapshot) {
|
||||||
SentryController.captureException(
|
if (snapshot.hasError) {
|
||||||
snapshot.error,
|
SentryController.captureException(
|
||||||
StackTrace.current,
|
snapshot.error,
|
||||||
);
|
StackTrace.current,
|
||||||
}
|
);
|
||||||
if (controller.timeline == null) {
|
}
|
||||||
return const Center(
|
if (controller.timeline == null) {
|
||||||
child: CircularProgressIndicator.adaptive(
|
return const Center(
|
||||||
strokeWidth: 2),
|
child: CircularProgressIndicator.adaptive(
|
||||||
);
|
strokeWidth: 2),
|
||||||
}
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// create a map of eventId --> index to greatly improve performance of
|
// create a map of eventId --> index to greatly improve performance of
|
||||||
// ListView's findChildIndexCallback
|
// ListView's findChildIndexCallback
|
||||||
final thisEventsKeyMap = <String, int>{};
|
final thisEventsKeyMap = <String, int>{};
|
||||||
for (var i = 0;
|
for (var i = 0;
|
||||||
i < controller.filteredEvents.length;
|
i < controller.filteredEvents.length;
|
||||||
i++) {
|
i++) {
|
||||||
thisEventsKeyMap[
|
thisEventsKeyMap[
|
||||||
controller.filteredEvents[i].eventId] = i;
|
controller.filteredEvents[i].eventId] = i;
|
||||||
}
|
}
|
||||||
return ListView.custom(
|
return ListView.custom(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
top: 16,
|
top: 16,
|
||||||
bottom: 4,
|
bottom: 4,
|
||||||
left: horizontalPadding,
|
left: horizontalPadding,
|
||||||
right: horizontalPadding,
|
right: horizontalPadding,
|
||||||
),
|
),
|
||||||
reverse: true,
|
reverse: true,
|
||||||
controller: controller.scrollController,
|
controller: controller.scrollController,
|
||||||
keyboardDismissBehavior: PlatformInfos.isIOS
|
keyboardDismissBehavior: PlatformInfos.isIOS
|
||||||
? ScrollViewKeyboardDismissBehavior.onDrag
|
? ScrollViewKeyboardDismissBehavior.onDrag
|
||||||
: ScrollViewKeyboardDismissBehavior.manual,
|
: ScrollViewKeyboardDismissBehavior.manual,
|
||||||
childrenDelegate: SliverChildBuilderDelegate(
|
childrenDelegate: SliverChildBuilderDelegate(
|
||||||
(BuildContext context, int i) {
|
(BuildContext context, int i) {
|
||||||
return i == controller.filteredEvents.length + 1
|
return i == controller.filteredEvents.length + 1
|
||||||
? controller.timeline.isRequestingHistory
|
? controller.timeline.isRequestingHistory
|
||||||
? const Center(
|
? const Center(
|
||||||
child: CircularProgressIndicator
|
child: CircularProgressIndicator
|
||||||
.adaptive(strokeWidth: 2),
|
.adaptive(strokeWidth: 2),
|
||||||
)
|
)
|
||||||
: controller.canLoadMore
|
: controller.canLoadMore
|
||||||
? Center(
|
? Center(
|
||||||
child: OutlinedButton(
|
child: OutlinedButton(
|
||||||
style: OutlinedButton.styleFrom(
|
style:
|
||||||
backgroundColor: Theme.of(
|
OutlinedButton.styleFrom(
|
||||||
context)
|
backgroundColor: Theme.of(
|
||||||
.scaffoldBackgroundColor,
|
context)
|
||||||
|
.scaffoldBackgroundColor,
|
||||||
|
),
|
||||||
|
onPressed:
|
||||||
|
controller.requestHistory,
|
||||||
|
child: Text(L10n.of(context)
|
||||||
|
.loadMore),
|
||||||
),
|
),
|
||||||
onPressed:
|
)
|
||||||
controller.requestHistory,
|
: Container()
|
||||||
child: Text(
|
: i == 0
|
||||||
L10n.of(context).loadMore),
|
? Column(
|
||||||
),
|
mainAxisSize: MainAxisSize.min,
|
||||||
)
|
children: [
|
||||||
: Container()
|
SeenByRow(controller),
|
||||||
: i == 0
|
TypingIndicators(controller),
|
||||||
? Column(
|
],
|
||||||
mainAxisSize: MainAxisSize.min,
|
)
|
||||||
children: [
|
: AutoScrollTag(
|
||||||
SeenByRow(controller),
|
|
||||||
TypingIndicators(controller),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
: AutoScrollTag(
|
|
||||||
key: ValueKey(controller
|
|
||||||
.filteredEvents[i - 1].eventId),
|
|
||||||
index: i - 1,
|
|
||||||
controller:
|
|
||||||
controller.scrollController,
|
|
||||||
child: Swipeable(
|
|
||||||
key: ValueKey(controller
|
key: ValueKey(controller
|
||||||
.filteredEvents[i - 1].eventId),
|
.filteredEvents[i - 1].eventId),
|
||||||
background: const Padding(
|
index: i - 1,
|
||||||
padding: EdgeInsets.symmetric(
|
controller:
|
||||||
horizontal: 12.0),
|
controller.scrollController,
|
||||||
child: Center(
|
child: Swipeable(
|
||||||
child:
|
key: ValueKey(controller
|
||||||
Icon(Icons.reply_outlined),
|
.filteredEvents[i - 1]
|
||||||
|
.eventId),
|
||||||
|
background: const Padding(
|
||||||
|
padding: EdgeInsets.symmetric(
|
||||||
|
horizontal: 12.0),
|
||||||
|
child: Center(
|
||||||
|
child: Icon(
|
||||||
|
Icons.reply_outlined),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
direction:
|
||||||
direction:
|
SwipeDirection.endToStart,
|
||||||
SwipeDirection.endToStart,
|
onSwipe: (direction) =>
|
||||||
onSwipe: (direction) =>
|
controller.replyAction(
|
||||||
controller.replyAction(
|
replyTo: controller
|
||||||
replyTo: controller
|
.filteredEvents[
|
||||||
.filteredEvents[i - 1]),
|
i - 1]),
|
||||||
child: Message(
|
child: Message(
|
||||||
controller
|
controller
|
||||||
.filteredEvents[i - 1],
|
.filteredEvents[i - 1],
|
||||||
onInfoTab:
|
onInfoTab:
|
||||||
controller.showEventInfo,
|
controller.showEventInfo,
|
||||||
onAvatarTab: (Event event) =>
|
onAvatarTab: (Event event) =>
|
||||||
showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (c) =>
|
builder: (c) =>
|
||||||
UserBottomSheet(
|
UserBottomSheet(
|
||||||
user: event.sender,
|
user: event.sender,
|
||||||
outerContext: context,
|
outerContext: context,
|
||||||
onMention: () => controller
|
onMention: () => controller
|
||||||
.sendController
|
.sendController
|
||||||
.text +=
|
.text +=
|
||||||
'${event.sender.mention} ',
|
'${event.sender.mention} ',
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
unfold: controller.unfold,
|
||||||
unfold: controller.unfold,
|
onSelect: controller
|
||||||
onSelect:
|
.onSelectMessage,
|
||||||
controller.onSelectMessage,
|
scrollToEventId: (String eventId) => controller
|
||||||
scrollToEventId: (String eventId) =>
|
.scrollToEventId(eventId),
|
||||||
controller.scrollToEventId(
|
longPressSelect: controller
|
||||||
eventId),
|
.selectedEvents.isEmpty,
|
||||||
longPressSelect: controller
|
selected: controller.selectedEvents.any((e) =>
|
||||||
.selectedEvents.isEmpty,
|
e.eventId ==
|
||||||
selected: controller.selectedEvents.any((e) =>
|
controller
|
||||||
e.eventId ==
|
.filteredEvents[i - 1]
|
||||||
controller
|
.eventId),
|
||||||
.filteredEvents[i - 1]
|
timeline: controller.timeline,
|
||||||
.eventId),
|
nextEvent: i <
|
||||||
timeline: controller.timeline,
|
controller
|
||||||
nextEvent:
|
.filteredEvents
|
||||||
i < controller.filteredEvents.length
|
.length
|
||||||
? controller
|
? controller.filteredEvents[i]
|
||||||
.filteredEvents[i]
|
: null),
|
||||||
: null),
|
),
|
||||||
),
|
);
|
||||||
);
|
},
|
||||||
},
|
childCount: controller.filteredEvents.length + 2,
|
||||||
childCount: controller.filteredEvents.length + 2,
|
findChildIndexCallback: (key) =>
|
||||||
findChildIndexCallback: (key) => controller
|
controller.findChildIndexCallback(
|
||||||
.findChildIndexCallback(key, thisEventsKeyMap),
|
key, thisEventsKeyMap),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
|
||||||
),
|
|
||||||
if (controller.room.canSendDefaultMessages &&
|
|
||||||
controller.room.membership == Membership.join)
|
|
||||||
Container(
|
|
||||||
margin: EdgeInsets.only(
|
|
||||||
bottom: bottomSheetPadding,
|
|
||||||
left: bottomSheetPadding,
|
|
||||||
right: bottomSheetPadding,
|
|
||||||
),
|
),
|
||||||
constraints: const BoxConstraints(
|
),
|
||||||
maxWidth: FluffyThemes.columnWidth * 2.5),
|
if (controller.room.canSendDefaultMessages &&
|
||||||
alignment: Alignment.center,
|
controller.room.membership == Membership.join)
|
||||||
child: Material(
|
Container(
|
||||||
borderRadius: const BorderRadius.only(
|
margin: EdgeInsets.only(
|
||||||
bottomLeft: Radius.circular(AppConfig.borderRadius),
|
bottom: bottomSheetPadding,
|
||||||
bottomRight: Radius.circular(AppConfig.borderRadius),
|
left: bottomSheetPadding,
|
||||||
|
right: bottomSheetPadding,
|
||||||
),
|
),
|
||||||
elevation: 6,
|
constraints: const BoxConstraints(
|
||||||
shadowColor: Theme.of(context)
|
maxWidth: FluffyThemes.columnWidth * 2.5),
|
||||||
.secondaryHeaderColor
|
alignment: Alignment.center,
|
||||||
.withAlpha(100),
|
child: Material(
|
||||||
clipBehavior: Clip.hardEdge,
|
borderRadius: const BorderRadius.only(
|
||||||
color: Theme.of(context).appBarTheme.backgroundColor,
|
bottomLeft: Radius.circular(AppConfig.borderRadius),
|
||||||
child: SafeArea(
|
bottomRight:
|
||||||
|
Radius.circular(AppConfig.borderRadius),
|
||||||
|
),
|
||||||
|
elevation: 6,
|
||||||
|
shadowColor: Theme.of(context)
|
||||||
|
.secondaryHeaderColor
|
||||||
|
.withAlpha(100),
|
||||||
|
clipBehavior: Clip.hardEdge,
|
||||||
|
color: Theme.of(context).appBarTheme.backgroundColor,
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
@ -355,8 +360,8 @@ class ChatView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user