diff --git a/app/lib/data/database.dart b/app/lib/data/database.dart index f0726e0..4c05187 100644 --- a/app/lib/data/database.dart +++ b/app/lib/data/database.dart @@ -12,7 +12,6 @@ dynamic encrypter(String password) { return encrypted; } - /// Update Company table V1 to V2 void _addIsFavouriteToAccountsTableV2(Batch batch) { batch.execute('ALTER TABLE accounts ADD isFavourite boolean default FALSE;'); @@ -24,23 +23,23 @@ class DbManager { Future openDb() async { _database = await openDatabase( - join(await getDatabasesPath(), "bankimoon.db"), - version: 2, - onCreate: (Database db, int version) async { - await db.execute( - "CREATE TABLE IF NOT EXISTS accounts(id INTEGER PRIMARY KEY autoincrement, bankName TEXT, accountName TEXT, accountNumber INTEGER)", - ); - await db.execute( - "CREATE TABLE IF NOT EXISTS password(id INTEGER PRIMARY KEY autoincrement, password TEXT)", - ); - }, - onUpgrade: (db, oldVersion, newVersion) async { - var batch = db.batch(); - if (oldVersion == 1) { - _addIsFavouriteToAccountsTableV2(batch); - } - await batch.commit(); - }, + join(await getDatabasesPath(), "bankimoon.db"), + version: 3, + onCreate: (Database db, int version) async { + await db.execute( + "CREATE TABLE IF NOT EXISTS accounts(id INTEGER PRIMARY KEY autoincrement, bankName TEXT, accountName TEXT, accountNumber INTEGER, isFavourite TEXT)", + ); + await db.execute( + "CREATE TABLE IF NOT EXISTS password(id INTEGER PRIMARY KEY autoincrement, password TEXT)", + ); + }, + onUpgrade: (db, oldVersion, newVersion) async { + var batch = db.batch(); + if (oldVersion == 1) { + _addIsFavouriteToAccountsTableV2(batch); + } + await batch.commit(); + }, ); return _database; } @@ -158,7 +157,7 @@ class DbManager { String sql = "UPDATE accounts SET isFavourite = 1 WHERE id = ?"; - List params = [ accountId ]; + List params = [accountId]; return await _database.rawQuery(sql, params); } diff --git a/app/lib/main.dart b/app/lib/main.dart index 65cbf5d..bfaf37d 100644 --- a/app/lib/main.dart +++ b/app/lib/main.dart @@ -14,7 +14,7 @@ Future main() async { theme: ThemeData( useMaterial3: true, fontFamily: GoogleFonts.lato().fontFamily, - colorSchemeSeed: Colors.deepPurple, + // colorSchemeSeed: Colors.deepPurple, appBarTheme: AppBarTheme( backgroundColor: Colors.deepPurple[800], ), diff --git a/app/lib/presentation/screens/favourites.dart b/app/lib/presentation/screens/favourites.dart index a9bc5da..159ba02 100644 --- a/app/lib/presentation/screens/favourites.dart +++ b/app/lib/presentation/screens/favourites.dart @@ -1,5 +1,5 @@ import 'package:bankimoon/data/cubit/accounts_cubit.dart'; -import 'package:bankimoon/presentation/widgets/account_card.dart'; +import 'package:bankimoon/presentation/widgets/card.dart'; import 'package:bankimoon/utils/constants.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -19,13 +19,13 @@ class Favourite extends StatelessWidget { ), centerTitle: true, leading: GestureDetector( - onTap: () { - Navigator.pop(context); - }, - child: const Icon( - Icons.arrow_back, - color: Colors.white, - )), + onTap: () { + Navigator.pop(context); + }, + child: const Icon( + Icons.arrow_back, + color: Colors.white, + )), bottom: PreferredSize( preferredSize: const Size.fromHeight(50.0), child: Padding( @@ -40,7 +40,8 @@ class Favourite extends StatelessWidget { BlocProvider.of(context) .searchFavouriteAccounts(value.toString()); } else { - BlocProvider.of(context).favouritedAccounts(); + BlocProvider.of(context) + .favouritedAccounts(); } }, ), @@ -234,10 +235,9 @@ class Favourite extends StatelessWidget { height: size.height, width: size.width, child: Center( - child: Text( - state.message, - ) - ), + child: Text( + state.message, + )), ); } else { return SizedBox( diff --git a/app/lib/presentation/screens/home.dart b/app/lib/presentation/screens/home.dart index b0b01fa..e1bc66c 100644 --- a/app/lib/presentation/screens/home.dart +++ b/app/lib/presentation/screens/home.dart @@ -1,9 +1,11 @@ import 'package:bankimoon/data/cubit/accounts_cubit.dart'; -import 'package:bankimoon/presentation/widgets/account_card.dart'; +import 'package:bankimoon/presentation/widgets/card.dart'; import 'package:bankimoon/utils/constants.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import '../widgets/nav_bar.dart'; + class Home extends StatelessWidget { const Home({super.key}); @@ -244,92 +246,7 @@ class Home extends StatelessWidget { } }, ), - bottomNavigationBar: BottomAppBar( - color: Color.fromARGB(255, 15, 91, 254), - shape: const CircularNotchedRectangle(), - padding: - EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Column( - mainAxisSize: MainAxisSize.min, - children: [ - IconButton( - // ignore: prefer_const_constructors - icon: Icon( - Icons.home, - color: Colors.white, // Set the icon color to white - ), - onPressed: () { - Navigator.pushNamed(context, Home as String); - }, - ), - // ignore: prefer_const_constructors - Text( - 'Home', - // ignore: prefer_const_constructors - style: TextStyle(color: Colors.white), - ), - ], - ), - Column( - mainAxisSize: MainAxisSize.min, - children: [ - IconButton( - // ignore: prefer_const_constructors - icon: Icon( - Icons.favorite, - color: Colors.white, // Set the icon color to white - ), - onPressed: () { - Navigator.pushNamed(context, favouritePage); - }, - ), - // ignore: prefer_const_constructors - Text( - 'Favorites', - style: TextStyle(color: Colors.white), - ), - ], - ), - Column( - mainAxisSize: MainAxisSize.min, - children: [ - IconButton( - icon: Icon( - Icons.add, - color: Colors.white, // Set the icon color to white - ), - onPressed: () { - Navigator.pushNamed(context, addAccount); - }, - ), - Text( - 'Add Account', - style: TextStyle(color: Colors.white), - ), - ], - ), - Column( - mainAxisSize: MainAxisSize.min, - children: [ - IconButton( - icon: Icon( - Icons.account_circle, - color: Colors.white, // Set the icon color to white - ), - onPressed: () {}, - ), - Text( - 'My Accounts', - style: TextStyle(color: Colors.white), - ), - ], - ), - ], - ), - ), + bottomNavigationBar: const BottomNavBar(), ); } } diff --git a/app/lib/presentation/widgets/account_card.dart b/app/lib/presentation/widgets/account_card.dart deleted file mode 100644 index 9865535..0000000 --- a/app/lib/presentation/widgets/account_card.dart +++ /dev/null @@ -1,94 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:share_plus/share_plus.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:bankimoon/data/cubit/accounts_cubit.dart'; - -class AccountCard extends StatelessWidget { - const AccountCard({ - super.key, - required this.accountId, - required this.accountName, - required this.accountNumber, - required this.bankName, - required this.isFavourite, - }); - - final int accountId; - final String accountName; - final String accountNumber; - final String bankName; - final bool isFavourite; - - @override - Widget build(BuildContext context) { - return Card( - child: ListTile( - title: Text( - accountName, - style: const TextStyle(fontWeight: FontWeight.bold), - ), - subtitle: Text( - '$accountNumber - $bankName', - ), - trailing: Row( - mainAxisSize: MainAxisSize.min, - children: [ - GestureDetector( - onTap: () { - BlocProvider.of(context) - .markAsFavourite(accountId); - - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text("Added to favourites"), - ), - ); - }, - child: Icon( - Icons.favorite, - color: isFavourite ? Colors.red[400] : Colors.deepPurple - ), - ), - const SizedBox( - width: 8, - ), - GestureDetector( - onTap: () { - // copy data to clipboard - Clipboard.setData( - ClipboardData( - text: accountNumber, - ), - ); - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text("Copied to clipboard"), - ), - ); - }, - child: const Icon( - Icons.copy, - color: Colors.deepPurple, - ), - ), - const SizedBox( - width: 8, - ), - GestureDetector( - onTap: () { - Share.share( - "$bankName \nName: $accountName \nAccount Number: $accountNumber \n \nShared from Bankimoon App", - ); - }, - child: const Icon( - Icons.share, - color: Colors.deepPurple, - ), - ) - ], - ), - ), - ); - } -} diff --git a/app/lib/presentation/widgets/card.dart b/app/lib/presentation/widgets/card.dart new file mode 100644 index 0000000..bda953d --- /dev/null +++ b/app/lib/presentation/widgets/card.dart @@ -0,0 +1,225 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:share_plus/share_plus.dart'; + +import '../../data/cubit/accounts_cubit.dart'; + +class AccountCard extends StatelessWidget { + const AccountCard({ + super.key, + required this.accountId, + required this.accountName, + required this.accountNumber, + required this.bankName, + required this.isFavourite, + }); + + final int accountId; + final String accountName; + final String accountNumber; + final String bankName; + final bool isFavourite; + + @override + Widget build(BuildContext context) { + return SizedBox( + child: Column( + children: [ + Card( + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(15))), + color: Colors.white, + child: SizedBox( + height: 115, + width: MediaQuery.of(context).size.width, + child: Stack(children: [ + Padding( + padding: const EdgeInsets.only( + left: 20, + top: 10, + ), + child: SizedBox( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + accountName, + style: const TextStyle( + fontSize: 24, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox( + height: 4, + ), + Text( + accountNumber, + style: const TextStyle( + fontSize: 18, + fontWeight: FontWeight.w300, + ), + ), + const SizedBox( + height: 4, + ), + Text( + bankName, + style: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.w300, + ), + ), + ], + ), + ), + ), + Positioned( + top: 0, + right: 0, + child: Padding( + padding: const EdgeInsets.only( + top: 20.0, + right: 15.0, + ), + child: SizedBox( + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + InkWell( + onTap: () { + BlocProvider.of(context) + .markAsFavourite(accountId); + + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text("Added to favourites"), + ), + ); + }, + child: Icon(Icons.favorite, + color: isFavourite + ? Colors.red[400] + : Colors.deepPurple), + ), + const InkWell( + //Todo: Add a dropdown menu + //? Options: Remove as favourite + //? : Delete + //? : Edit + + child: Icon( + Icons.more_vert, + size: 30, + color: Colors.blueAccent, + ), + ) + ], + ), + ), + ), + ) + ]), + ), + ), + SizedBox( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + InkWell( + onTap: () { + Clipboard.setData( + ClipboardData( + text: accountNumber, + ), + ); + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text("Copied to clipboard"), + ), + ); + }, + child: const Card( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(15))), + child: SizedBox( + height: 35, + width: 180, + child: SizedBox( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SizedBox( + child: Row( + children: [ + Icon( + Icons.copy, + color: Colors.blueAccent, + ), + SizedBox( + width: 5, + ), + Text( + "Copy", + style: TextStyle( + color: Colors.blueAccent, + fontWeight: FontWeight.bold), + ), + ], + ), + ), + ], + ), + ), + ), + ), + ), + InkWell( + onTap: () { + Share.share( + "$bankName \nName: $accountName \nAccount Number: $accountNumber \n \nShared from Bankimoon App", + ); + }, + child: const Card( + color: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(15))), + child: SizedBox( + height: 35, + width: 180, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SizedBox( + child: Row( + children: [ + Icon( + Icons.share, + color: Colors.blueAccent, + ), + SizedBox( + width: 5, + ), + Text( + "Share", + style: TextStyle( + color: Colors.blueAccent, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), + ], + ), + ), + ), + ) + ], + ), + ) + ], + ), + ); + } +} diff --git a/app/lib/presentation/widgets/nav_bar.dart b/app/lib/presentation/widgets/nav_bar.dart new file mode 100644 index 0000000..6b89427 --- /dev/null +++ b/app/lib/presentation/widgets/nav_bar.dart @@ -0,0 +1,100 @@ +import 'package:flutter/material.dart'; + +import '../../utils/constants.dart'; +import '../screens/home.dart'; + +class BottomNavBar extends StatelessWidget { + const BottomNavBar({ + super.key, + }); + + @override + Widget build(BuildContext context) { + return BottomAppBar( + color: Color.fromARGB(255, 15, 91, 254), + shape: const CircularNotchedRectangle(), + padding: + EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Column( + mainAxisSize: MainAxisSize.min, + children: [ + IconButton( + // ignore: prefer_const_constructors + icon: Icon( + Icons.home, + color: Colors.white, // Set the icon color to white + ), + onPressed: () { + Navigator.pushNamed(context, Home as String); + }, + ), + // ignore: prefer_const_constructors + Text( + 'Home', + // ignore: prefer_const_constructors + style: TextStyle(color: Colors.white), + ), + ], + ), + Column( + mainAxisSize: MainAxisSize.min, + children: [ + IconButton( + // ignore: prefer_const_constructors + icon: Icon( + Icons.favorite, + color: Colors.white, // Set the icon color to white + ), + onPressed: () { + Navigator.pushNamed(context, favouritePage); + }, + ), + // ignore: prefer_const_constructors + Text( + 'Favorites', + style: TextStyle(color: Colors.white), + ), + ], + ), + Column( + mainAxisSize: MainAxisSize.min, + children: [ + IconButton( + icon: Icon( + Icons.add, + color: Colors.white, // Set the icon color to white + ), + onPressed: () { + Navigator.pushNamed(context, addAccount); + }, + ), + Text( + 'Add Account', + style: TextStyle(color: Colors.white), + ), + ], + ), + Column( + mainAxisSize: MainAxisSize.min, + children: [ + IconButton( + icon: Icon( + Icons.account_circle, + color: Colors.white, // Set the icon color to white + ), + onPressed: () {}, + ), + Text( + 'My Accounts', + style: TextStyle(color: Colors.white), + ), + ], + ), + ], + ), + ); + } +} diff --git a/app/pubspec.lock b/app/pubspec.lock index 1539b0b..7763e5b 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -85,10 +85,10 @@ packages: dependency: transitive description: name: collection - sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted - version: "1.17.2" + version: "1.18.0" convert: dependency: transitive description: @@ -276,10 +276,10 @@ packages: dependency: transitive description: name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.10.0" mime: dependency: transitive description: @@ -505,18 +505,18 @@ packages: dependency: transitive description: name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" string_scanner: dependency: transitive description: @@ -545,10 +545,10 @@ packages: dependency: transitive description: name: test_api - sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" + sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" url: "https://pub.dev" source: hosted - version: "0.6.0" + version: "0.6.1" typed_data: dependency: transitive description: @@ -609,10 +609,10 @@ packages: dependency: transitive description: name: web - sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 + sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 url: "https://pub.dev" source: hosted - version: "0.1.4-beta" + version: "0.3.0" win32: dependency: transitive description: @@ -646,5 +646,5 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.1.0-185.0.dev <4.0.0" + dart: ">=3.2.0-194.0.dev <4.0.0" flutter: ">=3.3.0"