mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-25 06:19:22 +00:00
Load group information
This commit is contained in:
parent
4ed382a7c4
commit
c4790635df
@ -1,4 +1,6 @@
|
|||||||
|
import 'package:comunic/helpers/groups_helper.dart';
|
||||||
import 'package:comunic/helpers/preferences_helper.dart';
|
import 'package:comunic/helpers/preferences_helper.dart';
|
||||||
|
import 'package:comunic/models/advanced_group_info.dart';
|
||||||
|
|
||||||
/// Forez group helper
|
/// Forez group helper
|
||||||
///
|
///
|
||||||
@ -6,6 +8,8 @@ import 'package:comunic/helpers/preferences_helper.dart';
|
|||||||
///
|
///
|
||||||
/// @author Pierre Hubert
|
/// @author Pierre Hubert
|
||||||
|
|
||||||
|
AdvancedGroupInfo _forezGroup;
|
||||||
|
|
||||||
class ForezGroupHelper {
|
class ForezGroupHelper {
|
||||||
static Future<void> setId(int groupID) async {
|
static Future<void> setId(int groupID) async {
|
||||||
(await PreferencesHelper.getInstance())
|
(await PreferencesHelper.getInstance())
|
||||||
@ -16,4 +20,14 @@ class ForezGroupHelper {
|
|||||||
return (await PreferencesHelper.getInstance())
|
return (await PreferencesHelper.getInstance())
|
||||||
.getInt(PreferencesKeyList.FOREZ_GROUP);
|
.getInt(PreferencesKeyList.FOREZ_GROUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Future<void> refreshInfo() async {
|
||||||
|
final res = await GroupsHelper().getAdvancedInfo(await getId());
|
||||||
|
assert(res.status == GetAdvancedInfoStatus.SUCCESS);
|
||||||
|
_forezGroup = res.info;
|
||||||
|
}
|
||||||
|
|
||||||
|
static AdvancedGroupInfo getGroup() => _forezGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AdvancedGroupInfo get forezGroup => ForezGroupHelper.getGroup();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:comunic/forez/helpers/forez_group_helper.dart';
|
||||||
import 'package:comunic/forez/tour/forez_tour_builder.dart';
|
import 'package:comunic/forez/tour/forez_tour_builder.dart';
|
||||||
import 'package:comunic/forez/ui/routes/forez_route.dart';
|
import 'package:comunic/forez/ui/routes/forez_route.dart';
|
||||||
import 'package:comunic/main.dart';
|
import 'package:comunic/main.dart';
|
||||||
@ -34,6 +35,7 @@ void main() {
|
|||||||
appName: "#Forez",
|
appName: "#Forez",
|
||||||
appQuickDescription: tr("Events organisation in Forez plain"),
|
appQuickDescription: tr("Events organisation in Forez plain"),
|
||||||
toursEntriesBuilder: buildTour,
|
toursEntriesBuilder: buildTour,
|
||||||
|
additionalLoading: () => ForezGroupHelper.refreshInfo(),
|
||||||
mainRouteBuilder: (c, k) => ForezRoute(key: k),
|
mainRouteBuilder: (c, k) => ForezRoute(key: k),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:comunic/forez/helpers/forez_group_helper.dart';
|
||||||
import 'package:comunic/models/conversation.dart';
|
import 'package:comunic/models/conversation.dart';
|
||||||
import 'package:comunic/ui/dialogs/alert_dialog.dart';
|
import 'package:comunic/ui/dialogs/alert_dialog.dart';
|
||||||
import 'package:comunic/ui/routes/main_route/main_route.dart';
|
import 'package:comunic/ui/routes/main_route/main_route.dart';
|
||||||
@ -74,7 +75,7 @@ class _ForezRouteBodyState extends SafeState<ForezRouteBody> {
|
|||||||
length: _tabs.length,
|
length: _tabs.length,
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text("#Forez"),
|
title: Text(forezGroup.name),
|
||||||
actions: <Widget>[_buildPopupMenuButton()],
|
actions: <Widget>[_buildPopupMenuButton()],
|
||||||
bottom: TabBar(tabs: _tabs),
|
bottom: TabBar(tabs: _tabs),
|
||||||
),
|
),
|
||||||
@ -103,7 +104,7 @@ class _ForezRouteBodyState extends SafeState<ForezRouteBody> {
|
|||||||
MainController.of(context).openSettings();
|
MainController.of(context).openSettings();
|
||||||
break;
|
break;
|
||||||
case _PopupMenuItems.ACTION_SIGN_OUT:
|
case _PopupMenuItems.ACTION_SIGN_OUT:
|
||||||
// TODO : handle logout
|
MainController.of(context).requestLogout();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,9 @@ class Config {
|
|||||||
// Entries for the welcome tour
|
// Entries for the welcome tour
|
||||||
final TourEntriesBuilder toursEntriesBuilder;
|
final TourEntriesBuilder toursEntriesBuilder;
|
||||||
|
|
||||||
|
// Custom initialization
|
||||||
|
final Future<void> Function() additionalLoading;
|
||||||
|
|
||||||
// Custom main application route
|
// Custom main application route
|
||||||
final Widget Function(BuildContext, GlobalKey) mainRouteBuilder;
|
final Widget Function(BuildContext, GlobalKey) mainRouteBuilder;
|
||||||
|
|
||||||
@ -41,6 +44,7 @@ class Config {
|
|||||||
this.appName = "Comunic",
|
this.appName = "Comunic",
|
||||||
this.appQuickDescription,
|
this.appQuickDescription,
|
||||||
this.toursEntriesBuilder,
|
this.toursEntriesBuilder,
|
||||||
|
this.additionalLoading,
|
||||||
this.mainRouteBuilder,
|
this.mainRouteBuilder,
|
||||||
}) : assert(apiServerName != null),
|
}) : assert(apiServerName != null),
|
||||||
assert(apiServerUri != null),
|
assert(apiServerUri != null),
|
||||||
|
@ -114,8 +114,11 @@ class _ConversationScreenState extends SafeState<ConversationsListScreen> {
|
|||||||
|
|
||||||
/// Create a new conversation
|
/// Create a new conversation
|
||||||
void _createConversation() {
|
void _createConversation() {
|
||||||
MainController.of(context)
|
MainController.of(context).push(
|
||||||
.push(CreateConversationScreen(), canShowAsDialog: true);
|
CreateConversationScreen(),
|
||||||
|
canShowAsDialog: true,
|
||||||
|
hideNavBar: true,
|
||||||
|
);
|
||||||
if (widget.onOpen != null) widget.onOpen();
|
if (widget.onOpen != null) widget.onOpen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,6 +90,9 @@ class _InitializeWidgetState extends SafeState<InitializeWidget> {
|
|||||||
|
|
||||||
print("Attempting WebSocket connection...");
|
print("Attempting WebSocket connection...");
|
||||||
|
|
||||||
|
if (config().additionalLoading != null)
|
||||||
|
await config().additionalLoading();
|
||||||
|
|
||||||
setState(() {});
|
setState(() {});
|
||||||
} catch (e, stack) {
|
} catch (e, stack) {
|
||||||
print("Could not connect to server! $e");
|
print("Could not connect to server! $e");
|
||||||
|
Loading…
Reference in New Issue
Block a user