stack_wallet/lib/widgets/coin_card.dart
2023-11-08 15:40:12 -06:00

129 lines
3.5 KiB
Dart

/*
* 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 'package:stackwallet/themes/coin_card_provider.dart';
import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
class CoinCard extends ConsumerWidget {
const CoinCard({
super.key,
required this.walletId,
required this.width,
required this.height,
required this.isFavorite,
});
final String walletId;
final double width;
final double height;
final bool isFavorite;
@override
Widget build(BuildContext context, WidgetRef ref) {
final coin = ref.watch(pWalletCoin(walletId));
final bool hasCardImageBg = (isFavorite)
? ref.watch(coinCardFavoritesProvider(coin)) != null
: ref.watch(coinCardProvider(coin)) != null;
return Stack(
children: [
if (hasCardImageBg)
Container(
width: width,
height: height,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius,
),
image: DecorationImage(
fit: BoxFit.cover,
image: FileImage(
File(
(isFavorite)
? ref.watch(coinCardFavoritesProvider(coin))!
: ref.watch(coinCardProvider(coin))!,
),
),
),
),
),
if (!hasCardImageBg)
Container(
width: width,
height: height,
decoration: BoxDecoration(
color: Theme.of(context)
.extension<StackColors>()!
.colorForCoin(coin),
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,
),
],
),
],
);
}
}