2020-09-30 07:36:51 +00:00
|
|
|
import 'package:buypeeb_mobile/models/user_listings.dart';
|
|
|
|
import 'package:buypeeb_mobile/models/yahoo_auctions_item.dart';
|
2020-09-30 01:45:57 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:sprintf/sprintf.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'dart:math';
|
|
|
|
|
2020-09-30 11:38:07 +00:00
|
|
|
import 'package:transparent_image/transparent_image.dart';
|
|
|
|
|
2020-09-30 01:45:57 +00:00
|
|
|
class RouteHome extends StatelessWidget {
|
|
|
|
// This widget is the root of your application.
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2020-09-30 03:02:05 +00:00
|
|
|
return MainPage();
|
2020-09-30 01:45:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class MainPage extends StatefulWidget {
|
|
|
|
@override
|
|
|
|
_MainPageState createState() => _MainPageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _MainPageState extends State<MainPage> {
|
|
|
|
final _items = <YahooAuctionsItem>[];
|
|
|
|
final _rng = new Random();
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(title: Text("Buypeeb"), actions: [
|
|
|
|
IconButton(
|
|
|
|
icon: Icon(Icons.search),
|
|
|
|
onPressed: () => null,
|
|
|
|
tooltip: "Search",
|
|
|
|
),
|
|
|
|
IconButton(
|
|
|
|
icon: Icon(Icons.list),
|
|
|
|
onPressed: () => null,
|
|
|
|
tooltip: "Filter",
|
|
|
|
),
|
|
|
|
IconButton(
|
|
|
|
icon: Icon(Icons.settings),
|
|
|
|
onPressed: () => null,
|
|
|
|
tooltip: "Settings",
|
|
|
|
)
|
|
|
|
]),
|
|
|
|
body: _buildAuctionListings(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildAuctionListings() {
|
|
|
|
var listings = context.watch<UserListings>();
|
2020-09-30 01:58:10 +00:00
|
|
|
return ListView.separated(
|
|
|
|
padding: EdgeInsets.all(8.0),
|
|
|
|
separatorBuilder: (context, i) => Divider(),
|
2020-09-30 01:45:57 +00:00
|
|
|
itemCount: listings.items.length,
|
2020-09-30 03:23:01 +00:00
|
|
|
itemBuilder: (context, i) {
|
|
|
|
String key = listings.items.keys.elementAt(i);
|
|
|
|
return ListTile(
|
|
|
|
title: Text(listings.items[key].name),
|
2020-09-30 11:38:07 +00:00
|
|
|
subtitle: Text(
|
|
|
|
sprintf(
|
|
|
|
"¥%d (≈\$%2.2f)",
|
|
|
|
[listings.items[key].price, listings.items[key].getLocalPrice()]
|
|
|
|
)
|
|
|
|
),
|
|
|
|
leading: FadeInImage.memoryNetwork(
|
|
|
|
placeholder: kTransparentImage,
|
|
|
|
image: listings.items[key].imageUrl,
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
),
|
2020-09-30 03:23:01 +00:00
|
|
|
onTap: () {
|
|
|
|
Navigator.pushNamed(
|
|
|
|
context,
|
|
|
|
'/view_listing',
|
|
|
|
arguments: key
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2020-09-30 01:45:57 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|