-
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.
Merge pull request #56 from s14t284/feature/animation
スタンプアニメーションの実装
- Loading branch information
Showing
16 changed files
with
252 additions
and
83 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,81 @@ | ||
import 'dart:typed_data'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:http/http.dart'; | ||
import 'package:virtualpilgrimage/domain/temple/temple_info.codegen.dart'; | ||
import 'package:virtualpilgrimage/domain/temple/temple_repository.dart'; | ||
import 'package:virtualpilgrimage/ui/pages/home/home_presenter.dart'; | ||
import 'package:virtualpilgrimage/ui/wording_helper.dart'; | ||
|
||
class StampAnimation { | ||
late Uint8List image; | ||
late TempleInfo templeInfo; | ||
} | ||
|
||
class StampAnimationWidget extends ConsumerWidget { | ||
const StampAnimationWidget({ | ||
required this.animationTempleId, | ||
super.key, | ||
}); | ||
|
||
final int animationTempleId; | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
return ColoredBox( | ||
color: Colors.black54, | ||
child: Center( | ||
child: FutureBuilder<StampAnimation>( | ||
future: loadStampImage(ref), | ||
builder: (context, snapshot) { | ||
return snapshot.hasData | ||
? AlertDialog( | ||
backgroundColor: Colors.transparent, | ||
title: Center( | ||
child: Text( | ||
'${snapshot.data!.templeInfo.id}番 ${WordingHelper.templeNameFilter(snapshot.data!.templeInfo.name)}に到着', | ||
style: const TextStyle( | ||
color: Color(0xFFeeff41), | ||
), | ||
), | ||
), | ||
content: TweenAnimationBuilder( | ||
tween: Tween<double>(begin: 6, end: 1), | ||
duration: const Duration(milliseconds: 750), | ||
builder: (BuildContext context, double value, _) { | ||
return Transform.scale( | ||
scale: value, | ||
child: SizedBox( | ||
height: 500, | ||
child: Image.memory(snapshot.data!.image), | ||
), | ||
); | ||
}, | ||
), | ||
actionsAlignment: MainAxisAlignment.center, | ||
actions: [ | ||
ElevatedButton( | ||
onPressed: ref.read(homeProvider.notifier).onAnimationClosed, | ||
child: const Text('タップして次を目指そう!'), | ||
), | ||
], | ||
) | ||
: const CircularProgressIndicator(); | ||
}, | ||
), | ||
), | ||
); | ||
} | ||
|
||
Future<StampAnimation> loadStampImage(WidgetRef ref) async { | ||
final StampAnimation stampAnimation = StampAnimation(); | ||
final TempleInfo templeInfo = | ||
await ref.read(templeRepositoryProvider).getTempleInfo(animationTempleId); | ||
|
||
stampAnimation | ||
..templeInfo = templeInfo | ||
..image = (await get(Uri.parse(templeInfo.stampImage))).bodyBytes; | ||
return stampAnimation; | ||
} | ||
} |
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
Oops, something went wrong.