Skip to content

Commit

Permalink
render proper price icon
Browse files Browse the repository at this point in the history
check for image format
publish
  • Loading branch information
d-reader-luka committed Oct 24, 2024
1 parent 57fcc05 commit 332dfda
Show file tree
Hide file tree
Showing 15 changed files with 69 additions and 42 deletions.
1 change: 1 addition & 0 deletions lib/constants/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ const String failedToSignTransactionsMessage = 'Failed to sign transactions';

const String dAuthCouponName = 'dAuth';
const String solAddress = 'So11111111111111111111111111111111111111112';
const String svgExtension = '.svg';
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'package:d_reader_flutter/shared/utils/screen_navigation.dart';
import 'package:d_reader_flutter/shared/utils/show_snackbar.dart';
import 'package:d_reader_flutter/shared/widgets/buttons/custom_text_button.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';

Expand Down Expand Up @@ -115,6 +116,7 @@ class _MintButton extends ConsumerWidget {
activeSplToken,
),
);
final selectedSplToken = ref.watch(activeSplToken);
return CustomTextButton(
size: const Size(150, 50),
isLoading: isLoading,
Expand Down Expand Up @@ -144,13 +146,20 @@ class _MintButton extends ConsumerWidget {
const SizedBox(
width: 4,
),
CachedNetworkImage(
imageUrl: ref.read(activeSplToken)?.icon ??
ref.read(activeSplToken)?.symbol ??
'',
width: 16,
height: 16,
),
selectedSplToken != null &&
selectedSplToken.icon.endsWith(svgExtension)
? SvgPicture.network(
selectedSplToken.icon,
width: 12,
height: 12,
)
: CachedNetworkImage(
imageUrl: ref.read(activeSplToken)?.icon ??
ref.read(activeSplToken)?.symbol ??
'',
width: 16,
height: 16,
),
const SizedBox(
width: 4,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:d_reader_flutter/features/candy_machine/presentations/providers/
import 'package:d_reader_flutter/shared/utils/formatter.dart';
import 'package:d_reader_flutter/shared/widgets/buttons/custom_text_button.dart';
import 'package:d_reader_flutter/shared/widgets/unsorted/mint_price_widget.dart';
import 'package:d_reader_flutter/shared/widgets/unsorted/solana_price.dart';
import 'package:d_reader_flutter/shared/widgets/unsorted/price_widget.dart';
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';

Expand Down Expand Up @@ -59,7 +59,7 @@ class TransactionButton extends ConsumerWidget {
? const MintPriceWidget(
priceColor: Colors.black,
)
: SolanaPrice(
: PriceWidget(
price: price != null && price! > 0
? Formatter.formatPriceByCurrency(
mintPrice: price!,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:d_reader_flutter/constants/constants.dart';
import 'package:d_reader_flutter/features/candy_machine/domain/models/candy_machine_coupon.dart';
import 'package:d_reader_flutter/features/candy_machine/presentations/notifiers/candy_machine_notifier.dart';
import 'package:d_reader_flutter/features/candy_machine/presentations/providers/candy_machine_providers.dart';
import 'package:d_reader_flutter/features/settings/domain/models/spl_token.dart';
import 'package:d_reader_flutter/shared/theme/app_colors.dart';
import 'package:d_reader_flutter/shared/utils/formatter.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';

class CouponWithCurrencyRow extends ConsumerWidget {
Expand Down Expand Up @@ -54,11 +56,17 @@ class CouponWithCurrencyRow extends ConsumerWidget {
children: [
Row(
children: [
CachedNetworkImage(
imageUrl: splToken.icon,
width: 16,
height: 16,
),
splToken.icon.endsWith(svgExtension)
? SvgPicture.network(
splToken.icon,
height: 14,
width: 14,
)
: CachedNetworkImage(
imageUrl: splToken.icon,
width: 16,
height: 16,
),
const SizedBox(
width: 8,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:d_reader_flutter/features/settings/presentation/providers/spl_to
import 'package:d_reader_flutter/shared/theme/app_colors.dart';
import 'package:d_reader_flutter/shared/utils/formatter.dart';
import 'package:d_reader_flutter/shared/widgets/unsorted/mint_price_widget.dart';
import 'package:d_reader_flutter/shared/widgets/unsorted/solana_price.dart';
import 'package:d_reader_flutter/shared/widgets/unsorted/price_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_svg/flutter_svg.dart';
Expand Down Expand Up @@ -144,7 +144,7 @@ class _MintInfoContainerState extends ConsumerState<MintInfoContainer>
padding: const EdgeInsets.only(top: 16),
child: _HeadingRow(
candyMachineCoupon: selectedCandyMachineCoupon,
suffix: SolanaPrice(
suffix: PriceWidget(
price: mintPrice > 0
? Formatter.formatPriceByCurrency(
mintPrice: mintPrice,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:d_reader_flutter/shared/utils/formatter.dart';
import 'package:d_reader_flutter/shared/utils/screen_navigation.dart';
import 'package:d_reader_flutter/shared/widgets/image_widgets/cached_image_bg_placeholder.dart';
import 'package:d_reader_flutter/shared/widgets/icons/hot_icon.dart';
import 'package:d_reader_flutter/shared/widgets/unsorted/solana_price.dart';
import 'package:d_reader_flutter/shared/widgets/unsorted/price_widget.dart';
import 'package:flutter/material.dart';

class ComicIssueCard extends StatelessWidget {
Expand Down Expand Up @@ -118,7 +118,7 @@ class _IssueInfoContainer extends StatelessWidget {
'EP ${issue.number}/${issue.stats?.totalIssuesCount}',
style: textTheme.bodySmall,
),
SolanaPrice(
PriceWidget(
price: Formatter.formatLamportPrice(issue.stats?.price),
mainAxisAlignment: MainAxisAlignment.end,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'package:d_reader_flutter/shared/widgets/unsorted/date_widget.dart';
import 'package:d_reader_flutter/shared/widgets/icons/favorite_icon_count.dart';
import 'package:d_reader_flutter/shared/widgets/icons/rating_icon.dart';
import 'package:d_reader_flutter/shared/widgets/icons/viewed_icon_count.dart';
import 'package:d_reader_flutter/shared/widgets/unsorted/solana_price.dart';
import 'package:d_reader_flutter/shared/widgets/unsorted/price_widget.dart';
import 'package:flutter/material.dart';

class ComicIssueCardLarge extends StatelessWidget {
Expand Down Expand Up @@ -129,7 +129,7 @@ class ComicIssueCardLarge extends StatelessWidget {
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SolanaPrice(
PriceWidget(
price: issue.stats?.price != null
? Formatter.formatPriceWithSignificant(
issue.stats!.price!,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:d_reader_flutter/shared/utils/formatter.dart';
import 'package:d_reader_flutter/features/digital_asset/presentation/utils/utils.dart';
import 'package:d_reader_flutter/shared/widgets/image_widgets/cached_image_bg_placeholder.dart';
import 'package:d_reader_flutter/shared/widgets/unsorted/rarity.dart';
import 'package:d_reader_flutter/shared/widgets/unsorted/solana_price.dart';
import 'package:d_reader_flutter/shared/widgets/unsorted/price_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
Expand Down Expand Up @@ -123,7 +123,7 @@ class ListingItem extends ConsumerWidget {
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
SolanaPrice(
PriceWidget(
price: listing.price / lamportsPerSol,
priceDecimals: 4,
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:d_reader_flutter/shared/theme/app_colors.dart';
import 'package:d_reader_flutter/shared/widgets/buttons/custom_text_button.dart';
import 'package:d_reader_flutter/shared/widgets/image_widgets/cached_image_bg_placeholder.dart';
import 'package:d_reader_flutter/shared/widgets/unsorted/solana_price.dart';
import 'package:d_reader_flutter/shared/widgets/unsorted/price_widget.dart';
import 'package:flutter/material.dart';

const String imageUrl =
Expand Down Expand Up @@ -95,7 +95,7 @@ class CollectibleCard extends StatelessWidget {
style: textTheme.labelMedium
?.copyWith(fontSize: 11),
),
const SolanaPrice(
const PriceWidget(
price: 0.965,
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'package:d_reader_flutter/shared/widgets/unsorted/date_widget.dart';
import 'package:d_reader_flutter/shared/widgets/unsorted/mature_audience.dart';
import 'package:d_reader_flutter/shared/widgets/icons/favorite_icon_count.dart';
import 'package:d_reader_flutter/shared/widgets/icons/rating_icon.dart';
import 'package:d_reader_flutter/shared/widgets/unsorted/solana_price.dart';
import 'package:d_reader_flutter/shared/widgets/unsorted/price_widget.dart';
import 'package:d_reader_flutter/features/discover/genre/presentation/widgets/genre_tags_default.dart';
import 'package:flutter/material.dart';

Expand Down Expand Up @@ -110,7 +110,7 @@ class DiscoverComicIssueCard extends StatelessWidget {
),
Expanded(
flex: 1,
child: SolanaPrice(
child: PriceWidget(
mainAxisAlignment: MainAxisAlignment.end,
price:
Formatter.formatLamportPrice(issue.stats?.price),
Expand Down
19 changes: 14 additions & 5 deletions lib/shared/widgets/unsorted/mint_price_widget.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:d_reader_flutter/constants/constants.dart';
import 'package:d_reader_flutter/features/candy_machine/presentations/notifiers/candy_machine_notifier.dart';
import 'package:d_reader_flutter/features/candy_machine/presentations/providers/candy_machine_providers.dart';
import 'package:d_reader_flutter/shared/utils/formatter.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';

class MintPriceWidget extends ConsumerWidget {
Expand All @@ -14,13 +16,20 @@ class MintPriceWidget extends ConsumerWidget {

@override
Widget build(BuildContext context, WidgetRef ref) {
final selectedSplToken = ref.watch(activeSplToken);
return Row(
children: [
CachedNetworkImage(
imageUrl: ref.watch(activeSplToken)?.icon ?? '',
height: 18,
width: 18,
),
selectedSplToken != null && selectedSplToken.icon.endsWith(svgExtension)
? SvgPicture.network(
selectedSplToken.icon,
height: 14,
width: 14,
)
: CachedNetworkImage(
imageUrl: ref.watch(activeSplToken)?.icon ?? '',
height: 18,
width: 18,
),
const SizedBox(
width: 4,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import 'package:d_reader_flutter/config/config.dart';
import 'package:d_reader_flutter/shared/utils/formatter.dart';
import 'package:flutter/material.dart';

class SolanaPrice extends StatelessWidget {
class PriceWidget extends StatelessWidget {
final dynamic price;
final MainAxisAlignment mainAxisAlignment;
final TextDirection? textDirection;
final Color? textColor;
final int priceDecimals;
const SolanaPrice({
const PriceWidget({
super.key,
this.price,
this.mainAxisAlignment = MainAxisAlignment.start,
Expand Down
4 changes: 2 additions & 2 deletions publishing/.asset-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
},
"./dReader.apk": {
"path": "./dReader.apk",
"sha256": "GkcAkSlWBHx3nu03nmiH+fkXKExggAxXL0UHKny0PRM=",
"uri": "https://s3.us-east-1.amazonaws.com/d-reader-main-mainnet/lcU1kLPzAajQ3Tdt8CAe"
"sha256": "7bLOX0TDap1EkdjctrMmDnEz7ehgGc1615bTmBH19+0=",
"uri": "https://s3.us-east-1.amazonaws.com/d-reader-main-mainnet/jYdtFyEBrJtfgWjGjISY"
},
"./screenshots/1.png": {
"path": "./screenshots/1.png",
Expand Down
12 changes: 6 additions & 6 deletions publishing/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ app:
- purpose: icon
uri: ./512x512_rounded.png
release:
address: GFRybHsTyn4wsQXiLSz5Fe7CTjncZ6sqfCypg6AXSmQX
address: AdSaX7WDM9DdA29BFzcRiFDGy2ywudSoHWLD7Pb5mFyd
media:
- purpose: icon
uri: ./512x512_rounded.png
Expand All @@ -41,14 +41,14 @@ release:
name: dReader
short_description: Digital comic book store
long_description: Platform for discovering, trading, collecting, and reading digital graphic novels
new_in_version: New mint flow
new_in_version: Improve mint ui
saga_features: Exclusive early access, free/discounted collectible comics
solana_mobile_dapp_publisher_portal:
google_store_package: io.app.dreader
testing_instructions: Run the app
lastSubmittedVersionOnChain:
address: GFRybHsTyn4wsQXiLSz5Fe7CTjncZ6sqfCypg6AXSmQX
version_code: 2052
apk_hash: GkcAkSlWBHx3nu03nmiH+fkXKExggAxXL0UHKny0PRM=
address: AdSaX7WDM9DdA29BFzcRiFDGy2ywudSoHWLD7Pb5mFyd
version_code: 2053
apk_hash: 7bLOX0TDap1EkdjctrMmDnEz7ehgGc1615bTmBH19+0=
lastUpdatedVersionOnStore:
address: GFRybHsTyn4wsQXiLSz5Fe7CTjncZ6sqfCypg6AXSmQX
address: AdSaX7WDM9DdA29BFzcRiFDGy2ywudSoHWLD7Pb5mFyd
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: dReader Flutter app.

publish_to: 'none'

version: 1.4.4+84 # # dappStore: 1.4.2+52 (next release: 1.4.3+53) google play: 1.4.4+84 (next release: 1.4.5+85)
version: 1.4.5+85 # # dappStore: 1.4.3+53 (next release: 1.4.4+54) google play: 1.4.5+85 (next release: 1.4.6+86)

environment:
sdk: '>=3.0.0 <4.0.0'
Expand Down

0 comments on commit 332dfda

Please sign in to comment.