73 lines
1.7 KiB
Dart
73 lines
1.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:sprintf/sprintf.dart';
|
|
import 'yahoo_auctions_item.dart';
|
|
import 'dart:math';
|
|
|
|
void main() {
|
|
runApp(MyApp());
|
|
}
|
|
|
|
class MyApp extends StatelessWidget {
|
|
// This widget is the root of your application.
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
title: "Buypeeb",
|
|
theme: ThemeData(
|
|
primarySwatch: Colors.orange,
|
|
),
|
|
home: MainPage(),
|
|
);
|
|
}
|
|
}
|
|
|
|
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() {
|
|
return ListView.builder(
|
|
padding: EdgeInsets.all(16.0),
|
|
itemBuilder: (context, i) {
|
|
if (i.isOdd) return Divider();
|
|
|
|
final newItem = YahooAuctionsItem(id: "Henlo", name: "Hi Pempa!", price: _rng.nextInt(5000) + 500);
|
|
|
|
_items.add(newItem);
|
|
|
|
return ListTile(title: Text(newItem.name),
|
|
subtitle: Text(sprintf("¥%d (≈\$%2.2f)", [newItem.price, newItem.getLocalPrice()])));
|
|
},
|
|
);
|
|
}
|
|
}
|