Skip to content

Commit

Permalink
Progress screen completed, progress details screen is being developed
Browse files Browse the repository at this point in the history
  • Loading branch information
stelselim committed Jul 14, 2021
1 parent 483a03b commit 4349709
Show file tree
Hide file tree
Showing 10 changed files with 390 additions and 165 deletions.
3 changes: 3 additions & 0 deletions lib/main.dart
@@ -1,6 +1,7 @@
import 'package:cryptolostapp/application/provider/appstate.dart';
import 'package:cryptolostapp/presentation/app_widget.dart';
import 'package:cryptolostapp/presentation/screens/history_screen.dart';
import 'package:cryptolostapp/presentation/screens/progress_detail_screen.dart';
import 'package:cryptolostapp/utility/admob/admob_initialize.dart';
import 'package:cryptolostapp/utility/analytics/google_anayltics_functions.dart';
import 'package:cryptolostapp/utility/routes/routes.dart';
Expand Down Expand Up @@ -51,6 +52,8 @@ class App extends StatelessWidget {
homeRoute: (context) => const AppWidget(),
coinCalculationHistoryRoute: (context) =>
const CalculationHistoryScreen(),
progressDetailsRoute: (context) =>
const ProgressDetailScreen(),
},
),
);
Expand Down
6 changes: 3 additions & 3 deletions lib/presentation/screens/history_screen.dart
Expand Up @@ -48,9 +48,9 @@ class CalculationHistoryScreen extends StatelessWidget {
child: ElevatedButton(
onPressed: () async {
final AlertDialog alert = AlertDialog(
title: const Text("Delete All Calculations"),
content:
const Text("Calculations can not recovered."),
title: const Text("Delete Calculation History"),
content: const Text(
"Calculations can not be recovered."),
actions: [
TextButton(
onPressed: () {
Expand Down
15 changes: 15 additions & 0 deletions lib/presentation/screens/progress_detail_screen.dart
@@ -0,0 +1,15 @@
import 'package:flutter/material.dart';

class ProgressDetailScreen extends StatelessWidget {
const ProgressDetailScreen({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Center(
child: Text(12321.toString()),
),
);
}
}
12 changes: 10 additions & 2 deletions lib/presentation/screens/progress_screen.dart
Expand Up @@ -109,6 +109,10 @@ class _ProgressScreenState extends State<ProgressScreen> {
children: [
// Create New
ElevatedButton(
style: const ButtonStyle().copyWith(
backgroundColor:
MaterialStateProperty.all(Colors.green),
),
onPressed: () async {
final progressCreateDialog = Dialog(
child: Container(
Expand Down Expand Up @@ -137,11 +141,15 @@ class _ProgressScreenState extends State<ProgressScreen> {
),
// Delete New
ElevatedButton(
style: const ButtonStyle().copyWith(
backgroundColor:
MaterialStateProperty.all(Colors.redAccent),
),
onPressed: () async {
final AlertDialog alert = AlertDialog(
title: const Text("Delete All Calculations"),
title: const Text("Delete All Money Ladders"),
content:
const Text("Calculations can not recovered."),
const Text("Ladders can not be recovered."),
actions: [
TextButton(
onPressed: () {
Expand Down
278 changes: 153 additions & 125 deletions lib/presentation/screens/saved_screen.dart
@@ -1,150 +1,178 @@
import 'package:cryptolostapp/application/models/portfolio_calculations.dart';
import 'package:cryptolostapp/application/provider/appstate.dart';
import 'package:cryptolostapp/presentation/widgets/saved_calculations_widget.dart';
import 'package:cryptolostapp/presentation/widgets/total_calculations_widget.dart';
import 'package:cryptolostapp/infrastructure/calculation/save_calculation.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

class SavedScreen extends StatelessWidget {
class SavedScreen extends StatefulWidget {
const SavedScreen({Key? key}) : super(key: key);

@override
_SavedScreenState createState() => _SavedScreenState();
}

class _SavedScreenState extends State<SavedScreen> {
// Delete Calculation
Future<void> onDelete(int index) async {
try {
const snackBar = SnackBar(content: Text('Calculation deleted!'));
ScaffoldMessenger.of(context).showSnackBar(snackBar);
await deletePortfolioCalculations(index);
setState(() {});
} catch (e) {
print(e);
}
}

// Called Every Time the Screen is Shown
void listenPageOpens() {
Provider.of<AppState>(context, listen: false).addListener(() {
final index = Provider.of<AppState>(context, listen: false).index;
if (index == 3) {
setState(() {});
}
});
}

@override
void initState() {
super.initState();
listenPageOpens();
}

@override
Widget build(BuildContext context) {
return StatefulBuilder(
builder: (context, setStateFromBuilder) =>
FutureBuilder<List<PorfolioCalculation>>(
future: getPortfolioCalculations(),
builder: (context, snapshot) {
if (snapshot.data == null || snapshot.data!.isEmpty) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text("There is No Saved Data"),
const SizedBox(
height: 25,
),
ElevatedButton(
onPressed: () {
setStateFromBuilder(() {});
},
child: const Text("Refresh"),
),
],
),
);
}
return FutureBuilder<List<PorfolioCalculation>>(
future: getPortfolioCalculations(),
builder: (context, snapshot) {
if (snapshot.data == null || snapshot.data!.isEmpty) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text("There is No Saved Data"),
const SizedBox(
height: 25,
),
ElevatedButton(
onPressed: () {
setState(() {});
},
child: const Text("Refresh"),
),
],
),
);
}

if (snapshot.hasError) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Center(child: Text("An Error Occured")),
const SizedBox(
height: 25,
),
ElevatedButton(
onPressed: () => setState,
child: const Text("Refresh"),
),
],
),
);
}

if (snapshot.hasError) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
return Column(
children: [
Expanded(
flex: 2,
child: Row(
children: [
const Center(child: Text("An Error Occured")),
const SizedBox(
height: 25,
),
ElevatedButton(
onPressed: () {
setStateFromBuilder(() {});
},
child: const Text("Refresh"),
Expanded(
child: Container(
color: Colors.blueGrey,
child: TotalCalculations(
calculations: snapshot.data,
),
),
),
],
),
);
}

return Column(
children: [
Expanded(
flex: 2,
child: Row(
),
Expanded(
flex: 7,
child: RefreshIndicator(
onRefresh: () async {
await Future.delayed(const Duration(milliseconds: 200));
setState(() {});
},
child: Column(
children: [
Expanded(
child: Container(
color: Colors.blueGrey,
child: TotalCalculations(
calculations: snapshot.data,
),
),
),
],
),
),
Expanded(
flex: 7,
child: RefreshIndicator(
onRefresh: () async {
await Future.delayed(const Duration(milliseconds: 200));
setStateFromBuilder(() {});
},
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Padding(
padding: const EdgeInsets.only(right: 18.0),
child: ElevatedButton(
onPressed: () async {
final AlertDialog alert = AlertDialog(
title: const Text("Delete All Calculations"),
content: const Text(
"Calculations can not recovered."),
actions: [
TextButton(
onPressed: () {
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Padding(
padding: const EdgeInsets.only(right: 18.0),
child: ElevatedButton(
onPressed: () async {
final AlertDialog alert = AlertDialog(
title: const Text("Delete All Calculations"),
content: const Text(
"Calculations can not recovered."),
actions: [
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text("No"),
),
TextButton(
onPressed: () async {
try {
await clearPortfolioCalculations();
Navigator.pop(context);
},
child: const Text("No"),
),
TextButton(
onPressed: () async {
try {
await clearPortfolioCalculations();
Navigator.pop(context);
setStateFromBuilder(() {});
} catch (e) {
print(e);
}
},
child: const Text("Yes"),
),
],
);
showDialog(
context: context,
builder: (BuildContext context) {
return alert;
},
);
},
child: const Text("Delete All"),
),
setState(() {});
} catch (e) {
print(e);
}
},
child: const Text("Yes"),
),
],
);
showDialog(
context: context,
builder: (BuildContext context) {
return alert;
},
);
},
child: const Text("Delete All"),
),
],
),
Expanded(
child: ListView.builder(
itemCount: snapshot.data!.length,
itemBuilder: (context, index) {
return SavedCalculationWidget(
context: context,
index: index,
setState: setStateFromBuilder,
localcalculation: snapshot.data!.elementAt(index),
);
},
),
],
),
Expanded(
child: ListView.builder(
itemCount: snapshot.data!.length,
itemBuilder: (context, index) {
return SavedCalculationWidget(
onDelete: () => onDelete(index),
localcalculation: snapshot.data!.elementAt(index),
);
},
),
],
),
),
],
),
),
],
);
},
),
),
],
);
},
);
}
}
2 changes: 1 addition & 1 deletion lib/presentation/widgets/history/history_coin_widget.dart
Expand Up @@ -104,7 +104,7 @@ class HistoryCoinWidget extends StatelessWidget {
coinModel: historyCalculation.coinModel,
currentDateTime: historyCalculation.currentDateTime,
isLoss: historyCalculation.isLoss,
profit: historyCalculation.percentage,
profit: historyCalculation.profit,
percentage: historyCalculation.percentage,
oldDateTime: historyCalculation.oldDateTime,
));
Expand Down

0 comments on commit 4349709

Please sign in to comment.