stack_wallet/lib/pages/wallet_view/sub_widgets/wallet_summary.dart

159 lines
4.8 KiB
Dart
Raw Normal View History

2023-05-26 21:21:16 +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
*
*/
2023-06-07 20:34:27 +00:00
// import 'dart:html';
import 'dart:io';
2022-08-26 08:11:35 +00:00
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:stackwallet/pages/wallet_view/sub_widgets/wallet_summary_info.dart';
import 'package:stackwallet/services/coins/manager.dart';
import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart';
import 'package:stackwallet/themes/stack_colors.dart';
2022-08-26 08:11:35 +00:00
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart';
2023-06-07 20:34:27 +00:00
import '../../../themes/coin_card_provider.dart';
import '../../../utilities/enums/coin_enum.dart';
class WalletSummary extends ConsumerWidget {
2022-08-26 08:11:35 +00:00
const WalletSummary({
Key? key,
required this.walletId,
required this.managerProvider,
required this.initialSyncStatus,
this.aspectRatio = 2.0,
this.minHeight = 100.0,
this.minWidth = 200.0,
this.maxHeight = 250.0,
this.maxWidth = 400.0,
}) : super(key: key);
final String walletId;
final ChangeNotifierProvider<Manager> managerProvider;
final WalletSyncStatus initialSyncStatus;
final double aspectRatio;
final double minHeight;
final double minWidth;
final double maxHeight;
final double maxWidth;
@override
2023-06-07 20:34:27 +00:00
Widget build(BuildContext context, WidgetRef ref) {
final bool hasCardImageBg =
ref.watch(managerProvider.select((value) => value.coin)) != null;
final Coin coin = ref.watch(managerProvider.select((value) => value.coin));
2022-08-26 08:11:35 +00:00
return AspectRatio(
aspectRatio: aspectRatio,
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: minHeight,
minWidth: minWidth,
maxHeight: maxHeight,
maxWidth: minWidth,
),
child: Stack(
children: [
2023-06-07 20:34:27 +00:00
if (hasCardImageBg)
SvgPicture.file(
File(
2023-06-07 20:57:15 +00:00
ref.watch(coinCardProvider(coin))!,
2023-06-07 20:34:27 +00:00
),
height: 24,
width: 24,
),
if (!hasCardImageBg)
Consumer(
builder: (_, ref, __) {
return Container(
decoration: BoxDecoration(
color: Theme.of(context)
.extension<StackColors>()!
.colorForCoin(ref.watch(
managerProvider.select((value) => value.coin))),
borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius,
),
2022-08-26 08:11:35 +00:00
),
2023-06-07 20:34:27 +00:00
);
},
),
if (!hasCardImageBg)
Positioned.fill(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Spacer(
flex: 5,
2022-08-26 08:11:35 +00:00
),
2023-06-07 20:34:27 +00:00
Expanded(
flex: 6,
child: SvgPicture.asset(
Assets.svg.ellipse1,
// fit: BoxFit.fitWidth,
// clipBehavior: Clip.none,
),
),
const SizedBox(
width: 25,
),
],
),
2022-08-26 08:11:35 +00:00
),
// Positioned.fill(
// child:
// Column(
// mainAxisAlignment: MainAxisAlignment.end,
// children: [
2023-06-07 20:34:27 +00:00
if (!hasCardImageBg)
Align(
alignment: Alignment.bottomCenter,
child: Row(
children: [
const Spacer(
flex: 1,
2022-08-26 08:11:35 +00:00
),
2023-06-07 20:34:27 +00:00
Expanded(
flex: 3,
child: SvgPicture.asset(
Assets.svg.ellipse2,
// fit: BoxFit.f,
// clipBehavior: Clip.none,
),
),
const SizedBox(
width: 13,
),
],
),
2022-08-26 08:11:35 +00:00
),
// ],
// ),
// ),
Positioned.fill(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: WalletSummaryInfo(
walletId: walletId,
initialSyncStatus: initialSyncStatus,
),
),
),
],
),
),
);
}
}