Skip to content

Commit

Permalink
Switch to PNG home monKey
Browse files Browse the repository at this point in the history
  • Loading branch information
bbedward committed Apr 3, 2019
1 parent 21bf6cb commit 01f1a7c
Showing 1 changed file with 44 additions and 12 deletions.
56 changes: 44 additions & 12 deletions lib/ui/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:flare_flutter/flare_actor.dart';
import 'package:flare_flutter/flare_controller.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:event_taxi/event_taxi.dart';
import 'package:logging/logging.dart';
Expand Down Expand Up @@ -75,6 +74,7 @@ class _AppHomePageState extends State<AppHomePage>

// monKey widget
Widget _monKey;
Widget _largeMonkey;
bool _monkeyOverlayOpen = false;
bool _monkeyDownloadTriggered = false;
// List of contacts (Store it so we only have to query the DB once for transaction cards)
Expand Down Expand Up @@ -350,12 +350,28 @@ class _AppHomePageState extends State<AppHomePage>
});
_startAnimation();
UIUtil.downloadOrRetrieveMonkey(context,
event.account.address, MonkeySize.SVG)
event.account.address, MonkeySize.HOME_SMALL)
.then((result) {
if (result != null) {
/* TODO Validate */
setState(() {
_monKey = SvgPicture.file(result);
FileUtil.pngHasValidSignature(result).then((valid) {
if (valid) {
setState(() {
_monKey = Image.file(result);
});
}
});
}
});
UIUtil.downloadOrRetrieveMonkey(context,
StateContainer.of(context).wallet.address, MonkeySize.LARGE)
.then((result) {
if (result != null) {
FileUtil.pngHasValidSignature(result).then((valid) {
if (valid) {
setState(() {
_largeMonkey = Image.file(result);
});
}
});
}
});
Expand Down Expand Up @@ -640,12 +656,28 @@ class _AppHomePageState extends State<AppHomePage>
if (!_monkeyDownloadTriggered) {
_monkeyDownloadTriggered = true;
UIUtil.downloadOrRetrieveMonkey(context,
StateContainer.of(context).wallet.address, MonkeySize.SVG)
StateContainer.of(context).wallet.address, MonkeySize.HOME_SMALL)
.then((result) {
if (result != null) {
/* TODO Validate */
setState(() {
_monKey = SvgPicture.file(result);
FileUtil.pngHasValidSignature(result).then((valid) {
if (valid) {
setState(() {
_monKey = Image.file(result);
});
}
});
}
});
UIUtil.downloadOrRetrieveMonkey(context,
StateContainer.of(context).wallet.address, MonkeySize.LARGE)
.then((result) {
if (result != null) {
FileUtil.pngHasValidSignature(result).then((valid) {
if (valid) {
setState(() {
_largeMonkey = Image.file(result);
});
}
});
}
});
Expand Down Expand Up @@ -1411,7 +1443,7 @@ class _AppHomePageState extends State<AppHomePage>
child: _monkeyOverlayOpen
? SizedBox()
: Stack(children: <Widget>[
Container(width: 80, height: 80, child: _monKey),
Container(width: 80, height: 80, child: _largeMonkey),
Center(
child: Container(
width: 90,
Expand All @@ -1427,13 +1459,13 @@ class _AppHomePageState extends State<AppHomePage>
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(100.0)),
onPressed: () {
if (_monkeyOverlayOpen) {
if (_monkeyOverlayOpen || _largeMonkey == null) {
return;
}
setState(() {
_monkeyOverlayOpen = true;
});
Navigator.of(context).push(MonkeyOverlay(_monKey));
Navigator.of(context).push(MonkeyOverlay(_largeMonkey));
}),
),
],
Expand Down

0 comments on commit 01f1a7c

Please sign in to comment.