buypeeb-mobile/lib/pages/splash.dart

67 lines
1.8 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> {
_loadUserSettings() async {
// sleep for a bit to "simulate" loading
await Future.delayed(Duration(seconds: 2));
// 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(
name: names[_rng.nextInt(names.length)],
price: _rng.nextInt(5000) + 500
));
}
setState(() {
Navigator.pushNamedAndRemoveUntil(
context,
'/',
(Route<dynamic> route) => false,
);
});
}
@override
void initState() {
super.initState();
_loadUserSettings();
}
@override
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(),
]
)
)
);
}
}