-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add recognition of another player’s win
- Loading branch information
Showing
9 changed files
with
195 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
class Submission { | ||
final String id; | ||
final String submission; | ||
final bool correct; | ||
final DateTime insertedAt; | ||
final String? creatorId; | ||
|
||
Submission({ | ||
required this.id, | ||
required this.submission, | ||
required this.correct, | ||
required this.insertedAt, | ||
this.creatorId, | ||
}); | ||
|
||
factory Submission.fromJson(Map<String, dynamic> json) { | ||
print('submission json'); | ||
print(json); | ||
return Submission( | ||
id: json['id'], | ||
submission: json['attributes']['submission'], | ||
correct: json['attributes']['correct'], | ||
insertedAt: DateTime.parse(json['attributes']['inserted_at']), | ||
creatorId: json['relationships']['creator']['data']['id'], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class LosingAnimation extends StatefulWidget { | ||
const LosingAnimation({super.key}); | ||
|
||
static void show(BuildContext context) { | ||
showDialog( | ||
context: context, | ||
barrierDismissible: true, | ||
barrierColor: Colors.transparent, | ||
builder: (context) => const LosingAnimation(), | ||
); | ||
} | ||
|
||
@override | ||
State<LosingAnimation> createState() => _LosingAnimationState(); | ||
} | ||
|
||
class _LosingAnimationState extends State<LosingAnimation> | ||
with SingleTickerProviderStateMixin { | ||
late AnimationController _controller; | ||
late Animation<double> _fadeAnimation; | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
_controller = AnimationController( | ||
duration: const Duration(milliseconds: 1000), | ||
vsync: this, | ||
); | ||
|
||
_fadeAnimation = Tween<double>( | ||
begin: 0.0, | ||
end: 1.0, | ||
).animate(CurvedAnimation( | ||
parent: _controller, | ||
curve: Curves.easeInOut, | ||
)); | ||
|
||
_controller.forward(); | ||
} | ||
|
||
@override | ||
void dispose() { | ||
_controller.dispose(); | ||
super.dispose(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return FadeTransition( | ||
opacity: _fadeAnimation, | ||
child: Container( | ||
color: Colors.black, | ||
child: Stack( | ||
children: [ | ||
const Center( | ||
child: Text( | ||
'You lost!', | ||
style: TextStyle( | ||
color: Colors.white, | ||
fontSize: 48, | ||
fontWeight: FontWeight.bold, | ||
), | ||
), | ||
), | ||
Positioned( | ||
top: 40, | ||
right: 16, | ||
child: IconButton( | ||
icon: const Icon( | ||
Icons.close, | ||
color: Colors.white, | ||
size: 32, | ||
), | ||
onPressed: () => Navigator.of(context).pop(), | ||
), | ||
), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters