2021-04-23 11:43:24 +00:00
|
|
|
/// Application presentation tour pane
|
|
|
|
///
|
|
|
|
/// @author Pierre Hubert
|
|
|
|
import 'package:comunic/ui/widgets/tour/fixed_tour_size_text_area.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
class PresentationPane extends StatelessWidget {
|
2022-03-10 18:39:57 +00:00
|
|
|
final IconData? icon;
|
|
|
|
final Widget? iconWidget;
|
2021-04-23 11:43:24 +00:00
|
|
|
final String title;
|
2022-03-10 18:39:57 +00:00
|
|
|
final String? text;
|
|
|
|
final Function(BuildContext)? child;
|
|
|
|
final String? actionTitle;
|
|
|
|
final Function(BuildContext)? onActionTap;
|
2021-04-23 11:43:24 +00:00
|
|
|
final bool canGoNext;
|
2022-03-10 18:39:57 +00:00
|
|
|
final Future<bool> Function(BuildContext)? onTapNext;
|
2021-04-26 08:49:33 +00:00
|
|
|
final bool visible;
|
2021-04-23 11:43:24 +00:00
|
|
|
|
|
|
|
const PresentationPane({
|
2022-03-10 18:39:57 +00:00
|
|
|
Key? key,
|
2021-04-23 11:43:24 +00:00
|
|
|
this.icon,
|
|
|
|
this.iconWidget,
|
2022-03-10 18:39:57 +00:00
|
|
|
required this.title,
|
2021-04-23 11:43:24 +00:00
|
|
|
this.text,
|
|
|
|
this.child,
|
|
|
|
this.actionTitle,
|
|
|
|
this.onActionTap,
|
|
|
|
this.canGoNext = true,
|
|
|
|
this.onTapNext,
|
2021-04-26 08:49:33 +00:00
|
|
|
this.visible = true,
|
2021-04-23 11:43:24 +00:00
|
|
|
}) : assert(icon != null || iconWidget != null),
|
|
|
|
assert(text != null || child != null),
|
|
|
|
super(key: key);
|
|
|
|
|
|
|
|
bool get _hasAction => actionTitle != null && onActionTap != null;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
if (text != null)
|
|
|
|
return Column(
|
|
|
|
children: <Widget>[
|
|
|
|
Spacer(flex: 3),
|
2022-03-11 15:40:56 +00:00
|
|
|
icon != null
|
|
|
|
? Icon(icon, color: Colors.white, size: 50)
|
|
|
|
: iconWidget!,
|
2021-04-23 11:43:24 +00:00
|
|
|
Spacer(flex: 1),
|
|
|
|
Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(fontSize: 20),
|
|
|
|
),
|
|
|
|
Spacer(flex: 1),
|
|
|
|
FixedTourSizeTextArea(text),
|
|
|
|
Spacer(flex: 1),
|
|
|
|
_hasAction
|
|
|
|
? OutlinedButton(
|
2022-03-10 18:39:57 +00:00
|
|
|
onPressed: () => onActionTap!(context),
|
2021-04-23 11:43:24 +00:00
|
|
|
child: Text(
|
2022-03-10 18:39:57 +00:00
|
|
|
actionTitle!,
|
2021-04-23 11:43:24 +00:00
|
|
|
style: TextStyle(color: Colors.white),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: Opacity(
|
|
|
|
opacity: 0,
|
|
|
|
child: OutlinedButton(
|
|
|
|
onPressed: null,
|
|
|
|
child: Text(""),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Spacer(flex: 3),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
|
|
|
|
return Column(
|
|
|
|
children: <Widget>[
|
|
|
|
Spacer(flex: 1),
|
2022-03-10 18:39:57 +00:00
|
|
|
icon != null ? Icon(icon, color: Colors.white, size: 50) : iconWidget!,
|
2021-04-23 11:43:24 +00:00
|
|
|
Spacer(flex: 1),
|
|
|
|
Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(fontSize: 20),
|
|
|
|
),
|
|
|
|
Spacer(flex: 1),
|
|
|
|
ConstrainedBox(
|
|
|
|
constraints: BoxConstraints(maxHeight: 300),
|
2022-03-10 18:39:57 +00:00
|
|
|
child: SingleChildScrollView(child: child!(context))),
|
2021-04-23 11:43:24 +00:00
|
|
|
Spacer(flex: 1),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|