Commit 6e62df42 authored by Hans Muller's avatar Hans Muller Committed by GitHub

Removed unnecessary Shrine hero logic (#5394)

* Removed unnecessary Shrine hero logic
parent 955b3e21
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:collection' show HashSet;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
...@@ -265,8 +264,7 @@ class ProductItem extends StatelessWidget { ...@@ -265,8 +264,7 @@ class ProductItem extends StatelessWidget {
height: 144.0, height: 144.0,
padding: const EdgeInsets.symmetric(horizontal: 8.0), padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: new Hero( child: new Hero(
tag: productHeroTag, tag: product.tag,
key: new ObjectKey(product),
child: new Image.asset(product.imageAsset, fit: ImageFit.contain) child: new Image.asset(product.imageAsset, fit: ImageFit.contain)
) )
), ),
...@@ -306,12 +304,8 @@ class _ShrineHomeState extends State<ShrineHome> { ...@@ -306,12 +304,8 @@ class _ShrineHomeState extends State<ShrineHome> {
void showOrderPage(Product product) { void showOrderPage(Product product) {
final Order order = _shoppingCart[product] ?? new Order(product: product); final Order order = _shoppingCart[product] ?? new Order(product: product);
final Completer<Order> completer = new Completer<Order>(); final Completer<Order> completer = new Completer<Order>();
final Key productKey = new ObjectKey(product);
final Set<Key> mostValuableKeys = new HashSet<Key>();
mostValuableKeys.add(productKey);
Navigator.push(context, new ShrineOrderRoute( Navigator.push(context, new ShrineOrderRoute(
order: order, order: order,
settings: new RouteSettings(mostValuableKeys: mostValuableKeys),
completer: completer, completer: completer,
builder: (BuildContext context) { builder: (BuildContext context) {
return new OrderPage( return new OrderPage(
......
...@@ -40,7 +40,7 @@ class OrderItem extends StatelessWidget { ...@@ -40,7 +40,7 @@ class OrderItem extends StatelessWidget {
width: 248.0, width: 248.0,
height: 248.0, height: 248.0,
child: new Hero( child: new Hero(
tag: productHeroTag, tag: product.tag,
child: new Image.asset(product.imageAsset, fit: ImageFit.contain) child: new Image.asset(product.imageAsset, fit: ImageFit.contain)
) )
) )
......
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
import 'dart:ui' show hashValues; import 'dart:ui' show hashValues;
const String productHeroTag = 'Product';
class Vendor { class Vendor {
const Vendor({ const Vendor({
this.name, this.name,
...@@ -48,6 +46,7 @@ class Product { ...@@ -48,6 +46,7 @@ class Product {
final double price; final double price;
final Vendor vendor; final Vendor vendor;
String get tag => name; // Unique value for Heroes
String get priceString => '\$${price.floor()}'; String get priceString => '\$${price.floor()}';
bool isValid() { bool isValid() {
......
...@@ -387,7 +387,7 @@ class HeroParty { ...@@ -387,7 +387,7 @@ class HeroParty {
assert(to == null || to.sourceStates.length == 1); assert(to == null || to.sourceStates.length == 1);
assert(to == null || to.currentTurns.floor() == to.currentTurns); assert(to == null || to.currentTurns.floor() == to.currentTurns);
HeroState targetState = to != null ? to.sourceStates.elementAt(0) : null; HeroState targetState = to != null ? to.sourceStates.elementAt(0) : null;
Set<HeroState> sourceStates = from != null ? from.sourceStates : new HashSet<HeroState>(); Set<HeroState> sourceStates = from?.sourceStates ?? new HashSet<HeroState>();
sourceStates.remove(targetState); sourceStates.remove(targetState);
Rect sourceRect = from?.currentRect ?? to.currentRect.center & Size.zero; Rect sourceRect = from?.currentRect ?? to.currentRect.center & Size.zero;
Rect targetRect = to?.currentRect ?? from.currentRect.center & Size.zero; Rect targetRect = to?.currentRect ?? from.currentRect.center & Size.zero;
...@@ -545,7 +545,7 @@ class HeroController extends NavigatorObserver { ...@@ -545,7 +545,7 @@ class HeroController extends NavigatorObserver {
void _updateQuest(Duration timeStamp) { void _updateQuest(Duration timeStamp) {
if (navigator == null) { if (navigator == null) {
// The navigator has been removed for this end-of-frame callback was called. // The navigator was removed before this end-of-frame callback was called.
return; return;
} }
Set<Key> mostValuableKeys = _getMostValuableKeys(); Set<Key> mostValuableKeys = _getMostValuableKeys();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment