1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-23 05:19:22 +00:00
comunicmobile/lib/ui/widgets/tour/presentation_pane.dart

91 lines
2.4 KiB
Dart
Raw Normal View History

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 {
final IconData? icon;
final Widget? iconWidget;
2021-04-23 11:43:24 +00:00
final String title;
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;
final Future<bool> Function(BuildContext)? onTapNext;
final bool visible;
2021-04-23 11:43:24 +00:00
const PresentationPane({
Key? key,
2021-04-23 11:43:24 +00:00
this.icon,
this.iconWidget,
required this.title,
2021-04-23 11:43:24 +00:00
this.text,
this.child,
this.actionTitle,
this.onActionTap,
this.canGoNext = true,
this.onTapNext,
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(
onPressed: () => onActionTap!(context),
2021-04-23 11:43:24 +00:00
child: Text(
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),
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),
child: SingleChildScrollView(child: child!(context))),
2021-04-23 11:43:24 +00:00
Spacer(flex: 1),
],
);
}
}