stack_wallet/lib/widgets/coin_card.dart

128 lines
3.4 KiB
Dart
Raw Normal View History

2023-06-08 16:59:44 +00:00
/*
* This file is part of Stack Wallet.
*
* Copyright (c) 2023 Cypher Stack
* All Rights Reserved.
* The code is distributed under GPLv3 license, see LICENSE file for details.
* Generated by Cypher Stack on 2023-05-26
*
*/
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/flutter_svg.dart';
import '../themes/coin_card_provider.dart';
import '../themes/theme_providers.dart';
import '../utilities/assets.dart';
import '../utilities/constants.dart';
import '../wallets/isar/providers/wallet_info_provider.dart';
2023-06-08 16:59:44 +00:00
class CoinCard extends ConsumerWidget {
const CoinCard({
super.key,
required this.walletId,
required this.width,
required this.height,
required this.isFavorite,
2023-06-08 16:59:44 +00:00
});
final String walletId;
final double width;
final double height;
final bool isFavorite;
2023-06-08 16:59:44 +00:00
@override
Widget build(BuildContext context, WidgetRef ref) {
2023-11-08 21:40:12 +00:00
final coin = ref.watch(pWalletCoin(walletId));
2023-06-08 16:59:44 +00:00
final bool hasCardImageBg = (isFavorite)
? ref.watch(coinCardFavoritesProvider(coin)) != null
: ref.watch(coinCardProvider(coin)) != null;
2023-06-08 16:59:44 +00:00
return Stack(
children: [
if (hasCardImageBg)
Container(
width: width,
height: height,
decoration: BoxDecoration(
2023-06-15 23:47:58 +00:00
borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius,
),
2023-06-08 16:59:44 +00:00
image: DecorationImage(
2023-06-15 23:47:58 +00:00
fit: BoxFit.cover,
2023-06-08 16:59:44 +00:00
image: FileImage(
File(
(isFavorite)
? ref.watch(coinCardFavoritesProvider(coin))!
: ref.watch(coinCardProvider(coin))!,
2023-06-08 16:59:44 +00:00
),
),
),
),
),
if (!hasCardImageBg)
Container(
width: width,
height: height,
decoration: BoxDecoration(
2024-05-14 16:26:03 +00:00
color: ref.watch(pCoinColor(coin)),
2023-06-08 16:59:44 +00:00
borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius,
),
),
),
if (!hasCardImageBg)
Column(
children: [
const Spacer(),
SizedBox(
height: width * 0.3,
child: Row(
children: [
const Spacer(
flex: 9,
),
SvgPicture.asset(
Assets.svg.ellipse2,
height: width * 0.3,
),
// ),
const Spacer(
flex: 2,
),
],
),
),
],
),
if (!hasCardImageBg)
Row(
children: [
const Spacer(
flex: 5,
),
SizedBox(
width: width * 0.45,
child: Column(
children: [
SvgPicture.asset(
Assets.svg.ellipse1,
width: width * 0.45,
),
const Spacer(),
],
),
),
const Spacer(
flex: 1,
),
],
),
],
);
}
}