261 lines
11 KiB
Dart
261 lines
11 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
import 'package:robo_advisory/models/wallet.dart';
|
|
import 'package:robo_advisory/theme/theme.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:robo_advisory/providers/wallet_provider.dart';
|
|
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
|
import 'package:robo_advisory/screens/home/local_widgets/financial_health_stream.dart';
|
|
import 'package:robo_advisory/screens/home/local_widgets/expenses_chart.dart';
|
|
|
|
// TODO: temp
|
|
import 'dart:async';
|
|
|
|
class HomeScreen extends StatefulWidget {
|
|
HomeScreen({required this.toggleDrawer});
|
|
final Function toggleDrawer;
|
|
@override
|
|
_HomeScreenState createState() => _HomeScreenState();
|
|
}
|
|
|
|
class _HomeScreenState extends State<HomeScreen> {
|
|
bool loadingData = true;
|
|
Wallet walletData = Wallet.emptyWallet;
|
|
|
|
void initState() {
|
|
WalletProvider walletProvider =
|
|
Provider.of<WalletProvider>(context, listen: false);
|
|
walletProvider.loadWallet().then((value) {
|
|
if (value.totalAssets.isNotEmpty) {
|
|
Timer(Duration(seconds: 3), () {
|
|
setState(() {
|
|
loadingData = false;
|
|
walletData = value;
|
|
});
|
|
});
|
|
}
|
|
});
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return loadingData
|
|
? Container(
|
|
child: Center(
|
|
child: SpinKitFadingFour(
|
|
color: Colors.black,
|
|
size: 100.0,
|
|
),
|
|
),
|
|
)
|
|
: SingleChildScrollView(
|
|
child: Center(
|
|
child: SafeArea(
|
|
child: Padding(
|
|
padding: AppTheme.padding,
|
|
child: Column(
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
'Hi Johne',
|
|
style: GoogleFonts.inter(
|
|
textStyle: TextStyle(
|
|
fontWeight: FontWeight.bold,
|
|
fontSize: 36.0,
|
|
color: Colors.black,
|
|
),
|
|
),
|
|
),
|
|
GestureDetector(
|
|
onTap: () => widget.toggleDrawer(),
|
|
child: Icon(Icons.more_vert),
|
|
),
|
|
],
|
|
),
|
|
SizedBox(
|
|
height: 30.0,
|
|
),
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Container(
|
|
alignment: Alignment.centerLeft,
|
|
width: double.infinity,
|
|
padding: EdgeInsets.all(20.0),
|
|
color: Color(0xFFC4C4C4),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
'Total Assets',
|
|
style: GoogleFonts.inter(
|
|
textStyle: TextStyle(
|
|
fontWeight: FontWeight.normal,
|
|
fontSize: 16,
|
|
color: Colors.black,
|
|
),
|
|
),
|
|
),
|
|
Text(
|
|
walletData.totalAssets,
|
|
style: GoogleFonts.inter(
|
|
textStyle: TextStyle(
|
|
fontWeight: FontWeight.w600,
|
|
fontSize: 45,
|
|
color: Colors.black,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Container(
|
|
padding: EdgeInsets.only(
|
|
left: 20.0, right: 20.0, top: 7.0, bottom: 7.0),
|
|
color: Color(0xFFE5E5E5),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
'TRY pool',
|
|
style: GoogleFonts.inter(
|
|
textStyle: TextStyle(
|
|
fontWeight: FontWeight.normal,
|
|
fontSize: 16,
|
|
color: Colors.black,
|
|
),
|
|
),
|
|
),
|
|
Text(
|
|
walletData.totalTurkishLiraPool,
|
|
style: GoogleFonts.inter(
|
|
textStyle: TextStyle(
|
|
fontWeight: FontWeight.normal,
|
|
fontSize: 16,
|
|
color: Colors.black,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Container(
|
|
padding: EdgeInsets.only(
|
|
left: 20.0, right: 20.0, top: 7.0, bottom: 7.0),
|
|
color: Color(0xFFC4C4C4),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
'Total XAU grams',
|
|
style: GoogleFonts.inter(
|
|
textStyle: TextStyle(
|
|
fontWeight: FontWeight.normal,
|
|
fontSize: 16,
|
|
color: Colors.black,
|
|
),
|
|
),
|
|
),
|
|
Text(
|
|
walletData.totalGoldInGram,
|
|
style: GoogleFonts.inter(
|
|
textStyle: TextStyle(
|
|
fontWeight: FontWeight.normal,
|
|
fontSize: 16,
|
|
color: Colors.black,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
SizedBox(
|
|
height: 30.0,
|
|
),
|
|
FinancialHealthStream(
|
|
healthSteams: walletData.healthStreams),
|
|
SizedBox(
|
|
height: 30.0,
|
|
),
|
|
Column(
|
|
children: [
|
|
Container(
|
|
padding: EdgeInsets.only(
|
|
left: 20.0, right: 20.0, top: 7.0, bottom: 7.0),
|
|
color: Color(0xFFE5E5E5),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
'TRY pool',
|
|
style: GoogleFonts.inter(
|
|
textStyle: TextStyle(
|
|
fontWeight: FontWeight.normal,
|
|
fontSize: 16,
|
|
color: Colors.black,
|
|
),
|
|
),
|
|
),
|
|
Text(
|
|
walletData.totalGoldInTurkishLira,
|
|
style: GoogleFonts.inter(
|
|
textStyle: TextStyle(
|
|
fontWeight: FontWeight.normal,
|
|
fontSize: 16,
|
|
color: Color(0xFF896126),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Container(
|
|
padding: EdgeInsets.only(
|
|
left: 20.0, right: 20.0, top: 7.0, bottom: 7.0),
|
|
color: Color(0xFFC4C4C4),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
'Total XAU grams',
|
|
style: GoogleFonts.inter(
|
|
textStyle: TextStyle(
|
|
fontWeight: FontWeight.normal,
|
|
fontSize: 16,
|
|
color: Colors.black,
|
|
),
|
|
),
|
|
),
|
|
Text(
|
|
walletData.totalGoldInGram,
|
|
style: GoogleFonts.inter(
|
|
textStyle: TextStyle(
|
|
fontWeight: FontWeight.normal,
|
|
fontSize: 16,
|
|
color: Colors.black,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 20.0,
|
|
),
|
|
Container(height: 200, width: 200, child: ExpensesChart())
|
|
],
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|