mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 08:15:16 +00:00
Start to build groups page
This commit is contained in:
@ -2,6 +2,7 @@ import 'package:comunic/helpers/account_helper.dart';
|
||||
import 'package:comunic/ui/routes/app_settings_route.dart';
|
||||
import 'package:comunic/ui/screens/conversations_list_screen.dart';
|
||||
import 'package:comunic/ui/screens/friends_list_screen.dart';
|
||||
import 'package:comunic/ui/screens/group_screen.dart';
|
||||
import 'package:comunic/ui/screens/groups_list_screen.dart';
|
||||
import 'package:comunic/ui/screens/newest_posts.dart';
|
||||
import 'package:comunic/ui/screens/notifications_screen.dart';
|
||||
@ -21,6 +22,10 @@ import 'login_route.dart';
|
||||
class HomeRoute extends StatefulWidget {
|
||||
@override
|
||||
State<StatefulWidget> createState() => _HomeRouteState();
|
||||
|
||||
/// Get current instance of Home controller
|
||||
static HomeController of(BuildContext context) =>
|
||||
context.findAncestorStateOfType<HomeController>();
|
||||
}
|
||||
|
||||
class CurrPage {
|
||||
@ -28,9 +33,24 @@ class CurrPage {
|
||||
final Map<String, dynamic> args;
|
||||
|
||||
const CurrPage(this.action, {this.args}) : assert(action != null);
|
||||
|
||||
@override
|
||||
String toString() =>
|
||||
"CurrPage {\n\taction: " +
|
||||
this.action.toString() +
|
||||
"\n\targs: " +
|
||||
this.args.toString() +
|
||||
"\n}";
|
||||
}
|
||||
|
||||
class _HomeRouteState extends State<HomeRoute> {
|
||||
/// Public interface of home controller
|
||||
abstract class HomeController extends State<HomeRoute> {
|
||||
/// Open a specific group page specified by its [groupID]
|
||||
void openGroup(int groupID);
|
||||
}
|
||||
|
||||
/// Private implementation of HomeController
|
||||
class _HomeRouteState extends HomeController {
|
||||
CurrPage get _currTab => history.last;
|
||||
List<CurrPage> history = List();
|
||||
|
||||
@ -106,6 +126,9 @@ class _HomeRouteState extends State<HomeRoute> {
|
||||
case BarCallbackActions.OPEN_GROUPS:
|
||||
return GroupsListScreen();
|
||||
|
||||
case BarCallbackActions.OPEN_GROUP_PAGE:
|
||||
return GroupPageScreen(groupID: _currTab.args["groupID"]);
|
||||
|
||||
default:
|
||||
throw "Invalid tab : " + _currTab.toString();
|
||||
}
|
||||
@ -156,4 +179,10 @@ class _HomeRouteState extends State<HomeRoute> {
|
||||
return LoginRoute();
|
||||
}));
|
||||
}
|
||||
|
||||
@override
|
||||
void openGroup(int groupID) {
|
||||
_pushPage(CurrPage(BarCallbackActions.OPEN_GROUP_PAGE,
|
||||
args: {"groupID": groupID}));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user