Lynnesbian
caf0d03e3b
- split app into separate pages/routes - put models in their own folder - use provider to sync state between pages - generate a preset list of items instead of an infinite amount - added a splash screen
50 lines
1.3 KiB
Dart
50 lines
1.3 KiB
Dart
import 'package:buyeeb_mobile/models/user_listings.dart';
|
|
import 'package:buyeeb_mobile/models/yahoo_auctions_item.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'dart:math';
|
|
|
|
class RouteSplash extends StatefulWidget {
|
|
@override
|
|
_RouteSplashState createState() => _RouteSplashState();
|
|
}
|
|
|
|
class _RouteSplashState extends State<RouteSplash> {
|
|
bool _ready = false;
|
|
|
|
_loadUserSettings() async {
|
|
// sleep for a bit to "simulate" loading
|
|
await Future.delayed(Duration(seconds: 3));
|
|
// 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(YahooAuctionsItem(
|
|
id: "Henlo",
|
|
name: names[_rng.nextInt(names.length)],
|
|
price: _rng.nextInt(5000) + 500
|
|
));
|
|
}
|
|
|
|
setState(() {
|
|
_ready = true;
|
|
Navigator.pushNamed(context, '/');
|
|
});
|
|
}
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_loadUserSettings();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: Center(
|
|
child: CircularProgressIndicator(),
|
|
)
|
|
);
|
|
}
|
|
}
|