mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 00:05:16 +00:00
Start to build Forez main route
This commit is contained in:
@ -108,7 +108,7 @@ class _InitializeWidgetState extends SafeState<InitializeWidget> {
|
||||
if (_error || !WebSocketHelper.isConnected()) return _buildNonReadyWidget();
|
||||
|
||||
if (config().mainRouteBuilder != null)
|
||||
return config().mainRouteBuilder(context);
|
||||
return config().mainRouteBuilder(context, mainControllerKey);
|
||||
|
||||
return isTablet(context)
|
||||
? TabletRoute(key: mainControllerKey)
|
||||
|
62
lib/ui/widgets/status_widget.dart
Normal file
62
lib/ui/widgets/status_widget.dart
Normal file
@ -0,0 +1,62 @@
|
||||
import 'package:comunic/helpers/events_helper.dart';
|
||||
import 'package:comunic/helpers/notifications_helper.dart';
|
||||
import 'package:comunic/ui/widgets/safe_state.dart';
|
||||
import 'package:comunic/utils/log_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Status widget
|
||||
///
|
||||
/// Store for its children information about the number of unread conversations
|
||||
/// & the number of unread conversations
|
||||
///
|
||||
/// @author Pierre Hubert
|
||||
|
||||
class StatusWidget extends StatefulWidget {
|
||||
final Widget Function(BuildContext) child;
|
||||
|
||||
const StatusWidget({
|
||||
Key key,
|
||||
@required this.child,
|
||||
}) : assert(child != null),
|
||||
super(key: key);
|
||||
|
||||
@override
|
||||
StatusWidgetState createState() => StatusWidgetState();
|
||||
}
|
||||
|
||||
class StatusWidgetState extends SafeState<StatusWidget> {
|
||||
int unreadNotifications = 0;
|
||||
int unreadConversations = 0;
|
||||
|
||||
Future<void> init() async {
|
||||
try {
|
||||
final res = await NotificationsHelper().countUnread();
|
||||
unreadNotifications = res.notifications;
|
||||
unreadConversations = res.conversations;
|
||||
|
||||
setState(() {});
|
||||
} catch (e, s) {
|
||||
logError(e, s);
|
||||
print("Failed to initialize StatusWidget!");
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
init();
|
||||
super.initState();
|
||||
|
||||
listenChangeState<NewNumberNotifsEvent>(
|
||||
(e) => unreadNotifications = e.newNum);
|
||||
|
||||
listenChangeState<NewNumberUnreadConversations>(
|
||||
(e) => unreadConversations = e.newNum);
|
||||
}
|
||||
|
||||
/// Find an ancestor of this object
|
||||
static StatusWidgetState of(BuildContext c) =>
|
||||
c.findAncestorStateOfType<StatusWidgetState>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => widget.child(context);
|
||||
}
|
32
lib/ui/widgets/tab_transition_widget.dart
Normal file
32
lib/ui/widgets/tab_transition_widget.dart
Normal file
@ -0,0 +1,32 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class TabTransitionWidget extends StatefulWidget {
|
||||
final Widget child;
|
||||
|
||||
const TabTransitionWidget(this.child, {Key key})
|
||||
: assert(child != null),
|
||||
super(key: key);
|
||||
|
||||
@override
|
||||
_TabTransitionWidgetState createState() => _TabTransitionWidgetState();
|
||||
}
|
||||
|
||||
class _TabTransitionWidgetState extends State<TabTransitionWidget> {
|
||||
var _show = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
Future.delayed(Duration(microseconds: 10)).then((value) {
|
||||
if (mounted) setState(() => _show = true);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (!_show)
|
||||
return Center(child: CircularProgressIndicator());
|
||||
else
|
||||
return widget.child;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user