Skip to content

add expenses and activity screen #17

Merged
merged 1 commit into from
Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions expense_tracker/.vscode/launch.json

This file was deleted.

29 changes: 18 additions & 11 deletions expense_tracker/lib/Components/navbar.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:expense_tracker/Screens/addexpenses.dart';
import 'package:expense_tracker/Screens/myhomepage.dart';
import 'package:expense_tracker/Screens/profile.dart';
import 'package:flutter/material.dart';
import '../Screens/activity.dart';
Expand Down Expand Up @@ -42,9 +43,15 @@ class DesktopNavbar extends StatelessWidget {
),
Row(
children: <Widget>[
const Text(
"Home",
style: TextStyle(color: Colors.white),
GestureDetector(
onTap: () => {
Navigator.push(context,
MaterialPageRoute(builder: (context) => MyHomePage()))
},
child: const Text(
"Home",
style: TextStyle(color: Colors.white, fontSize: 20),
),
),
const SizedBox(
width: 30,
Expand All @@ -56,7 +63,7 @@ class DesktopNavbar extends StatelessWidget {
},
child: const Text(
"Add expenses",
style: TextStyle(color: Colors.white),
style: TextStyle(color: Colors.white, fontSize: 20),
),
),
const SizedBox(
Expand All @@ -69,7 +76,7 @@ class DesktopNavbar extends StatelessWidget {
},
child: const Text(
"Activity",
style: TextStyle(color: Colors.white),
style: TextStyle(color: Colors.white, fontSize: 20),
),
),
const SizedBox(
Expand All @@ -82,7 +89,7 @@ class DesktopNavbar extends StatelessWidget {
},
child: const Text(
"Profile",
style: TextStyle(color: Colors.white),
style: TextStyle(color: Colors.white, fontSize: 20),
),
),
const SizedBox(
Expand All @@ -95,7 +102,7 @@ class DesktopNavbar extends StatelessWidget {
onPressed: () {},
child: const Text(
"Get Started",
style: TextStyle(color: Colors.white),
style: TextStyle(color: Colors.white, fontSize: 20),
),
)
],
Expand Down Expand Up @@ -128,28 +135,28 @@ class MobileNavbar extends StatelessWidget {
children: <Widget>[
Text(
"Home",
style: TextStyle(color: Colors.white),
style: TextStyle(color: Colors.white, fontSize: 20),
),
SizedBox(
width: 30,
),
Text(
"Activity",
style: TextStyle(color: Colors.white),
style: TextStyle(color: Colors.white, fontSize: 20),
),
SizedBox(
width: 30,
),
Text(
"Profile",
style: TextStyle(color: Colors.white),
style: TextStyle(color: Colors.white, fontSize: 20),
),
SizedBox(
width: 30,
),
Text(
"About us",
style: TextStyle(color: Colors.white),
style: TextStyle(color: Colors.white, fontSize: 20),
),
],
),
Expand Down
7 changes: 4 additions & 3 deletions expense_tracker/lib/Screens/Login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ class LoginState extends State<Login> {
),
autovalidateMode: AutovalidateMode.onUserInteraction,
validator: (value) => value != null && value.length < 8
? 'Enter min 6 char'
? 'Enter min 8 char'
: null,
),
),
const SizedBox(height: 20),
RichText(
text: TextSpan(
style: TextStyle(
color: Colors.orangeAccent[700], fontSize: 20),
color: Colors.orangeAccent[700], fontSize: 15),
text: 'No account?',
children: [
TextSpan(
Expand All @@ -119,7 +119,8 @@ class LoginState extends State<Login> {
text: 'Sign up',
style: TextStyle(
decoration: TextDecoration.underline,
color: Colors.orangeAccent[700])),
color: Colors.orangeAccent[700],
fontSize: 15)),
],
),
),
Expand Down
172 changes: 133 additions & 39 deletions expense_tracker/lib/Screens/activity.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_database/firebase_database.dart';
import 'package:flutter/material.dart';
import '../Components/navbar.dart';
import './myhomepage.dart';
Expand All @@ -12,49 +14,141 @@ class Activity extends StatefulWidget {
}

class _ActivityState extends State<Activity> {
late DatabaseReference expensesRef;
List<DataSnapshot> expenseList = [];
@override
void initState() {
super.initState();
expensesRef = FirebaseDatabase.instance
.ref('expenses/${FirebaseAuth.instance.currentUser!.uid}');
expensesRef.onValue.listen((event) {
setState(() {
expenseList = event.snapshot.children.toList();
});
});
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: SingleChildScrollView(
child: Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [
Color.fromARGB(255, 83, 78, 212),
Color.fromARGB(255, 28, 28, 28)
])),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
// mainAxisAlignment: MainAxisAlignment.center,
children: [
const Navbar(),
const Padding(
padding: EdgeInsets.symmetric(vertical: 20.0, horizontal: 40.0),
),
Container(
width: 600,
// height: 50,
child: Card(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Padding(
padding: EdgeInsetsDirectional.fromSTEB(20, 0, 0, 0),
child: const ListTile(
title: Text('kjasdhksgjdv'),
subtitle: Text('jdfndnhgvfvdsjn'),
),
body: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [
Color.fromARGB(255, 83, 78, 212),
Color.fromARGB(255, 28, 28, 28)
])),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Navbar(),
const Padding(
padding: EdgeInsets.symmetric(vertical: 20.0, horizontal: 40.0),
),
Expanded(
child: expenseList.length == 0
? Center(
child: Text(
'No Expense Added',
style: TextStyle(color: Colors.white),
),
)
: Container(
width: 900,
child: ListView.builder(
itemCount: expenseList.length,
itemBuilder: (context, index) {
var childData = expenseList[index];
return Card(
child: Padding(
padding: EdgeInsets.all(10),
child: Row(
children: [
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
'${childData.child('Marchantname').value} - ${childData.child('category').value}',
style: TextStyle(
fontWeight: FontWeight.bold),
),
SizedBox(height: 20),
Text(
'${childData.child('Description').value}'),
],
),
Spacer(),
Column(
children: [
Text(
'\$20.0',
style: TextStyle(
fontWeight: FontWeight.bold),
),
SizedBox(height: 20),
InkWell(
onTap: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: const Text('Alert'),
content: const Text(
'Do you want to remove this expense? '),
actions: <Widget>[
TextButton(
style:
TextButton.styleFrom(
textStyle:
Theme.of(context)
.textTheme
.labelLarge,
),
child: const Text('No'),
onPressed: () {
Navigator.of(context)
.pop();
},
),
TextButton(
style:
TextButton.styleFrom(
textStyle:
Theme.of(context)
.textTheme
.labelLarge,
),
child: const Text('Yes'),
onPressed: () {
childData.ref.remove();
Navigator.of(context)
.pop();
},
),
],
);
});
//
},
child: Icon(
Icons.delete,
color: Colors.redAccent,
),
)
],
),
],
),
),
);
},
),
],
),
),
),
],
),
),
),
],
),
),
);
Expand Down
Loading