Compare commits

..

No commits in common. "395778a6239c50ded848d52b16b334fa3cfe37c4" and "0969b41bc3c2bc7a50e16da8a5542d4c9f72beeb" have entirely different histories.

6 changed files with 31 additions and 79 deletions

View file

@ -17,7 +17,6 @@
import 'package:buyeeb_mobile/pages/main_page.dart';
import 'package:buyeeb_mobile/pages/splash.dart';
import 'package:buyeeb_mobile/pages/view_listing.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'models/user_listings.dart';
@ -31,12 +30,11 @@ void main() {
routes: {
'/': (context) => RouteHome(),
'/splash': (context) => RouteSplash(),
'/view_listing': (context) => RouteViewListing(),
},
title: "Buypeeb Mobile",
theme: ThemeData(
primarySwatch: Colors.pink,
primarySwatch: Colors.orange,
),
)
),

View file

@ -3,18 +3,17 @@ import 'package:buyeeb_mobile/models/yahoo_auctions_item.dart';
import 'package:flutter/foundation.dart';
class UserListings extends ChangeNotifier {
// final List<YahooAuctionsItem> _items = [];
final Map<String, YahooAuctionsItem> _items = {};
final List<YahooAuctionsItem> _items = [];
UnmodifiableMapView<String, YahooAuctionsItem> get items => UnmodifiableMapView(_items);
UnmodifiableListView<YahooAuctionsItem> get items => UnmodifiableListView(_items);
void add (String key, YahooAuctionsItem item) {
_items[key] = item;
void add (YahooAuctionsItem item) {
_items.add(item);
notifyListeners();
}
void remove(String key) {
_items.remove(key);
void remove(YahooAuctionsItem item) {
_items.remove(item);
notifyListeners();
}

View file

@ -1,10 +1,12 @@
import 'package:flutter/foundation.dart';
class YahooAuctionsItem {
String id;
String name;
int price;
YahooAuctionsItem({
@required this.id,
@required this.name,
@required this.price
});

View file

@ -9,7 +9,13 @@ class RouteHome extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MainPage();
return MaterialApp(
title: "Buypeeb",
theme: ThemeData(
primarySwatch: Colors.orange,
),
home: MainPage(),
);
}
}
@ -52,23 +58,13 @@ class _MainPageState extends State<MainPage> {
padding: EdgeInsets.all(8.0),
separatorBuilder: (context, i) => Divider(),
itemCount: listings.items.length,
itemBuilder: (context, i) {
String key = listings.items.keys.elementAt(i);
return ListTile(
title: Text(listings.items[key].name),
subtitle: Text(sprintf(
"¥%d (≈\$%2.2f)",
[listings.items[key].price, listings.items[key].getLocalPrice()]
)),
onTap: () {
Navigator.pushNamed(
context,
'/view_listing',
arguments: key
);
}
);
}
itemBuilder: (context, i) => ListTile(
title: Text(listings.items[i].name),
subtitle: Text(sprintf(
"¥%d (≈\$%2.2f)",
[listings.items[i].price, listings.items[i].getLocalPrice()]
)),
),
);
}
}

View file

@ -10,28 +10,26 @@ class RouteSplash extends StatefulWidget {
}
class _RouteSplashState extends State<RouteSplash> {
bool _ready = false;
_loadUserSettings() async {
// sleep for a bit to "simulate" loading
await Future.delayed(Duration(seconds: 2));
await Future.delayed(Duration(seconds: 1));
// add some random stuff to the listings
var listings = context.read<UserListings>();
var _rng = new Random();
final names = ["Hi Pempa!", "Pebulon Crystal", "The Peebler Chronicles", "Pecha Sludge", "The Forbidden Book of Peebus"];
for (var i = 0; i < 15; i++) {
listings.add(
"k" + (_rng.nextInt(500000) + 100000).toString(),
YahooAuctionsItem(
listings.add(YahooAuctionsItem(
id: "Henlo",
name: names[_rng.nextInt(names.length)],
price: _rng.nextInt(5000) + 500
));
}
setState(() {
Navigator.pushNamedAndRemoveUntil(
context,
'/',
(Route<dynamic> route) => false,
);
_ready = true;
Navigator.pushNamed(context, '/');
});
}
@ -45,22 +43,7 @@ class _RouteSplashState extends State<RouteSplash> {
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
margin: const EdgeInsets.all(12.0),
child: Text(
"Buypeeb Mobile",
style: TextStyle(
fontSize: 36.0,
fontWeight: FontWeight.w200
),
),
),
CircularProgressIndicator(),
]
)
child: CircularProgressIndicator(),
)
);
}

View file

@ -1,26 +0,0 @@
import 'package:flutter/material.dart';
class RouteViewListing extends StatefulWidget {
@override
_RouteViewListingState createState() => _RouteViewListingState();
}
class _RouteViewListingState extends State<RouteViewListing> {
@override
Widget build(BuildContext context) {
final String id = ModalRoute.of(context).settings.arguments;
return Scaffold(
appBar: AppBar(
title: Text("View listing"),
automaticallyImplyLeading: false, // remove the useless back button
),
body: ListView(
children: [
ListTile(
title: Text("ID: $id")
)
]
)
);
}
}