mirror of
https://github.com/johrpan/christmas_cats.git
synced 2025-10-28 19:27:25 +01:00
Version 0.1.0
This commit is contained in:
commit
5dda59a6cd
73 changed files with 5741 additions and 0 deletions
57
lib/widgets/menu.dart
Normal file
57
lib/widgets/menu.dart
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../localizations.dart';
|
||||
|
||||
import 'menu_entry.dart';
|
||||
|
||||
class Menu extends StatelessWidget {
|
||||
final String title;
|
||||
final String subtitle;
|
||||
final List<Widget> children;
|
||||
final bool showBackButton;
|
||||
|
||||
Menu({
|
||||
this.title,
|
||||
this.subtitle,
|
||||
this.children,
|
||||
this.showBackButton = false,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final localizations = ChristmasCatsLocalizations.of(context);
|
||||
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
if (title != null)
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 64.0,
|
||||
),
|
||||
),
|
||||
if (subtitle != null)
|
||||
Text(
|
||||
subtitle,
|
||||
style: TextStyle(fontSize: 32.0),
|
||||
),
|
||||
SizedBox(
|
||||
height: 16.0,
|
||||
),
|
||||
...?children,
|
||||
if (showBackButton) ...[
|
||||
SizedBox(
|
||||
height: 32.0,
|
||||
),
|
||||
MenuEntry(
|
||||
text: localizations.back,
|
||||
onTap: () => Navigator.pop(context),
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
31
lib/widgets/menu_entry.dart
Normal file
31
lib/widgets/menu_entry.dart
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class MenuEntry extends StatelessWidget {
|
||||
final String text;
|
||||
final void Function() onTap;
|
||||
|
||||
MenuEntry({
|
||||
@required this.text,
|
||||
this.onTap,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
child: Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
text,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 40.0,
|
||||
height: 1.1,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
onTap: onTap,
|
||||
);
|
||||
}
|
||||
}
|
||||
45
lib/widgets/transparent_route.dart
Normal file
45
lib/widgets/transparent_route.dart
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
// This is a modified version of MaterialPageRoute that we can't extend without
|
||||
// hitting an assertion.
|
||||
class TransparentRoute<T> extends PageRoute<T> {
|
||||
final Widget Function(BuildContext context) builder;
|
||||
|
||||
MaterialPageRoute route;
|
||||
|
||||
TransparentRoute({
|
||||
this.builder,
|
||||
});
|
||||
|
||||
@override
|
||||
bool get opaque => false;
|
||||
|
||||
@override
|
||||
Color get barrierColor => null;
|
||||
|
||||
@override
|
||||
String get barrierLabel => null;
|
||||
|
||||
@override
|
||||
bool get maintainState => true;
|
||||
|
||||
@override
|
||||
Duration get transitionDuration => Duration(milliseconds: 300);
|
||||
|
||||
@override
|
||||
Widget buildPage(BuildContext context, Animation<double> animation,
|
||||
Animation<double> secondaryAnimation) {
|
||||
final result = builder(context);
|
||||
return Semantics(
|
||||
scopesRoute: true,
|
||||
explicitChildNodes: true,
|
||||
child: result,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildTransitions(BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
|
||||
final PageTransitionsTheme theme = Theme.of(context).pageTransitionsTheme;
|
||||
return theme.buildTransitions<T>(this, context, animation, secondaryAnimation, child);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue