diff --git a/README.md b/README.md
index f03d84c..fa597b1 100644
--- a/README.md
+++ b/README.md
@@ -1,16 +1,24 @@
-# currency_exchange_rate_app_flutter
+# Currency Exchange Rate application using Flutter + GetIt + Dio
-A new Flutter project.
+## Descriptions
+👋 Hey there!
-## Getting Started
+As part of my Flutter course, I developed an app for some practice. I used Bloc as state manager and GetIt for dependency injection and Dio requests. Overall, I'm pretty excited about how this project turned out and I hope you will enjoy it too! ❤️
-This project is a starting point for a Flutter application.
+## ScreenShots
+
+
+
-A few resources to get you started if this is your first Flutter project:
+## My Socials:
+* [INSTAGRAM](https://www.instagram.com/sepehrfakoori)
+* [LINKEDIN](https://www.linkedin.com/in/sepehrfakoori)
+* [CONTACT ME](https://sepehrfakoori99@gmail.com)
-- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
-- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
-
-For help getting started with Flutter development, view the
-[online documentation](https://docs.flutter.dev/), which offers tutorials,
-samples, guidance on mobile development, and a full API reference.
diff --git a/lib/data/datasource/price_datasource.dart b/lib/data/datasource/price_datasource.dart
index d3b1553..756a93a 100644
--- a/lib/data/datasource/price_datasource.dart
+++ b/lib/data/datasource/price_datasource.dart
@@ -1,30 +1,33 @@
-import 'package:currency_exchange_rate_app_flutter/data/model/crypto_currency.dart';
+import 'package:currency_exchange_rate_app_flutter/data/model/coin.dart';
import 'package:currency_exchange_rate_app_flutter/data/model/currency.dart';
+import 'package:currency_exchange_rate_app_flutter/data/model/gold.dart';
import 'package:currency_exchange_rate_app_flutter/di/di.dart';
import 'package:currency_exchange_rate_app_flutter/util/api_exception.dart';
import 'package:currency_exchange_rate_app_flutter/util/map_to_list_convertor.dart';
import 'package:dio/dio.dart';
-abstract class ICryptoCurrencyDataSource {
- Future> getCryptoCurrencies();
-
+abstract class IPriceDataSource {
Future> getCurrencies();
+
+ Future> getGolds();
+
+ Future> getCoins();
}
-class CryptoCurrencyRemoteDatasource extends ICryptoCurrencyDataSource {
+class PriceRemoteDatasource extends IPriceDataSource {
final Dio _dio = locator.get();
@override
- Future> getCryptoCurrencies() async {
+ Future> getCurrencies() async {
try {
Map qParams = {
"token": "440714:668d2eb4c7b96",
+ "action": "tgju",
};
- var response =
- await _dio.get("DigitalCurrency/", queryParameters: qParams);
- return response.data["result"]
- .map(
- (jsonObject) => CryptoCurrency.fromMapJson(jsonObject))
+ var response = await _dio.get("price/", queryParameters: qParams);
+ var result = convertMap(response.data, "currencies");
+ return result
+ .map((jsonObject) => Currency.fromMapJson(jsonObject))
.toList();
} on DioException catch (ex) {
throw ApiException(ex.response!.statusCode, ex.response!.statusMessage);
@@ -34,16 +37,35 @@ class CryptoCurrencyRemoteDatasource extends ICryptoCurrencyDataSource {
}
@override
- Future> getCurrencies() async {
+ Future> getGolds() async {
try {
Map qParams = {
"token": "440714:668d2eb4c7b96",
"action": "tgju",
};
var response = await _dio.get("price/", queryParameters: qParams);
- var result = convertMap(response.data, "currencies");
+ var result = convertMap(response.data, "gold");
return result
- .map((jsonObject) => Currency.fromMapJson(jsonObject))
+ .map((jsonObject) => Gold.fromMapJson(jsonObject))
+ .toList();
+ } on DioException catch (ex) {
+ throw ApiException(ex.response!.statusCode, ex.response!.statusMessage);
+ } catch (ex) {
+ throw ApiException(0, "Unknown Error!");
+ }
+ }
+
+ @override
+ Future> getCoins() async {
+ try {
+ Map qParams = {
+ "token": "440714:668d2eb4c7b96",
+ "action": "tgju",
+ };
+ var response = await _dio.get("price/", queryParameters: qParams);
+ var result = convertMap(response.data, "coin");
+ return result
+ .map((jsonObject) => Coin.fromMapJson(jsonObject))
.toList();
} on DioException catch (ex) {
throw ApiException(ex.response!.statusCode, ex.response!.statusMessage);
diff --git a/lib/data/repository/price_repository.dart b/lib/data/repository/price_repository.dart
index f8944c2..491885d 100644
--- a/lib/data/repository/price_repository.dart
+++ b/lib/data/repository/price_repository.dart
@@ -1,24 +1,27 @@
-import 'package:currency_exchange_rate_app_flutter/data/datasource/crypto_currency_datasource.dart';
-import 'package:currency_exchange_rate_app_flutter/data/model/crypto_currency.dart';
+import 'package:currency_exchange_rate_app_flutter/data/datasource/price_datasource.dart';
+import 'package:currency_exchange_rate_app_flutter/data/model/coin.dart';
import 'package:currency_exchange_rate_app_flutter/data/model/currency.dart';
+import 'package:currency_exchange_rate_app_flutter/data/model/gold.dart';
import 'package:currency_exchange_rate_app_flutter/di/di.dart';
import 'package:currency_exchange_rate_app_flutter/util/api_exception.dart';
import 'package:dartz/dartz.dart';
-abstract class ICryptoCurrencyRepository {
- Future>> getCryptoCurrencies();
-
+abstract class IPriceRepository {
Future>> getCurrencies();
+
+ Future>> getGolds();
+
+ Future>> getCoins();
}
-class CryptoCurrencyRepository extends ICryptoCurrencyRepository {
- final ICryptoCurrencyDataSource _dataSource = locator.get();
+class PriceRepository extends IPriceRepository {
+ final IPriceDataSource _dataSource = locator.get();
@override
- Future>> getCryptoCurrencies() async {
+ Future>> getCurrencies() async {
try {
- var response = await _dataSource.getCryptoCurrencies();
+ var response = await _dataSource.getCurrencies();
return right(response);
} on ApiException catch (ex) {
return left(ex.message ?? "Text Error We Got!");
@@ -26,9 +29,19 @@ class CryptoCurrencyRepository extends ICryptoCurrencyRepository {
}
@override
- Future>> getCurrencies() async {
+ Future>> getGolds() async {
try {
- var response = await _dataSource.getCurrencies();
+ var response = await _dataSource.getGolds();
+ return right(response);
+ } on ApiException catch (ex) {
+ return left(ex.message ?? "Text Error We Got!");
+ }
+ }
+
+ @override
+ Future>> getCoins() async {
+ try {
+ var response = await _dataSource.getCoins();
return right(response);
} on ApiException catch (ex) {
return left(ex.message ?? "Text Error We Got!");
diff --git a/lib/di/di.dart b/lib/di/di.dart
index 9905a2c..3e9cb28 100644
--- a/lib/di/di.dart
+++ b/lib/di/di.dart
@@ -1,5 +1,5 @@
-import 'package:currency_exchange_rate_app_flutter/data/datasource/crypto_currency_datasource.dart';
-import 'package:currency_exchange_rate_app_flutter/data/repository/crypto_currency_repository.dart';
+import 'package:currency_exchange_rate_app_flutter/data/datasource/price_datasource.dart';
+import 'package:currency_exchange_rate_app_flutter/data/repository/price_repository.dart';
import 'package:dio/dio.dart';
import 'package:get_it/get_it.dart';
@@ -7,6 +7,6 @@ var locator = GetIt.instance;
Future getItInit() async {
locator.registerSingleton(Dio(BaseOptions(baseUrl: "https://one-api.ir/")));
- locator.registerSingleton(CryptoCurrencyRemoteDatasource());
- locator.registerSingleton(CryptoCurrencyRepository());
+ locator.registerSingleton(PriceRemoteDatasource());
+ locator.registerSingleton(PriceRepository());
}
diff --git a/lib/main.dart b/lib/main.dart
index 187538e..865bfa0 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -1,5 +1,5 @@
-import 'package:currency_exchange_rate_app_flutter/bloc/crypto/crypto_bloc.dart';
-import 'package:currency_exchange_rate_app_flutter/bloc/crypto/crypto_event.dart';
+import 'package:currency_exchange_rate_app_flutter/bloc/home/home_bloc.dart';
+import 'package:currency_exchange_rate_app_flutter/bloc/home/home_event.dart';
import 'package:currency_exchange_rate_app_flutter/constants/app_colors.dart';
import 'package:currency_exchange_rate_app_flutter/di/di.dart';
import 'package:currency_exchange_rate_app_flutter/screens/home_screen.dart';
@@ -40,8 +40,8 @@ class MyApp extends StatelessWidget {
),
home: BlocProvider(
create: (context) {
- var bloc = CryptoBloc();
- bloc.add(CryptoInitializeEvent());
+ var bloc = HomeBloc();
+ bloc.add(HomeInitializeEvent());
return bloc;
},
child: const HomeScreen(),
diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart
index 11de651..e7ebaf7 100644
--- a/lib/screens/home_screen.dart
+++ b/lib/screens/home_screen.dart
@@ -1,208 +1,424 @@
-import 'package:currency_exchange_rate_app_flutter/bloc/crypto/crypto_bloc.dart';
-import 'package:currency_exchange_rate_app_flutter/bloc/crypto/crypto_state.dart';
+import 'package:auto_size_text/auto_size_text.dart';
+import 'package:currency_exchange_rate_app_flutter/bloc/home/home_bloc.dart';
+import 'package:currency_exchange_rate_app_flutter/bloc/home/home_state.dart';
import 'package:currency_exchange_rate_app_flutter/constants/app_colors.dart';
-import 'package:currency_exchange_rate_app_flutter/data/model/crypto_currency.dart';
+import 'package:currency_exchange_rate_app_flutter/data/model/coin.dart';
+import 'package:currency_exchange_rate_app_flutter/data/model/currency.dart';
+import 'package:currency_exchange_rate_app_flutter/data/model/gold.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.dart';
-import 'package:auto_size_text/auto_size_text.dart';
import 'package:loading_animation_widget/loading_animation_widget.dart';
-class HomeScreen extends StatefulWidget {
+class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
- @override
- State createState() => _HomeScreenState();
-}
-
-class _HomeScreenState extends State
- with SingleTickerProviderStateMixin {
- TabController? tabController;
-
- @override
- void initState() {
- super.initState();
- tabController = TabController(length: 2, vsync: this);
- }
-
@override
Widget build(BuildContext context) {
return Scaffold(
- backgroundColor: AppColors.backgroundColor,
- body: SafeArea(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- const SizedBox(height: 20),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 20.0),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Text(
- "EX Rate",
- style: Theme.of(context)
- .textTheme
- .headlineLarge!
- .copyWith(color: AppColors.priceColor),
- ),
- SvgPicture.asset(
- "assets/icons/settings.svg",
- color: AppColors.priceColor,
- width: 40,
- height: 40,
- ),
- ],
+ body: BlocBuilder(
+ builder: ((context, state) {
+ if (state is HomeLoadingState) {
+ return Center(
+ child: LoadingAnimationWidget.halfTriangleDot(
+ color: AppColors.priceColor,
+ size: 80,
),
- ),
- const SizedBox(height: 20),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 20.0),
- child: Text(
- "Exchange Rate",
- style: Theme.of(context).textTheme.headlineMedium!.copyWith(
- color: AppColors.priceColor,
+ );
+ }
+ return SafeArea(
+ child: CustomScrollView(
+ slivers: [
+ SliverPadding(
+ padding: const EdgeInsets.symmetric(horizontal: 20),
+ sliver: SliverToBoxAdapter(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Text(
+ "EX Rate",
+ style: Theme.of(context)
+ .textTheme
+ .headlineLarge!
+ .copyWith(color: AppColors.priceColor),
+ ),
+ SvgPicture.asset(
+ "assets/icons/settings.svg",
+ color: AppColors.priceColor,
+ width: 40,
+ height: 40,
+ ),
+ ],
),
- ),
- ),
- const SizedBox(height: 20),
- TabBarContainer(tabController: tabController),
- Directionality(
- textDirection: TextDirection.rtl,
- child: Container(
- padding: const EdgeInsets.symmetric(vertical: 5),
- width: double.infinity,
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 20.0),
- child: Row(
- children: [
- Text(
- "23:54",
- style:
- Theme.of(context).textTheme.headlineSmall!.copyWith(
- fontSize: 14,
- ),
+ ),
+ ),
+ SliverToBoxAdapter(
+ child: Container(
+ margin: const EdgeInsets.symmetric(
+ horizontal: 20, vertical: 20),
+ padding: const EdgeInsets.symmetric(horizontal: 10),
+ decoration: BoxDecoration(
+ color: Colors.white,
+ borderRadius: BorderRadius.circular(20),
+ ),
+ child: const TextField(
+ decoration: InputDecoration(
+ border: InputBorder.none,
+ prefixIcon: Icon(Icons.search),
),
- const SizedBox(width: 5),
- Text(
- ", 2022.10.30",
- style:
- Theme.of(context).textTheme.headlineSmall!.copyWith(
- fontSize: 14,
- ),
+ ),
+ ),
+ ),
+ SliverPadding(
+ padding: const EdgeInsets.symmetric(horizontal: 20),
+ sliver: SliverToBoxAdapter(
+ child: Text(
+ "Currencies",
+ style: Theme.of(context)
+ .textTheme
+ .headlineSmall!
+ .copyWith(fontSize: 18),
+ ),
+ ),
+ ),
+ if (state is HomeResponseState) ...{
+ state.currencyResponse.fold((exceptionMessage) {
+ return const Center(
+ child: Text("Data Currency Not Found!"),
+ );
+ }, (currencyList) {
+ return SliverPadding(
+ padding: const EdgeInsets.symmetric(horizontal: 20),
+ sliver: SliverList(
+ delegate: SliverChildBuilderDelegate(
+ (context, index) {
+ return CurrencyCardContainer(currencyList[index]);
+ },
+ childCount: currencyList.length,
+ ),
),
- ],
+ );
+ })
+ },
+ SliverPadding(
+ padding: const EdgeInsets.only(left: 20, right: 20, top: 20),
+ sliver: SliverToBoxAdapter(
+ child: Text(
+ "Gold",
+ style: Theme.of(context)
+ .textTheme
+ .headlineSmall!
+ .copyWith(fontSize: 18),
+ ),
),
),
- ),
- ),
- Expanded(
- child: BlocBuilder(
- builder: (context, state) {
- if (state is CryptoLoadingState) {
- return Center(
- child: LoadingAnimationWidget.halfTriangleDot(
- color: AppColors.priceColor,
- size: 80,
+ if (state is HomeResponseState) ...{
+ state.goldResponse.fold((exceptionMessage) {
+ return const Center(
+ child: Text("Data Currency Not Found!"),
+ );
+ }, (goldList) {
+ return SliverPadding(
+ padding: const EdgeInsets.symmetric(horizontal: 20),
+ sliver: SliverList(
+ delegate: SliverChildBuilderDelegate(
+ (context, index) {
+ return GoldCardContainer(goldList[index]);
+ },
+ childCount: goldList.length,
+ ),
),
);
- } else if (state is CryptoResponseState) {
- return state.response.fold((exceptionMessage) {
- return const Center(
- child: Text("Fuck it!"),
- );
- }, (cryptoCurrencyList) {
- return TabBarView(
- controller: tabController,
- children: [
- Padding(
- padding:
- const EdgeInsets.symmetric(horizontal: 20.0),
- child: CustomScrollView(
- slivers: [
- SliverList(
- delegate: SliverChildBuilderDelegate(
- (context, index) {
- return CardContainer(
- index, cryptoCurrencyList[index]);
- },
- childCount: cryptoCurrencyList.length,
- ),
- ),
- ],
- ),
- ),
- Padding(
- padding:
- const EdgeInsets.symmetric(horizontal: 20.0),
- child: CustomScrollView(
- slivers: [
- SliverList(
- delegate: SliverChildBuilderDelegate(
- (context, index) {
- return CardContainer(
- index, cryptoCurrencyList[index]);
- },
- childCount: cryptoCurrencyList.length,
- ),
- ),
- ],
- ),
- ),
- ],
- );
- });
- } else {
+ })
+ },
+ SliverPadding(
+ padding: const EdgeInsets.only(left: 20, right: 20, top: 20),
+ sliver: SliverToBoxAdapter(
+ child: Text(
+ "Coin",
+ style: Theme.of(context)
+ .textTheme
+ .headlineSmall!
+ .copyWith(fontSize: 18),
+ ),
+ ),
+ ),
+ if (state is HomeResponseState) ...{
+ state.coinResponse.fold((exceptionMessage) {
return const Center(
- child: Text("Fuck it!"),
+ child: Text("Data Currency Not Found!"),
);
- }
+ }, (coinList) {
+ return SliverPadding(
+ padding: const EdgeInsets.symmetric(horizontal: 20),
+ sliver: SliverList(
+ delegate: SliverChildBuilderDelegate(
+ (context, index) {
+ return CoinCardContainer(coinList[index]);
+ },
+ childCount: coinList.length,
+ ),
+ ),
+ );
+ })
},
- ),
+ const SliverPadding(
+ padding: EdgeInsets.only(bottom: 50.0),
+ ),
+ ],
),
- ],
- ),
+ );
+ }),
),
);
}
}
-class TabBarContainer extends StatelessWidget {
- const TabBarContainer({
- super.key,
- required TabController? tabController,
- }) : _tabController = tabController;
+class CurrencyCardContainer extends StatefulWidget {
+ Currency currency;
+
+ CurrencyCardContainer(
+ this.currency, {
+ super.key,
+ });
+
+ @override
+ State createState() => _CurrencyCardContainerState();
+}
- final TabController? _tabController;
+class _CurrencyCardContainerState extends State {
+ bool _isFavorite = false;
@override
Widget build(BuildContext context) {
return Container(
- margin: const EdgeInsets.symmetric(horizontal: 20.0),
- height: 40,
+ margin: const EdgeInsets.symmetric(vertical: 5),
+ padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 15),
+ height: 130,
decoration: BoxDecoration(
color: Colors.white,
- borderRadius: BorderRadius.circular(25),
+ borderRadius: BorderRadius.circular(10),
+ border: Border.all(
+ color: AppColors.lowEmphasisColor,
+ width: 0.5,
+ ),
+ boxShadow: const [
+ BoxShadow(
+ color: AppColors.priceColor,
+ blurRadius: 7,
+ spreadRadius: -2,
+ offset: Offset(0, 3),
+ ),
+ ],
),
- child: TabBar(
- controller: _tabController,
- labelColor: Colors.white,
- labelStyle:
- Theme.of(context).textTheme.headlineSmall!.copyWith(fontSize: 16),
- unselectedLabelColor: AppColors.lowEmphasisColor,
- indicator: BoxDecoration(
- borderRadius: BorderRadius.circular(25),
- color: AppColors.priceColor,
+ child: Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ "1",
+ style: Theme.of(context).textTheme.headlineLarge,
+ ),
+ const SizedBox(width: 10),
+ Expanded(
+ child: Column(
+ children: [
+ Row(
+ children: [
+ Expanded(
+ child: Text(
+ widget.currency.name!,
+ style: Theme.of(context)
+ .textTheme
+ .headlineMedium!
+ .copyWith(
+ color: AppColors.highEmphasisColor,
+ ),
+ ),
+ ),
+ Text(
+ widget.currency.name!,
+ style:
+ Theme.of(context).textTheme.headlineSmall!.copyWith(
+ color: AppColors.lowEmphasisColor,
+ ),
+ ),
+ ],
+ ),
+ const Spacer(),
+ Row(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Row(
+ mainAxisSize: MainAxisSize.max,
+ children: [
+ AutoSizeText(
+ widget.currency.currentPrice!,
+ maxLines: 1,
+ style: Theme.of(context)
+ .textTheme
+ .headlineLarge!
+ .copyWith(
+ color: AppColors.priceColor,
+ ),
+ ),
+ const SizedBox(width: 5),
+ Text(
+ "IRT",
+ style: Theme.of(context)
+ .textTheme
+ .headlineMedium!
+ .copyWith(
+ color: AppColors.priceColor,
+ ),
+ ),
+ ],
+ ),
+ GestureDetector(
+ onTap: () {
+ setState(() {
+ _isFavorite = !_isFavorite;
+ });
+ },
+ child: SvgPicture.asset(
+ _isFavorite
+ ? "assets/icons/filled_star.svg"
+ : "assets/icons/unfilled_star.svg",
+ color: AppColors.priceColor,
+ width: 30,
+ height: 30,
+ ),
+ ),
+ ],
+ ),
+ ],
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+}
+
+class GoldCardContainer extends StatefulWidget {
+ Gold gold;
+
+ GoldCardContainer(
+ this.gold, {
+ super.key,
+ });
+
+ @override
+ State createState() => _GoldCardContainerState();
+}
+
+class _GoldCardContainerState extends State {
+ bool _isFavorite = false;
+
+ @override
+ Widget build(BuildContext context) {
+ return Container(
+ margin: const EdgeInsets.symmetric(vertical: 5),
+ padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 15),
+ height: 130,
+ decoration: BoxDecoration(
+ color: Colors.white,
+ borderRadius: BorderRadius.circular(10),
+ border: Border.all(
+ color: AppColors.lowEmphasisColor,
+ width: 0.5,
),
- indicatorPadding: const EdgeInsets.all(3),
- dividerColor: Colors.transparent,
- indicatorSize: TabBarIndicatorSize.tab,
- tabs: const [
- Tab(
- text: "All",
+ boxShadow: const [
+ BoxShadow(
+ color: AppColors.priceColor,
+ blurRadius: 7,
+ spreadRadius: -2,
+ offset: Offset(0, 3),
+ ),
+ ],
+ ),
+ child: Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ "1",
+ style: Theme.of(context).textTheme.headlineLarge,
),
- Tab(
- text: "Favorites",
+ const SizedBox(width: 10),
+ Expanded(
+ child: Column(
+ children: [
+ Row(
+ children: [
+ Expanded(
+ child: Text(
+ widget.gold.name!,
+ style: Theme.of(context)
+ .textTheme
+ .headlineMedium!
+ .copyWith(
+ color: AppColors.highEmphasisColor,
+ ),
+ ),
+ ),
+ Text(
+ widget.gold.name!,
+ style:
+ Theme.of(context).textTheme.headlineSmall!.copyWith(
+ color: AppColors.lowEmphasisColor,
+ ),
+ ),
+ ],
+ ),
+ const Spacer(),
+ Row(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Row(
+ mainAxisSize: MainAxisSize.max,
+ children: [
+ AutoSizeText(
+ widget.gold.currentPrice!,
+ maxLines: 1,
+ style: Theme.of(context)
+ .textTheme
+ .headlineLarge!
+ .copyWith(
+ color: AppColors.priceColor,
+ ),
+ ),
+ const SizedBox(width: 5),
+ Text(
+ "IRT",
+ style: Theme.of(context)
+ .textTheme
+ .headlineMedium!
+ .copyWith(
+ color: AppColors.priceColor,
+ ),
+ ),
+ ],
+ ),
+ GestureDetector(
+ onTap: () {
+ setState(() {
+ _isFavorite = !_isFavorite;
+ });
+ },
+ child: SvgPicture.asset(
+ _isFavorite
+ ? "assets/icons/filled_star.svg"
+ : "assets/icons/unfilled_star.svg",
+ color: AppColors.priceColor,
+ width: 30,
+ height: 30,
+ ),
+ ),
+ ],
+ ),
+ ],
+ ),
),
],
),
@@ -210,21 +426,19 @@ class TabBarContainer extends StatelessWidget {
}
}
-class CardContainer extends StatefulWidget {
- final int index;
- CryptoCurrency cryptoCurrency;
+class CoinCardContainer extends StatefulWidget {
+ Coin coin;
- CardContainer(
- this.index,
- this.cryptoCurrency, {
- super.key,
- });
+ CoinCardContainer(
+ this.coin, {
+ super.key,
+ });
@override
- State createState() => _CardContainerState();
+ State createState() => _CoinCardContainerState();
}
-class _CardContainerState extends State {
+class _CoinCardContainerState extends State {
bool _isFavorite = false;
@override
@@ -253,7 +467,7 @@ class _CardContainerState extends State {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
- "${widget.index + 1}",
+ "1",
style: Theme.of(context).textTheme.headlineLarge,
),
const SizedBox(width: 10),
@@ -264,21 +478,21 @@ class _CardContainerState extends State {
children: [
Expanded(
child: Text(
- widget.cryptoCurrency.englishName.toString(),
+ widget.coin.name!,
style: Theme.of(context)
.textTheme
.headlineMedium!
.copyWith(
- color: AppColors.highEmphasisColor,
- ),
+ color: AppColors.highEmphasisColor,
+ ),
),
),
Text(
- widget.cryptoCurrency.keyName.toString(),
+ widget.coin.name!,
style:
- Theme.of(context).textTheme.headlineSmall!.copyWith(
- color: AppColors.lowEmphasisColor,
- ),
+ Theme.of(context).textTheme.headlineSmall!.copyWith(
+ color: AppColors.lowEmphasisColor,
+ ),
),
],
),
@@ -291,14 +505,14 @@ class _CardContainerState extends State {
mainAxisSize: MainAxisSize.max,
children: [
AutoSizeText(
- widget.cryptoCurrency.price.toString(),
+ widget.coin.currentPrice!,
maxLines: 1,
style: Theme.of(context)
.textTheme
.headlineLarge!
.copyWith(
- color: AppColors.priceColor,
- ),
+ color: AppColors.priceColor,
+ ),
),
const SizedBox(width: 5),
Text(
@@ -307,8 +521,8 @@ class _CardContainerState extends State {
.textTheme
.headlineMedium!
.copyWith(
- color: AppColors.priceColor,
- ),
+ color: AppColors.priceColor,
+ ),
),
],
),
diff --git a/lib/screens/splash_screen.dart b/lib/screens/splash_screen.dart
index 107bb98..de53430 100644
--- a/lib/screens/splash_screen.dart
+++ b/lib/screens/splash_screen.dart
@@ -1,9 +1,5 @@
-import 'package:currency_exchange_rate_app_flutter/bloc/crypto/crypto_bloc.dart';
-import 'package:currency_exchange_rate_app_flutter/bloc/crypto/crypto_event.dart';
import 'package:currency_exchange_rate_app_flutter/constants/app_colors.dart';
-import 'package:currency_exchange_rate_app_flutter/screens/home_screen.dart';
import 'package:flutter/material.dart';
-import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:lottie/lottie.dart';
class SplashScreen extends StatefulWidget {