mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-04 12:14:11 +00:00 
			
		
		
		
	Start to build join group pane
This commit is contained in:
		@@ -1,21 +0,0 @@
 | 
			
		||||
import 'package:comunic/ui/routes/tour_route.dart';
 | 
			
		||||
import 'package:comunic/ui/widgets/tour/first_pane.dart';
 | 
			
		||||
import 'package:comunic/ui/widgets/tour/last_pane.dart';
 | 
			
		||||
import 'package:comunic/utils/intl_utils.dart';
 | 
			
		||||
import 'package:flutter/material.dart';
 | 
			
		||||
 | 
			
		||||
/// Forez tour builder
 | 
			
		||||
///
 | 
			
		||||
/// Handles the presentation tour for the Forez flavor application
 | 
			
		||||
///
 | 
			
		||||
/// @author Pierre Hubert
 | 
			
		||||
 | 
			
		||||
List<Widget> buildTour(TourRouteState state) => [
 | 
			
		||||
      FirstTourPane(
 | 
			
		||||
        msgOne: tr(
 | 
			
		||||
            "Welcome to #Forez, the central application dedicated to events planning in the Forez plain!"),
 | 
			
		||||
        msgTwo: tr(
 | 
			
		||||
            "Let's configure the application and present you some features!"),
 | 
			
		||||
      ),
 | 
			
		||||
      LastTourPane(),
 | 
			
		||||
    ];
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
import 'dart:io';
 | 
			
		||||
 | 
			
		||||
import 'package:comunic/forez/forez_tour_builder.dart';
 | 
			
		||||
import 'package:comunic/forez/tour/forez_tour_builder.dart';
 | 
			
		||||
import 'package:comunic/main.dart';
 | 
			
		||||
import 'package:comunic/models/config.dart';
 | 
			
		||||
import 'package:comunic/utils/intl_utils.dart';
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										33
									
								
								lib/forez/tour/forez_tour_builder.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								lib/forez/tour/forez_tour_builder.dart
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,33 @@
 | 
			
		||||
import 'package:comunic/forez/tour/join_group_pane.dart';
 | 
			
		||||
import 'package:comunic/ui/routes/tour_route.dart';
 | 
			
		||||
import 'package:comunic/ui/widgets/tour/first_pane.dart';
 | 
			
		||||
import 'package:comunic/ui/widgets/tour/last_pane.dart';
 | 
			
		||||
import 'package:comunic/utils/intl_utils.dart';
 | 
			
		||||
import 'package:flutter/material.dart';
 | 
			
		||||
 | 
			
		||||
/// Forez tour builder
 | 
			
		||||
///
 | 
			
		||||
/// Handles the presentation tour for the Forez flavor application
 | 
			
		||||
///
 | 
			
		||||
/// @author Pierre Hubert
 | 
			
		||||
 | 
			
		||||
const _JOIN_GROUP_KEY_ID = 1;
 | 
			
		||||
 | 
			
		||||
List<Widget> buildTour(TourRouteState state) {
 | 
			
		||||
  if (!state.pubKeys.containsKey(_JOIN_GROUP_KEY_ID))
 | 
			
		||||
    state.pubKeys[_JOIN_GROUP_KEY_ID] = GlobalKey();
 | 
			
		||||
 | 
			
		||||
  return [
 | 
			
		||||
    FirstTourPane(
 | 
			
		||||
      msgOne: tr(
 | 
			
		||||
          "Welcome to #Forez, the central application dedicated to events planning in the Forez plain!"),
 | 
			
		||||
      msgTwo: tr(
 | 
			
		||||
          "Let's configure the application and present you some essential features!"),
 | 
			
		||||
    ),
 | 
			
		||||
    JoinGroupPane(
 | 
			
		||||
      key: state.pubKeys[_JOIN_GROUP_KEY_ID],
 | 
			
		||||
      onUpdated: () => state.rebuild(),
 | 
			
		||||
    ),
 | 
			
		||||
    LastTourPane(),
 | 
			
		||||
  ];
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										66
									
								
								lib/forez/tour/join_group_pane.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								lib/forez/tour/join_group_pane.dart
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,66 @@
 | 
			
		||||
import 'package:comunic/helpers/forez_groups_helper.dart';
 | 
			
		||||
import 'package:comunic/models/group.dart';
 | 
			
		||||
import 'package:comunic/ui/widgets/async_screen_widget.dart';
 | 
			
		||||
import 'package:comunic/ui/widgets/tour/presentation_pane.dart';
 | 
			
		||||
import 'package:comunic/utils/intl_utils.dart';
 | 
			
		||||
import 'package:flutter/material.dart';
 | 
			
		||||
 | 
			
		||||
/// Ask the user to join a Forez group
 | 
			
		||||
///
 | 
			
		||||
/// @author Pierre Hubert
 | 
			
		||||
 | 
			
		||||
class JoinGroupPane extends PresentationPane {
 | 
			
		||||
  JoinGroupPane({
 | 
			
		||||
    @required Function() onUpdated,
 | 
			
		||||
    @required GlobalKey key,
 | 
			
		||||
  }) : super(
 | 
			
		||||
          icon: Icons.login,
 | 
			
		||||
          title: tr("Join a group"),
 | 
			
		||||
          child: (c) => _JoinGroupPaneBody(
 | 
			
		||||
            key: key,
 | 
			
		||||
            onUpdated: onUpdated,
 | 
			
		||||
          ),
 | 
			
		||||
        );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class _JoinGroupPaneBody extends StatefulWidget {
 | 
			
		||||
  final Function() onUpdated;
 | 
			
		||||
 | 
			
		||||
  const _JoinGroupPaneBody({
 | 
			
		||||
    Key key,
 | 
			
		||||
    @required this.onUpdated,
 | 
			
		||||
  })  : assert(onUpdated != null),
 | 
			
		||||
        super(key: key);
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  __JoinGroupPaneBodyState createState() => __JoinGroupPaneBodyState();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class __JoinGroupPaneBodyState extends State<_JoinGroupPaneBody> {
 | 
			
		||||
  List<Group> _groups;
 | 
			
		||||
 | 
			
		||||
  Future<void> _load() async {
 | 
			
		||||
    _groups = await ForezGroupsHelper.getForezGroups();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  Widget build(BuildContext context) => AsyncScreenWidget(
 | 
			
		||||
      onReload: _load,
 | 
			
		||||
      onBuild: onBuild,
 | 
			
		||||
      errorMessage: tr("Failed to load the list of Forez groups!"));
 | 
			
		||||
 | 
			
		||||
  List<Widget> get _initialWidgets => [
 | 
			
		||||
        Text(tr("Please choose now the Forez group you want to join...")),
 | 
			
		||||
      ];
 | 
			
		||||
 | 
			
		||||
  Widget onBuild() => Flexible(
 | 
			
		||||
          child: ListView.builder(
 | 
			
		||||
        itemCount: _initialWidgets.length + _groups.length,
 | 
			
		||||
        itemBuilder: (c, i) {
 | 
			
		||||
          if (i < _initialWidgets.length) return _initialWidgets[i];
 | 
			
		||||
 | 
			
		||||
          final group = _groups[i - _initialWidgets.length];
 | 
			
		||||
          return ListTile();
 | 
			
		||||
        },
 | 
			
		||||
      ));
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user