Skip to content

Commit a9f7f90

Browse files
authored
Merge pull request #2 from lhmzhou/develop
set up app route with bookstore and location tabs
2 parents 540ca98 + cdcefb1 commit a9f7f90

File tree

7 files changed

+1105
-0
lines changed

7 files changed

+1105
-0
lines changed

lib/animations.dart

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
import 'package:flutter/material.dart';
2+
3+
class AnimationSwitcher extends StatelessWidget {
4+
const AnimationSwitcher({
5+
Key key,
6+
@required this.child1,
7+
@required this.child2,
8+
@required this.animation,
9+
}) : assert(child1 != null),
10+
assert(child2 != null),
11+
assert(animation != null),
12+
super(key: key);
13+
14+
final Widget child1;
15+
final Widget child2;
16+
final Animation animation;
17+
18+
@override
19+
Widget build(BuildContext context) {
20+
return AnimatedBuilder(
21+
animation: animation,
22+
builder: (BuildContext context, Widget child) => Stack(
23+
children: [
24+
IgnorePointer(
25+
ignoring: animation.status == AnimationStatus.forward ||
26+
animation.status == AnimationStatus.completed,
27+
child: FadeTransition(
28+
opacity: Tween(begin: 1.0, end: 0.0).animate(animation),
29+
child: child1,
30+
),
31+
),
32+
IgnorePointer(
33+
ignoring: animation.status == AnimationStatus.reverse ||
34+
animation.status == AnimationStatus.dismissed,
35+
child: FadeTransition(
36+
opacity: animation,
37+
child: child2,
38+
),
39+
),
40+
],
41+
),
42+
);
43+
}
44+
}
45+
46+
/// a widget that shows a widget and when it changes, based on given conditions,
47+
/// it will perform top-to-down stack/fade animation (usually, when, e.g. new number is greater than the prev),
48+
/// or same down-to-bot animation
49+
class CountSwitcher extends StatelessWidget {
50+
const CountSwitcher({
51+
Key key,
52+
this.childKey,
53+
this.child,
54+
this.valueIncreased = true,
55+
}) : super(key: key);
56+
57+
/// a key that will be applied to the child widget, can be used to lock the switch animation.
58+
final Key childKey;
59+
final Widget child;
60+
61+
/// `true` will play top-to-down animation, `false` vice-versa
62+
final bool valueIncreased;
63+
64+
@override
65+
Widget build(BuildContext context) {
66+
return ConstrainedBox(
67+
constraints: const BoxConstraints(minWidth: 20.0),
68+
child: AnimatedSwitcher(
69+
duration: const Duration(milliseconds: 200),
70+
transitionBuilder: (Widget child, Animation<double> animation) {
71+
final baseAnimation = CurvedAnimation(
72+
curve: Curves.easeOut,
73+
parent: animation,
74+
);
75+
final baseReversedAnimation = CurvedAnimation(
76+
curve: Curves.easeIn,
77+
parent: animation,
78+
);
79+
80+
final inForwardAnimation = Tween<Offset>(
81+
begin: const Offset(0.0, -0.7),
82+
end: const Offset(0.0, 0.0),
83+
).animate(baseAnimation);
84+
85+
final inBackAnimation = Tween<Offset>(
86+
begin: const Offset(0.0, 0.7),
87+
end: const Offset(0.0, 0.0),
88+
).animate(baseAnimation);
89+
90+
final outForwardAnimation = Tween<Offset>(
91+
begin: const Offset(0.0, 0.7),
92+
end: const Offset(0.0, 0.0),
93+
).animate(baseReversedAnimation);
94+
95+
final outBackAnimation = Tween<Offset>(
96+
begin: const Offset(0.0, -0.7),
97+
end: const Offset(0.0, 0.0),
98+
).animate(baseReversedAnimation);
99+
100+
//* For entering widget
101+
if (child.key == childKey) {
102+
if (valueIncreased)
103+
return SlideTransition(
104+
position: inForwardAnimation,
105+
child: FadeTransition(
106+
opacity: animation,
107+
child: child,
108+
),
109+
);
110+
else
111+
return SlideTransition(
112+
position: inBackAnimation,
113+
child: FadeTransition(
114+
opacity: animation,
115+
child: child,
116+
),
117+
);
118+
}
119+
//* for exiting widget
120+
else {
121+
if (valueIncreased) {
122+
return SlideTransition(
123+
position: outForwardAnimation,
124+
child: FadeTransition(
125+
opacity: animation,
126+
child: child,
127+
),
128+
);
129+
} else
130+
return SlideTransition(
131+
position: outBackAnimation,
132+
child: FadeTransition(
133+
opacity: animation,
134+
child: child,
135+
),
136+
);
137+
}
138+
},
139+
child: Container(
140+
key: childKey,
141+
child: child,
142+
),
143+
),
144+
);
145+
}
146+
}

lib/content.dart

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import 'package:flutter/material.dart';
2+
3+
class Bookstore {
4+
const Bookstore({
5+
@required this.id,
6+
@required this.storeName,
7+
@required this.location,
8+
@required this.webUrl,
9+
});
10+
final int id;
11+
final String storeName;
12+
final String location;
13+
final String webUrl;
14+
}
15+
16+
abstract class ContentControl {
17+
static const List<Bookstore> Bookstores = [
18+
Bookstore(id: 0, storeName: "A Cultural Exchange", location: "Cleveland, Ohio", webUrl: "https://www.aculturalexchange.org"),
19+
Bookstore(id: 1, storeName: "Aframerican Book Store", location: "Omaha, Nebraska", webUrl: "http://aframericanbookstore.com"),
20+
Bookstore(id: 2, storeName: "Afriware Books, Co", location: "Maywood, Illinois", webUrl: "https://www.afriwarebooks.com"),
21+
Bookstore(id: 3, storeName: "Akoma Novelties & Books", location: "Evansville, Indiana", webUrl: "https://www.akomabooks.com"),
22+
Bookstore(id: 4, storeName: "Alkebulan Ujaama Book Store", location: "Columbus, Ohio", webUrl: ""),
23+
Bookstore(id: 5, storeName: "Ashay by the Bay", location: "Vallejo, California", webUrl: "https://ashaybythebay.com"),
24+
Bookstore(id: 6, storeName: "Best Richardson African Diaspora Literature & Culture Museum", location: "Tampa, Florida", webUrl: "https://www.bradlcmuseum.com"),
25+
Bookstore(id: 7, storeName: "Beyond Barcodes Bookstore", location: "Kokomo, Indiana", webUrl: ""),
26+
Bookstore(id: 8, storeName: "Black Dot Cultural Center", location: "Lithonia, Georgia", webUrl: "https://www.blackdotcc.com"),
27+
Bookstore(id: 9, storeName: "Black Pearl Books", location: "Austin, Texas", webUrl: "https://blackpearlbookstore.com"),
28+
Bookstore(id: 10, storeName: "Black Stone Bookstore & Cultural Center", location: "Ypsilanti, MI", webUrl: "https://www.blackstonebookstore.com"),
29+
Bookstore(id: 11, storeName: "Black World Books", location: "Killeen, Texas", webUrl: "https://blackworldbooks.org/"),
30+
Bookstore(id: 12, storeName: "Bliss Books & Wine", location: "Kansas City, Missouri", webUrl: "https://bliss-books-wine.business.site"),
31+
Bookstore(id: 13, storeName: "Books & Stuff", location: "Philadelphia, Pennsylvania", webUrl: "https://www.booksandstuff.info"),
32+
Bookstore(id: 14, storeName: "Books and Crannies", location: "Martinsville, Virginia", webUrl: "https://www.booksandcranniesva.com"),
33+
Bookstore(id: 15, storeName: "Brave + Kind Bookshop", location: "Decatur, Georgia", webUrl: "https://www.braveandkindbooks.com"),
34+
Bookstore(id: 16, storeName: "Burgundy Books", location: "Old Saybrook, Connecticut", webUrl: "https://burgundybooks.com"),
35+
Bookstore(id: 17, storeName: "Carol’s Books", location: "Sacramento, California", webUrl: "https://carolsbookstore.com"),
36+
Bookstore(id: 18, storeName: "Dare Books", location: "Longwood, Florida", webUrl: "https://darebooks.com"),
37+
Bookstore(id: 19, storeName: "Detroit Book City", location: "Southfield, Michigan", webUrl: "https://www.detroitbookcity.com"),
38+
Bookstore(id: 20, storeName: "Elizabeth’s Bookshop & Writing Centre", location: "Akron, Ohio", webUrl: ""),
39+
Bookstore(id: 21, storeName: "Enda’s Booktique", location: "Duncanville, Texas", webUrl: "https://endasbooktique.com"),
40+
Bookstore(id: 22, storeName: "Eso Won Bookstore", location: "Los Angeles, California", webUrl: "https://www.esowonbookstore.com"),
41+
Bookstore(id: 23, storeName: "Everyone’s Place", location: "Baltimore, Maryland", webUrl: ""),
42+
Bookstore(id: 24, storeName: "EyeSeeMe", location: "University City, Missouri", webUrl: "https://www.eyeseeme.com"),
43+
Bookstore(id: 25, storeName: "Frontline Bookstore", location: "Chicago, Illinois", webUrl: ""),
44+
Bookstore(id: 26, storeName: "Frugal Bookstore", location: "Boston, Massachusetts", webUrl: "https://frugalbookstore.net"),
45+
Bookstore(id: 27, storeName: "Harambee Books and Artworks", location: "Alexandria, Virginia", webUrl: "https://harambeebooks.org"),
46+
Bookstore(id: 28, storeName: "House of Consciousness", location: "Norfolk, Virginia", webUrl: "https://www.hocbookstore.com"),
47+
Bookstore(id: 29, storeName: "La Unique African American Books & Cultural Center", location: "Camden, NJ", webUrl: "http://www.launiquebooks.net"),
48+
Bookstore(id: 30, storeName: "Loyalty Bookstore", location: "Washington, D.C.", webUrl: "https://www.loyaltybookstores.com"),
49+
Bookstore(id: 31, storeName: "Mahogany Books", location: "West Palm Beach, Florida", webUrl: "https://www.mahoganybooks.com"),
50+
Bookstore(id: 32, storeName: "Marcus Books", location: "Oakland, California", webUrl: "https://tapmybio.com/marcusbook"),
51+
Bookstore(id: 33, storeName: "Medu Bookstore", location: "Atlanta, Georgia", webUrl: "https://www.medubookstore.com"),
52+
Bookstore(id: 34, storeName: "Mocha Books", location: "Tulsa, Oklahoma", webUrl: "https://www.readwithmochabooks.com"),
53+
Bookstore(id: 35, storeName: "Nandi’s Knowledge Cafe", location: "Highland Park, Michigan", webUrl: "http://nandisknowledgecafe.com"),
54+
Bookstore(id: 36, storeName: "NuBian Books", location: "Morrow, Georgia", webUrl: "https://www.houseofnubian.com"),
55+
Bookstore(id: 37, storeName: "Olive Tree Books N Voices", location: "Springfield, Massachusetts", webUrl: "http://olivetreebooksonline.com"),
56+
Bookstore(id: 38, storeName: "Positive Vibes", location: "Virginia Beach, Virginia", webUrl: "https://www.positivevibesva.com"),
57+
Bookstore(id: 39, storeName: "Pyramid Art Books & Custom Framing", location: "Little Rock, Arkansas", webUrl: ""),
58+
Bookstore(id: 40, storeName: "Semicolon Bookstore & Gallery", location: "Chicago, Illinois", webUrl: "http://www.semicolonchi.com"),
59+
Bookstore(id: 41, storeName: "Shades of Afrika", location: "Long Beach, California", webUrl: "https://shadesofafrika.com"),
60+
Bookstore(id: 42, storeName: "Source of Knowledge Book Store", location: "Newark, New Jersey", webUrl: ""),
61+
Bookstore(id: 43, storeName: "The Brain Lair Bookstore", location: "South Bend, Indiana", webUrl: "https://www.brainlairbooks.com"),
62+
Bookstore(id: 44, storeName: "The Dock Bookshop", location: "Fort Worth, Texas", webUrl: "https://www.thedockbookshop.com"),
63+
Bookstore(id: 45, storeName: "The Listening Tree", location: "Candler-McAfee, Georgia", webUrl: "https://listeningtreebooks.com"),
64+
Bookstore(id: 46, storeName: "The Lit. Bar", location: "Bronx, New York", webUrl: "http://www.thelitbar.com"),
65+
Bookstore(id: 48, storeName: "Cafe con Libros", location: "Brooklyn, New York", webUrl: "https://www.cafeconlibrosbk.com"),
66+
Bookstore(id: 49, storeName: "The Tiny Bookstore", location: "Pittsburgh, Pennsylvania", webUrl: "https://tinybookspgh.com"),
67+
Bookstore(id: 50, storeName: "The Underground Bookstore", location: "Chicago, Illinois", webUrl: ""),
68+
Bookstore(id: 51, storeName: "Turning Page Bookshop", location: "Goose Creek, South Carolina", webUrl: "https://turningpagebookshop.com"),
69+
Bookstore(id: 52, storeName: "Willa’s Books and Vinyl", location: "Kansas City, Missouri", webUrl: "https://www.willasbookskc.com")
70+
];
71+
}

0 commit comments

Comments
 (0)