mirror of
https://github.com/jaysavsani07/math-metrix.git
synced 2025-08-06 15:11:40 +08:00
Unused code remoced
This commit is contained in:
@ -1,5 +1,4 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:mathgame/src/resources/gameCategoryDataProvider.dart';
|
||||
|
||||
class GameInfoDialog {
|
||||
String title;
|
||||
|
@ -30,4 +30,7 @@ class MathPair {
|
||||
other is MathPair &&
|
||||
runtimeType == other.runtimeType &&
|
||||
text == other.text;
|
||||
|
||||
@override
|
||||
int get hashCode => text.hashCode;
|
||||
}
|
||||
|
@ -1,6 +0,0 @@
|
||||
library giffy_dialog;
|
||||
|
||||
export 'src/asset.dart';
|
||||
export 'src/flare.dart';
|
||||
export 'src/network.dart';
|
||||
export 'src/base_dialog.dart' show EntryAnimation;
|
@ -1,141 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../giffy_dialog.dart';
|
||||
import 'base_dialog.dart';
|
||||
|
||||
/// Widget that displays Giffy Dialog with local asset.
|
||||
///
|
||||
/// You need local asset for this type of Giffy Dialog.
|
||||
/// Asset can be `.gif`, `.jpg` or `.png` image file. GIF animation is supported.
|
||||
/// Transparency of the image is retained.
|
||||
/// Place the asset under `/assets` directory in the project root.
|
||||
/// Add the asset to `pubspec.yaml` like so
|
||||
/// ```
|
||||
/// assets:
|
||||
/// - assets/my_awesome_image.gif
|
||||
/// ```
|
||||
/// Pass the asset to [AssetGiffyDialog] via [image] prop using Flutter's `Image.asset(name)` widget.
|
||||
/// ```
|
||||
/// AssetGiffyDialog(
|
||||
/// title: Text('Example'),
|
||||
/// description: Text('Dialog text'),
|
||||
/// image: Image.asset(
|
||||
/// 'assets/my_awesome_image.gif',
|
||||
/// fit: BoxFit.cover,
|
||||
/// ),
|
||||
/// ...,
|
||||
/// );
|
||||
class AssetGiffyDialog extends StatelessWidget {
|
||||
AssetGiffyDialog({
|
||||
Key key,
|
||||
@required this.image,
|
||||
@required this.title,
|
||||
this.onOkButtonPressed,
|
||||
this.onCancelButtonPressed,
|
||||
this.description,
|
||||
this.onlyOkButton = false,
|
||||
this.onlyCancelButton = false,
|
||||
this.buttonOkText,
|
||||
this.buttonCancelText,
|
||||
this.buttonOkColor = Colors.green,
|
||||
this.buttonCancelColor = Colors.grey,
|
||||
this.cornerRadius = 8.0,
|
||||
this.buttonRadius = 8.0,
|
||||
this.entryAnimation = EntryAnimation.DEFAULT,
|
||||
}) : assert(image != null),
|
||||
assert(title != null),
|
||||
super(key: key);
|
||||
|
||||
/// Image to display in dialog.
|
||||
///
|
||||
/// Pass `Image.asset(name)` widget here.
|
||||
/// Preferably with `fit: BoxFit.cover` property to cover entire top part of Giffy Dialog.
|
||||
/// All properties of Image widget are directly passed to Giffy Dialog so feel free to experiment.
|
||||
final Image image;
|
||||
|
||||
/// Title text.
|
||||
final Text title;
|
||||
|
||||
/// Description text.
|
||||
final Text description;
|
||||
|
||||
/// Sets dialog to have only OK button.
|
||||
///
|
||||
/// Default is false.
|
||||
/// If set to true there is no need to set [buttonCancelText], [buttonCancelColor] and [onCancelButtonPressed]
|
||||
final bool onlyOkButton;
|
||||
|
||||
/// Sets dialog to have only Cancel button.
|
||||
///
|
||||
/// Default is false.
|
||||
/// If set to true there is no need to set [buttonOkText], [buttonOkColor] and [onOkButtonPressed]
|
||||
final bool onlyCancelButton;
|
||||
|
||||
|
||||
/// Text for OK button.
|
||||
///
|
||||
/// Default is `OK`.
|
||||
final Text buttonOkText;
|
||||
|
||||
/// Text for cancel button
|
||||
///
|
||||
/// Default is `Cancel`.
|
||||
final Text buttonCancelText;
|
||||
|
||||
/// Color of OK button.
|
||||
///
|
||||
/// Default is `Colors.green`.
|
||||
final Color buttonOkColor;
|
||||
|
||||
/// Color of Cancel button
|
||||
///
|
||||
/// Default is `Colors.grey`.
|
||||
final Color buttonCancelColor;
|
||||
|
||||
/// Radius applied to the button corners.
|
||||
///
|
||||
/// Default is 8.
|
||||
final double buttonRadius;
|
||||
|
||||
/// Radius applied to the dialog box corners.
|
||||
///
|
||||
/// Default is 8.
|
||||
final double cornerRadius;
|
||||
|
||||
/// Callback function to be called on when OK button is pressed.
|
||||
///
|
||||
/// If set to null, then the button will be disabled and by
|
||||
/// default will resemble a flat button in the Theme's `disabledColor`.
|
||||
final VoidCallback onOkButtonPressed;
|
||||
|
||||
/// Callback function to be called on when Cancel button is pressed.
|
||||
///
|
||||
/// By default (or if set to null) closes the Giffy Dialog via `Navigator.of(context).pop()`.
|
||||
final VoidCallback onCancelButtonPressed;
|
||||
|
||||
/// Defines how Giffy Dialog will enter the screen.
|
||||
///
|
||||
/// Default is [EntryAnimation.DEFAULT] - standard Material dialog
|
||||
/// entrance animation, i.e. slow fade-in in the center of the screen.
|
||||
final EntryAnimation entryAnimation;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BaseGiffyDialog(
|
||||
imageWidget: image,
|
||||
cornerRadius: cornerRadius,
|
||||
title: title,
|
||||
description: description,
|
||||
onlyOkButton: onlyOkButton,
|
||||
onlyCancelButton: onlyCancelButton,
|
||||
buttonCancelColor: buttonCancelColor,
|
||||
buttonRadius: buttonRadius,
|
||||
buttonCancelText: buttonCancelText,
|
||||
buttonOkColor: buttonOkColor,
|
||||
onOkButtonPressed: onOkButtonPressed,
|
||||
onCancelButtonPressed: onCancelButtonPressed,
|
||||
buttonOkText: buttonOkText,
|
||||
entryAnimation: entryAnimation,
|
||||
);
|
||||
}
|
||||
}
|
@ -1,268 +0,0 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Defines variants of entry animations
|
||||
enum EntryAnimation {
|
||||
/// Appears in Center, standard Material dialog entrance animation, i.e. slow fade-in in the center of the screen.
|
||||
DEFAULT,
|
||||
|
||||
/// Enters screen horizontally from the left
|
||||
LEFT,
|
||||
|
||||
/// Enters screen horizontally from the right
|
||||
RIGHT,
|
||||
|
||||
/// Enters screen horizontally from the top
|
||||
TOP,
|
||||
|
||||
/// Enters screen horizontally from the bottom
|
||||
BOTTOM,
|
||||
|
||||
/// Enters screen from the top left corner
|
||||
TOP_LEFT,
|
||||
|
||||
/// Enters screen from the top right corner
|
||||
TOP_RIGHT,
|
||||
|
||||
/// Enters screen from the bottom left corner
|
||||
BOTTOM_LEFT,
|
||||
|
||||
/// Enters screen from the bottom right corner
|
||||
BOTTOM_RIGHT,
|
||||
}
|
||||
|
||||
class BaseGiffyDialog extends StatefulWidget {
|
||||
BaseGiffyDialog({
|
||||
Key key,
|
||||
@required this.imageWidget,
|
||||
@required this.title,
|
||||
@required this.onOkButtonPressed,
|
||||
@required this.description,
|
||||
@required this.onlyOkButton,
|
||||
@required this.onlyCancelButton,
|
||||
@required this.buttonOkText,
|
||||
@required this.buttonCancelText,
|
||||
@required this.buttonOkColor,
|
||||
@required this.buttonCancelColor,
|
||||
@required this.cornerRadius,
|
||||
@required this.buttonRadius,
|
||||
@required this.entryAnimation,
|
||||
@required this.onCancelButtonPressed,
|
||||
}) : super(key: key);
|
||||
|
||||
final Widget imageWidget;
|
||||
final Text title;
|
||||
final Text description;
|
||||
final bool onlyOkButton;
|
||||
final bool onlyCancelButton;
|
||||
final Text buttonOkText;
|
||||
final Text buttonCancelText;
|
||||
final Color buttonOkColor;
|
||||
final Color buttonCancelColor;
|
||||
final double buttonRadius;
|
||||
final double cornerRadius;
|
||||
final VoidCallback onOkButtonPressed;
|
||||
final VoidCallback onCancelButtonPressed;
|
||||
final EntryAnimation entryAnimation;
|
||||
|
||||
@override
|
||||
_BaseGiffyDialogState createState() => _BaseGiffyDialogState();
|
||||
}
|
||||
|
||||
class _BaseGiffyDialogState extends State<BaseGiffyDialog>
|
||||
with TickerProviderStateMixin {
|
||||
AnimationController _animationController;
|
||||
Animation<Offset> _entryAnimation;
|
||||
|
||||
get _start {
|
||||
switch (widget.entryAnimation) {
|
||||
case EntryAnimation.DEFAULT:
|
||||
break;
|
||||
case EntryAnimation.TOP:
|
||||
return Offset(0.0, -1.0);
|
||||
case EntryAnimation.TOP_LEFT:
|
||||
return Offset(-1.0, -1.0);
|
||||
case EntryAnimation.TOP_RIGHT:
|
||||
return Offset(1.0, -1.0);
|
||||
case EntryAnimation.LEFT:
|
||||
return Offset(-1.0, 0.0);
|
||||
case EntryAnimation.RIGHT:
|
||||
return Offset(1.0, 0.0);
|
||||
case EntryAnimation.BOTTOM:
|
||||
return Offset(0.0, 1.0);
|
||||
case EntryAnimation.BOTTOM_LEFT:
|
||||
return Offset(-1.0, 1.0);
|
||||
case EntryAnimation.BOTTOM_RIGHT:
|
||||
return Offset(1.0, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
get _isDefaultEntryAnimation =>
|
||||
widget.entryAnimation == EntryAnimation.DEFAULT;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (!_isDefaultEntryAnimation) {
|
||||
_animationController = AnimationController(
|
||||
vsync: this,
|
||||
duration: Duration(milliseconds: 300),
|
||||
);
|
||||
_entryAnimation =
|
||||
Tween<Offset>(begin: _start, end: Offset(0.0, 0.0)).animate(
|
||||
CurvedAnimation(
|
||||
parent: _animationController,
|
||||
curve: Curves.easeIn,
|
||||
),
|
||||
)..addListener(() => setState(() {}));
|
||||
_animationController.forward();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_animationController?.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Widget _buildPortraitWidget(BuildContext context, Widget imageWidget) {
|
||||
return Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(5),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.only(
|
||||
topRight: Radius.circular(widget.cornerRadius),
|
||||
topLeft: Radius.circular(widget.cornerRadius)),
|
||||
),
|
||||
child: imageWidget
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 16.0),
|
||||
child: widget.title,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: widget.description,
|
||||
),
|
||||
_buildButtonsBar(context)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLandscapeWidget(BuildContext context, Widget imageWidget) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(widget.cornerRadius),
|
||||
bottomLeft: Radius.circular(widget.cornerRadius)),
|
||||
child: imageWidget,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 16.0),
|
||||
child: widget.title,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(3.0),
|
||||
child: widget.description,
|
||||
),
|
||||
_buildButtonsBar(context),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildButtonsBar(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: !widget.onlyOkButton
|
||||
? MainAxisAlignment.spaceEvenly
|
||||
: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
if (!widget.onlyOkButton) ...[
|
||||
RaisedButton(
|
||||
color: widget.buttonCancelColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(widget.buttonRadius)),
|
||||
onPressed: widget.onCancelButtonPressed ??
|
||||
() => Navigator.of(context).pop(),
|
||||
child: widget.buttonCancelText ??
|
||||
Text(
|
||||
'Cancel',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
)
|
||||
],
|
||||
if (!widget.onlyCancelButton) ...[
|
||||
RaisedButton(
|
||||
color: widget.buttonOkColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(widget.buttonRadius)),
|
||||
onPressed: widget.onOkButtonPressed,
|
||||
child: widget.buttonOkText ??
|
||||
Text(
|
||||
'OK',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final width = MediaQuery.of(context).size.width;
|
||||
final isPortrait =
|
||||
MediaQuery.of(context).orientation == Orientation.portrait;
|
||||
return Dialog(
|
||||
elevation: 0.0,
|
||||
backgroundColor: Colors.transparent,
|
||||
child: Container(
|
||||
transform: !_isDefaultEntryAnimation
|
||||
? Matrix4.translationValues(
|
||||
_entryAnimation.value.dx * width,
|
||||
_entryAnimation.value.dy * width,
|
||||
0,
|
||||
)
|
||||
: null,
|
||||
height: MediaQuery.of(context).size.height * 0.7,
|
||||
width: MediaQuery.of(context).size.width * (isPortrait ? 0.8 : 0.6),
|
||||
child: Material(
|
||||
type: MaterialType.card,
|
||||
color: Color(0xFF363636),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(widget.cornerRadius)),
|
||||
elevation: Theme.of(context).dialogTheme.elevation ?? 24.0,
|
||||
child: isPortrait
|
||||
? _buildPortraitWidget(context, widget.imageWidget)
|
||||
: _buildLandscapeWidget(context, widget.imageWidget),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,152 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flare_flutter/flare_actor.dart';
|
||||
|
||||
import 'base_dialog.dart';
|
||||
|
||||
/// Widget that displays Giffy Dialog with flare asset.
|
||||
///
|
||||
/// You need local [Flare](https://github.com/2d-inc/Flare-Flutter) `.flr` asset for this type of Giffy Dialog.
|
||||
/// Place the asset under `/assets` directory in the project root.
|
||||
/// Add the asset to `pubspec.yaml` like so
|
||||
/// ```
|
||||
/// assets:
|
||||
/// - assets/my_awesome_flare.flr
|
||||
/// ```
|
||||
/// Set [FlareGiffyDialog]'s [flarePath] prop to the asset path.
|
||||
/// You also must specify the name of animation sequence to apply via `flareAnimation` prop.
|
||||
/// ```
|
||||
/// FlareGiffyDialog(
|
||||
/// title: Text('Example'),
|
||||
/// description: Text('Dialog text'),
|
||||
/// flarePath: 'assets/my_awesome_flare.flr',
|
||||
/// flareAnimation: 'dancing',
|
||||
/// ...,
|
||||
/// );
|
||||
class FlareGiffyDialog extends StatelessWidget {
|
||||
FlareGiffyDialog({
|
||||
Key key,
|
||||
@required this.flarePath,
|
||||
@required this.flareAnimation,
|
||||
@required this.title,
|
||||
this.onOkButtonPressed,
|
||||
this.flareFit = BoxFit.cover,
|
||||
this.onCancelButtonPressed,
|
||||
this.description,
|
||||
this.onlyOkButton = false,
|
||||
this.onlyCancelButton = false,
|
||||
this.buttonOkText,
|
||||
this.buttonCancelText,
|
||||
this.cardBackgroundColor,
|
||||
this.buttonOkColor = Colors.green,
|
||||
this.buttonCancelColor = Colors.grey,
|
||||
this.cornerRadius = 8.0,
|
||||
this.buttonRadius = 8.0,
|
||||
this.entryAnimation = EntryAnimation.DEFAULT,
|
||||
}) : assert(flarePath != null),
|
||||
assert(title != null),
|
||||
assert(flareAnimation != null),
|
||||
super(key: key);
|
||||
|
||||
/// Path to the Flare asset.
|
||||
final String flarePath;
|
||||
|
||||
/// Name of Flare animation to apply.
|
||||
final String flareAnimation;
|
||||
|
||||
/// BoxFit sizing of the Flare asset.
|
||||
final BoxFit flareFit;
|
||||
|
||||
/// Title text.
|
||||
final Text title;
|
||||
|
||||
/// Description text.
|
||||
final Text description;
|
||||
|
||||
/// Sets dialog to have only OK button.
|
||||
///
|
||||
/// Default is false.
|
||||
/// If set to true there is no need to set [buttonCancelText], [buttonCancelColor] and [onCancelButtonPressed]
|
||||
final bool onlyOkButton;
|
||||
|
||||
/// Sets dialog to have only Cancel button.
|
||||
///
|
||||
/// Default is false.
|
||||
/// If set to true there is no need to set [buttonOkText], [buttonOkColor] and [onOkButtonPressed]
|
||||
final bool onlyCancelButton;
|
||||
|
||||
/// Text for OK button.
|
||||
///
|
||||
/// Default is `OK`.
|
||||
final Text buttonOkText;
|
||||
|
||||
/// Text for cancel button
|
||||
///
|
||||
/// Default is `Cancel`.
|
||||
final Text buttonCancelText;
|
||||
|
||||
/// Color of OK button.
|
||||
///
|
||||
/// Default is `Colors.green`.
|
||||
final Color buttonOkColor;
|
||||
|
||||
/// Color of Cancel button
|
||||
///
|
||||
/// Default is `Colors.grey`.
|
||||
final Color buttonCancelColor;
|
||||
|
||||
/// TODO: this props is not used at the moment.
|
||||
final Color cardBackgroundColor;
|
||||
|
||||
/// Radius applied to the button corners.
|
||||
///
|
||||
/// Default is 8.
|
||||
final double buttonRadius;
|
||||
|
||||
/// Radius applied to the dialog box corners.
|
||||
///
|
||||
/// Default is 8.
|
||||
final double cornerRadius;
|
||||
|
||||
/// Callback function to be called on when OK button is pressed.
|
||||
///
|
||||
/// If set to null, then the button will be disabled and by
|
||||
/// default will resemble a flat button in the Theme's `disabledColor`.
|
||||
final VoidCallback onOkButtonPressed;
|
||||
|
||||
/// Callback function to be called on when Cancel button is pressed.
|
||||
///
|
||||
/// By default (or if set to null) closes the Giffy Dialog via `Navigator.of(context).pop()`.
|
||||
final VoidCallback onCancelButtonPressed;
|
||||
|
||||
/// Defines how Giffy Dialog will enter the screen.
|
||||
///
|
||||
/// Default is [EntryAnimation.DEFAULT] - standard Material dialog
|
||||
/// entrance animation, i.e. slow fade-in in the center of the screen.
|
||||
final EntryAnimation entryAnimation;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final imageWidget = FlareActor(
|
||||
flarePath,
|
||||
alignment: Alignment.center,
|
||||
fit: flareFit,
|
||||
animation: flareAnimation,
|
||||
);
|
||||
return BaseGiffyDialog(
|
||||
imageWidget: imageWidget,
|
||||
cornerRadius: cornerRadius,
|
||||
title: title,
|
||||
description: description,
|
||||
onlyOkButton: onlyOkButton,
|
||||
onlyCancelButton: onlyCancelButton,
|
||||
buttonCancelColor: buttonCancelColor,
|
||||
buttonRadius: buttonRadius,
|
||||
buttonCancelText: buttonCancelText,
|
||||
buttonOkColor: buttonOkColor,
|
||||
onOkButtonPressed: onOkButtonPressed,
|
||||
buttonOkText: buttonOkText,
|
||||
onCancelButtonPressed: onCancelButtonPressed,
|
||||
entryAnimation: entryAnimation,
|
||||
);
|
||||
}
|
||||
}
|
@ -1,130 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'base_dialog.dart';
|
||||
|
||||
/// Widget that displays Giffy Dialog with image obtained from the network.
|
||||
///
|
||||
/// Pass the network image URL to [NetworkGiffyDialog]'s [image] prop using Flutter's `Image.network(src)` widget.
|
||||
/// ```
|
||||
/// NetworkGiffyDialog(
|
||||
/// title: Text('Example'),
|
||||
/// description: Text('Dialog text'),
|
||||
/// image: Image.network(
|
||||
/// 'https://example.com/link/to/image.gif',
|
||||
/// fit: BoxFit.cover,
|
||||
/// ),
|
||||
/// ...,
|
||||
/// );
|
||||
class NetworkGiffyDialog extends StatelessWidget {
|
||||
NetworkGiffyDialog({
|
||||
Key key,
|
||||
@required this.image,
|
||||
@required this.title,
|
||||
this.onOkButtonPressed,
|
||||
this.onCancelButtonPressed,
|
||||
this.description,
|
||||
this.onlyOkButton = false,
|
||||
this.onlyCancelButton = false,
|
||||
this.buttonOkText,
|
||||
this.buttonCancelText,
|
||||
this.buttonOkColor = Colors.green,
|
||||
this.buttonCancelColor = Colors.grey,
|
||||
this.cornerRadius = 8.0,
|
||||
this.buttonRadius = 8.0,
|
||||
this.entryAnimation = EntryAnimation.DEFAULT,
|
||||
}) : assert(image != null),
|
||||
assert(title != null),
|
||||
super(key: key);
|
||||
|
||||
/// Image to display in dialog.
|
||||
///
|
||||
/// Pass `Image.network(src)` widget here.
|
||||
/// Preferably with `fit: BoxFit.cover` property to cover entire top part of Giffy Dialog.
|
||||
/// All properties of Image widget are directly passed to Giffy Dialog so feel free to experiment.
|
||||
final Widget image;
|
||||
|
||||
/// Title text.
|
||||
final Text title;
|
||||
|
||||
/// Description text
|
||||
final Text description;
|
||||
|
||||
/// Sets dialog to have only OK button.
|
||||
///
|
||||
/// Default is false.
|
||||
/// If set to true there is no need to set [buttonCancelText], [buttonCancelColor] and [onCancelButtonPressed]
|
||||
final bool onlyOkButton;
|
||||
|
||||
/// Sets dialog to have only Cancel button.
|
||||
///
|
||||
/// Default is false.
|
||||
/// If set to true there is no need to set [buttonOkText], [buttonOkColor] and [onOkButtonPressed]
|
||||
final bool onlyCancelButton;
|
||||
|
||||
/// Text for OK button.
|
||||
///
|
||||
/// Default is `OK`.
|
||||
final Text buttonOkText;
|
||||
|
||||
/// Text for cancel button
|
||||
///
|
||||
/// Default is `Cancel`.
|
||||
final Text buttonCancelText;
|
||||
|
||||
/// Color of OK button.
|
||||
///
|
||||
/// Default is `Colors.green`.
|
||||
final Color buttonOkColor;
|
||||
|
||||
/// Color of Cancel button
|
||||
///
|
||||
/// Default is `Colors.grey`.
|
||||
final Color buttonCancelColor;
|
||||
|
||||
/// Radius applied to the button corners.
|
||||
///
|
||||
/// Default is 8.
|
||||
final double buttonRadius;
|
||||
|
||||
/// Radius applied to the dialog box corners.
|
||||
///
|
||||
/// Default is 8.
|
||||
final double cornerRadius;
|
||||
|
||||
/// Callback function to be called on when OK button is pressed.
|
||||
///
|
||||
/// If set to null, then the button will be disabled and by
|
||||
/// default will resemble a flat button in the Theme's `disabledColor`.
|
||||
final VoidCallback onOkButtonPressed;
|
||||
|
||||
/// Callback function to be called on when Cancel button is pressed.
|
||||
///
|
||||
/// By default (or if set to null) closes the Giffy Dialog via `Navigator.of(context).pop()`.
|
||||
final VoidCallback onCancelButtonPressed;
|
||||
|
||||
/// Defines how Giffy Dialog will enter the screen.
|
||||
///
|
||||
/// Default is [EntryAnimation.DEFAULT] - standard Material dialog
|
||||
/// entrance animation, i.e. slow fade-in in the center of the screen.
|
||||
final EntryAnimation entryAnimation;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BaseGiffyDialog(
|
||||
imageWidget: image,
|
||||
cornerRadius: cornerRadius,
|
||||
title: title,
|
||||
description: description,
|
||||
onlyOkButton: onlyOkButton,
|
||||
onlyCancelButton: onlyCancelButton,
|
||||
buttonCancelColor: buttonCancelColor,
|
||||
buttonRadius: buttonRadius,
|
||||
buttonCancelText: buttonCancelText,
|
||||
buttonOkColor: buttonOkColor,
|
||||
onOkButtonPressed: onOkButtonPressed,
|
||||
onCancelButtonPressed: onCancelButtonPressed,
|
||||
buttonOkText: buttonOkText,
|
||||
entryAnimation: entryAnimation,
|
||||
);
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@ class MagicTriangleProvider with ChangeNotifier {
|
||||
bool _timeOut;
|
||||
int _time;
|
||||
bool _pause = false;
|
||||
int currentScore = 0 ;
|
||||
int currentScore = 0;
|
||||
|
||||
bool get timeOut => _timeOut;
|
||||
|
||||
@ -75,7 +75,7 @@ class MagicTriangleProvider with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> checkResult(int index, MagicTriangleGrid digit) async {
|
||||
Future<void> checkResult(int index, MagicTriangleGrid digit) async {
|
||||
if (!timeOut) {
|
||||
int activeTriangelIndex =
|
||||
_currentState.listTriangle.indexWhere((val) => val.isActive == true);
|
||||
@ -101,7 +101,7 @@ class MagicTriangleProvider with ChangeNotifier {
|
||||
_currentState.answer == sumOfBottomSide) {
|
||||
await Future.delayed(Duration(milliseconds: 300));
|
||||
_index = _index + 1;
|
||||
currentScore = currentScore+(ScoreUtil.magicTriangleScore ).toInt();
|
||||
currentScore = currentScore + (ScoreUtil.magicTriangleScore).toInt();
|
||||
_currentState = _list[_index];
|
||||
restartTimer();
|
||||
notifyListeners();
|
||||
@ -146,21 +146,17 @@ class MagicTriangleProvider with ChangeNotifier {
|
||||
var dialogResult = await _dialogService.showDialog(
|
||||
type: KeyUtil.GameOverDialog,
|
||||
gameCategoryType: GameCategoryType.MAGIC_TRIANGLE,
|
||||
score: currentScore.toDouble(),
|
||||
score: currentScore.toDouble(),
|
||||
coin: _index * CoinUtil.magicTriangleCoin,
|
||||
isPause: _pause);
|
||||
|
||||
if (dialogResult.exit) {
|
||||
homeViewModel.updateScoreboard(
|
||||
GameCategoryType.MAGIC_TRIANGLE,
|
||||
currentScore.toDouble(),
|
||||
_index * CoinUtil.magicTriangleCoin);
|
||||
homeViewModel.updateScoreboard(GameCategoryType.MAGIC_TRIANGLE,
|
||||
currentScore.toDouble(), _index * CoinUtil.magicTriangleCoin);
|
||||
GetIt.I<NavigationService>().goBack();
|
||||
} else if (dialogResult.restart) {
|
||||
homeViewModel.updateScoreboard(
|
||||
GameCategoryType.MAGIC_TRIANGLE,
|
||||
currentScore.toDouble(),
|
||||
_index * CoinUtil.magicTriangleCoin);
|
||||
homeViewModel.updateScoreboard(GameCategoryType.MAGIC_TRIANGLE,
|
||||
currentScore.toDouble(), _index * CoinUtil.magicTriangleCoin);
|
||||
timerSubscription.cancel();
|
||||
startGame();
|
||||
} else if (dialogResult.play) {
|
||||
@ -196,6 +192,7 @@ class MagicTriangleProvider with ChangeNotifier {
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
this.timerSubscription.cancel();
|
||||
}
|
||||
}
|
||||
|
@ -189,6 +189,7 @@ class MathGridProvider with ChangeNotifier {
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
this.timerSubscription.cancel();
|
||||
}
|
||||
}
|
||||
|
@ -167,6 +167,7 @@ class CalculatorProvider with ChangeNotifier {
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
this.timerSubscription.cancel();
|
||||
}
|
||||
}
|
||||
|
@ -166,6 +166,7 @@ class CorrectAnswerProvider with ChangeNotifier {
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
this.timerSubscription.cancel();
|
||||
}
|
||||
}
|
||||
|
@ -175,6 +175,7 @@ class MathPairsProvider with ChangeNotifier {
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
this.timerSubscription.cancel();
|
||||
}
|
||||
}
|
||||
|
@ -191,6 +191,7 @@ class MentalArithmeticProvider with ChangeNotifier {
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
this.timerSubscription.cancel();
|
||||
this.localTimerSubscription.cancel();
|
||||
}
|
||||
|
@ -178,6 +178,7 @@ class QuickCalculationProvider with ChangeNotifier {
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
this.timerSubscription.cancel();
|
||||
}
|
||||
}
|
||||
|
@ -164,6 +164,7 @@ class SignProvider with ChangeNotifier {
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
this.timerSubscription.cancel();
|
||||
}
|
||||
}
|
||||
|
@ -165,6 +165,7 @@ class SquareRootProvider with ChangeNotifier {
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
this.timerSubscription.cancel();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mathgame/src/module/giffy_dialog.dart';
|
||||
import 'package:mathgame/src/provider/calculatorProvider.dart';
|
||||
import 'package:mathgame/src/resources/gameCategoryDataProvider.dart';
|
||||
import 'package:mathgame/src/ui/calculator/calculator_button.dart';
|
||||
|
@ -37,6 +37,5 @@ class CorrectAnswerButton extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
);
|
||||
;
|
||||
}
|
||||
}
|
||||
|
@ -8,9 +8,6 @@ import 'package:mathgame/src/utility/keyUtil.dart';
|
||||
|
||||
import 'package:mathgame/src/utility/sizeConfig.dart';
|
||||
|
||||
import 'home.dart';
|
||||
import 'package:mathgame/src/ui/home.dart';
|
||||
import 'package:async/async.dart';
|
||||
import 'package:provider_architecture/provider_architecture.dart';
|
||||
|
||||
class DashBoardPage extends StatefulWidget {
|
||||
|
@ -1,7 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:mathgame/src/module/giffy_dialog.dart';
|
||||
import 'package:mathgame/src/resources/gameCategoryDataProvider.dart';
|
||||
import 'package:mathgame/src/resources/navigation_service.dart';
|
||||
import 'package:provider_architecture/provider_architecture.dart';
|
||||
|
@ -45,6 +45,5 @@ class MathPairsButton extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
);
|
||||
;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mathgame/src/provider/mentalArithmeticProvider.dart';
|
||||
import 'package:mathgame/src/resources/gameCategoryDataProvider.dart';
|
||||
import 'package:mathgame/src/ui/calculator/calculator_button.dart';
|
||||
import 'package:mathgame/src/ui/timer.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
|
@ -40,6 +40,5 @@ class MentalArithmeticButton extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
);
|
||||
;
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,5 @@ class QuickCalculationButton extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
);
|
||||
;
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,5 @@ class SquareRootButton extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
);
|
||||
;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mathgame/src/provider/signProvider.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'SingleDigitCounter.dart';
|
||||
|
||||
|
||||
|
@ -14,6 +14,7 @@ class MathUtil {
|
||||
return x[result];
|
||||
}
|
||||
|
||||
// ignore: missing_return
|
||||
static int evaluate(int x1, String sign, int x3) {
|
||||
switch (sign) {
|
||||
case "+":
|
||||
@ -29,7 +30,8 @@ class MathUtil {
|
||||
}
|
||||
|
||||
void main() {
|
||||
for(int i=0;i<100;i++){
|
||||
print("${MathUtil.generateRandomAnswer(10, 30)} ${MathUtil.generateRandomAnswer(10, 30)}");
|
||||
for (int i = 0; i < 100; i++) {
|
||||
print(
|
||||
"${MathUtil.generateRandomAnswer(10, 30)} ${MathUtil.generateRandomAnswer(10, 30)}");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user