Compare commits
1 Commits
master-gen
...
master
Author | SHA1 | Date | |
---|---|---|---|
1172e650aa |
@ -1,6 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:helpers/helpers/misc_build/build_media.dart';
|
||||
import 'package:rluv/features/account/signup.dart';
|
||||
import 'package:rluv/global/styles.dart';
|
||||
|
||||
@ -13,8 +12,7 @@ class AccountCreateScreen extends ConsumerStatefulWidget {
|
||||
const AccountCreateScreen({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<AccountCreateScreen> createState() =>
|
||||
_AccountCreateScreenState();
|
||||
ConsumerState<AccountCreateScreen> createState() => _AccountCreateScreenState();
|
||||
}
|
||||
|
||||
enum _AccountScreen { options, login, signup }
|
||||
@ -40,7 +38,7 @@ class _AccountCreateScreenState extends ConsumerState<AccountCreateScreen> {
|
||||
},
|
||||
);
|
||||
}
|
||||
final screen = BuildMedia(context).size;
|
||||
final screen = MediaQuery.of(context).size;
|
||||
return Scaffold(
|
||||
backgroundColor: Styles.purpleNurple,
|
||||
body: SafeArea(
|
||||
@ -60,11 +58,8 @@ class _AccountCreateScreenState extends ConsumerState<AccountCreateScreen> {
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 40.0),
|
||||
child: Image.asset("assets/app_icon.png",
|
||||
height:
|
||||
screen.width > 500 ? 250 : screen.width * 0.5,
|
||||
width: screen.width > 500
|
||||
? 250
|
||||
: screen.width * 0.5),
|
||||
height: screen.width > 500 ? 250 : screen.width * 0.5,
|
||||
width: screen.width > 500 ? 250 : screen.width * 0.5),
|
||||
),
|
||||
UiButton(
|
||||
color: Styles.sunflower,
|
||||
|
@ -1,7 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:helpers/helpers/misc_build/build_media.dart';
|
||||
import 'package:helpers/helpers/print.dart';
|
||||
|
||||
import '../../global/api.dart';
|
||||
import '../../global/styles.dart';
|
||||
@ -32,7 +30,7 @@ class _LoginState extends ConsumerState<Login> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final screen = BuildMedia(context).size;
|
||||
final screen = MediaQuery.of(context).size;
|
||||
return Form(
|
||||
key: widget.formKey,
|
||||
child: Stack(
|
||||
@ -205,14 +203,11 @@ class _LoginState extends ConsumerState<Login> {
|
||||
|
||||
Future login() async {
|
||||
try {
|
||||
if (widget.formKey.currentState != null &&
|
||||
!widget.formKey.currentState!.validate()) {
|
||||
if (widget.formKey.currentState != null && !widget.formKey.currentState!.validate()) {
|
||||
return;
|
||||
}
|
||||
final data =
|
||||
await ref.read(apiProvider.notifier).post(path: 'auth/login', data: {
|
||||
'username':
|
||||
usernameController.text.isEmpty ? null : usernameController.text,
|
||||
final data = await ref.read(apiProvider.notifier).post(path: 'auth/login', data: {
|
||||
'username': usernameController.text.isEmpty ? null : usernameController.text,
|
||||
'email': emailController.text.isEmpty ? null : emailController.text,
|
||||
'password': passwordController.text,
|
||||
});
|
||||
@ -227,13 +222,10 @@ class _LoginState extends ConsumerState<Login> {
|
||||
}
|
||||
}
|
||||
// final bool success = data?['success'] ?? false;
|
||||
printAmber(data);
|
||||
showSnack(
|
||||
ref: ref,
|
||||
text: message,
|
||||
type: !success ? SnackType.error : SnackType.success);
|
||||
print(data);
|
||||
showSnack(ref: ref, text: message, type: !success ? SnackType.error : SnackType.success);
|
||||
} catch (err, st) {
|
||||
printRed('Error in login: $err\n$st');
|
||||
print('Error in login: $err\n$st');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:helpers/helpers/misc_build/build_media.dart';
|
||||
import 'package:helpers/helpers/print.dart';
|
||||
|
||||
import '../../global/api.dart';
|
||||
import '../../global/styles.dart';
|
||||
@ -36,7 +34,7 @@ class _SignupState extends ConsumerState<Signup> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final screen = BuildMedia(context).size;
|
||||
final screen = MediaQuery.of(context).size;
|
||||
return Form(
|
||||
key: widget.formKey,
|
||||
child: Stack(
|
||||
@ -126,8 +124,7 @@ class _SignupState extends ConsumerState<Signup> {
|
||||
),
|
||||
UiButton(
|
||||
width: screen.width * 0.4,
|
||||
icon: const Icon(Icons.cancel,
|
||||
color: Styles.washedStone, size: 20),
|
||||
icon: const Icon(Icons.cancel, color: Styles.washedStone, size: 20),
|
||||
onPressed: () {
|
||||
setState(
|
||||
() => hasFamilyCode = false,
|
||||
@ -140,9 +137,7 @@ class _SignupState extends ConsumerState<Signup> {
|
||||
: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: UiButton(
|
||||
width: screen.width * 0.5 > 400
|
||||
? 400
|
||||
: screen.width * 0.5,
|
||||
width: screen.width * 0.5 > 400 ? 400 : screen.width * 0.5,
|
||||
text: 'JOIN FAMILY',
|
||||
// color: Styles.flounderBlue,
|
||||
onPressed: () {
|
||||
@ -190,8 +185,7 @@ class _SignupState extends ConsumerState<Signup> {
|
||||
text,
|
||||
style: TextStyle(fontSize: size.width < 350 ? 16 : 20),
|
||||
),
|
||||
if (subtext != null)
|
||||
Text(subtext, style: const TextStyle(fontSize: 12)),
|
||||
if (subtext != null) Text(subtext, style: const TextStyle(fontSize: 12)),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -223,36 +217,29 @@ class _SignupState extends ConsumerState<Signup> {
|
||||
|
||||
Future signup() async {
|
||||
try {
|
||||
if (widget.formKey.currentState != null &&
|
||||
!widget.formKey.currentState!.validate()) {
|
||||
if (widget.formKey.currentState != null && !widget.formKey.currentState!.validate()) {
|
||||
return;
|
||||
}
|
||||
final data =
|
||||
await ref.read(apiProvider.notifier).post(path: 'auth/signup', data: {
|
||||
final data = await ref.read(apiProvider.notifier).post(path: 'auth/signup', data: {
|
||||
'name': nameCotroller.text,
|
||||
'username':
|
||||
usernameController.text.isEmpty ? null : usernameController.text,
|
||||
'username': usernameController.text.isEmpty ? null : usernameController.text,
|
||||
'email': emailController.text.isEmpty ? null : emailController.text,
|
||||
'password': passwordController.text,
|
||||
'family_code': familyCodeController.text.isEmpty
|
||||
? null
|
||||
: familyCodeController.text.toUpperCase(),
|
||||
'family_code': familyCodeController.text.isEmpty ? null : familyCodeController.text.toUpperCase(),
|
||||
'budget_name': 'Budget'
|
||||
});
|
||||
|
||||
final success = data?['success'] ?? false;
|
||||
showSnack(
|
||||
ref: ref,
|
||||
text: data?['message'] ?? success
|
||||
? 'Login successful'
|
||||
: 'Login unsuccessful',
|
||||
text: data?['message'] ?? success ? 'Login successful' : 'Login unsuccessful',
|
||||
type: !success ? SnackType.error : SnackType.success);
|
||||
|
||||
printAmber(data);
|
||||
print(data);
|
||||
// final user = User.fromJson(data?['user']);
|
||||
// ref.read(tokenProvider.notifier).state =
|
||||
} catch (err) {
|
||||
printRed(err);
|
||||
print(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:helpers/helpers.dart';
|
||||
import 'package:rluv/features/budget/screens/transactions_listview.dart';
|
||||
import 'package:rluv/features/budget/widgets/add_transaction_dialog.dart';
|
||||
import 'package:rluv/features/budget/widgets/budget_category_bar.dart';
|
||||
import 'package:rluv/features/budget/widgets/budget_net_bar.dart';
|
||||
import 'package:rluv/global/styles.dart';
|
||||
import 'package:rluv/global/utils.dart';
|
||||
import 'package:rluv/models/budget_category_model.dart';
|
||||
|
||||
import '../../../global/store.dart';
|
||||
import '../../../global/widgets/ui_button.dart';
|
||||
@ -19,8 +19,7 @@ class BudgetOverviewScreen extends ConsumerStatefulWidget {
|
||||
final Map<String, dynamic> initialData;
|
||||
|
||||
@override
|
||||
ConsumerState<BudgetOverviewScreen> createState() =>
|
||||
_BudgetOverviewScreenState();
|
||||
ConsumerState<BudgetOverviewScreen> createState() => _BudgetOverviewScreenState();
|
||||
}
|
||||
|
||||
class _BudgetOverviewScreenState extends ConsumerState<BudgetOverviewScreen> {
|
||||
@ -30,23 +29,18 @@ class _BudgetOverviewScreenState extends ConsumerState<BudgetOverviewScreen> {
|
||||
final budget = ref.watch(budgetProvider);
|
||||
final budgetCategories = ref.watch(budgetCategoriesProvider);
|
||||
final transactions = ref.watch(transactionsProvider);
|
||||
final screen = BuildMedia(context).size;
|
||||
final screen = MediaQuery.of(context).size;
|
||||
double netExpense = 0.0;
|
||||
double netIncome = 0.0;
|
||||
double expectedExpenses = 0.0;
|
||||
Map<int, double> budgetCategoryNetMap = {};
|
||||
netExpense = transactions
|
||||
.where((t) => t.type == TransactionType.expense)
|
||||
.fold(netExpense, (net, t) => net + t.amount);
|
||||
netIncome = transactions
|
||||
.where((t) => t.type == TransactionType.income)
|
||||
.fold(netIncome, (net, t) => net + t.amount);
|
||||
netExpense =
|
||||
transactions.where((t) => t.type == TransactionType.expense).fold(netExpense, (net, t) => net + t.amount);
|
||||
netIncome = transactions.where((t) => t.type == TransactionType.income).fold(netIncome, (net, t) => net + t.amount);
|
||||
for (final bud in budgetCategories) {
|
||||
double net = 0.0;
|
||||
expectedExpenses += bud.amount;
|
||||
net = transactions
|
||||
.where((t) => t.budgetCategoryId == bud.id)
|
||||
.fold(net, (net, t) => net + t.amount);
|
||||
net = transactions.where((t) => t.budgetCategoryId == bud.id).fold(net, (net, t) => net + t.amount);
|
||||
budgetCategoryNetMap[bud.id!] = net;
|
||||
}
|
||||
return Stack(
|
||||
@ -64,23 +58,14 @@ class _BudgetOverviewScreenState extends ConsumerState<BudgetOverviewScreen> {
|
||||
const Spacer(flex: 2),
|
||||
Text(
|
||||
formatDate(DateTime.now()),
|
||||
style: const TextStyle(
|
||||
fontSize: 16, color: Styles.electricBlue),
|
||||
style: const TextStyle(fontSize: 16, color: Styles.electricBlue),
|
||||
),
|
||||
const Spacer(),
|
||||
const Text('MONTHLY',
|
||||
style:
|
||||
TextStyle(fontSize: 42, color: Styles.electricBlue)),
|
||||
const Text('MONTHLY', style: TextStyle(fontSize: 42, color: Styles.electricBlue)),
|
||||
const Spacer(flex: 2),
|
||||
BudgetNetBar(
|
||||
isPositive: true,
|
||||
net: netIncome,
|
||||
expected: budget?.expectedIncome ?? 0.0),
|
||||
BudgetNetBar(isPositive: true, net: netIncome, expected: budget?.expectedIncome ?? 0.0),
|
||||
const Spacer(),
|
||||
BudgetNetBar(
|
||||
isPositive: false,
|
||||
net: netExpense,
|
||||
expected: expectedExpenses),
|
||||
BudgetNetBar(isPositive: false, net: netExpense, expected: expectedExpenses),
|
||||
const Spacer(),
|
||||
],
|
||||
),
|
||||
@ -107,8 +92,7 @@ class _BudgetOverviewScreenState extends ConsumerState<BudgetOverviewScreen> {
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
'BUDGET',
|
||||
style: TextStyle(
|
||||
fontSize: 28, color: Styles.electricBlue),
|
||||
style: TextStyle(fontSize: 28, color: Styles.electricBlue),
|
||||
),
|
||||
),
|
||||
budgetCategories.isEmpty
|
||||
@ -120,25 +104,18 @@ class _BudgetOverviewScreenState extends ConsumerState<BudgetOverviewScreen> {
|
||||
children: [
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
'No budget categories created yet, add some!'),
|
||||
child: Text('No budget categories created yet, add some!'),
|
||||
),
|
||||
UiButton(
|
||||
onPressed:
|
||||
ref.watch(budgetProvider) ==
|
||||
null
|
||||
? null
|
||||
: () => showDialog(
|
||||
context: context,
|
||||
builder: (context) => Dialog(
|
||||
shape: Styles
|
||||
.dialogShape,
|
||||
backgroundColor:
|
||||
Styles
|
||||
.dialogColor,
|
||||
child:
|
||||
const BudgetCategoryDialog()),
|
||||
),
|
||||
onPressed: ref.watch(budgetProvider) == null
|
||||
? null
|
||||
: () => showDialog(
|
||||
context: context,
|
||||
builder: (context) => Dialog(
|
||||
shape: Styles.dialogShape,
|
||||
backgroundColor: Styles.dialogColor,
|
||||
child: const BudgetCategoryDialog()),
|
||||
),
|
||||
text: 'Add Category',
|
||||
),
|
||||
],
|
||||
@ -146,55 +123,42 @@ class _BudgetOverviewScreenState extends ConsumerState<BudgetOverviewScreen> {
|
||||
),
|
||||
)
|
||||
: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 2.0, vertical: 4.0),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 2.0, vertical: 4.0),
|
||||
child: SizedBox(
|
||||
height: screen.height * 0.36,
|
||||
child: Scrollbar(
|
||||
controller: budgetListScrollController,
|
||||
thumbVisibility: true,
|
||||
child: ListView(
|
||||
physics:
|
||||
const BouncingScrollPhysics(),
|
||||
controller:
|
||||
budgetListScrollController,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
controller: budgetListScrollController,
|
||||
shrinkWrap: true,
|
||||
children: [
|
||||
...budgetCategories
|
||||
.mapIndexed((i, category) {
|
||||
...budgetCategories.map((BudgetCategory category) {
|
||||
final i = budgetCategories.indexOf(category);
|
||||
return BudgetCategoryBar(
|
||||
budgetCategory: category,
|
||||
currentAmount:
|
||||
budgetCategoryNetMap[
|
||||
category.id]!,
|
||||
currentAmount: budgetCategoryNetMap[category.id]!,
|
||||
index: i,
|
||||
);
|
||||
}).toList(),
|
||||
const SizedBox(height: 20),
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 140,
|
||||
child: ElevatedButton(
|
||||
onPressed: ref.watch(
|
||||
budgetProvider) ==
|
||||
null
|
||||
onPressed: ref.watch(budgetProvider) == null
|
||||
? null
|
||||
: () => showDialog(
|
||||
context: context,
|
||||
builder: (context) => Dialog(
|
||||
shape: Styles
|
||||
.dialogShape,
|
||||
backgroundColor:
|
||||
Styles
|
||||
.dialogColor,
|
||||
child:
|
||||
const BudgetCategoryDialog()),
|
||||
shape: Styles.dialogShape,
|
||||
backgroundColor: Styles.dialogColor,
|
||||
child: const BudgetCategoryDialog()),
|
||||
),
|
||||
child: const Text(
|
||||
'Add Category'),
|
||||
child: const Text('Add Category'),
|
||||
),
|
||||
),
|
||||
],
|
||||
@ -214,8 +178,7 @@ class _BudgetOverviewScreenState extends ConsumerState<BudgetOverviewScreen> {
|
||||
children: [
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(left: 20.0, right: 15.0),
|
||||
padding: const EdgeInsets.only(left: 20.0, right: 15.0),
|
||||
child: Container(
|
||||
height: 70,
|
||||
decoration: BoxDecoration(
|
||||
@ -225,8 +188,7 @@ class _BudgetOverviewScreenState extends ConsumerState<BudgetOverviewScreen> {
|
||||
child: InkWell(
|
||||
child: const Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 20.0, vertical: 14.0),
|
||||
padding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 14.0),
|
||||
child: FittedBox(
|
||||
child: Text(
|
||||
'Transaction History',
|
||||
@ -238,10 +200,7 @@ class _BudgetOverviewScreenState extends ConsumerState<BudgetOverviewScreen> {
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
const TransactionsListview()));
|
||||
context, MaterialPageRoute(builder: (context) => const TransactionsListview()));
|
||||
},
|
||||
),
|
||||
),
|
||||
@ -292,8 +251,7 @@ class _BudgetOverviewScreenState extends ConsumerState<BudgetOverviewScreen> {
|
||||
child: IconButton(
|
||||
icon: const Icon(Icons.loop),
|
||||
color: Styles.seaweedGreen,
|
||||
onPressed: () =>
|
||||
ref.read(dashboardProvider.notifier).fetchDashboard(),
|
||||
onPressed: () => ref.read(dashboardProvider.notifier).fetchDashboard(),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -1,6 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:helpers/helpers/misc_build/build_media.dart';
|
||||
import 'package:rluv/features/budget/widgets/transaction_list_item.dart';
|
||||
import 'package:rluv/global/styles.dart';
|
||||
import 'package:rluv/models/transaction_model.dart';
|
||||
@ -12,8 +11,7 @@ class TransactionsListview extends ConsumerStatefulWidget {
|
||||
const TransactionsListview({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<TransactionsListview> createState() =>
|
||||
_TransactionsListviewState();
|
||||
ConsumerState<TransactionsListview> createState() => _TransactionsListviewState();
|
||||
}
|
||||
|
||||
class _TransactionsListviewState extends ConsumerState<TransactionsListview> {
|
||||
@ -23,8 +21,7 @@ class _TransactionsListviewState extends ConsumerState<TransactionsListview> {
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
ref.read(selectedTransactionSortProvider.notifier).state =
|
||||
TransactionSort.all;
|
||||
ref.read(selectedTransactionSortProvider.notifier).state = TransactionSort.all;
|
||||
ref.read(selectedSortDateProvider.notifier).state = SortDate.decending;
|
||||
});
|
||||
super.initState();
|
||||
@ -34,8 +31,8 @@ class _TransactionsListviewState extends ConsumerState<TransactionsListview> {
|
||||
Widget build(BuildContext context) {
|
||||
final budgetCategories = ref.watch(budgetCategoriesProvider);
|
||||
if (ref.read(selectedCategory) == null && budgetCategories.isNotEmpty) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) =>
|
||||
ref.read(selectedCategory.notifier).state = budgetCategories.first);
|
||||
WidgetsBinding.instance
|
||||
.addPostFrameCallback((_) => ref.read(selectedCategory.notifier).state = budgetCategories.first);
|
||||
}
|
||||
final sortType = ref.watch(selectedTransactionSortProvider);
|
||||
final sortDate = ref.watch(selectedSortDateProvider);
|
||||
@ -60,8 +57,7 @@ class _TransactionsListviewState extends ConsumerState<TransactionsListview> {
|
||||
if (ref.read(selectedCategory) != null) {
|
||||
transactions = transactions
|
||||
.where(
|
||||
(element) =>
|
||||
element.budgetCategoryId == ref.read(selectedCategory)!.id,
|
||||
(element) => element.budgetCategoryId == ref.read(selectedCategory)!.id,
|
||||
)
|
||||
.toList();
|
||||
}
|
||||
@ -79,15 +75,15 @@ class _TransactionsListviewState extends ConsumerState<TransactionsListview> {
|
||||
break;
|
||||
}
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) =>
|
||||
ref.read(transactionHistoryListProvider.notifier).state = transactions);
|
||||
WidgetsBinding.instance
|
||||
.addPostFrameCallback((_) => ref.read(transactionHistoryListProvider.notifier).state = transactions);
|
||||
return Scaffold(
|
||||
endDrawer: Drawer(
|
||||
backgroundColor: Styles.purpleNurple,
|
||||
child: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(height: BuildMedia(context).height * 0.15),
|
||||
SizedBox(height: MediaQuery.of(context).size.height * 0.15),
|
||||
DropdownButton<TransactionSort>(
|
||||
dropdownColor: Styles.lavender,
|
||||
value: ref.watch(selectedTransactionSortProvider),
|
||||
@ -108,8 +104,7 @@ class _TransactionsListviewState extends ConsumerState<TransactionsListview> {
|
||||
.toList(),
|
||||
onChanged: (TransactionSort? value) {
|
||||
if (value != null) {
|
||||
ref.read(selectedTransactionSortProvider.notifier).state =
|
||||
value;
|
||||
ref.read(selectedTransactionSortProvider.notifier).state = value;
|
||||
}
|
||||
}),
|
||||
const SizedBox(height: 20),
|
||||
@ -137,8 +132,7 @@ class _TransactionsListviewState extends ConsumerState<TransactionsListview> {
|
||||
}
|
||||
}),
|
||||
const SizedBox(height: 20),
|
||||
if (ref.read(selectedTransactionSortProvider) ==
|
||||
TransactionSort.category)
|
||||
if (ref.read(selectedTransactionSortProvider) == TransactionSort.category)
|
||||
DropdownButton<BudgetCategory>(
|
||||
dropdownColor: Styles.lavender,
|
||||
value: ref.watch(selectedCategory),
|
||||
@ -154,8 +148,7 @@ class _TransactionsListviewState extends ConsumerState<TransactionsListview> {
|
||||
width: 18,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: Colors.black, width: 1.5),
|
||||
border: Border.all(color: Colors.black, width: 1.5),
|
||||
color: e.color,
|
||||
),
|
||||
),
|
||||
@ -186,9 +179,7 @@ class _TransactionsListviewState extends ConsumerState<TransactionsListview> {
|
||||
alignment: Alignment.topLeft,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0, top: 16.0),
|
||||
child: IconButton(
|
||||
icon: const Icon(Icons.chevron_left),
|
||||
onPressed: () => Navigator.pop(context)),
|
||||
child: IconButton(icon: const Icon(Icons.chevron_left), onPressed: () => Navigator.pop(context)),
|
||||
),
|
||||
),
|
||||
const Center(
|
||||
@ -201,14 +192,11 @@ class _TransactionsListviewState extends ConsumerState<TransactionsListview> {
|
||||
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0, top: 16.0),
|
||||
child: IconButton(
|
||||
icon: const Icon(Icons.chevron_left),
|
||||
onPressed: () => Navigator.pop(context)),
|
||||
child: IconButton(icon: const Icon(Icons.chevron_left), onPressed: () => Navigator.pop(context)),
|
||||
),
|
||||
const Spacer(),
|
||||
const Padding(
|
||||
padding:
|
||||
EdgeInsets.symmetric(vertical: 18.0, horizontal: 0.0),
|
||||
padding: EdgeInsets.symmetric(vertical: 18.0, horizontal: 0.0),
|
||||
child: Text(
|
||||
'Transaction History',
|
||||
style: TextStyle(fontSize: 28),
|
||||
@ -245,8 +233,7 @@ class _TransactionsListviewState extends ConsumerState<TransactionsListview> {
|
||||
}
|
||||
|
||||
void toggleDrawer() {
|
||||
if (scaffoldKey.currentState != null &&
|
||||
scaffoldKey.currentState!.isDrawerOpen) {
|
||||
if (scaffoldKey.currentState != null && scaffoldKey.currentState!.isDrawerOpen) {
|
||||
scaffoldKey.currentState!.openDrawer();
|
||||
} else if (scaffoldKey.currentState != null) {
|
||||
scaffoldKey.currentState!.openEndDrawer();
|
||||
@ -292,8 +279,7 @@ final selectedTransactionSortProvider = StateProvider<TransactionSort>(
|
||||
(ref) => TransactionSort.all,
|
||||
);
|
||||
|
||||
final selectedSortDateProvider =
|
||||
StateProvider<SortDate>((ref) => SortDate.decending);
|
||||
final selectedSortDateProvider = StateProvider<SortDate>((ref) => SortDate.decending);
|
||||
|
||||
final transactionHistoryListProvider = StateProvider<List<Transaction>>(
|
||||
(ref) => [],
|
||||
|
@ -1,7 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:helpers/helpers/misc_build/build_media.dart';
|
||||
import 'package:helpers/helpers/print.dart';
|
||||
import 'package:rluv/global/styles.dart';
|
||||
import 'package:rluv/models/budget.dart';
|
||||
import 'package:rluv/models/budget_category_model.dart';
|
||||
@ -17,12 +15,10 @@ class BudgetCategoryDialog extends ConsumerStatefulWidget {
|
||||
final BudgetCategory? category;
|
||||
|
||||
@override
|
||||
ConsumerState<BudgetCategoryDialog> createState() =>
|
||||
_AddBudgetCategoryDialogState();
|
||||
ConsumerState<BudgetCategoryDialog> createState() => _AddBudgetCategoryDialogState();
|
||||
}
|
||||
|
||||
class _AddBudgetCategoryDialogState
|
||||
extends ConsumerState<BudgetCategoryDialog> {
|
||||
class _AddBudgetCategoryDialogState extends ConsumerState<BudgetCategoryDialog> {
|
||||
late final Budget? budget;
|
||||
final categoryNameController = TextEditingController();
|
||||
final amountController = TextEditingController();
|
||||
@ -65,12 +61,11 @@ class _AddBudgetCategoryDialogState
|
||||
return Container();
|
||||
}
|
||||
return SizedBox(
|
||||
width: BuildMedia(context).width * Styles.dialogScreenWidthFactor,
|
||||
width: MediaQuery.of(context).size.width * Styles.dialogScreenWidthFactor,
|
||||
child: Stack(
|
||||
children: [
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 18.0, horizontal: 32.0),
|
||||
padding: const EdgeInsets.symmetric(vertical: 18.0, horizontal: 32.0),
|
||||
child: Form(
|
||||
key: formKey,
|
||||
child: Column(
|
||||
@ -78,9 +73,7 @@ class _AddBudgetCategoryDialogState
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 18.0),
|
||||
child: Text(widget.category == null
|
||||
? 'Add Category:'
|
||||
: 'Edit Category'),
|
||||
child: Text(widget.category == null ? 'Add Category:' : 'Edit Category'),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
@ -149,8 +142,7 @@ class _AddBudgetCategoryDialogState
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 6.0, horizontal: 16.0),
|
||||
padding: const EdgeInsets.symmetric(vertical: 6.0, horizontal: 16.0),
|
||||
child: SizedBox(
|
||||
height: 76,
|
||||
child: ListView.builder(
|
||||
@ -164,23 +156,21 @@ class _AddBudgetCategoryDialogState
|
||||
} else {
|
||||
setState(() => selectedColorIndex = -1);
|
||||
}
|
||||
printBlue(selectedColorIndex);
|
||||
print(selectedColorIndex);
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: AnimatedContainer(
|
||||
decoration: selectedColorIndex == index
|
||||
? BoxDecoration(
|
||||
borderRadius:
|
||||
BorderRadius.circular(15.0),
|
||||
borderRadius: BorderRadius.circular(15.0),
|
||||
border: Border.all(
|
||||
color: Styles.washedStone,
|
||||
width: 2.0,
|
||||
),
|
||||
)
|
||||
: BoxDecoration(
|
||||
borderRadius:
|
||||
BorderRadius.circular(5.0),
|
||||
borderRadius: BorderRadius.circular(5.0),
|
||||
border: Border.all(
|
||||
color: Colors.transparent,
|
||||
width: 2.0,
|
||||
@ -205,8 +195,7 @@ class _AddBudgetCategoryDialogState
|
||||
decoration: BoxDecoration(
|
||||
color: colors[index],
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: Colors.black, width: 1.5),
|
||||
border: Border.all(color: Colors.black, width: 1.5),
|
||||
),
|
||||
),
|
||||
],
|
||||
@ -227,8 +216,7 @@ class _AddBudgetCategoryDialogState
|
||||
color: Styles.expensesRed,
|
||||
text: 'DELETE',
|
||||
onPressed: () {
|
||||
if (formKey.currentState != null &&
|
||||
formKey.currentState!.validate()) {
|
||||
if (formKey.currentState != null && formKey.currentState!.validate()) {
|
||||
removeCategory().then((success) {
|
||||
Navigator.pop(context);
|
||||
if (success) {
|
||||
@ -254,8 +242,7 @@ class _AddBudgetCategoryDialogState
|
||||
color: Styles.lavender,
|
||||
text: 'SAVE',
|
||||
onPressed: () {
|
||||
if (formKey.currentState != null &&
|
||||
formKey.currentState!.validate()) {
|
||||
if (formKey.currentState != null && formKey.currentState!.validate()) {
|
||||
submitCategory(colors[selectedColorIndex]).then((_) {
|
||||
Navigator.pop(context);
|
||||
showSnack(
|
||||
@ -282,7 +269,7 @@ class _AddBudgetCategoryDialogState
|
||||
|
||||
Future submitCategory(Color categoryColor) async {
|
||||
if (formKey.currentState != null && !formKey.currentState!.validate()) {
|
||||
printPink('Failed validation');
|
||||
print('Failed validation');
|
||||
return;
|
||||
}
|
||||
Map<String, dynamic>? budgetData;
|
||||
@ -296,58 +283,41 @@ class _AddBudgetCategoryDialogState
|
||||
name: categoryNameController.text,
|
||||
);
|
||||
|
||||
budgetData = await ref
|
||||
.read(apiProvider.notifier)
|
||||
.post(path: 'budget_category', data: newBudget.toJson());
|
||||
budgetData = await ref.read(apiProvider.notifier).post(path: 'budget_category', data: newBudget.toJson());
|
||||
success = budgetData != null ? budgetData['success'] as bool : false;
|
||||
if (success) {
|
||||
ref
|
||||
.read(dashboardProvider.notifier)
|
||||
.add({'budget_categories': budgetData});
|
||||
ref.read(dashboardProvider.notifier).add({'budget_categories': budgetData});
|
||||
}
|
||||
} else {
|
||||
final newBudget =
|
||||
BudgetCategory.copyWith(category: widget.category!, data: {
|
||||
final newBudget = BudgetCategory.copyWith(category: widget.category!, data: {
|
||||
'amount': double.parse(amountController.text),
|
||||
'color': categoryColor,
|
||||
'name': categoryNameController.text
|
||||
});
|
||||
budgetData = await ref
|
||||
.read(apiProvider.notifier)
|
||||
.put(path: 'budget_category', data: newBudget.toJson());
|
||||
budgetData = await ref.read(apiProvider.notifier).put(path: 'budget_category', data: newBudget.toJson());
|
||||
success = budgetData != null ? budgetData['success'] as bool : false;
|
||||
if (success) {
|
||||
ref
|
||||
.read(dashboardProvider.notifier)
|
||||
.update({'budget_categories': budgetData});
|
||||
ref.read(dashboardProvider.notifier).update({'budget_categories': budgetData});
|
||||
}
|
||||
}
|
||||
if (success) {
|
||||
showSnack(
|
||||
ref: ref,
|
||||
text: widget.category == null
|
||||
? 'Added budget category!'
|
||||
: 'Updated category!',
|
||||
text: widget.category == null ? 'Added budget category!' : 'Updated category!',
|
||||
type: SnackType.error);
|
||||
} else {
|
||||
showSnack(
|
||||
ref: ref,
|
||||
text: widget.category == null
|
||||
? 'Could not add budget category'
|
||||
: 'Could not update category',
|
||||
text: widget.category == null ? 'Could not add budget category' : 'Could not update category',
|
||||
type: SnackType.error);
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> removeCategory() async {
|
||||
final res = await ref
|
||||
.read(apiProvider.notifier)
|
||||
.delete(path: 'budget_category', data: {'id': widget.category!.id});
|
||||
final res = await ref.read(apiProvider.notifier).delete(path: 'budget_category', data: {'id': widget.category!.id});
|
||||
final success = res != null ? res['success'] as bool : false;
|
||||
if (success) {
|
||||
ref
|
||||
.read(dashboardProvider.notifier)
|
||||
.removeWithId('budget_categories', widget.category!.id!);
|
||||
ref.read(dashboardProvider.notifier).removeWithId('budget_categories', widget.category!.id!);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:helpers/helpers/misc_build/build_media.dart';
|
||||
import 'package:rluv/global/utils.dart';
|
||||
|
||||
import '../../../global/api.dart';
|
||||
@ -18,8 +17,7 @@ class TransactionDialog extends ConsumerStatefulWidget {
|
||||
final Transaction? transaction;
|
||||
|
||||
@override
|
||||
ConsumerState<TransactionDialog> createState() =>
|
||||
_AddTransactionDialogState();
|
||||
ConsumerState<TransactionDialog> createState() => _AddTransactionDialogState();
|
||||
}
|
||||
|
||||
class _AddTransactionDialogState extends ConsumerState<TransactionDialog> {
|
||||
@ -37,8 +35,7 @@ class _AddTransactionDialogState extends ConsumerState<TransactionDialog> {
|
||||
@override
|
||||
void initState() {
|
||||
if (widget.transaction != null) {
|
||||
amountController =
|
||||
TextEditingController(text: widget.transaction!.amount.toString());
|
||||
amountController = TextEditingController(text: widget.transaction!.amount.toString());
|
||||
memoController = TextEditingController(text: widget.transaction!.memo);
|
||||
transactionType = widget.transaction!.type;
|
||||
selectedDate = widget.transaction!.date;
|
||||
@ -53,8 +50,7 @@ class _AddTransactionDialogState extends ConsumerState<TransactionDialog> {
|
||||
}
|
||||
final u = ref.read(userProvider);
|
||||
if (u == null) {
|
||||
WidgetsBinding.instance.addPostFrameCallback(
|
||||
(_) => ref.read(jwtProvider.notifier).revokeToken());
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) => ref.read(jwtProvider.notifier).revokeToken());
|
||||
} else {
|
||||
user = u;
|
||||
}
|
||||
@ -65,10 +61,9 @@ class _AddTransactionDialogState extends ConsumerState<TransactionDialog> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (user == null) return Container();
|
||||
final List<BudgetCategory> budgetCategories =
|
||||
ref.read(budgetCategoriesProvider);
|
||||
final List<BudgetCategory> budgetCategories = ref.read(budgetCategoriesProvider);
|
||||
return SizedBox(
|
||||
width: BuildMedia(context).width * Styles.dialogScreenWidthFactor,
|
||||
width: MediaQuery.of(context).size.width * Styles.dialogScreenWidthFactor,
|
||||
child: budgetCategories.isEmpty
|
||||
? const Padding(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
@ -91,25 +86,21 @@ class _AddTransactionDialogState extends ConsumerState<TransactionDialog> {
|
||||
onTap: transactionType == TransactionType.expense
|
||||
? null
|
||||
: () {
|
||||
setState(() => transactionType =
|
||||
TransactionType.expense);
|
||||
setState(() => transactionType = TransactionType.expense);
|
||||
},
|
||||
child: AnimatedContainer(
|
||||
height: 38,
|
||||
width: 80,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(8.0),
|
||||
topRight: Radius.circular(8.0)),
|
||||
color: transactionType ==
|
||||
TransactionType.expense
|
||||
topLeft: Radius.circular(8.0), topRight: Radius.circular(8.0)),
|
||||
color: transactionType == TransactionType.expense
|
||||
? Styles.lavender
|
||||
: Styles.washedStone),
|
||||
duration: const Duration(milliseconds: 300),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: Text('Expense',
|
||||
style: TextStyle(fontSize: 16)),
|
||||
child: Text('Expense', style: TextStyle(fontSize: 16)),
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -117,25 +108,20 @@ class _AddTransactionDialogState extends ConsumerState<TransactionDialog> {
|
||||
onTap: transactionType == TransactionType.income
|
||||
? null
|
||||
: () {
|
||||
setState(() => transactionType =
|
||||
TransactionType.income);
|
||||
setState(() => transactionType = TransactionType.income);
|
||||
},
|
||||
child: AnimatedContainer(
|
||||
height: 38,
|
||||
width: 80,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(8.0),
|
||||
topRight: Radius.circular(8.0)),
|
||||
topLeft: Radius.circular(8.0), topRight: Radius.circular(8.0)),
|
||||
color:
|
||||
transactionType == TransactionType.income
|
||||
? Styles.lavender
|
||||
: Styles.washedStone),
|
||||
transactionType == TransactionType.income ? Styles.lavender : Styles.washedStone),
|
||||
duration: const Duration(milliseconds: 300),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: Text('Income',
|
||||
style: TextStyle(fontSize: 16)),
|
||||
child: Text('Income', style: TextStyle(fontSize: 16)),
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -208,9 +194,7 @@ class _AddTransactionDialogState extends ConsumerState<TransactionDialog> {
|
||||
width: 18,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: Colors.black,
|
||||
width: 1.5),
|
||||
border: Border.all(color: Colors.black, width: 1.5),
|
||||
color: e.color,
|
||||
),
|
||||
),
|
||||
@ -226,8 +210,7 @@ class _AddTransactionDialogState extends ConsumerState<TransactionDialog> {
|
||||
if (kDebugMode) {
|
||||
print('${value.name} selected');
|
||||
}
|
||||
setState(() =>
|
||||
selectedBudgetCategory = value);
|
||||
setState(() => selectedBudgetCategory = value);
|
||||
}
|
||||
},
|
||||
),
|
||||
@ -247,7 +230,7 @@ class _AddTransactionDialogState extends ConsumerState<TransactionDialog> {
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: BuildMedia(context).width * 0.65,
|
||||
width: MediaQuery.of(context).size.width * 0.65,
|
||||
height: 100,
|
||||
decoration: Styles.boxLavenderBubble,
|
||||
child: TextFormField(
|
||||
@ -266,12 +249,12 @@ class _AddTransactionDialogState extends ConsumerState<TransactionDialog> {
|
||||
text: 'ADD',
|
||||
color: Styles.lavender,
|
||||
onPressed: () => submitTransaction().then((_) {
|
||||
Navigator.pop(context);
|
||||
if (mounted) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
showSnack(
|
||||
ref: ref,
|
||||
text: widget.transaction != null
|
||||
? 'Transaction updated!'
|
||||
: 'Transaction added!',
|
||||
text: widget.transaction != null ? 'Transaction updated!' : 'Transaction added!',
|
||||
type: SnackType.success,
|
||||
);
|
||||
}),
|
||||
@ -289,9 +272,7 @@ class _AddTransactionDialogState extends ConsumerState<TransactionDialog> {
|
||||
data: Transaction.copyWith(widget.transaction!, {
|
||||
'memo': memoController.text.isNotEmpty ? memoController.text : null,
|
||||
'amount': double.parse(amountController.text),
|
||||
'budget_category_id': transactionType == TransactionType.income
|
||||
? null
|
||||
: selectedBudgetCategory.id,
|
||||
'budget_category_id': transactionType == TransactionType.income ? null : selectedBudgetCategory.id,
|
||||
}).toJson());
|
||||
} else {
|
||||
data = await ref.read(apiProvider.notifier).post(
|
||||
@ -299,15 +280,11 @@ class _AddTransactionDialogState extends ConsumerState<TransactionDialog> {
|
||||
data: Transaction(
|
||||
amount: double.parse(amountController.text),
|
||||
createdByUserId: user!.id!,
|
||||
budgetCategoryId: transactionType == TransactionType.income
|
||||
? null
|
||||
: selectedBudgetCategory.id,
|
||||
budgetCategoryId: transactionType == TransactionType.income ? null : selectedBudgetCategory.id,
|
||||
budgetId: user!.budgetId,
|
||||
date: DateTime.now(),
|
||||
type: transactionType,
|
||||
memo: memoController.text.isNotEmpty
|
||||
? memoController.text
|
||||
: null)
|
||||
memo: memoController.text.isNotEmpty ? memoController.text : null)
|
||||
.toJson());
|
||||
}
|
||||
final success = data != null ? data['success'] as bool : false;
|
||||
@ -320,9 +297,7 @@ class _AddTransactionDialogState extends ConsumerState<TransactionDialog> {
|
||||
} else {
|
||||
showSnack(
|
||||
ref: ref,
|
||||
text: widget.transaction != null
|
||||
? 'Failed to edit transaction'
|
||||
: 'Failed to add transaction',
|
||||
text: widget.transaction != null ? 'Failed to edit transaction' : 'Failed to add transaction',
|
||||
type: SnackType.error);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:helpers/helpers/print.dart';
|
||||
import 'package:rluv/features/budget/widgets/add_budget_category_dialog.dart';
|
||||
import 'package:rluv/global/utils.dart';
|
||||
import 'package:rluv/models/budget_category_model.dart';
|
||||
@ -45,8 +44,7 @@ class _BudgetCategoryBarState extends State<BudgetCategoryBar> {
|
||||
}
|
||||
});
|
||||
final innerHeight = widget.height - widget.innerPadding * 2;
|
||||
final isBright =
|
||||
getBrightness(widget.budgetCategory.color) == Brightness.light;
|
||||
final isBright = getBrightness(widget.budgetCategory.color) == Brightness.light;
|
||||
final textStyle = TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
@ -155,7 +153,6 @@ class _BudgetCategoryBarState extends State<BudgetCategoryBar> {
|
||||
if (!name.contains(' ') || name.indexOf(' ') == name.length - 1) {
|
||||
return name;
|
||||
}
|
||||
printLime('here');
|
||||
final words = name.split(' ');
|
||||
int index = 0;
|
||||
String firstLine = words[index];
|
||||
|
@ -1,14 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:helpers/helpers.dart';
|
||||
import 'package:rluv/global/styles.dart';
|
||||
import 'package:rluv/global/utils.dart';
|
||||
|
||||
class BudgetNetBar extends StatelessWidget {
|
||||
const BudgetNetBar(
|
||||
{super.key,
|
||||
required this.isPositive,
|
||||
required this.net,
|
||||
required this.expected});
|
||||
const BudgetNetBar({super.key, required this.isPositive, required this.net, required this.expected});
|
||||
|
||||
final bool isPositive;
|
||||
final double net;
|
||||
@ -16,7 +11,7 @@ class BudgetNetBar extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final screenWidth = BuildMedia(context).width;
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
return Container(
|
||||
width: screenWidth * 0.85,
|
||||
decoration: BoxDecoration(
|
||||
@ -25,8 +20,7 @@ class BudgetNetBar extends StatelessWidget {
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 12.0),
|
||||
child:
|
||||
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
|
||||
child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
|
||||
Text(
|
||||
isPositive ? 'Income' : 'Expenses',
|
||||
style: const TextStyle(
|
||||
@ -35,9 +29,7 @@ class BudgetNetBar extends StatelessWidget {
|
||||
),
|
||||
Text(
|
||||
'${net.currency()} / ${expected.currency()}',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
color: isPositive ? Styles.incomeGreen : Styles.expensesRed),
|
||||
style: TextStyle(fontSize: 20, color: isPositive ? Styles.incomeGreen : Styles.expensesRed),
|
||||
),
|
||||
]),
|
||||
),
|
||||
|
@ -1,6 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:helpers/helpers/misc_build/build_media.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:rluv/features/budget/screens/transactions_listview.dart';
|
||||
import 'package:rluv/features/budget/widgets/add_transaction_dialog.dart';
|
||||
@ -19,8 +18,7 @@ class TransactionListItem extends ConsumerStatefulWidget {
|
||||
final int index;
|
||||
|
||||
@override
|
||||
ConsumerState<TransactionListItem> createState() =>
|
||||
_TransactionListItemState();
|
||||
ConsumerState<TransactionListItem> createState() => _TransactionListItemState();
|
||||
}
|
||||
|
||||
class _TransactionListItemState extends ConsumerState<TransactionListItem> {
|
||||
@ -54,17 +52,13 @@ class _TransactionListItemState extends ConsumerState<TransactionListItem> {
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0, left: 8.0, bottom: 8.0),
|
||||
child: ClipRRect(
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(10.0),
|
||||
bottomLeft: Radius.circular(10.0)),
|
||||
borderRadius: const BorderRadius.only(topLeft: Radius.circular(10.0), bottomLeft: Radius.circular(10.0)),
|
||||
child: AnimatedContainer(
|
||||
curve: Curves.easeOut,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
height: cardHeight,
|
||||
decoration: const BoxDecoration(
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(10.0),
|
||||
bottomLeft: Radius.circular(10.0)),
|
||||
borderRadius: BorderRadius.only(topLeft: Radius.circular(10.0), bottomLeft: Radius.circular(10.0)),
|
||||
color: Styles.washedStone,
|
||||
),
|
||||
child: Row(
|
||||
@ -74,19 +68,16 @@ class _TransactionListItemState extends ConsumerState<TransactionListItem> {
|
||||
duration: const Duration(milliseconds: 200),
|
||||
height: cardHeight,
|
||||
width: 6,
|
||||
color: transaction!.type == TransactionType.income
|
||||
? Styles.incomeBlue
|
||||
: Styles.expensesOrange),
|
||||
color: transaction!.type == TransactionType.income ? Styles.incomeBlue : Styles.expensesOrange),
|
||||
SizedBox(
|
||||
width: BuildMedia(context).width * 0.65,
|
||||
width: MediaQuery.of(context).size.width * 0.65,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(DateFormat('EEE MMM d, h:mm a')
|
||||
.format(transaction!.date)),
|
||||
Text(DateFormat('EEE MMM d, h:mm a').format(transaction!.date)),
|
||||
Row(
|
||||
children: [
|
||||
const SizedBox(
|
||||
@ -101,9 +92,7 @@ class _TransactionListItemState extends ConsumerState<TransactionListItem> {
|
||||
),
|
||||
],
|
||||
Text(
|
||||
transaction!.type == TransactionType.income
|
||||
? 'Income'
|
||||
: budgetCategory!.name,
|
||||
transaction!.type == TransactionType.income ? 'Income' : budgetCategory!.name,
|
||||
style: const TextStyle(fontSize: 20),
|
||||
),
|
||||
],
|
||||
@ -125,9 +114,7 @@ class _TransactionListItemState extends ConsumerState<TransactionListItem> {
|
||||
transaction!.amount.currency(),
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
color: transaction!.type == TransactionType.income
|
||||
? Styles.incomeGreen
|
||||
: Styles.expensesRed),
|
||||
color: transaction!.type == TransactionType.income ? Styles.incomeGreen : Styles.expensesRed),
|
||||
),
|
||||
if (showDetails) ...[
|
||||
IconButton(
|
||||
@ -140,8 +127,7 @@ class _TransactionListItemState extends ConsumerState<TransactionListItem> {
|
||||
builder: (context) => Dialog(
|
||||
backgroundColor: Styles.dialogColor,
|
||||
shape: Styles.dialogShape,
|
||||
child:
|
||||
TransactionDialog(transaction: transaction),
|
||||
child: TransactionDialog(transaction: transaction),
|
||||
),
|
||||
);
|
||||
},
|
||||
@ -182,21 +168,14 @@ class _TransactionListItemState extends ConsumerState<TransactionListItem> {
|
||||
}
|
||||
|
||||
Future deleteTransaction() async {
|
||||
final res = await ref
|
||||
.read(apiProvider.notifier)
|
||||
.delete(path: 'transaction', data: {'id': transaction!.id});
|
||||
final res = await ref.read(apiProvider.notifier).delete(path: 'transaction', data: {'id': transaction!.id});
|
||||
|
||||
final success = res != null ? res['success'] as bool : false;
|
||||
if (success) {
|
||||
ref
|
||||
.read(dashboardProvider.notifier)
|
||||
.removeWithId('transactions', transaction!.id!);
|
||||
ref.read(dashboardProvider.notifier).removeWithId('transactions', transaction!.id!);
|
||||
showSnack(ref: ref, text: 'Transaction removed', type: SnackType.success);
|
||||
} else {
|
||||
showSnack(
|
||||
ref: ref,
|
||||
text: 'Could not delete transaction',
|
||||
type: SnackType.error);
|
||||
showSnack(ref: ref, text: 'Could not delete transaction', type: SnackType.error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:helpers/helpers/misc_build/build_media.dart';
|
||||
import 'package:helpers/helpers/print.dart';
|
||||
import 'package:rluv/global/utils.dart';
|
||||
import 'package:rluv/models/shared_note.dart';
|
||||
|
||||
@ -22,7 +20,7 @@ class SharedNotesScreen extends ConsumerStatefulWidget {
|
||||
class _SharedNotesScreenState extends ConsumerState<SharedNotesScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final screen = BuildMedia(context).size;
|
||||
final screen = MediaQuery.of(context).size;
|
||||
final sharedNotes = ref.watch(sharedNotesProvider);
|
||||
return Column(
|
||||
children: [
|
||||
@ -47,14 +45,10 @@ class _SharedNotesScreenState extends ConsumerState<SharedNotesScreen> {
|
||||
),
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
final note = sharedNotes[index];
|
||||
final colorBrightness = note.color == null
|
||||
? Brightness.light
|
||||
: getBrightness(note.color!);
|
||||
final colorBrightness = note.color == null ? Brightness.light : getBrightness(note.color!);
|
||||
final textStyle = TextStyle(
|
||||
fontSize: 16.0,
|
||||
color: colorBrightness == Brightness.light
|
||||
? Colors.black54
|
||||
: Colors.white70,
|
||||
color: colorBrightness == Brightness.light ? Colors.black54 : Colors.white70,
|
||||
);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
@ -67,14 +61,10 @@ class _SharedNotesScreenState extends ConsumerState<SharedNotesScreen> {
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
children: [
|
||||
FittedBox(
|
||||
child: Text(note.title,
|
||||
style: const TextStyle(fontSize: 20))),
|
||||
FittedBox(child: Text(note.title, style: const TextStyle(fontSize: 20))),
|
||||
Flexible(
|
||||
child: Text(
|
||||
note.content.length > 80
|
||||
? "${note.content.substring(0, 75)}..."
|
||||
: note.content,
|
||||
note.content.length > 80 ? "${note.content.substring(0, 75)}..." : note.content,
|
||||
style: textStyle,
|
||||