remove additional navigator widget

This commit is contained in:
Salvatore Giordano
2020-05-14 10:30:56 +02:00
parent 2de3cc2b69
commit cb284f773b
17 changed files with 148 additions and 104 deletions
+1 -1
View File
@@ -46,7 +46,7 @@ class AttachmentTitle extends StatelessWidget {
.toList()
.reversed
.join('.'),
style: messageTheme.createdAt,
style: messageTheme.messageText,
),
],
),
+4 -1
View File
@@ -21,11 +21,13 @@ class _FullScreenVideoState extends State<FullScreenVideo> {
ChewieController _chewieController;
VideoPlayerController _videoPlayerController;
bool initialized = false;
GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey();
@override
Widget build(BuildContext context) {
return Scaffold(
body: Builder(
key: _scaffoldKey,
builder: (context) {
if (!initialized) {
return Center(
@@ -60,7 +62,7 @@ class _FullScreenVideoState extends State<FullScreenVideo> {
errorListener = () {
if (_videoPlayerController.value.hasError) {
Navigator.pop(context);
launchURL(context, widget.attachment.titleLink);
launchURL(_scaffoldKey.currentContext, widget.attachment.titleLink);
}
_videoPlayerController.removeListener(errorListener);
};
@@ -70,6 +72,7 @@ class _FullScreenVideoState extends State<FullScreenVideo> {
@override
void dispose() {
_videoPlayerController.dispose();
_chewieController.dispose();
super.dispose();
}
}
+25 -19
View File
@@ -47,26 +47,31 @@ class GiphyAttachment extends StatelessWidget {
);
}));
},
child: CachedNetworkImage(
height: size?.height,
width: size?.width,
placeholder: (_, __) {
return Container(
width: size?.width,
height: size?.height,
child: Center(
child: CircularProgressIndicator(),
),
);
},
imageUrl: attachment.thumbUrl ??
attachment.imageUrl ??
attachment.assetUrl,
errorWidget: (context, url, error) => AttachmentError(
attachment: attachment,
size: size,
child: Hero(
tag: attachment.imageUrl ??
attachment.assetUrl ??
attachment.thumbUrl,
child: CachedNetworkImage(
height: size?.height,
width: size?.width,
placeholder: (_, __) {
return Container(
width: size?.width,
height: size?.height,
child: Center(
child: CircularProgressIndicator(),
),
);
},
imageUrl: attachment.thumbUrl ??
attachment.imageUrl ??
attachment.assetUrl,
errorWidget: (context, url, error) => AttachmentError(
attachment: attachment,
size: size,
),
fit: BoxFit.cover,
),
fit: BoxFit.cover,
),
),
],
@@ -75,6 +80,7 @@ class GiphyAttachment extends StatelessWidget {
Container(
alignment: Alignment.bottomCenter,
child: Material(
color: messageTheme.messageBackgroundColor,
child: AttachmentTitle(
messageTheme: messageTheme,
attachment: attachment,
+1
View File
@@ -75,6 +75,7 @@ class ImageAttachment extends StatelessWidget {
),
if (attachment.title != null)
Material(
color: messageTheme.messageBackgroundColor,
child: AttachmentTitle(
messageTheme: messageTheme,
attachment: attachment,
-2
View File
@@ -913,8 +913,6 @@ class MessageInputState extends State<MessageInput> {
void initState() {
super.initState();
StreamChannel.of(context).queryMembersAndWatchers();
_keyboardListener = KeyboardVisibility.onChange.listen((visible) {
if (visible) {
if (_commandsOverlay != null) {
+17
View File
@@ -50,8 +50,14 @@ class StreamChannelState extends State<StreamChannel> {
/// The stream notifying the state of queryMessage call
Stream<bool> get queryMessage => _queryMessageController.stream;
bool _paginationEnded = false;
/// Calls [channel.query] updating [queryMessage] stream
void queryMessages() {
if (_paginationEnded) {
return;
}
_queryMessageController.add(true);
String firstId;
@@ -67,6 +73,10 @@ class StreamChannelState extends State<StreamChannel> {
),
)
.then((res) {
print('res.messages.length: ${res.messages.length}');
if (res.messages.isEmpty) {
_paginationEnded = true;
}
_queryMessageController.add(false);
}).catchError((e, stack) {
_queryMessageController.addError(e, stack);
@@ -75,6 +85,10 @@ class StreamChannelState extends State<StreamChannel> {
/// Calls [channel.getReplies] updating [queryMessage] stream
Future<void> getReplies(String parentId) async {
if (_paginationEnded) {
return;
}
_queryMessageController.add(true);
String firstId;
@@ -95,6 +109,9 @@ class StreamChannelState extends State<StreamChannel> {
),
)
.then((res) {
if (res.messages.isEmpty) {
_paginationEnded = true;
}
_queryMessageController.add(false);
}).catchError((e, stack) {
_queryMessageController.addError(e, stack);
+1 -21
View File
@@ -61,7 +61,6 @@ class StreamChat extends StatefulWidget {
/// The current state of the StreamChat widget
class StreamChatState extends State<StreamChat> with WidgetsBindingObserver {
Client get client => widget.client;
final GlobalKey<NavigatorState> _navigatorKey = GlobalKey<NavigatorState>();
Timer _disconnectTimer;
@override
@@ -79,26 +78,7 @@ class StreamChatState extends State<StreamChat> with WidgetsBindingObserver {
accentColor: streamTheme.accentColor,
scaffoldBackgroundColor: streamTheme.backgroundColor,
),
child: WillPopScope(
onWillPop: () async {
if (_navigatorKey.currentState.canPop()) {
_navigatorKey.currentState.pop();
return false;
} else {
return true;
}
},
child: Navigator(
initialRoute: '/',
key: _navigatorKey,
onGenerateRoute: (settings) {
return MaterialPageRoute(
settings: settings,
builder: (_) => widget.child,
);
},
),
),
child: widget.child,
);
},
),
+1
View File
@@ -149,6 +149,7 @@ class _VideoAttachmentState extends State<VideoAttachment> {
@override
void dispose() {
_videoPlayerController.dispose();
_chewieController.dispose();
super.dispose();
}
}