From ffd291427aaa78103148a40cfcefb32815ea6f8a Mon Sep 17 00:00:00 2001 From: Thiago Carvalho <32248947+thiagocarvalhodev@users.noreply.github.com> Date: Fri, 12 Jul 2024 14:37:11 -0300 Subject: [PATCH 01/11] account menu --- lib/components/profile_card.dart | 278 +++++++++++++----- lib/components/side_bar.dart | 179 ++++++++--- lib/components/truncated_address.dart | 20 +- lib/misc/resources.dart | 1 + .../components/turbo_balance_widget.dart | 25 +- .../lib/src/styles/fonts/typography.dart | 2 + 6 files changed, 362 insertions(+), 143 deletions(-) diff --git a/lib/components/profile_card.dart b/lib/components/profile_card.dart index a5cfb42c0d..f05af1d767 100644 --- a/lib/components/profile_card.dart +++ b/lib/components/profile_card.dart @@ -1,7 +1,11 @@ import 'package:ardrive/authentication/ardrive_auth.dart'; import 'package:ardrive/blocs/profile/profile_cubit.dart'; import 'package:ardrive/components/details_panel.dart'; +import 'package:ardrive/components/side_bar.dart'; import 'package:ardrive/components/truncated_address.dart'; +import 'package:ardrive/gift/bloc/redeem_gift_bloc.dart'; +import 'package:ardrive/gift/redeem_gift_modal.dart'; +import 'package:ardrive/misc/resources.dart'; import 'package:ardrive/pages/drive_detail/components/hover_widget.dart'; import 'package:ardrive/services/arconnect/arconnect_wallet.dart'; import 'package:ardrive/turbo/services/payment_service.dart'; @@ -9,8 +13,10 @@ import 'package:ardrive/turbo/topup/components/turbo_balance_widget.dart'; import 'package:ardrive/turbo/utils/utils.dart'; import 'package:ardrive/user/download_wallet/download_wallet_modal.dart'; import 'package:ardrive/utils/app_localizations_wrapper.dart'; +import 'package:ardrive/utils/open_url.dart'; import 'package:ardrive/utils/open_url_utils.dart'; import 'package:ardrive/utils/plausible_event_tracker/plausible_event_tracker.dart'; +import 'package:ardrive/utils/show_general_dialog.dart'; import 'package:ardrive/utils/truncate_string.dart'; import 'package:ardrive_ui/ardrive_ui.dart'; import 'package:flutter/material.dart'; @@ -102,6 +108,7 @@ class _ProfileCardState extends State { ProfileLoggedIn state, { required bool isMobile, }) { + final typography = ArDriveTypographyNew.of(context); return ArDriveCard( contentPadding: const EdgeInsets.all(0), width: 281, @@ -112,76 +119,154 @@ class _ProfileCardState extends State { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ - if (isMobile) - Row( + Container( + color: ArDriveTheme.of(context).themeData.colorTokens.containerL0, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Padding( - padding: const EdgeInsets.all(16), - child: ArDriveIconButton( - onPressed: () { - setState(() { - _showProfileCard = false; - }); - }, - icon: ArDriveIcons.x( - size: 24, - ), + if (isMobile) + Row( + children: [ + Padding( + padding: const EdgeInsets.all(16), + child: ArDriveIconButton( + onPressed: () { + setState(() { + _showProfileCard = false; + }); + }, + icon: ArDriveIcons.x( + size: 24, + ), + ), + ), + ], ), + const SizedBox(height: 8), + _buildWalletAddressRow(context, state), + if (state.wallet is! ArConnectWallet) ...[ + const SizedBox(height: 8), + ], + const Divider( + height: 21, + indent: 16, + endIndent: 16, ), + _buildBalanceRow(context, state), + if (context.read().useTurboPayment) ...[ + Padding( + padding: const EdgeInsets.only(top: 20.0), + child: TurboBalance( + paymentService: context.read(), + wallet: state.wallet, + onTapAddButton: () { + setState(() { + _showProfileCard = false; + }); + }, + ), + ), + ], + const SizedBox(height: 20), ], ), - const SizedBox(height: 8), - _buildWalletAddressRow(context, state), - if (state.wallet is! ArConnectWallet) ...[ - const SizedBox(height: 8), - _buildDownloadWalletRow(context), - const SizedBox(height: 8), - ], - const Divider( - height: 21, - indent: 16, - endIndent: 16, ), - _buildBalanceRow(context, state), - if (context.read().useTurboPayment) ...[ - Padding( - padding: const EdgeInsets.only(top: 20.0), - child: TurboBalance( - paymentService: context.read(), - wallet: state.wallet, - onTapAddButton: () { - setState(() { - _showProfileCard = false; - }); - }, + // Padding( + // padding: const EdgeInsets.only(top: 20.0, left: 16, right: 16), + // child: ArDriveClickArea( + // child: GestureDetector( + // onTap: () { + // openFeedbackSurveyUrl(); + // }, + // child: Text( + // appLocalizationsOf(context).leaveFeedback, + // style: ArDriveTypography.body.captionRegular().copyWith( + // fontWeight: FontWeight.w600, + // fontSize: 18, + // color: ArDriveTheme.of(context) + // .themeData + // .colors + // .themeFgMuted, + // decoration: TextDecoration.underline, + // ), + // ), + // ), + // ), + // ), + ArDriveAccordion( + backgroundColor: Colors.transparent, + children: [ + ArDriveAccordionItem( + Text( + 'Gift', + style: typography.paragraphNormal( + fontWeight: ArFontWeight.semiBold, + ), + ), + [ + _ProfileMenuAccordionItem( + text: 'Gift', + onTap: () { + openUrl(url: Resources.sendGiftLink); + }, + ), + _ProfileMenuAccordionItem( + text: 'Reedem Gift', + onTap: () { + showArDriveDialog( + context, + content: BlocProvider( + create: (context) => RedeemGiftBloc( + paymentService: context.read(), + auth: context.read()), + child: const RedeemGiftModal(), + ), + ); + }, + ), + ], ), - ), - ], - Padding( - padding: const EdgeInsets.only(top: 20.0, left: 16, right: 16), - child: ArDriveClickArea( - child: GestureDetector( - onTap: () { - openFeedbackSurveyUrl(); - }, - child: Text( - appLocalizationsOf(context).leaveFeedback, - style: ArDriveTypography.body.captionRegular().copyWith( - fontWeight: FontWeight.w600, - fontSize: 18, - color: ArDriveTheme.of(context) - .themeData - .colors - .themeFgMuted, - decoration: TextDecoration.underline, - ), + ArDriveAccordionItem( + Text( + 'Support', + style: typography.paragraphNormal( + fontWeight: ArFontWeight.semiBold, + ), ), + [ + _ProfileMenuAccordionItem( + text: 'Docs', + onTap: () { + openUrl(url: Resources.docsLink); + }, + ), + _ProfileMenuAccordionItem( + text: 'Help', + onTap: () { + openUrl(url: Resources.helpLink); + }, + ), + _ProfileMenuAccordionItem( + text: 'Leave Feedback', + onTap: () async { + openFeedbackSurveyUrl(); + }, + ), + _ProfileMenuAccordionItem( + text: 'Share Logs', + onTap: () { + shareLogs( + context: context, + ); + }, + ), + ], ), - ), + ], ), - Padding( - padding: const EdgeInsets.only(top: 20.0), - child: _buildLogoutButton(context), + const Padding( + padding: EdgeInsets.only(top: 20.0), + child: _LogoutButton(), ), if (isMobile) Expanded( @@ -196,6 +281,7 @@ class _ProfileCardState extends State { Widget _buildWalletAddressRow(BuildContext context, ProfileLoggedIn state) { final walletAddress = state.walletAddress; + final colorTokens = ArDriveTheme.of(context).themeData.colorTokens; return Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0), @@ -204,15 +290,19 @@ class _ProfileCardState extends State { children: [ const SizedBox(height: 8), Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ if (walletAddress.isNotEmpty) TruncatedAddress( walletAddress: walletAddress, fontSize: 18, ), + const Spacer(), + ArDriveIconButton( + icon: ArDriveIcons.arrowDownload( + color: colorTokens.textHigh, size: 21), + ), CopyButton( - size: 24, + size: 21, text: walletAddress, showCopyText: false, ), @@ -260,6 +350,8 @@ class _ProfileCardState extends State { Widget _buildBalanceRow(BuildContext context, ProfileLoggedIn state) { final walletBalance = convertWinstonToLiteralString(state.walletBalance); + final typography = ArDriveTypographyNew.of(context); + final colorTokens = ArDriveTheme.of(context).themeData.colorTokens; return Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0), @@ -269,28 +361,23 @@ class _ProfileCardState extends State { children: [ Text( appLocalizationsOf(context).arBalance, - style: ArDriveTypography.body.buttonLargeBold().copyWith( - fontWeight: FontWeight.w800, - fontSize: 18, - ), + style: typography.paragraphNormal( + fontWeight: ArFontWeight.semiBold, + color: colorTokens.textHigh, + ), ), Text( '$walletBalance AR', - style: ArDriveTypography.body.captionRegular().copyWith( - fontWeight: FontWeight.w600, - fontSize: 18, - color: ArDriveTheme.of(context).themeData.colors.themeFgMuted, - ), + style: typography.paragraphNormal( + color: colorTokens.textLow, + fontWeight: ArFontWeight.semiBold, + ), ), ], ), ); } - Widget _buildLogoutButton(BuildContext context) { - return const _LogoutButton(); - } - Widget _buildProfileCardHeader(BuildContext context, String walletAddress) { final typography = ArDriveTypographyNew.of(context); return ArDriveButtonNew( @@ -319,6 +406,8 @@ class __LogoutButtonState extends State<_LogoutButton> { @override Widget build(BuildContext context) { + final colorTokens = ArDriveTheme.of(context).themeData.colorTokens; + final typography = ArDriveTypographyNew.of(context); return HoverDetector( onExit: () { setState(() { @@ -353,10 +442,13 @@ class __LogoutButtonState extends State<_LogoutButton> { children: [ Text( appLocalizationsOf(context).logOut, - style: ArDriveTypography.body - .captionBold() - .copyWith(fontSize: 15), + style: typography.paragraphNormal( + color: colorTokens.textHigh, + fontWeight: ArFontWeight.semiBold, + ), ), + const Spacer(), + ArDriveIcons.logout(size: 21), ], ), ), @@ -365,3 +457,33 @@ class __LogoutButtonState extends State<_LogoutButton> { ); } } + +class _ProfileMenuAccordionItem extends StatelessWidget { + const _ProfileMenuAccordionItem({ + required this.text, + required this.onTap, + }); + + final String text; + final Function() onTap; + + @override + Widget build(BuildContext context) { + final typography = ArDriveTypographyNew.of(context); + + return ArDriveClickArea( + child: GestureDetector( + onTap: onTap, + child: Padding( + padding: const EdgeInsets.only(left: 30.0, right: 15), + child: Text( + text, + style: typography.paragraphNormal( + fontWeight: ArFontWeight.semiBold, + ), + ), + ), + ), + ); + } +} diff --git a/lib/components/side_bar.dart b/lib/components/side_bar.dart index fc04e76ca9..fa1eff1040 100644 --- a/lib/components/side_bar.dart +++ b/lib/components/side_bar.dart @@ -1,3 +1,5 @@ +// ignore_for_file: use_build_context_synchronously + import 'package:ardrive/blocs/drive_detail/drive_detail_cubit.dart'; import 'package:ardrive/blocs/drives/drives_cubit.dart'; import 'package:ardrive/blocs/profile/profile_cubit.dart'; @@ -138,27 +140,27 @@ class _AppSideBarState extends State { height: 16, ), ], - const Padding( - padding: EdgeInsets.only(left: 16.0), - child: HelpButton(), - ), - const SizedBox( - height: 16, - ), - Padding( - padding: const EdgeInsets.only(left: 16.0), - child: _exportLogsButton(), - ), - const SizedBox( - height: 4, - ), - const Padding( - padding: EdgeInsets.only(left: 16.0), - child: ThemeSwitcher(), - ), - const SizedBox( - height: 4, - ), + // const Padding( + // padding: EdgeInsets.only(left: 16.0), + // child: HelpButton(), + // ), + // const SizedBox( + // height: 16, + // ), + // Padding( + // padding: const EdgeInsets.only(left: 16.0), + // child: _exportLogsButton(), + // ), + // const SizedBox( + // height: 4, + // ), + // const Padding( + // padding: EdgeInsets.only(left: 16.0), + // child: ThemeSwitcher(), + // ), + // const SizedBox( + // height: 4, + // ), const Padding( padding: EdgeInsets.only(left: 20.0), child: AppVersionWidget(), @@ -387,20 +389,20 @@ class _AppSideBarState extends State { child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - const Align( - alignment: Alignment.centerLeft, - child: HelpButton(), - ), - const SizedBox( - height: 16, - ), - Align( - alignment: Alignment.centerLeft, - child: _exportLogsButton(), - ), - const SizedBox( - height: 8, - ), + // const Align( + // alignment: Alignment.centerLeft, + // child: HelpButton(), + // ), + // const SizedBox( + // height: 16, + // ), + // Align( + // alignment: Alignment.centerLeft, + // child: _exportLogsButton(), + // ), + // const SizedBox( + // height: 8, + // ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, @@ -438,10 +440,10 @@ class _AppSideBarState extends State { ) : Column( children: [ - const HelpButton(), - const SizedBox( - height: 24, - ), + // const HelpButton(), + // const SizedBox( + // height: 24, + // ), ArDriveIconButton( tooltip: appLocalizationsOf(context).expandSideBar, icon: ArDriveIcons.arrowRightFilled(), @@ -756,3 +758,102 @@ class HelpButton extends StatelessWidget { ); } } + +Future shareLogs({ + required BuildContext context, +}) async { + final logExportInfo = LogExportInfo( + emailSubject: appLocalizationsOf(context).shareLogsEmailSubject, + emailBody: appLocalizationsOf(context).shareLogsEmailBody, + shareText: appLocalizationsOf(context).shareLogsNativeShareText, + shareSubject: appLocalizationsOf(context).shareLogsNativeShareSubject, + emailSupport: Resources.emailSupport, +); + final canLaunchEmail = await canLaunchUrl(Uri.parse('mailto:')); + showArDriveDialog( + context, + content: ArDriveStandardModal( + hasCloseButton: true, + title: appLocalizationsOf(context).help, + content: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + appLocalizationsOf(context).shareLogsDescription, + style: ArDriveTypography.body.buttonLargeBold(), + ), + const SizedBox( + height: 16, + ), + Text( + appLocalizationsOf(context).ourChannels, + style: ArDriveTypography.body.buttonLargeBold().copyWith( + fontWeight: FontWeight.bold, + ), + ), + ArDriveClickArea( + child: GestureDetector( + onTap: () { + openUrl( + url: Resources.discordLink, + ); + }, + child: Text( + discord, + style: ArDriveTypography.body.buttonLargeBold().copyWith( + decoration: TextDecoration.underline, + ), + ), + ), + ), + const SizedBox( + height: 4, + ), + ArDriveClickArea( + child: GestureDetector( + onTap: () { + openUrl( + url: Resources.helpCenterLink, + ); + }, + child: Text( + appLocalizationsOf(context).helpCenter, + style: ArDriveTypography.body.buttonLargeBold().copyWith( + decoration: TextDecoration.underline, + ), + ), + ), + ), + ], + ), + actions: [ + ModalAction( + action: () { + logger.exportLogs(info: logExportInfo); + }, + title: appLocalizationsOf(context).download, + ), + if (AppPlatform.isMobile && canLaunchEmail) + ModalAction( + action: () { + logger.exportLogs( + info: logExportInfo, + shareAsEmail: true, + ); + }, + title: appLocalizationsOf(context).shareLogsWithEmailText, + ), + if (AppPlatform.isMobile) + ModalAction( + action: () { + logger.exportLogs( + info: logExportInfo, + share: true, + ); + }, + title: appLocalizationsOf(context).share, + ), + ], + ), + ); +} diff --git a/lib/components/truncated_address.dart b/lib/components/truncated_address.dart index acb1e56a78..44a0b3cae7 100644 --- a/lib/components/truncated_address.dart +++ b/lib/components/truncated_address.dart @@ -19,6 +19,9 @@ class TruncatedAddress extends StatelessWidget { @override Widget build(BuildContext context) { + final typography = ArDriveTypographyNew.of(context); + final colorTokens = ArDriveTheme.of(context).themeData.colorTokens; + return MouseRegion( cursor: SystemMouseCursors.click, child: GestureDetector( @@ -28,17 +31,12 @@ class TruncatedAddress extends StatelessWidget { ); }, child: Text( - truncateString( - walletAddress, - offsetStart: offsetStart, - offsetEnd: offsetEnd, - ), - style: ArDriveTypography.body.captionRegular().copyWith( - fontWeight: FontWeight.w600, - fontSize: fontSize, - decoration: TextDecoration.underline, - ), - ), + truncateString( + walletAddress, + offsetStart: offsetStart, + offsetEnd: offsetEnd, + ), + style: typography.paragraphNormal(color: colorTokens.textLink)), ), ); } diff --git a/lib/misc/resources.dart b/lib/misc/resources.dart index 7993a55f03..617dc61d1c 100644 --- a/lib/misc/resources.dart +++ b/lib/misc/resources.dart @@ -28,6 +28,7 @@ class Resources { static const ardriveAppLimits = 'https://help.ardrive.io/hc/en-us/articles/5300389777179-ArDrive-App-'; static const priceCalculatorLink = 'https://prices.ardrive.io/'; + static const docsLink = 'https://docs.ardrive.io/'; } class Images { diff --git a/lib/turbo/topup/components/turbo_balance_widget.dart b/lib/turbo/topup/components/turbo_balance_widget.dart index 1dd342f00c..eac1b8f530 100644 --- a/lib/turbo/topup/components/turbo_balance_widget.dart +++ b/lib/turbo/topup/components/turbo_balance_widget.dart @@ -70,6 +70,8 @@ class _TurboBalanceState extends State { @override Widget build(BuildContext context) { + final typography = ArDriveTypographyNew.of(context); + final colorTokens = ArDriveTheme.of(context).themeData.colorTokens; return Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 4), child: Column( @@ -90,13 +92,10 @@ class _TurboBalanceState extends State { flex: 2, child: Text( appLocalizationsOf(context).turboAddCreditsBlurb, - style: ArDriveTypography.body.captionRegular().copyWith( - fontWeight: FontWeight.w600, - color: ArDriveTheme.of(context) - .themeData - .colors - .themeFgMuted, - ), + style: typography.paragraphNormal( + color: colorTokens.textLow, + fontWeight: ArFontWeight.semiBold, + ), ), ), Flexible( @@ -114,14 +113,10 @@ class _TurboBalanceState extends State { children: [ Text( '${convertWinstonToLiteralString(balance)} ${appLocalizationsOf(context).credits}', - style: ArDriveTypography.body.captionRegular().copyWith( - fontWeight: FontWeight.w600, - fontSize: 18, - color: ArDriveTheme.of(context) - .themeData - .colors - .themeFgMuted, - ), + style: typography.paragraphNormal( + color: colorTokens.textLow, + fontWeight: ArFontWeight.semiBold, + ), ), addButton(context), ], diff --git a/packages/ardrive_ui/lib/src/styles/fonts/typography.dart b/packages/ardrive_ui/lib/src/styles/fonts/typography.dart index e64fffdada..7d161e2be1 100644 --- a/packages/ardrive_ui/lib/src/styles/fonts/typography.dart +++ b/packages/ardrive_ui/lib/src/styles/fonts/typography.dart @@ -6,6 +6,8 @@ const String _package = 'ardrive_ui'; class ArDriveTypography { static Body body = const Body(); static Headline headline = const Headline(); + + static of(BuildContext context) {} } class Body { From 457c885ffaf6a5a55a3cab0dff6bfe00b7634c7d Mon Sep 17 00:00:00 2001 From: Thiago Carvalho <32248947+thiagocarvalhodev@users.noreply.github.com> Date: Thu, 18 Jul 2024 11:29:04 -0300 Subject: [PATCH 02/11] feat(account menu) - implement new menu with new icons --- lib/app_shell.dart | 3 +- lib/components/app_top_bar.dart | 6 +- lib/components/details_panel.dart | 8 +- lib/components/icon_theme_switcher.dart | 6 +- lib/components/profile_card.dart | 69 ++++------ lib/components/side_bar.dart | 120 +----------------- lib/components/topbar/help_button.dart | 66 ++++++++++ lib/components/truncated_address.dart | 16 ++- lib/gift/reedem_button.dart | 61 --------- .../components/drive_explorer_item_tile.dart | 12 +- lib/pages/drive_detail/drive_detail_page.dart | 10 +- lib/pages/no_drives/no_drives_page.dart | 7 +- lib/pages/shared_file/shared_file_page.dart | 2 +- lib/search/search_modal.dart | 2 +- lib/utils/open_urls.dart | 10 ++ .../ardrive_ui/assets/fonts/ArDriveIcons.ttf | Bin 20472 -> 21692 bytes packages/ardrive_ui/assets/fonts/config.json | 56 ++++++++ .../styles/icons/ar_drive_icons_icons.dart | 9 +- .../lib/src/styles/icons/icons.dart | 21 +-- .../ardrive_ui/storybook/lib/src/icons.dart | 3 +- 20 files changed, 211 insertions(+), 276 deletions(-) create mode 100644 lib/components/topbar/help_button.dart delete mode 100644 lib/gift/reedem_button.dart create mode 100644 lib/utils/open_urls.dart diff --git a/lib/app_shell.dart b/lib/app_shell.dart index 5a0ad88e1e..045386e8b3 100644 --- a/lib/app_shell.dart +++ b/lib/app_shell.dart @@ -3,7 +3,6 @@ import 'package:ardrive/blocs/prompt_to_snapshot/prompt_to_snapshot_event.dart'; import 'package:ardrive/components/profile_card.dart'; import 'package:ardrive/components/side_bar.dart'; import 'package:ardrive/drive_explorer/multi_thumbnail_creation/bloc/multi_thumbnail_creation_bloc.dart'; -import 'package:ardrive/gift/reedem_button.dart'; import 'package:ardrive/misc/misc.dart'; import 'package:ardrive/pages/drive_detail/components/hover_widget.dart'; import 'package:ardrive/shared/blocs/banner/app_banner_bloc.dart'; @@ -363,7 +362,7 @@ class MobileAppBar extends StatelessWidget implements PreferredSizeWidget { width: 24, ), if (AppPlatform.isMobileWeb()) ...[ - const RedeemButton(), + const HelpButton(), const SizedBox( width: 24, ), diff --git a/lib/components/app_top_bar.dart b/lib/components/app_top_bar.dart index 35feb1cb55..e4468d2051 100644 --- a/lib/components/app_top_bar.dart +++ b/lib/components/app_top_bar.dart @@ -1,6 +1,6 @@ import 'package:ardrive/blocs/drive_detail/drive_detail_cubit.dart'; import 'package:ardrive/components/profile_card.dart'; -import 'package:ardrive/gift/reedem_button.dart'; +import 'package:ardrive/components/topbar/help_button.dart'; import 'package:ardrive/pages/drive_detail/components/dropdown_item.dart'; import 'package:ardrive/pages/drive_detail/components/hover_widget.dart'; import 'package:ardrive/search/search_modal.dart'; @@ -51,8 +51,8 @@ class AppTopBar extends StatelessWidget { ], const Spacer(), const SyncButton(), - const SizedBox(width: 24), - const RedeemButton(), + const SizedBox(width: 8), + const HelpButtonTopBar(), const SizedBox(width: 24), const ProfileCard(), ], diff --git a/lib/components/details_panel.dart b/lib/components/details_panel.dart index af31b79bb6..85864707aa 100644 --- a/lib/components/details_panel.dart +++ b/lib/components/details_panel.dart @@ -379,7 +379,7 @@ class _DetailsPanelState extends State { children: [ Expanded( child: ArDriveButton( - icon: ArDriveIcons.download2( + icon: ArDriveIcons.download( color: Colors.white), onPressed: () { final file = ARFSFactory() @@ -484,7 +484,7 @@ class _DetailsPanelState extends State { ), const SizedBox(height: 24), ArDriveButton( - icon: ArDriveIcons.download2(color: Colors.white), + icon: ArDriveIcons.download(color: Colors.white), onPressed: () { final file = ARFSFactory().getARFSFileFromFileRevision( widget.revisions!.last, @@ -1249,7 +1249,7 @@ class _DownloadOrPreview extends StatelessWidget { ); }, tooltip: appLocalizationsOf(context).download, - icon: ArDriveIcons.download2(size: 20), + icon: ArDriveIcons.download(size: 20), ); } } @@ -1328,7 +1328,7 @@ class DetailsPanelToolbar extends StatelessWidget { ), _buildActionIcon( tooltip: appLocalizationsOf(context).download, - icon: ArDriveIcons.download2(size: defaultIconSize), + icon: ArDriveIcons.download(size: defaultIconSize), onTap: () { if (item is FileDataTableItem) { promptToDownloadProfileFile( diff --git a/lib/components/icon_theme_switcher.dart b/lib/components/icon_theme_switcher.dart index 834228a3e2..60743ab44d 100644 --- a/lib/components/icon_theme_switcher.dart +++ b/lib/components/icon_theme_switcher.dart @@ -3,7 +3,9 @@ import 'package:ardrive_ui/ardrive_ui.dart'; import 'package:flutter/material.dart'; class IconThemeSwitcher extends StatelessWidget { - const IconThemeSwitcher({super.key}); + const IconThemeSwitcher({super.key, this.color}); + + final Color? color; @override Widget build(BuildContext context) { @@ -14,7 +16,7 @@ class IconThemeSwitcher extends StatelessWidget { ), customDarkModeContent: Icon( Icons.sunny, - color: colorTokens.iconLow, + color: color ?? colorTokens.iconLow, ), ); } diff --git a/lib/components/profile_card.dart b/lib/components/profile_card.dart index f05af1d767..6f22d58bbf 100644 --- a/lib/components/profile_card.dart +++ b/lib/components/profile_card.dart @@ -1,6 +1,7 @@ import 'package:ardrive/authentication/ardrive_auth.dart'; import 'package:ardrive/blocs/profile/profile_cubit.dart'; import 'package:ardrive/components/details_panel.dart'; +import 'package:ardrive/components/icon_theme_switcher.dart'; import 'package:ardrive/components/side_bar.dart'; import 'package:ardrive/components/truncated_address.dart'; import 'package:ardrive/gift/bloc/redeem_gift_bloc.dart'; @@ -11,10 +12,10 @@ import 'package:ardrive/services/arconnect/arconnect_wallet.dart'; import 'package:ardrive/turbo/services/payment_service.dart'; import 'package:ardrive/turbo/topup/components/turbo_balance_widget.dart'; import 'package:ardrive/turbo/utils/utils.dart'; -import 'package:ardrive/user/download_wallet/download_wallet_modal.dart'; import 'package:ardrive/utils/app_localizations_wrapper.dart'; import 'package:ardrive/utils/open_url.dart'; import 'package:ardrive/utils/open_url_utils.dart'; +import 'package:ardrive/utils/open_urls.dart'; import 'package:ardrive/utils/plausible_event_tracker/plausible_event_tracker.dart'; import 'package:ardrive/utils/show_general_dialog.dart'; import 'package:ardrive/utils/truncate_string.dart'; @@ -92,7 +93,7 @@ class _ProfileCardState extends State { anchor: Aligned( follower: Alignment.topRight, target: Alignment.bottomRight, - offset: isMobile ? const Offset(12, -60) : const Offset(0, 4), + offset: isMobile ? const Offset(12, -60) : const Offset(0, 18), ), content: _buildProfileCardContent( context, @@ -120,7 +121,7 @@ class _ProfileCardState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( - color: ArDriveTheme.of(context).themeData.colorTokens.containerL0, + color: ArDriveTheme.of(context).themeData.colorTokens.containerL3, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -237,18 +238,18 @@ class _ProfileCardState extends State { _ProfileMenuAccordionItem( text: 'Docs', onTap: () { - openUrl(url: Resources.docsLink); + openDocs(); }, ), _ProfileMenuAccordionItem( text: 'Help', onTap: () { - openUrl(url: Resources.helpLink); + openHelp(); }, ), _ProfileMenuAccordionItem( text: 'Leave Feedback', - onTap: () async { + onTap: () { openFeedbackSurveyUrl(); }, ), @@ -264,6 +265,25 @@ class _ProfileCardState extends State { ), ], ), + const SizedBox(height: 8), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Theme', + style: typography.paragraphNormal( + fontWeight: ArFontWeight.semiBold, + ), + ), + IconThemeSwitcher( + color: + ArDriveTheme.of(context).themeData.colorTokens.iconHigh, + ), + ], + ), + ), const Padding( padding: EdgeInsets.only(top: 20.0), child: _LogoutButton(), @@ -298,7 +318,7 @@ class _ProfileCardState extends State { ), const Spacer(), ArDriveIconButton( - icon: ArDriveIcons.arrowDownload( + icon: ArDriveIcons.download( color: colorTokens.textHigh, size: 21), ), CopyButton( @@ -313,41 +333,6 @@ class _ProfileCardState extends State { ); } - Widget _buildDownloadWalletRow( - BuildContext context, - ) { - return Padding( - padding: const EdgeInsets.only(left: 10.0, right: 15), - child: HoverWidget( - hoverScale: 1, - child: ArDriveClickArea( - child: GestureDetector( - onTap: () { - _showProfileCard = false; - setState(() {}); - showDownloadWalletModal(context); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Flexible( - child: Text( - appLocalizationsOf(context).downloadWalletKeyfile, - style: ArDriveTypography.body.captionRegular().copyWith( - fontWeight: FontWeight.w600, - fontSize: 18, - ), - ), - ), - ArDriveIcons.arrowDownload(), - ], - ), - ), - ), - ), - ); - } - Widget _buildBalanceRow(BuildContext context, ProfileLoggedIn state) { final walletBalance = convertWinstonToLiteralString(state.walletBalance); final typography = ArDriveTypographyNew.of(context); diff --git a/lib/components/side_bar.dart b/lib/components/side_bar.dart index fa1eff1040..d8f5d547d5 100644 --- a/lib/components/side_bar.dart +++ b/lib/components/side_bar.dart @@ -490,124 +490,6 @@ class _AppSideBarState extends State { } } - Widget _exportLogsButton() { - final logExportInfo = LogExportInfo( - emailSubject: appLocalizationsOf(context).shareLogsEmailSubject, - emailBody: appLocalizationsOf(context).shareLogsEmailBody, - shareText: appLocalizationsOf(context).shareLogsNativeShareText, - shareSubject: appLocalizationsOf(context).shareLogsNativeShareSubject, - emailSupport: Resources.emailSupport, - ); - return FutureBuilder( - future: canLaunchUrl(Uri.parse('mailto:')), - builder: (context, snapshot) { - final canLaunchEmail = snapshot.data ?? false; - return HoverWidget( - child: GestureDetector( - onTap: () { - showArDriveDialog( - context, - content: ArDriveStandardModal( - hasCloseButton: true, - title: appLocalizationsOf(context).help, - content: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - appLocalizationsOf(context).shareLogsDescription, - style: ArDriveTypography.body.buttonLargeBold(), - ), - const SizedBox( - height: 16, - ), - Text( - appLocalizationsOf(context).ourChannels, - style: - ArDriveTypography.body.buttonLargeBold().copyWith( - fontWeight: FontWeight.bold, - ), - ), - ArDriveClickArea( - child: GestureDetector( - onTap: () { - openUrl( - url: Resources.discordLink, - ); - }, - child: Text( - discord, - style: ArDriveTypography.body - .buttonLargeBold() - .copyWith( - decoration: TextDecoration.underline, - ), - ), - ), - ), - const SizedBox( - height: 4, - ), - ArDriveClickArea( - child: GestureDetector( - onTap: () { - openUrl( - url: Resources.helpCenterLink, - ); - }, - child: Text( - appLocalizationsOf(context).helpCenter, - style: ArDriveTypography.body - .buttonLargeBold() - .copyWith( - decoration: TextDecoration.underline, - ), - ), - ), - ), - ], - ), - actions: [ - ModalAction( - action: () { - logger.exportLogs(info: logExportInfo); - }, - title: appLocalizationsOf(context).download, - ), - if (AppPlatform.isMobile && canLaunchEmail) - ModalAction( - action: () { - logger.exportLogs( - info: logExportInfo, - shareAsEmail: true, - ); - }, - title: - appLocalizationsOf(context).shareLogsWithEmailText, - ), - if (AppPlatform.isMobile) - ModalAction( - action: () { - logger.exportLogs( - info: logExportInfo, - share: true, - ); - }, - title: appLocalizationsOf(context).share, - ), - ], - ), - ); - }, - child: Text( - appLocalizationsOf(context).shareLogsText, - style: ArDriveTypography.body.buttonNormalBold(), - ), - ), - ); - }, - ); - } - Widget _newButton( bool isExpanded, bool isMobile, @@ -768,7 +650,7 @@ Future shareLogs({ shareText: appLocalizationsOf(context).shareLogsNativeShareText, shareSubject: appLocalizationsOf(context).shareLogsNativeShareSubject, emailSupport: Resources.emailSupport, -); + ); final canLaunchEmail = await canLaunchUrl(Uri.parse('mailto:')); showArDriveDialog( context, diff --git a/lib/components/topbar/help_button.dart b/lib/components/topbar/help_button.dart new file mode 100644 index 0000000000..c8a2cd5dbe --- /dev/null +++ b/lib/components/topbar/help_button.dart @@ -0,0 +1,66 @@ +import 'package:ardrive/components/side_bar.dart'; +import 'package:ardrive/pages/drive_detail/components/dropdown_item.dart'; +import 'package:ardrive/pages/drive_detail/components/hover_widget.dart'; +import 'package:ardrive/utils/app_localizations_wrapper.dart'; +import 'package:ardrive/utils/open_url_utils.dart'; +import 'package:ardrive/utils/open_urls.dart'; +import 'package:ardrive_ui/ardrive_ui.dart'; +import 'package:flutter/widgets.dart'; + +class HelpButtonTopBar extends StatelessWidget { + const HelpButtonTopBar({super.key}); + + @override + Widget build(BuildContext context) { + final colorTokens = ArDriveTheme.of(context).themeData.colorTokens; + return HoverWidget( + child: ArDriveDropdown( + anchor: const Aligned( + follower: Alignment.topRight, + target: Alignment.bottomRight, + ), + items: [ + ArDriveDropdownItem( + onClick: () { + openDocs(); + }, + content: const ArDriveDropdownItemTile( + name: 'Docs', + ), + ), + ArDriveDropdownItem( + onClick: () { + openHelp(); + }, + content: ArDriveDropdownItemTile( + name: appLocalizationsOf(context).help, + ), + ), + ArDriveDropdownItem( + onClick: () { + openFeedbackSurveyUrl(); + }, + content: ArDriveDropdownItemTile( + name: appLocalizationsOf(context).leaveFeedback, + ), + ), + ArDriveDropdownItem( + onClick: () { + shareLogs(context: context); + }, + content: ArDriveDropdownItemTile( + name: appLocalizationsOf(context).shareLogsText, + ), + ), + ], + child: ArDriveIconButton( + icon: ArDriveIcons.question( + size: 20, + color: colorTokens.textMid, + ), + tooltip: appLocalizationsOf(context).help, + ), + ), + ); + } +} diff --git a/lib/components/truncated_address.dart b/lib/components/truncated_address.dart index 44a0b3cae7..87613e8452 100644 --- a/lib/components/truncated_address.dart +++ b/lib/components/truncated_address.dart @@ -31,12 +31,16 @@ class TruncatedAddress extends StatelessWidget { ); }, child: Text( - truncateString( - walletAddress, - offsetStart: offsetStart, - offsetEnd: offsetEnd, - ), - style: typography.paragraphNormal(color: colorTokens.textLink)), + truncateString( + walletAddress, + offsetStart: offsetStart, + offsetEnd: offsetEnd, + ), + style: typography.paragraphNormal( + color: colorTokens.textLink, + fontWeight: ArFontWeight.semiBold, + ), + ), ), ); } diff --git a/lib/gift/reedem_button.dart b/lib/gift/reedem_button.dart deleted file mode 100644 index dddc129c4f..0000000000 --- a/lib/gift/reedem_button.dart +++ /dev/null @@ -1,61 +0,0 @@ -import 'package:ardrive/authentication/ardrive_auth.dart'; -import 'package:ardrive/gift/bloc/redeem_gift_bloc.dart'; -import 'package:ardrive/gift/redeem_gift_modal.dart'; -import 'package:ardrive/misc/misc.dart'; -import 'package:ardrive/pages/drive_detail/components/dropdown_item.dart'; -import 'package:ardrive/pages/drive_detail/components/hover_widget.dart'; -import 'package:ardrive/turbo/services/payment_service.dart'; -import 'package:ardrive/utils/app_localizations_wrapper.dart'; -import 'package:ardrive/utils/open_url.dart'; -import 'package:ardrive/utils/show_general_dialog.dart'; -import 'package:ardrive_ui/ardrive_ui.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; - -class RedeemButton extends StatelessWidget { - const RedeemButton({super.key}); - - @override - Widget build(BuildContext context) { - final colorTokens = ArDriveTheme.of(context).themeData.colorTokens; - return ArDriveDropdown( - anchor: const Aligned( - follower: Alignment.topRight, - target: Alignment.bottomRight, - ), - items: [ - ArDriveDropdownItem( - onClick: () { - openUrl(url: Resources.sendGiftLink); - }, - content: ArDriveDropdownItemTile( - name: appLocalizationsOf(context).sendGift, - ), - ), - ArDriveDropdownItem( - onClick: () { - showArDriveDialog( - context, - content: BlocProvider( - create: (context) => RedeemGiftBloc( - paymentService: context.read(), - auth: context.read()), - child: const RedeemGiftModal(), - ), - ); - }, - content: ArDriveDropdownItemTile( - name: appLocalizationsOf(context).redeemGift, - ), - ), - ], - child: ArDriveIconButton( - icon: ArDriveIcons.gift( - size: 20, - color: colorTokens.textMid, - ), - tooltip: appLocalizationsOf(context).giftCredits, - ), - ); - } -} diff --git a/lib/pages/drive_detail/components/drive_explorer_item_tile.dart b/lib/pages/drive_detail/components/drive_explorer_item_tile.dart index cdc9572677..ba5cfb1b55 100644 --- a/lib/pages/drive_detail/components/drive_explorer_item_tile.dart +++ b/lib/pages/drive_detail/components/drive_explorer_item_tile.dart @@ -383,7 +383,7 @@ class _DriveExplorerItemTileTrailingState }, content: _buildItem( appLocalizationsOf(context).download, - ArDriveIcons.download2( + ArDriveIcons.download( size: defaultIconSize, ), ), @@ -466,7 +466,7 @@ class _DriveExplorerItemTileTrailingState }, content: _buildItem( appLocalizationsOf(context).download, - ArDriveIcons.download2( + ArDriveIcons.download( size: defaultIconSize, ), ), @@ -631,7 +631,7 @@ class EntityActionsMenu extends StatelessWidget { }, content: _buildItem( appLocalizationsOf(context).download, - ArDriveIcons.download2( + ArDriveIcons.download( size: defaultIconSize, ), ), @@ -683,7 +683,7 @@ class EntityActionsMenu extends StatelessWidget { }, content: ArDriveDropdownItemTile( name: appLocalizationsOf(context).download, - icon: ArDriveIcons.download2( + icon: ArDriveIcons.download( size: defaultIconSize, ), )), @@ -725,7 +725,7 @@ class EntityActionsMenu extends StatelessWidget { }, content: ArDriveDropdownItemTile( name: appLocalizationsOf(context).exportDriveContents, - icon: ArDriveIcons.download2( + icon: ArDriveIcons.download( size: defaultIconSize, ), ), @@ -762,7 +762,7 @@ class EntityActionsMenu extends StatelessWidget { }, content: _buildItem( appLocalizationsOf(context).download, - ArDriveIcons.download2( + ArDriveIcons.download( size: defaultIconSize, ), ), diff --git a/lib/pages/drive_detail/drive_detail_page.dart b/lib/pages/drive_detail/drive_detail_page.dart index 61cc1db0f9..8898de238f 100644 --- a/lib/pages/drive_detail/drive_detail_page.dart +++ b/lib/pages/drive_detail/drive_detail_page.dart @@ -378,7 +378,7 @@ class _DriveDetailPageState extends State { .enableMultipleFileDownload) ...[ ArDriveIconButton( tooltip: 'Download selected files', - icon: ArDriveIcons.download2(), + icon: ArDriveIcons.download(), onPressed: () async { final selectedItems = context .read() @@ -445,7 +445,7 @@ class _DriveDetailPageState extends State { content: ArDriveDropdownItemTile( name: appLocalizationsOf(context) .download, - icon: ArDriveIcons.download2( + icon: ArDriveIcons.download( size: defaultIconSize, ), ), @@ -510,7 +510,7 @@ class _DriveDetailPageState extends State { content: ArDriveDropdownItemTile( name: appLocalizationsOf(context) .exportDriveContents, - icon: ArDriveIcons.download2( + icon: ArDriveIcons.download( size: defaultIconSize, ), ), @@ -1098,7 +1098,7 @@ class MobileFolderNavigation extends StatelessWidget { }, content: ArDriveDropdownItemTile( name: appLocalizationsOf(context).download, - icon: ArDriveIcons.download2( + icon: ArDriveIcons.download( size: defaultIconSize, ), )), @@ -1153,7 +1153,7 @@ class MobileFolderNavigation extends StatelessWidget { }, content: _buildItem( appLocalizationsOf(context).exportDriveContents, - ArDriveIcons.download2( + ArDriveIcons.download( size: defaultIconSize, ), ), diff --git a/lib/pages/no_drives/no_drives_page.dart b/lib/pages/no_drives/no_drives_page.dart index 97bcd89dee..55954fd896 100644 --- a/lib/pages/no_drives/no_drives_page.dart +++ b/lib/pages/no_drives/no_drives_page.dart @@ -3,6 +3,7 @@ import 'package:ardrive/authentication/components/login_modal.dart'; import 'package:ardrive/blocs/drive_detail/drive_detail_cubit.dart'; import 'package:ardrive/components/drive_create_form.dart'; import 'package:ardrive/components/profile_card.dart'; +import 'package:ardrive/components/topbar/help_button.dart'; import 'package:ardrive/core/arfs/entities/arfs_entities.dart'; import 'package:ardrive/misc/resources.dart'; import 'package:ardrive/pages/drive_detail/drive_detail_page.dart'; @@ -13,8 +14,6 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_svg/svg.dart'; import 'package:responsive_builder/responsive_builder.dart'; -import '../../gift/reedem_button.dart'; - /// A page letting the user know that they have no personal or attached drives /// with a call to action for them to add new ones. class NoDrivesPage extends StatelessWidget { @@ -65,8 +64,8 @@ class NoDrivesPage extends StatelessWidget { const Row( mainAxisAlignment: MainAxisAlignment.end, children: [ - RedeemButton(), - SizedBox(width: 24), + HelpButtonTopBar(), + SizedBox(width: 8), ProfileCard(), ], ), diff --git a/lib/pages/shared_file/shared_file_page.dart b/lib/pages/shared_file/shared_file_page.dart index 1bdd1f643f..283a2962d8 100644 --- a/lib/pages/shared_file/shared_file_page.dart +++ b/lib/pages/shared_file/shared_file_page.dart @@ -196,7 +196,7 @@ class SharedFilePage extends StatelessWidget { ), const SizedBox(height: 24), ArDriveButton( - icon: ArDriveIcons.download2(color: Colors.white), + icon: ArDriveIcons.download(color: Colors.white), onPressed: () { final file = ARFSFactory().getARFSFileFromFileRevision( state.fileRevisions.first, diff --git a/lib/search/search_modal.dart b/lib/search/search_modal.dart index c58f9aa103..dba0c1b60c 100644 --- a/lib/search/search_modal.dart +++ b/lib/search/search_modal.dart @@ -372,7 +372,7 @@ class _FileSearchModalState extends State<_FileSearchModal> { const SizedBox(width: 8), if (searchResult.result is FileEntry) ArDriveIconButton( - icon: ArDriveIcons.download2(color: colorTokens.iconHigh), + icon: ArDriveIcons.download(color: colorTokens.iconHigh), onPressed: () => promptToDownloadProfileFile( context: context, file: DriveDataTableItemMapper.fromFileEntryForSearchModal( diff --git a/lib/utils/open_urls.dart b/lib/utils/open_urls.dart new file mode 100644 index 0000000000..b7f0e5b44a --- /dev/null +++ b/lib/utils/open_urls.dart @@ -0,0 +1,10 @@ +import 'package:ardrive/misc/resources.dart'; +import 'package:ardrive/utils/open_url.dart'; + +Future openDocs() { + return openUrl(url: Resources.docsLink); +} + +Future openHelp() { + return openUrl(url: Resources.helpLink); +} diff --git a/packages/ardrive_ui/assets/fonts/ArDriveIcons.ttf b/packages/ardrive_ui/assets/fonts/ArDriveIcons.ttf index bf42c5c4650ed44f5248c1307ad9f34485e321a6..a0542cd545517ea9c69470f3f77c2cc9a9870554 100644 GIT binary patch delta 1689 zcmZuwUuaup6hG(Q{7-X}oBuZ?*W|X|8#7X~G`(rqOtQ6G>zcH~S%mpeLes52Qlc=94bDDFFwrq;)@KyD6$tP43Wh1i|=^mE~GJdG=Q;0Q^YMSLni8 zh$kxe>lO({O2or0KrP{@lXDR@;ujulPBej!9v4#Ta!gP+W*N!ZIKKba| z0M*whXXa>Q)3vpq|L_XH{;%oc_w!eWOLKrMAi!UjuX`5VJO2PD-=Q10dF}ex{k^x! z|H2=jvkf?QON;r-bY=``;An#jaH+M< zUv%z+S*SpjqFGv^=}s$da=M3@75{$UmTGT@%{<>MQy2p5qJ03^P4WORN%8RQ6^Lk#-X{x5S zJ}L&AiY4H;DC&5wh*=p)whHXaZpg5R<2jYj>0{foLBC~qyQ1Rlr>nDRTC>$p?+RU0 zA-`C=SzF8(?g{u-Y+G27QqxaPr_@BqCn=KbO}M?O8A%i+2JSryGIu{pKU}wc?13;W z9)?pgb4g97=$G6R@PzE_oK%8AN8Br?y640&<&pr}-<8hUng;o8tj|8iLLbWpLoy1e zjpDE(U<~~-j%7(9BjY=)uy%}N5m|%$tW~2(+I&J$iF-mNzXM5a_tbp8o^)YIaYbje z!s5ilVnLgUx|9&QlJ)%j)NU=wJ?~JOLRt5C^s=A?%tF%J)u}oWzwssoGyc%G(ng$0 zgmX$!itr}|ib_r{qBuvieiHNvCP!vhAQRY?ahReCais2f;|_(M0{c7ke&%20Za@?Y zG}&x0AhJQp$m(WHnrab=M@Y=+Ov|_?vTTw%I}zQ4GRjVPTkJ=T{wG`abx}%J(l|#S zN1sONtftv`$blS133#g57|9N(!Fg8m z4$M-4a=+g+4XRu~Hz)KdY(qw36xmE3L*o^exFWJaTL0x~+_Kkf*t2IYG%-Z3!^$xA z!%b6XePK`ENXOoP5lj8~=EeV%6! zkkp6ff7aC33{u|Jyo0=LQ0X3bhH~!gr@oiWp&d65a=0c`F-Cc1 z&pj=bVzrq)QD3esv2xl^&2T21YaOgyuwezOIEVA?Ta{NhkNep1<;|_t#(H{bbz^C5 yxpjKJp0PKMZ>2X@53g(u)f*?)*BZ5YdVTqXWvOxWRC>Em+t_HFNZ-}a>-`&c(@pUJ delta 516 zcmdn9lJUoU#t8=XE7vLLGcYjoFfg!Iq~}zo+5We!VqoBuVPLR-laZR3q7i*6o`Hek z0T7#I00r3XnCAf5dw^IaBe$eNAsfhIV0;3^8aesNi9u@|7cekzv;YOCYqK2VdB({fnPetQGMnjh zfu)&V*uQXl;rXKB|9=LC7Yr{PUwA;+U~M3cTnrrylNhE_?E%3I z?m*fTf*C+!4G_!#6a#`yj8=?gjE|VAm{V9DvCd$9Gx-)rzTi6<3z-A50kVr^&&WNH zpC|uqa}wu1v&}k=tsI-*`ut&L^qTxCV9MsUz)4J#H9}HE_!5hX^2>Eo^2_sb@)J|Q GCIbMFeTOpu diff --git a/packages/ardrive_ui/assets/fonts/config.json b/packages/ardrive_ui/assets/fonts/config.json index 5a15694fa4..fdce01d850 100644 --- a/packages/ardrive_ui/assets/fonts/config.json +++ b/packages/ardrive_ui/assets/fonts/config.json @@ -1027,6 +1027,62 @@ "search": [ "asc" ] + }, + { + "uid": "c98a1f8b572f29f5a38f646dcf10621d", + "css": "question-circle", + "code": 59456, + "src": "custom_icons", + "selected": true, + "svg": { + "path": "M500 166.7C315.9 166.7 166.7 315.9 166.7 500 166.7 684.1 315.9 833.3 500 833.3 684.1 833.3 833.3 684.1 833.3 500 833.3 315.9 684.1 166.7 500 166.7ZM83.3 500C83.3 269.9 269.9 83.3 500 83.3 730.1 83.3 916.7 269.9 916.7 500 916.7 730.1 730.1 916.7 500 916.7 269.9 916.7 83.3 730.1 83.3 500ZM500 333.3C460.5 333.3 428.4 365.4 428.4 404.9 428.4 427.9 409.7 446.6 386.7 446.6 363.7 446.6 345.1 427.9 345.1 404.9 345.1 319.4 414.4 250 500 250 585.6 250 654.9 319.4 654.9 404.9 654.9 459.5 626.7 507.4 584.3 535 570.8 543.7 559.3 552.9 551.4 562.3 543.8 571.4 541.7 578.2 541.7 583.3 541.7 606.3 523 625 500 625 477 625 458.3 606.3 458.3 583.3 458.3 552.5 471.9 527.4 487.5 508.8 503 490.4 522.2 475.9 538.9 465.1 558.7 452.2 571.6 430.1 571.6 404.9 571.6 365.4 539.5 333.3 500 333.3ZM458.3 708.3C458.3 685.3 477 666.7 500 666.7H500C523.1 666.7 541.7 685.3 541.7 708.3 541.7 731.3 523.1 750 500 750H500C477 750 458.3 731.3 458.3 708.3Z", + "width": 1000 + }, + "search": [ + "question-circle" + ] + }, + { + "uid": "38bb7097090a8d768b596015427403f9", + "css": "out-right", + "code": 59466, + "src": "custom_icons", + "selected": true, + "svg": { + "path": "M83.3 375C83.3 213.9 213.9 83.3 375 83.3 449.7 83.3 517.9 111.5 569.5 157.6 586.6 173 588.1 199.3 572.7 216.4 557.4 233.6 531 235.1 513.9 219.7 477 186.7 428.4 166.7 375 166.7 259.9 166.7 166.7 259.9 166.7 375V625C166.7 740.1 259.9 833.3 375 833.3 428.4 833.3 477 813.3 513.9 780.3 531 764.9 557.4 766.4 572.7 783.6 588.1 800.7 586.6 827 569.5 842.4 517.9 888.5 449.7 916.7 375 916.7 213.9 916.7 83.3 786.1 83.3 625V375ZM724.5 350C738.3 331.6 764.4 327.9 782.9 341.7 826.7 374.6 866.3 412.7 900.8 455.3 911.4 468.3 916.7 484.2 916.7 500 916.7 515.8 911.4 531.7 900.8 544.7 866.3 587.3 826.7 625.4 782.9 658.3 764.4 672.1 738.3 668.4 724.5 650 710.7 631.6 714.4 605.5 732.9 591.7 753.4 576.3 772.8 559.6 791.1 541.7H333.3C310.3 541.7 291.7 523 291.7 500 291.7 477 310.3 458.3 333.3 458.3H791.1C772.8 440.4 753.4 423.7 732.9 408.3 714.4 394.5 710.7 368.4 724.5 350Z", + "width": 1000 + }, + "search": [ + "out-right" + ] + }, + { + "uid": "7dd874a568fad791727738e3192a514e", + "css": "download-new", + "code": 59467, + "src": "custom_icons", + "selected": true, + "svg": { + "path": "M500 125C523 125 541.7 143.7 541.7 166.7V541.1C559.6 522.8 576.3 503.4 591.7 482.9 605.5 464.4 631.6 460.7 650 474.5 668.4 488.3 672.1 514.4 658.3 532.9 625.4 576.7 587.3 616.3 544.7 650.8 531.7 661.4 515.8 666.7 500 666.7 484.2 666.7 468.3 661.4 455.3 650.8 412.7 616.3 374.6 576.7 341.7 532.9 327.9 514.4 331.6 488.3 350 474.5 368.4 460.7 394.5 464.4 408.3 482.9 423.7 503.4 440.4 522.8 458.3 541.1V166.7C458.3 143.7 477 125 500 125ZM125 583.3C148 583.3 166.7 602 166.7 625 166.7 717 241.3 791.7 333.3 791.7H666.7C758.7 791.7 833.3 717 833.3 625 833.3 602 852 583.3 875 583.3 898 583.3 916.7 602 916.7 625 916.7 763.1 804.7 875 666.7 875H333.3C195.3 875 83.3 763.1 83.3 625 83.3 602 102 583.3 125 583.3Z", + "width": 1000 + }, + "search": [ + "02" + ] + }, + { + "uid": "68bd2411791e323599c9d4c13d1a6145", + "css": "copy-1", + "code": 59468, + "src": "custom_icons", + "selected": true, + "svg": { + "path": "M575 83.3C577.8 83.3 580.5 83.3 583.3 83.3 586.1 83.3 588.9 83.3 591.6 83.3 661.2 83.3 706.2 83.3 743.9 95.6 820 120.3 879.7 180 904.4 256.1 916.7 293.8 916.7 338.8 916.7 408.3 916.7 411.1 916.7 413.9 916.7 416.7 916.7 419.5 916.7 422.2 916.7 425 916.7 494.5 916.7 539.5 904.4 577.2 879.7 653.4 820 713 743.9 737.8 742.4 738.3 740.8 738.8 739.2 739.2 738.8 740.8 738.3 742.4 737.8 743.9 713 820 653.4 879.7 577.3 904.4 539.5 916.7 494.5 916.7 425 916.7 422.3 916.7 419.5 916.7 416.7 916.7 413.9 916.7 411.1 916.7 408.4 916.7 338.8 916.7 293.8 916.7 256.1 904.4 180 879.7 120.3 820 95.6 743.9 83.3 706.2 83.3 661.2 83.3 591.6 83.3 588.9 83.3 586.1 83.3 583.3 83.3 580.5 83.3 577.8 83.3 575 83.3 505.5 83.3 460.5 95.6 422.7 120.3 346.6 180 287 256.1 262.2 257.6 261.7 259.2 261.2 260.8 260.8 261.2 259.2 261.7 257.6 262.2 256.1 287 180 346.6 120.3 422.8 95.6 460.5 83.3 505.5 83.3 575 83.3ZM355.5 250.3C372.5 250 391.5 250 412.8 250 414.1 250 415.4 250 416.7 250 419.5 250 422.3 250 425 250 494.5 250 539.5 250 577.3 262.2 653.4 287 713 346.6 737.8 422.7 750 460.5 750 505.5 750 575 750 577.8 750 580.5 750 583.3L750 587.2C750 608.5 750 627.5 749.7 644.5 785.2 624.1 812.3 591.2 825.2 551.5 832.8 528 833.3 497.5 833.3 416.7 833.3 335.9 832.8 305.4 825.2 281.8 808.7 231.1 768.9 191.3 718.2 174.8 694.6 167.2 664.1 166.7 583.3 166.7 502.5 166.7 472 167.2 448.5 174.8 408.8 187.7 375.9 214.8 355.5 250.3ZM551.5 341.5C528 333.8 497.5 333.3 416.7 333.3 358 333.3 325.7 333.4 301.9 337 293.9 338.1 287.5 339.6 281.8 341.5 231.1 358 191.3 397.8 174.8 448.5 167.2 472 166.7 502.5 166.7 583.3 166.7 664.1 167.2 694.6 174.8 718.2 191.3 768.9 231.1 808.7 281.8 825.2 305.4 832.8 335.9 833.3 416.7 833.3 497.5 833.3 528 832.8 551.5 825.2 602.2 808.7 642 768.9 658.5 718.2 660.4 712.5 661.8 706.1 663 698.1 666.6 674.3 666.7 642 666.7 583.3 666.7 502.5 666.2 472 658.5 448.5 642 397.8 602.2 358 551.5 341.5Z", + "width": 1000 + }, + "search": [ + "copy" + ] } ] } \ No newline at end of file diff --git a/packages/ardrive_ui/lib/src/styles/icons/ar_drive_icons_icons.dart b/packages/ardrive_ui/lib/src/styles/icons/ar_drive_icons_icons.dart index 4fa4466f86..ac4f847497 100644 --- a/packages/ardrive_ui/lib/src/styles/icons/ar_drive_icons_icons.dart +++ b/packages/ardrive_ui/lib/src/styles/icons/ar_drive_icons_icons.dart @@ -13,7 +13,6 @@ /// /// /// -library; // ignore_for_file: constant_identifier_names import 'package:flutter/widgets.dart'; @@ -152,6 +151,8 @@ class ArDriveIconsData { IconData(0xe83e, fontFamily: _kFontFam, fontPackage: _kFontPkg); static const IconData detach = IconData(0xe83f, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData question_circle = + IconData(0xe840, fontFamily: _kFontFam, fontPackage: _kFontPkg); static const IconData manifest_icon_flattened = IconData(0xe841, fontFamily: _kFontFam, fontPackage: _kFontPkg); static const IconData download_2 = @@ -168,6 +169,12 @@ class ArDriveIconsData { IconData(0xe848, fontFamily: _kFontFam, fontPackage: _kFontPkg); static const IconData public_drive = IconData(0xe849, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData out_right = + IconData(0xe84a, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData download_new = + IconData(0xe84b, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData copy_1 = + IconData(0xe84c, fontFamily: _kFontFam, fontPackage: _kFontPkg); static const IconData arrow_download = IconData(0xe880, fontFamily: _kFontFam, fontPackage: _kFontPkg); } diff --git a/packages/ardrive_ui/lib/src/styles/icons/icons.dart b/packages/ardrive_ui/lib/src/styles/icons/icons.dart index 8d280afc60..4144bc732d 100644 --- a/packages/ardrive_ui/lib/src/styles/icons/icons.dart +++ b/packages/ardrive_ui/lib/src/styles/icons/icons.dart @@ -194,7 +194,7 @@ class ArDriveIcons { ); static ArDriveIcon copy({double? size, Color? color}) => ArDriveIcon( - icon: ArDriveIconsData.copy, + icon: ArDriveIconsData.copy_1, size: size, color: color, ); @@ -206,7 +206,7 @@ class ArDriveIcons { ); static ArDriveIcon download({double? size, Color? color}) => ArDriveIcon( - icon: ArDriveIconsData.download, + icon: ArDriveIconsData.download_new, size: size, color: color, ); @@ -326,7 +326,7 @@ class ArDriveIcons { // logout static ArDriveIcon logout({double? size, Color? color}) => ArDriveIcon( - icon: ArDriveIconsData.logout, + icon: ArDriveIconsData.out_right, size: size, color: color, ); @@ -347,7 +347,7 @@ class ArDriveIcons { // help static ArDriveIcon question({double? size, Color? color}) => ArDriveIcon( - icon: ArDriveIconsData.question, + icon: ArDriveIconsData.question_circle, size: size, color: color, ); @@ -421,13 +421,6 @@ class ArDriveIcons { color: color, ); - // arrow-download - static ArDriveIcon arrowDownload({double? size, Color? color}) => ArDriveIcon( - icon: ArDriveIconsData.arrow_download, - size: size, - color: color, - ); - static ArDriveIcon cloudSync({double? size, Color? color}) => ArDriveIcon( icon: Icons.cloud_sync, size: size, @@ -440,12 +433,6 @@ class ArDriveIcons { color: color, ); - static ArDriveIcon download2({double? size, Color? color}) => ArDriveIcon( - icon: ArDriveIconsData.download_2, - size: size ?? 18, - color: color, - ); - static ArDriveIcon manifest({double? size, Color? color}) => ArDriveIcon( icon: ArDriveIconsData.manifest_icon_flattened, size: size ?? 26, diff --git a/packages/ardrive_ui/storybook/lib/src/icons.dart b/packages/ardrive_ui/storybook/lib/src/icons.dart index 09b9349a6a..0cf9714ddb 100644 --- a/packages/ardrive_ui/storybook/lib/src/icons.dart +++ b/packages/ardrive_ui/storybook/lib/src/icons.dart @@ -95,10 +95,9 @@ List _options = [ IconOption(icon: ArDriveIcons.keypad(), name: 'keypad'), IconOption(icon: ArDriveIcons.pinNoCircle(), name: 'pinNoCircle'), IconOption(icon: ArDriveIcons.pinWithCircle(), name: 'pinWithCircle'), - IconOption(icon: ArDriveIcons.arrowDownload(), name: 'arrowDownload'), IconOption(icon: ArDriveIcons.cloudSync(), name: 'cloudSync'), IconOption(icon: ArDriveIcons.detach(), name: 'detach'), - IconOption(icon: ArDriveIcons.download2(), name: 'download2'), + IconOption(icon: ArDriveIcons.download(), name: 'download'), IconOption(icon: ArDriveIcons.manifest(), name: 'manifest'), ]; From 49b19de814f98aacdc79f765b1d32957c4d35eb0 Mon Sep 17 00:00:00 2001 From: Thiago Carvalho <32248947+thiagocarvalhodev@users.noreply.github.com> Date: Mon, 22 Jul 2024 10:53:37 -0300 Subject: [PATCH 03/11] remove comments and fix lint wanrning --- lib/components/profile_card.dart | 22 ----------- lib/components/side_bar.dart | 39 ------------------- .../styles/icons/ar_drive_icons_icons.dart | 2 + 3 files changed, 2 insertions(+), 61 deletions(-) diff --git a/lib/components/profile_card.dart b/lib/components/profile_card.dart index 6f22d58bbf..32afa41fde 100644 --- a/lib/components/profile_card.dart +++ b/lib/components/profile_card.dart @@ -172,28 +172,6 @@ class _ProfileCardState extends State { ], ), ), - // Padding( - // padding: const EdgeInsets.only(top: 20.0, left: 16, right: 16), - // child: ArDriveClickArea( - // child: GestureDetector( - // onTap: () { - // openFeedbackSurveyUrl(); - // }, - // child: Text( - // appLocalizationsOf(context).leaveFeedback, - // style: ArDriveTypography.body.captionRegular().copyWith( - // fontWeight: FontWeight.w600, - // fontSize: 18, - // color: ArDriveTheme.of(context) - // .themeData - // .colors - // .themeFgMuted, - // decoration: TextDecoration.underline, - // ), - // ), - // ), - // ), - // ), ArDriveAccordion( backgroundColor: Colors.transparent, children: [ diff --git a/lib/components/side_bar.dart b/lib/components/side_bar.dart index d8f5d547d5..fb520d2044 100644 --- a/lib/components/side_bar.dart +++ b/lib/components/side_bar.dart @@ -140,27 +140,6 @@ class _AppSideBarState extends State { height: 16, ), ], - // const Padding( - // padding: EdgeInsets.only(left: 16.0), - // child: HelpButton(), - // ), - // const SizedBox( - // height: 16, - // ), - // Padding( - // padding: const EdgeInsets.only(left: 16.0), - // child: _exportLogsButton(), - // ), - // const SizedBox( - // height: 4, - // ), - // const Padding( - // padding: EdgeInsets.only(left: 16.0), - // child: ThemeSwitcher(), - // ), - // const SizedBox( - // height: 4, - // ), const Padding( padding: EdgeInsets.only(left: 20.0), child: AppVersionWidget(), @@ -389,20 +368,6 @@ class _AppSideBarState extends State { child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - // const Align( - // alignment: Alignment.centerLeft, - // child: HelpButton(), - // ), - // const SizedBox( - // height: 16, - // ), - // Align( - // alignment: Alignment.centerLeft, - // child: _exportLogsButton(), - // ), - // const SizedBox( - // height: 8, - // ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, @@ -440,10 +405,6 @@ class _AppSideBarState extends State { ) : Column( children: [ - // const HelpButton(), - // const SizedBox( - // height: 24, - // ), ArDriveIconButton( tooltip: appLocalizationsOf(context).expandSideBar, icon: ArDriveIcons.arrowRightFilled(), diff --git a/packages/ardrive_ui/lib/src/styles/icons/ar_drive_icons_icons.dart b/packages/ardrive_ui/lib/src/styles/icons/ar_drive_icons_icons.dart index ac4f847497..42c05ef51e 100644 --- a/packages/ardrive_ui/lib/src/styles/icons/ar_drive_icons_icons.dart +++ b/packages/ardrive_ui/lib/src/styles/icons/ar_drive_icons_icons.dart @@ -15,6 +15,8 @@ /// // ignore_for_file: constant_identifier_names +library; + import 'package:flutter/widgets.dart'; class ArDriveIconsData { From 1b236db9fdc6637f756dc84d329a5e79426f34ad Mon Sep 17 00:00:00 2001 From: Thiago Carvalho <32248947+thiagocarvalhodev@users.noreply.github.com> Date: Wed, 31 Jul 2024 10:45:29 -0300 Subject: [PATCH 04/11] feat(profile menu) - enhance auto sync functionality - remove old feature flags / env config - add upload thumbnails to advanced options on profile menu --- assets/config/dev.json | 9 +- assets/config/prod.json | 9 +- assets/config/staging.json | 9 +- .../login/blocs/login_bloc.dart | 8 +- .../login/views/login_page.dart | 2 - .../create_snapshot_cubit.dart | 23 ++- .../fs_entry_preview_cubit.dart | 32 ++-- lib/blocs/upload/upload_cubit.dart | 17 ++- lib/components/app_top_bar.dart | 32 ++-- lib/components/new_button/new_button.dart | 26 ++-- lib/components/profile_card.dart | 83 +++++++++- lib/components/side_bar.dart | 2 - lib/components/upload_form.dart | 6 +- lib/dev_tools/app_dev_tools.dart | 142 ------------------ lib/pages/drive_detail/drive_detail_page.dart | 6 +- lib/services/config/app_config.dart | 58 +------ lib/services/config/config_fetcher.dart | 7 +- lib/sync/domain/cubit/sync_cubit.dart | 19 ++- .../payment_review/payment_review_bloc.dart | 4 +- .../payment_review/payment_review_event.dart | 2 - lib/turbo/topup/views/topup_modal.dart | 13 +- lib/turbo/topup/views/topup_review_view.dart | 10 +- lib/turbo/turbo.dart | 10 +- .../login/blocs/login_bloc_test.dart | 22 +-- test/blocs/create_snapshot_cubit_test.dart | 5 - test/blocs/upload_cubit_test.dart | 10 ++ test/core/upload/uploader_test.dart | 2 - test/services/config/config_fetcher_test.dart | 9 -- 28 files changed, 197 insertions(+), 380 deletions(-) diff --git a/assets/config/dev.json b/assets/config/dev.json index c668370178..69ff755df6 100644 --- a/assets/config/dev.json +++ b/assets/config/dev.json @@ -5,13 +5,6 @@ "defaultTurboUploadUrl": "https://upload.ardrive.dev", "defaultTurboPaymentUrl": "https://payment.ardrive.dev", "allowedDataItemSizeForTurbo": 100000, - "enableQuickSyncAuthoring": true, - "enableMultipleFileDownload": true, - "enableVideoPreview": true, - "enableAudioPreview": true, "stripePublishableKey": "pk_test_51JUAtwC8apPOWkDLh2FPZkQkiKZEkTo6wqgLCtQoClL6S4l2jlbbc5MgOdwOUdU9Tn93NNvqAGbu115lkJChMikG00XUfTmo2z", - "enablePins": true, - "useNewUploader": true, - "enableMetamaskLogin": true, - "enableSearch": true + "uploadThumbnails": true } diff --git a/assets/config/prod.json b/assets/config/prod.json index 573f1b2782..347cb3ffd4 100644 --- a/assets/config/prod.json +++ b/assets/config/prod.json @@ -5,13 +5,6 @@ "defaultTurboUploadUrl": "https://upload.ardrive.io", "defaultTurboPaymentUrl": "https://payment.ardrive.io", "allowedDataItemSizeForTurbo": 100000, - "enableQuickSyncAuthoring": true, - "enableMultipleFileDownload": true, - "enableVideoPreview": true, - "enableAudioPreview": true, "stripePublishableKey": "pk_live_51JUAtwC8apPOWkDLMQqNF9sPpfneNSPnwX8YZ8y1FNDl6v94hZIwzgFSYl27bWE4Oos8CLquunUswKrKcaDhDO6m002Yj9AeKj", - "enablePins": true, - "useNewUploader": true, - "enableMetamaskLogin": true, - "enableSearch": true + "uploadThumbnails": true } diff --git a/assets/config/staging.json b/assets/config/staging.json index 573f1b2782..347cb3ffd4 100644 --- a/assets/config/staging.json +++ b/assets/config/staging.json @@ -5,13 +5,6 @@ "defaultTurboUploadUrl": "https://upload.ardrive.io", "defaultTurboPaymentUrl": "https://payment.ardrive.io", "allowedDataItemSizeForTurbo": 100000, - "enableQuickSyncAuthoring": true, - "enableMultipleFileDownload": true, - "enableVideoPreview": true, - "enableAudioPreview": true, "stripePublishableKey": "pk_live_51JUAtwC8apPOWkDLMQqNF9sPpfneNSPnwX8YZ8y1FNDl6v94hZIwzgFSYl27bWE4Oos8CLquunUswKrKcaDhDO6m002Yj9AeKj", - "enablePins": true, - "useNewUploader": true, - "enableMetamaskLogin": true, - "enableSearch": true + "uploadThumbnails": true } diff --git a/lib/authentication/login/blocs/login_bloc.dart b/lib/authentication/login/blocs/login_bloc.dart index 9ed6f13e53..a573251e6e 100644 --- a/lib/authentication/login/blocs/login_bloc.dart +++ b/lib/authentication/login/blocs/login_bloc.dart @@ -11,7 +11,6 @@ import 'package:ardrive/entities/profile_types.dart'; import 'package:ardrive/services/arconnect/arconnect.dart'; import 'package:ardrive/services/arconnect/arconnect_wallet.dart'; import 'package:ardrive/services/arweave/arweave_service.dart'; -import 'package:ardrive/services/config/config_service.dart'; import 'package:ardrive/services/ethereum/ethereum_wallet.dart'; import 'package:ardrive/services/ethereum/provider/ethereum_provider.dart'; import 'package:ardrive/services/ethereum/provider/ethereum_provider_wallet.dart'; @@ -39,7 +38,6 @@ class LoginBloc extends Bloc { final TurboUploadService _turboUploadService; final ArweaveService _arweaveService; final DownloadService _downloadService; - final ConfigService _configService; bool ignoreNextWaletSwitch = false; @@ -60,14 +58,12 @@ class LoginBloc extends Bloc { required ArweaveService arweaveService, required DownloadService downloadService, required UserRepository userRepository, - required ConfigService configService, }) : _arDriveAuth = arDriveAuth, _arConnectService = arConnectService, _ethereumProviderService = ethereumProviderService, _arweaveService = arweaveService, _turboUploadService = turboUploadService, _downloadService = downloadService, - _configService = configService, super(LoginLoading()) { on(_onLoginEvent); _listenToWalletChange(); @@ -75,9 +71,7 @@ class LoginBloc extends Bloc { get isArConnectAvailable => _arConnectService.isExtensionPresent(); - get isMetamaskAvailable => - _configService.config.enableMetamaskLogin && - _ethereumProviderService.isExtensionPresent(); + get isMetamaskAvailable => _ethereumProviderService.isExtensionPresent(); Future _onLoginEvent(LoginEvent event, Emitter emit) async { if (event is SelectLoginFlow) { diff --git a/lib/authentication/login/views/login_page.dart b/lib/authentication/login/views/login_page.dart index ff6c0c2fac..f666c1a2ab 100644 --- a/lib/authentication/login/views/login_page.dart +++ b/lib/authentication/login/views/login_page.dart @@ -14,7 +14,6 @@ import 'package:ardrive/services/arconnect/arconnect.dart'; import 'package:ardrive/services/arweave/arweave_service.dart'; import 'package:ardrive/services/authentication/biometric_authentication.dart'; import 'package:ardrive/services/authentication/biometric_permission_dialog.dart'; -import 'package:ardrive/services/config/config_service.dart'; import 'package:ardrive/services/ethereum/provider/ethereum_provider.dart'; import 'package:ardrive/turbo/services/upload_service.dart'; import 'package:ardrive/user/repositories/user_repository.dart'; @@ -71,7 +70,6 @@ class _LoginPageState extends State { downloadService: downloadService, arDriveAuth: context.read(), userRepository: context.read(), - configService: context.read(), )..add( CheckIfUserIsLoggedIn( gettingStarted: widget.gettingStarted, diff --git a/lib/blocs/create_snapshot/create_snapshot_cubit.dart b/lib/blocs/create_snapshot/create_snapshot_cubit.dart index 4c239d8f84..e0f4f615f8 100644 --- a/lib/blocs/create_snapshot/create_snapshot_cubit.dart +++ b/lib/blocs/create_snapshot/create_snapshot_cubit.dart @@ -425,16 +425,14 @@ class CreateSnapshotCubit extends Cubit { final profileState = _profileCubit.state as ProfileLoggedIn; final wallet = profileState.wallet; - final BigInt? fakeTurboCredits = appConfig.fakeTurboCredits; - /// necessary to wait for backend update the balance await Future.delayed(const Duration(seconds: 2)); - final BigInt turboBalance = fakeTurboCredits ?? + final BigInt turboBalance = await turboBalanceRetriever.getBalance(wallet).catchError((e) { - logger.e('Error while retrieving turbo balance', e); - return BigInt.zero; - }); + logger.e('Error while retrieving turbo balance', e); + return BigInt.zero; + }); logger.d('Balance after topping up: $turboBalance'); @@ -472,13 +470,11 @@ class CreateSnapshotCubit extends Cubit { final ProfileLoggedIn profileState = _profileCubit.state as ProfileLoggedIn; final Wallet wallet = profileState.wallet; - final BigInt? fakeTurboCredits = appConfig.fakeTurboCredits; - - final BigInt turboBalance = fakeTurboCredits ?? + final BigInt turboBalance = await turboBalanceRetriever.getBalance(wallet).catchError((e) { - logger.e('Error while retrieving turbo balance', e); - return BigInt.zero; - }); + logger.e('Error while retrieving turbo balance', e); + return BigInt.zero; + }); logger.d('Balance before topping up: $turboBalance'); @@ -507,10 +503,9 @@ class CreateSnapshotCubit extends Cubit { void _computeIsFreeThanksToTurbo() { final allowedDataItemSizeForTurbo = appConfig.allowedDataItemSizeForTurbo; - final forceNoFreeThanksToTurbo = appConfig.forceNoFreeThanksToTurbo; final isFreeThanksToTurbo = _snapshotEntity!.data!.length <= allowedDataItemSizeForTurbo; - _isFreeThanksToTurbo = isFreeThanksToTurbo && !forceNoFreeThanksToTurbo; + _isFreeThanksToTurbo = isFreeThanksToTurbo; } void setUploadMethod(UploadMethod method) { diff --git a/lib/blocs/fs_entry_preview/fs_entry_preview_cubit.dart b/lib/blocs/fs_entry_preview/fs_entry_preview_cubit.dart index aeea37ac17..2866156d43 100644 --- a/lib/blocs/fs_entry_preview/fs_entry_preview_cubit.dart +++ b/lib/blocs/fs_entry_preview/fs_entry_preview_cubit.dart @@ -325,36 +325,28 @@ class FsEntryPreviewCubit extends Cubit { void _previewAudio( bool isPrivate, FileDataTableItem selectedItem, previewUrl) { - if (_configService.config.enableAudioPreview) { - if (isPrivate) { - emit(FsEntryPreviewUnavailable()); - return; - } - - emit(FsEntryPreviewAudio( - filename: selectedItem.name, previewUrl: previewUrl)); - + if (isPrivate) { + emit(FsEntryPreviewUnavailable()); return; } - emit(FsEntryPreviewUnavailable()); + emit(FsEntryPreviewAudio( + filename: selectedItem.name, previewUrl: previewUrl)); + + return; } void _previewVideo( bool isPrivate, FileDataTableItem selectedItem, previewUrl) { - if (_configService.config.enableVideoPreview) { - if (isPrivate) { - emit(FsEntryPreviewUnavailable()); - return; - } - - emit(FsEntryPreviewVideo( - filename: selectedItem.name, previewUrl: previewUrl)); - + if (isPrivate) { + emit(FsEntryPreviewUnavailable()); return; } - emit(FsEntryPreviewUnavailable()); + emit(FsEntryPreviewVideo( + filename: selectedItem.name, previewUrl: previewUrl)); + + return; } Future _getBytesFromCache({ diff --git a/lib/blocs/upload/upload_cubit.dart b/lib/blocs/upload/upload_cubit.dart index 751bf01569..bb15e0d3f7 100644 --- a/lib/blocs/upload/upload_cubit.dart +++ b/lib/blocs/upload/upload_cubit.dart @@ -9,10 +9,11 @@ import 'package:ardrive/core/activity_tracker.dart'; import 'package:ardrive/core/upload/uploader.dart'; import 'package:ardrive/entities/file_entity.dart'; import 'package:ardrive/entities/folder_entity.dart'; -import 'package:ardrive/main.dart'; import 'package:ardrive/models/forms/cc.dart'; import 'package:ardrive/models/forms/udl.dart'; import 'package:ardrive/models/models.dart'; +import 'package:ardrive/services/config/config.dart'; +import 'package:ardrive/services/config/config_service.dart'; import 'package:ardrive/services/license/license.dart'; import 'package:ardrive/turbo/services/upload_service.dart'; import 'package:ardrive/utils/logger.dart'; @@ -49,12 +50,13 @@ class UploadCubit extends Cubit { final ArDriveAuth _auth; final ActivityTracker _activityTracker; final LicenseService _licenseService; + final ConfigService _configService; late bool uploadFolders; late Drive _targetDrive; late FolderEntry _targetFolder; UploadMethod? _uploadMethod; - bool _uploadThumbnail = true; + bool _uploadThumbnail; void changeUploadThumbnailOption(bool uploadThumbnail) { _uploadThumbnail = uploadThumbnail; @@ -204,6 +206,7 @@ class UploadCubit extends Cubit { required ArDriveUploadPreparationManager arDriveUploadManager, required ActivityTracker activityTracker, required LicenseService licenseService, + required ConfigService configService, this.folder, this.uploadFolders = false, this.isDragNDrop = false, @@ -214,6 +217,8 @@ class UploadCubit extends Cubit { _auth = auth, _activityTracker = activityTracker, _licenseService = licenseService, + _configService = configService, + _uploadThumbnail = configService.config.uploadThumbnails, super(UploadPreparationInProgress()); Future startUploadPreparation({ @@ -533,14 +538,14 @@ class UploadCubit extends Cubit { LicenseState? licenseStateConfigured, }) async { final ardriveUploader = ArDriveUploader( - turboUploadUri: Uri.parse(configService.config.defaultTurboUploadUrl!), + turboUploadUri: Uri.parse(_configService.config.defaultTurboUploadUrl!), metadataGenerator: ARFSUploadMetadataGenerator( tagsGenerator: ARFSTagsGenetator( appInfoServices: AppInfoServices(), ), ), arweave: Arweave( - gatewayUrl: Uri.parse(configService.config.defaultArweaveGatewayUrl!), + gatewayUrl: Uri.parse(_configService.config.defaultArweaveGatewayUrl!), ), pstService: _pst, ); @@ -674,14 +679,14 @@ class UploadCubit extends Cubit { LicenseState? licenseStateConfigured, }) async { final ardriveUploader = ArDriveUploader( - turboUploadUri: Uri.parse(configService.config.defaultTurboUploadUrl!), + turboUploadUri: Uri.parse(_configService.config.defaultTurboUploadUrl!), metadataGenerator: ARFSUploadMetadataGenerator( tagsGenerator: ARFSTagsGenetator( appInfoServices: AppInfoServices(), ), ), arweave: Arweave( - gatewayUrl: Uri.parse(configService.config.defaultArweaveGatewayUrl!), + gatewayUrl: Uri.parse(_configService.config.defaultArweaveGatewayUrl!), ), pstService: _pst, ); diff --git a/lib/components/app_top_bar.dart b/lib/components/app_top_bar.dart index e4468d2051..a4d974b000 100644 --- a/lib/components/app_top_bar.dart +++ b/lib/components/app_top_bar.dart @@ -5,7 +5,6 @@ import 'package:ardrive/pages/drive_detail/components/dropdown_item.dart'; import 'package:ardrive/pages/drive_detail/components/hover_widget.dart'; import 'package:ardrive/search/search_modal.dart'; import 'package:ardrive/search/search_text_field.dart'; -import 'package:ardrive/services/config/config.dart'; import 'package:ardrive/sync/domain/cubit/sync_cubit.dart'; import 'package:ardrive/utils/app_localizations_wrapper.dart'; import 'package:ardrive/utils/plausible_event_tracker/plausible_custom_event_properties.dart'; @@ -19,7 +18,6 @@ class AppTopBar extends StatelessWidget { @override Widget build(BuildContext context) { - final enableSearch = context.read().config.enableSearch; final controller = TextEditingController(); return SizedBox( @@ -31,24 +29,22 @@ class AppTopBar extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.end, children: [ - if (enableSearch) ...[ - Expanded( - child: ConstrainedBox( - constraints: const BoxConstraints(maxWidth: 400), - child: SearchTextField( - controller: controller, - onFieldSubmitted: (query) { - showSearchModalDesktop( - context: context, - driveDetailCubit: context.read(), - controller: controller, - ); - }, - ), + Expanded( + child: ConstrainedBox( + constraints: const BoxConstraints(maxWidth: 400), + child: SearchTextField( + controller: controller, + onFieldSubmitted: (query) { + showSearchModalDesktop( + context: context, + driveDetailCubit: context.read(), + controller: controller, + ); + }, ), ), - const SizedBox(width: 24), - ], + ), + const SizedBox(width: 24), const Spacer(), const SyncButton(), const SizedBox(width: 8), diff --git a/lib/components/new_button/new_button.dart b/lib/components/new_button/new_button.dart index 1b7147aad8..4da43b896d 100644 --- a/lib/components/new_button/new_button.dart +++ b/lib/components/new_button/new_button.dart @@ -10,7 +10,6 @@ import 'package:ardrive/models/daos/daos.dart'; import 'package:ardrive/models/database/database.dart'; import 'package:ardrive/models/enums.dart'; import 'package:ardrive/pages/drive_detail/components/dropdown_item.dart'; -import 'package:ardrive/services/services.dart'; import 'package:ardrive/utils/app_localizations_wrapper.dart'; import 'package:ardrive/utils/plausible_event_tracker/plausible_custom_event_properties.dart'; import 'package:ardrive/utils/plausible_event_tracker/plausible_event_tracker.dart'; @@ -346,19 +345,18 @@ class NewButton extends StatelessWidget { name: appLocalizations.createManifest, icon: ArDriveIcons.manifest(size: defaultIconSize), ), - if (context.read().config.enableQuickSyncAuthoring) - ArDriveNewButtonItem( - onClick: () { - promptToCreateSnapshot( - context, - drive!, - ); - }, - isDisabled: !driveDetailState.hasWritePermissions || - driveDetailState.driveIsEmpty, - name: appLocalizations.newSnapshot, - icon: ArDriveIcons.iconCreateSnapshot(size: defaultIconSize), - ), + ArDriveNewButtonItem( + onClick: () { + promptToCreateSnapshot( + context, + drive!, + ); + }, + isDisabled: !driveDetailState.hasWritePermissions || + driveDetailState.driveIsEmpty, + name: appLocalizations.newSnapshot, + icon: ArDriveIcons.iconCreateSnapshot(size: defaultIconSize), + ), ] ]; } diff --git a/lib/components/profile_card.dart b/lib/components/profile_card.dart index 32afa41fde..8a75e86615 100644 --- a/lib/components/profile_card.dart +++ b/lib/components/profile_card.dart @@ -9,9 +9,11 @@ import 'package:ardrive/gift/redeem_gift_modal.dart'; import 'package:ardrive/misc/resources.dart'; import 'package:ardrive/pages/drive_detail/components/hover_widget.dart'; import 'package:ardrive/services/arconnect/arconnect_wallet.dart'; +import 'package:ardrive/services/config/config.dart'; import 'package:ardrive/turbo/services/payment_service.dart'; import 'package:ardrive/turbo/topup/components/turbo_balance_widget.dart'; import 'package:ardrive/turbo/utils/utils.dart'; +import 'package:ardrive/user/download_wallet/download_wallet_modal.dart'; import 'package:ardrive/utils/app_localizations_wrapper.dart'; import 'package:ardrive/utils/open_url.dart'; import 'package:ardrive/utils/open_url_utils.dart'; @@ -244,6 +246,80 @@ class _ProfileCardState extends State { ], ), const SizedBox(height: 8), + ArDriveAccordion(backgroundColor: Colors.transparent, children: [ + ArDriveAccordionItem( + Text( + 'Advanced', + style: typography.paragraphNormal( + fontWeight: ArFontWeight.semiBold, + ), + ), + [ + const SizedBox(height: 8), + Padding( + padding: const EdgeInsets.only(left: 30.0), + child: ArDriveToggleSwitch( + value: context + .read() + .config + .enableSyncFromSnapshot, + text: 'Sync From Snapshots', + textStyle: typography.paragraphNormal( + fontWeight: ArFontWeight.semiBold, + ), + onChanged: (value) { + final config = context.read().config; + context.read().updateAppConfig( + config.copyWith( + enableSyncFromSnapshot: value, + ), + ); + }, + ), + ), + const SizedBox(height: 8), + Padding( + padding: const EdgeInsets.only(left: 30.0), + child: ArDriveToggleSwitch( + value: context.read().config.autoSync, + text: 'Auto Sync', + textStyle: typography.paragraphNormal( + fontWeight: ArFontWeight.semiBold, + ), + onChanged: (value) { + final config = context.read().config; + context.read().updateAppConfig( + config.copyWith( + autoSync: value, + ), + ); + }, + ), + ), + const SizedBox(height: 8), + Padding( + padding: const EdgeInsets.only(left: 30.0), + child: ArDriveToggleSwitch( + value: + context.read().config.uploadThumbnails, + text: 'Upload Thumbnails', + textStyle: typography.paragraphNormal( + fontWeight: ArFontWeight.semiBold, + ), + onChanged: (value) { + final config = context.read().config; + context.read().updateAppConfig( + config.copyWith( + uploadThumbnails: value, + ), + ); + }, + ), + ), + ], + ), + ]), + const SizedBox(height: 8), Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0), child: Row( @@ -297,7 +373,12 @@ class _ProfileCardState extends State { const Spacer(), ArDriveIconButton( icon: ArDriveIcons.download( - color: colorTokens.textHigh, size: 21), + color: colorTokens.textHigh, + size: 21, + ), + onPressed: () { + showDownloadWalletModal(context); + }, ), CopyButton( size: 21, diff --git a/lib/components/side_bar.dart b/lib/components/side_bar.dart index fb520d2044..ebabbf9a6d 100644 --- a/lib/components/side_bar.dart +++ b/lib/components/side_bar.dart @@ -5,7 +5,6 @@ import 'package:ardrive/blocs/drives/drives_cubit.dart'; import 'package:ardrive/blocs/profile/profile_cubit.dart'; import 'package:ardrive/components/app_version_widget.dart'; import 'package:ardrive/components/new_button/new_button.dart'; -import 'package:ardrive/components/theme_switcher.dart'; import 'package:ardrive/dev_tools/app_dev_tools.dart'; import 'package:ardrive/main.dart'; import 'package:ardrive/misc/resources.dart'; @@ -375,7 +374,6 @@ class _AppSideBarState extends State { const Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - ThemeSwitcher(), SizedBox( height: 8, ), diff --git a/lib/components/upload_form.dart b/lib/components/upload_form.dart index 7e19026d14..ff2a67d7ba 100644 --- a/lib/components/upload_form.dart +++ b/lib/components/upload_form.dart @@ -170,6 +170,7 @@ Future promptToUpload( uploadFolders: isFolderUpload, auth: context.read(), licenseService: context.read(), + configService: context.read(), )..startUploadPreparation(), ), BlocProvider( @@ -485,7 +486,10 @@ class _UploadFormState extends State { children: [ ArDriveCheckBox( title: 'Upload with thumbnails', - checked: true, + checked: context + .read() + .config + .uploadThumbnails, titleStyle: typography.paragraphLarge( fontWeight: ArFontWeight.semiBold, ), diff --git a/lib/dev_tools/app_dev_tools.dart b/lib/dev_tools/app_dev_tools.dart index cee604c94e..3c50dbfc25 100644 --- a/lib/dev_tools/app_dev_tools.dart +++ b/lib/dev_tools/app_dev_tools.dart @@ -1,10 +1,8 @@ import 'dart:convert'; import 'package:ardrive/dev_tools/drives_health_check.dart'; -import 'package:ardrive/dev_tools/thumbnail_generator_poc.dart'; import 'package:ardrive/main.dart'; import 'package:ardrive/services/config/config.dart'; -import 'package:ardrive/turbo/topup/blocs/payment_form/payment_form_bloc.dart'; import 'package:ardrive/utils/logger.dart'; import 'package:ardrive/utils/show_general_dialog.dart'; import 'package:ardrive_ui/ardrive_ui.dart'; @@ -97,8 +95,6 @@ class AppConfigWindowManager extends StatefulWidget { class AppConfigWindowManagerState extends State { final _windowTitle = ValueNotifier('Dev Tools'); - final _devTools = ArDriveDevTools.instance; - @override Widget build(BuildContext context) { final ConfigService configService = context.read(); @@ -184,60 +180,6 @@ class AppConfigWindowManagerState extends State { type: ArDriveDevToolOptionType.number, ); - final ArDriveDevToolOption enableQuickSyncAuthoringOption = - ArDriveDevToolOption( - name: 'enableQuickSyncAuthoring', - value: config.enableQuickSyncAuthoring, - onChange: (value) { - setState(() { - configService.updateAppConfig( - config.copyWith(enableQuickSyncAuthoring: value), - ); - }); - }, - type: ArDriveDevToolOptionType.bool, - ); - - final ArDriveDevToolOption enableMultipleFileDownloadOption = - ArDriveDevToolOption( - name: 'enableMultipleFileDownload', - value: config.enableMultipleFileDownload, - onChange: (value) { - setState(() { - configService.updateAppConfig( - config.copyWith(enableMultipleFileDownload: value), - ); - }); - }, - type: ArDriveDevToolOptionType.bool, - ); - - final ArDriveDevToolOption enableVideoPreviewOption = ArDriveDevToolOption( - name: 'enableVideoPreview', - value: config.enableVideoPreview, - onChange: (value) { - setState(() { - configService.updateAppConfig( - config.copyWith(enableVideoPreview: value), - ); - }); - }, - type: ArDriveDevToolOptionType.bool, - ); - - final ArDriveDevToolOption enableAudioPreviewOption = ArDriveDevToolOption( - name: 'enableAudioPreview', - value: config.enableAudioPreview, - onChange: (value) { - setState(() { - configService.updateAppConfig( - config.copyWith(enableAudioPreview: value), - ); - }); - }, - type: ArDriveDevToolOptionType.bool, - ); - final ArDriveDevToolOption autoSyncIntervalInSecondsOption = ArDriveDevToolOption( name: 'autoSyncIntervalInSeconds', @@ -301,100 +243,16 @@ class AppConfigWindowManagerState extends State { type: ArDriveDevToolOptionType.bool, ); - final ArDriveDevToolOption enableSeedPhreaseLogin = ArDriveDevToolOption( - name: 'enableSeedPhreaseLogin', - value: config.enableSeedPhraseLogin, - onChange: (value) { - setState(() { - configService.updateAppConfig( - config.copyWith(enableSeedPhraseLogin: value), - ); - }); - }, - type: ArDriveDevToolOptionType.bool, - ); - - // reload option - final ArDriveDevToolOption turboSetDefaultData = ArDriveDevToolOption( - name: 'setDefaultDataOnPaymentForm', - value: '', - onChange: (value) {}, - onInteraction: () { - try { - _devTools.context - ?.read() - .add(PaymentFormPrePopulateFields()); - } catch (e) { - logger.e('Error setting default data on payment form', e); - } - }, - type: ArDriveDevToolOptionType.button, - ); - - final ArDriveDevToolOption pickImageAndGenerateThumbnailItem = - ArDriveDevToolOption( - name: 'Generate Thumbnails', - value: '', - onChange: (value) {}, - onInteraction: () async { - try { - final BuildContext context = ArDriveDevTools().context!; - - showArDriveDialog(context, - content: - const ArDriveStandardModal(content: ThumbnailGeneratorPOC())); - } catch (e) { - logger.e('Error setting default data on payment form', e); - } - }, - type: ArDriveDevToolOptionType.button, - ); - - final ArDriveDevToolOption forceNoFreeThanksToTurbo = ArDriveDevToolOption( - name: 'forceNoFreeThanksToTurbo', - value: config.forceNoFreeThanksToTurbo, - onChange: (value) { - setState(() { - configService.updateAppConfig( - config.copyWith(forceNoFreeThanksToTurbo: value), - ); - }); - }, - type: ArDriveDevToolOptionType.bool, - ); - - final ArDriveDevToolOption topUpDryRun = ArDriveDevToolOption( - name: 'topUpDryRun', - value: config.topUpDryRun, - onChange: (value) { - setState(() { - configService.updateAppConfig( - config.copyWith(topUpDryRun: value), - ); - }); - }, - type: ArDriveDevToolOptionType.bool, - ); - final List options = [ runHealthCheck, useTurboOption, useTurboPaymentOption, enableSyncFromSnapshotOption, - pickImageAndGenerateThumbnailItem, stripePublishableKey, - enableQuickSyncAuthoringOption, - enableMultipleFileDownloadOption, - enableVideoPreviewOption, - enableAudioPreviewOption, - enableSeedPhreaseLogin, allowedDataItemSizeForTurboOption, defaultArweaveGatewayUrlOption, defaultTurboUrlOption, autoSyncIntervalInSecondsOption, - turboSetDefaultData, - forceNoFreeThanksToTurbo, - topUpDryRun, reloadOption, resetOptions, ]; diff --git a/lib/pages/drive_detail/drive_detail_page.dart b/lib/pages/drive_detail/drive_detail_page.dart index 2552644c22..1c7f228698 100644 --- a/lib/pages/drive_detail/drive_detail_page.dart +++ b/lib/pages/drive_detail/drive_detail_page.dart @@ -374,11 +374,7 @@ class _DriveDetailPageState extends State { ), ], const SizedBox(width: 8), - if (canDownloadMultipleFiles && - context - .read() - .config - .enableMultipleFileDownload) ...[ + if (canDownloadMultipleFiles) ...[ ArDriveIconButton( tooltip: 'Download selected files', icon: ArDriveIcons.download(), diff --git a/lib/services/config/app_config.dart b/lib/services/config/app_config.dart index b608f6268d..d1ce054468 100644 --- a/lib/services/config/app_config.dart +++ b/lib/services/config/app_config.dart @@ -11,19 +11,11 @@ class AppConfig { final String? defaultTurboUploadUrl; final String? defaultTurboPaymentUrl; final int allowedDataItemSizeForTurbo; - final bool enableQuickSyncAuthoring; - final bool enableMultipleFileDownload; - final bool enableVideoPreview; - final bool enableAudioPreview; final int autoSyncIntervalInSeconds; final bool enableSyncFromSnapshot; - final bool enableSeedPhraseLogin; final String stripePublishableKey; - final bool forceNoFreeThanksToTurbo; - final BigInt? fakeTurboCredits; - final bool topUpDryRun; - final bool enableMetamaskLogin; - final bool enableSearch; + final bool autoSync; + final bool uploadThumbnails; AppConfig({ this.defaultArweaveGatewayUrl, @@ -32,19 +24,11 @@ class AppConfig { this.defaultTurboUploadUrl, this.defaultTurboPaymentUrl, required this.allowedDataItemSizeForTurbo, - this.enableQuickSyncAuthoring = false, - this.enableMultipleFileDownload = false, - this.enableVideoPreview = false, - this.enableAudioPreview = false, this.autoSyncIntervalInSeconds = 5 * 60, this.enableSyncFromSnapshot = true, - this.enableSeedPhraseLogin = true, required this.stripePublishableKey, - this.forceNoFreeThanksToTurbo = false, - this.fakeTurboCredits, - this.topUpDryRun = false, - this.enableMetamaskLogin = false, - this.enableSearch = false, + this.autoSync = true, + this.uploadThumbnails = true, }); AppConfig copyWith({ @@ -54,26 +38,12 @@ class AppConfig { String? defaultTurboUploadUrl, String? defaultTurboPaymentUrl, int? allowedDataItemSizeForTurbo, - bool? enableQuickSyncAuthoring, - bool? enableMultipleFileDownload, - bool? enableVideoPreview, - bool? enableAudioPreview, int? autoSyncIntervalInSeconds, bool? enableSyncFromSnapshot, - bool? enableSeedPhraseLogin, String? stripePublishableKey, - bool? useNewUploader, - bool? forceNoFreeThanksToTurbo, - BigInt? fakeTurboCredits, - bool? topUpDryRun, - bool? unsetFakeTurboCredits, - bool? enableMetamaskLogin, - bool? enableSearch, + bool? autoSync, + bool? uploadThumbnails, }) { - final theFakeTurboCredits = unsetFakeTurboCredits == true - ? null - : fakeTurboCredits ?? this.fakeTurboCredits; - return AppConfig( defaultArweaveGatewayUrl: defaultArweaveGatewayUrl ?? this.defaultArweaveGatewayUrl, @@ -85,25 +55,13 @@ class AppConfig { defaultTurboPaymentUrl ?? this.defaultTurboPaymentUrl, allowedDataItemSizeForTurbo: allowedDataItemSizeForTurbo ?? this.allowedDataItemSizeForTurbo, - enableMultipleFileDownload: - enableMultipleFileDownload ?? this.enableMultipleFileDownload, - enableQuickSyncAuthoring: - enableQuickSyncAuthoring ?? this.enableQuickSyncAuthoring, - enableVideoPreview: enableVideoPreview ?? this.enableVideoPreview, - enableAudioPreview: enableAudioPreview ?? this.enableAudioPreview, autoSyncIntervalInSeconds: autoSyncIntervalInSeconds ?? this.autoSyncIntervalInSeconds, enableSyncFromSnapshot: enableSyncFromSnapshot ?? this.enableSyncFromSnapshot, - enableSeedPhraseLogin: - enableSeedPhraseLogin ?? this.enableSeedPhraseLogin, stripePublishableKey: stripePublishableKey ?? this.stripePublishableKey, - forceNoFreeThanksToTurbo: - forceNoFreeThanksToTurbo ?? this.forceNoFreeThanksToTurbo, - fakeTurboCredits: theFakeTurboCredits, - topUpDryRun: topUpDryRun ?? this.topUpDryRun, - enableMetamaskLogin: enableMetamaskLogin ?? this.enableMetamaskLogin, - enableSearch: enableSearch ?? this.enableSearch, + autoSync: autoSync ?? this.autoSync, + uploadThumbnails: uploadThumbnails ?? this.uploadThumbnails, ); } diff --git a/lib/services/config/config_fetcher.dart b/lib/services/config/config_fetcher.dart index d7d915b2d2..a3e072ae0c 100644 --- a/lib/services/config/config_fetcher.dart +++ b/lib/services/config/config_fetcher.dart @@ -29,13 +29,8 @@ class ConfigFetcher { AppConfig configFromEnv = AppConfig.fromJson(json.decode(configContent)); final gatewayUrl = localStore.getString('arweaveGatewayUrl'); - final enableQuickSyncAuthoring = - localStore.getBool('enableQuickSyncAuthoring'); - return configFromEnv.copyWith( - defaultArweaveGatewayUrl: gatewayUrl, - enableQuickSyncAuthoring: enableQuickSyncAuthoring, - ); + return configFromEnv.copyWith(defaultArweaveGatewayUrl: gatewayUrl); } @visibleForTesting diff --git a/lib/sync/domain/cubit/sync_cubit.dart b/lib/sync/domain/cubit/sync_cubit.dart index f7afbf3eb0..9282907dee 100644 --- a/lib/sync/domain/cubit/sync_cubit.dart +++ b/lib/sync/domain/cubit/sync_cubit.dart @@ -87,8 +87,12 @@ class SyncCubit extends Cubit { _syncSub = Stream.periodic( Duration(seconds: _configService.config.autoSyncIntervalInSeconds)) // Do not start another sync until the previous sync has completed. - .map((value) => Stream.fromFuture(startSync())) - .listen((_) { + .map((value) { + /// Only start sync if autoSync is enabled. + if (_configService.config.autoSync) { + return Stream.fromFuture(startSync()); + } + }).listen((_) { logger.d('Listening to startSync periodic stream'); }); @@ -120,7 +124,8 @@ class SyncCubit extends Cubit { /// This delay is for don't abruptly open the modal when the user is back /// to ArDrive browser tab Future.delayed(const Duration(seconds: 2)).then((value) { - createSyncStream(); + /// Only restart sync if autoSync is enabled. + if (_configService.config.autoSync) createSyncStream(); }); } @@ -131,8 +136,12 @@ class SyncCubit extends Cubit { _arconnectSyncSub = Stream.periodic( const Duration(minutes: kArConnectSyncTimerDuration)) // Do not start another sync until the previous sync has completed. - .map((value) => Stream.fromFuture(arconnectSync())) - .listen((_) {}); + .map((value) { + /// Only start sync if autoSync is enabled. + if (_configService.config.autoSync) { + return Stream.fromFuture(arconnectSync()); + } + }).listen((_) {}); arconnectSync(); } }); diff --git a/lib/turbo/topup/blocs/payment_review/payment_review_bloc.dart b/lib/turbo/topup/blocs/payment_review/payment_review_bloc.dart index ba58db6cc8..52af6fb3b1 100644 --- a/lib/turbo/topup/blocs/payment_review/payment_review_bloc.dart +++ b/lib/turbo/topup/blocs/payment_review/payment_review_bloc.dart @@ -47,9 +47,7 @@ class PaymentReviewBloc extends Bloc { userAcceptedToReceiveEmails: event.userAcceptedToReceiveEmails, ); - final paymentStatus = await turbo.confirmPayment( - dryRun: event.dryRun, - ); + final paymentStatus = await turbo.confirmPayment(); if (paymentStatus == PaymentStatus.success) { _emitPaymentSuccess(emit); diff --git a/lib/turbo/topup/blocs/payment_review/payment_review_event.dart b/lib/turbo/topup/blocs/payment_review/payment_review_event.dart index 97ac2d813c..e5abbd7285 100644 --- a/lib/turbo/topup/blocs/payment_review/payment_review_event.dart +++ b/lib/turbo/topup/blocs/payment_review/payment_review_event.dart @@ -10,12 +10,10 @@ abstract class PaymentReviewEvent extends Equatable { class PaymentReviewFinishPayment extends PaymentReviewEvent { final String? email; final bool userAcceptedToReceiveEmails; - final bool dryRun; const PaymentReviewFinishPayment({ this.email, this.userAcceptedToReceiveEmails = false, - this.dryRun = false, }); @override diff --git a/lib/turbo/topup/views/topup_modal.dart b/lib/turbo/topup/views/topup_modal.dart index 75616d40c8..15de0defe3 100644 --- a/lib/turbo/topup/views/topup_modal.dart +++ b/lib/turbo/topup/views/topup_modal.dart @@ -80,10 +80,7 @@ void showTurboTopupModal(BuildContext context, {Function()? onSuccess}) { )..add(LoadInitialData()), ), ], - child: TurboModal( - parentContext: modalContext, - appConfig: appConfig, - ), + child: TurboModal(parentContext: modalContext), ), barrierDismissible: false, barrierColor: @@ -110,14 +107,12 @@ void showTurboTopupModal(BuildContext context, {Function()? onSuccess}) { } class TurboModal extends StatefulWidget { - final AppConfig _appConfig; final BuildContext parentContext; const TurboModal({ super.key, required this.parentContext, - required AppConfig appConfig, - }) : _appConfig = appConfig; + }); @override State createState() => _TurboModalState(); @@ -232,9 +227,7 @@ class _TurboModalState extends State with TickerProviderStateMixin { child: Container( color: ArDriveTheme.of(context).themeData.colors.themeBgCanvas, - child: TurboReviewView( - dryRun: widget._appConfig.topUpDryRun, - ), + child: const TurboReviewView(), ), ), ], diff --git a/lib/turbo/topup/views/topup_review_view.dart b/lib/turbo/topup/views/topup_review_view.dart index 0d858fee9b..4be6c0ec06 100644 --- a/lib/turbo/topup/views/topup_review_view.dart +++ b/lib/turbo/topup/views/topup_review_view.dart @@ -17,11 +17,7 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:responsive_builder/responsive_builder.dart'; class TurboReviewView extends StatefulWidget { - final bool dryRun; - const TurboReviewView({ - super.key, - required this.dryRun, - }); + const TurboReviewView({super.key}); @override State createState() => _TurboReviewViewState(); @@ -617,7 +613,6 @@ class _TurboReviewViewState extends State { PaymentReviewFinishPayment( email: _emailController.text, userAcceptedToReceiveEmails: _emailChecked, - dryRun: widget.dryRun, ), ); }, @@ -651,7 +646,6 @@ class _TurboReviewViewState extends State { PaymentReviewFinishPayment( email: _emailController.text, userAcceptedToReceiveEmails: _emailChecked, - dryRun: widget.dryRun, ), ); }, @@ -738,7 +732,6 @@ class _TurboReviewViewState extends State { PaymentReviewFinishPayment( email: _emailController.text, userAcceptedToReceiveEmails: _emailChecked, - dryRun: widget.dryRun, ), ); }, @@ -772,7 +765,6 @@ class _TurboReviewViewState extends State { PaymentReviewFinishPayment( email: _emailController.text, userAcceptedToReceiveEmails: _emailChecked, - dryRun: widget.dryRun, ), ); }, diff --git a/lib/turbo/turbo.dart b/lib/turbo/turbo.dart index 06ee0a259f..d2a46941a9 100644 --- a/lib/turbo/turbo.dart +++ b/lib/turbo/turbo.dart @@ -182,20 +182,12 @@ class Turbo extends Disposable { return _currentPaymentIntent!; } - Future confirmPayment({ - bool dryRun = false, - }) async { + Future confirmPayment() async { if (_currentPaymentIntent == null) { throw Exception( 'Current payment intent is null. You should create it before calling this method.'); } - if (dryRun) { - logger.d('Confirming payment with dry run'); - _paymentStatus = PaymentStatus.success; - return _paymentStatus!; - } - logger.d('Confirming payment with payment provider'); _paymentStatus = await _paymentProvider.confirmPayment( paymentUserInformation: paymentUserInformation, diff --git a/test/authentication/login/blocs/login_bloc_test.dart b/test/authentication/login/blocs/login_bloc_test.dart index 6ae91c5645..9bc21f5417 100644 --- a/test/authentication/login/blocs/login_bloc_test.dart +++ b/test/authentication/login/blocs/login_bloc_test.dart @@ -21,7 +21,6 @@ void main() { late EthereumProviderService mockEthereumProviderService; late UserRepository mockUserRepository; late TurboUploadService mockTurboUploadService; - late ConfigService mockConfigService; late DownloadService mockDownloadService; late ArweaveService mockArweaveService; @@ -33,14 +32,14 @@ void main() { LoginBloc createBloc() { return LoginBloc( - arDriveAuth: mockArDriveAuth, - arConnectService: mockArConnectService, - ethereumProviderService: mockEthereumProviderService, - turboUploadService: mockTurboUploadService, - arweaveService: mockArweaveService, - downloadService: mockDownloadService, - userRepository: mockUserRepository, - configService: mockConfigService); + arDriveAuth: mockArDriveAuth, + arConnectService: mockArConnectService, + ethereumProviderService: mockEthereumProviderService, + turboUploadService: mockTurboUploadService, + arweaveService: mockArweaveService, + downloadService: mockDownloadService, + userRepository: mockUserRepository, + ); } setUp(() { @@ -51,7 +50,6 @@ void main() { mockUserRepository = MockUserRepository(); mockDownloadService = MockDownloadService(); mockArweaveService = MockArweaveService(); - mockConfigService = MockConfigService(); }); group('AddWalletFile', () { @@ -71,7 +69,6 @@ void main() { arweaveService: mockArweaveService, downloadService: mockDownloadService, userRepository: mockUserRepository, - configService: mockConfigService, ); }, setUp: () { @@ -106,7 +103,6 @@ void main() { arweaveService: mockArweaveService, downloadService: mockDownloadService, userRepository: mockUserRepository, - configService: mockConfigService, ); }, setUp: () { @@ -143,7 +139,6 @@ void main() { arweaveService: mockArweaveService, downloadService: mockDownloadService, userRepository: mockUserRepository, - configService: mockConfigService, ); }, setUp: () { @@ -248,7 +243,6 @@ void main() { arweaveService: mockArweaveService, downloadService: mockDownloadService, userRepository: mockUserRepository, - configService: mockConfigService, ); }, setUp: () { diff --git a/test/blocs/create_snapshot_cubit_test.dart b/test/blocs/create_snapshot_cubit_test.dart index d95d2006b4..d764df0f23 100644 --- a/test/blocs/create_snapshot_cubit_test.dart +++ b/test/blocs/create_snapshot_cubit_test.dart @@ -216,11 +216,6 @@ void main() { when(() => appConfig.allowedDataItemSizeForTurbo) .thenAnswer((invocation) => 100); when(() => appConfig.useTurboUpload).thenAnswer((invocation) => true); - when(() => appConfig.forceNoFreeThanksToTurbo) - .thenAnswer((invocation) => false); - when(() => appConfig.fakeTurboCredits).thenAnswer((invocation) => null); - when(() => appConfig.topUpDryRun).thenAnswer((invocation) => false); - when(() => configService.config).thenAnswer((invocation) => appConfig); when(() => tabVisibility.isTabFocused()) diff --git a/test/blocs/upload_cubit_test.dart b/test/blocs/upload_cubit_test.dart index c0212d1792..26bf56a601 100644 --- a/test/blocs/upload_cubit_test.dart +++ b/test/blocs/upload_cubit_test.dart @@ -12,6 +12,7 @@ import 'package:ardrive/core/upload/uploader.dart'; import 'package:ardrive/entities/profile_types.dart'; import 'package:ardrive/models/daos/drive_dao/drive_dao.dart'; import 'package:ardrive/models/database/database.dart'; +import 'package:ardrive/services/services.dart'; import 'package:ardrive/turbo/services/upload_service.dart'; import 'package:ardrive/turbo/turbo.dart'; import 'package:ardrive/user/user.dart'; @@ -68,6 +69,7 @@ void main() { late MockTurboUploadCostCalculator mockTurboUploadCostCalculator; late MockArDriveUploadPreparationManager mockArDriveUploadPreparationManager; late MockLicenseService mockLicense; + late MockConfigService mockConfigService; const tDriveId = 'drive_id'; const tRootFolderId = 'root-folder-id'; @@ -93,8 +95,15 @@ void main() { final tKeyBytes = Uint8List(32); fillBytesWithSecureRandom(tKeyBytes); + mockConfigService = MockConfigService(); setUpAll(() async { + when(() => mockConfigService.config).thenReturn(AppConfig( + allowedDataItemSizeForTurbo: 1, + stripePublishableKey: 'stripePublishableKey', + defaultTurboUploadUrl: 'defaultTurboUploadUrl', + )); + registerFallbackValue(SecretKey([])); registerFallbackValue(Wallet()); registerFallbackValue(getFakeUser()); @@ -256,6 +265,7 @@ void main() { auth: mockArDriveAuth, pst: mockPst, licenseService: mockLicense, + configService: mockConfigService, ); } diff --git a/test/core/upload/uploader_test.dart b/test/core/upload/uploader_test.dart index a2de2c953f..739223fa42 100644 --- a/test/core/upload/uploader_test.dart +++ b/test/core/upload/uploader_test.dart @@ -46,8 +46,6 @@ class MockArDriveAuth extends Mock implements ArDriveAuth {} class MockSizeUtils extends Mock implements SizeUtils {} -class MockConfigService extends Mock implements ConfigService {} - class MockUploadPlan extends Mock implements UploadPlan {} class MockUploadPaymentInfo extends Mock implements UploadPaymentInfo {} diff --git a/test/services/config/config_fetcher_test.dart b/test/services/config/config_fetcher_test.dart index 94977f39c3..87071c4c1f 100644 --- a/test/services/config/config_fetcher_test.dart +++ b/test/services/config/config_fetcher_test.dart @@ -30,7 +30,6 @@ void main() { allowedDataItemSizeForTurbo: 100, stripePublishableKey: 'stripeKey', defaultArweaveGatewayUrl: 'devGatewayUrl', - enableQuickSyncAuthoring: false, )..toJson()); group('fetchConfig', () { @@ -46,7 +45,6 @@ void main() { expect(result, isInstanceOf()); expect(result.defaultArweaveGatewayUrl, equals('gatewayUrl')); - expect(result.enableQuickSyncAuthoring, equals(true)); }); test('returns the dev config when flavor is dev', () async { @@ -56,7 +54,6 @@ void main() { expect(result, isInstanceOf()); expect(result.defaultArweaveGatewayUrl, equals('devGatewayUrl')); - expect(result.enableQuickSyncAuthoring, equals(false)); }); test('returns the staging config when flavor is destagingv', () async { @@ -67,7 +64,6 @@ void main() { expect(result, isInstanceOf()); expect(result.defaultArweaveGatewayUrl, equals('devGatewayUrl')); - expect(result.enableQuickSyncAuthoring, equals(false)); }); test( 'returns the dev config when flavor is dev from env when there is no previous dev config saved on dev tools', @@ -85,7 +81,6 @@ void main() { expect(result, isInstanceOf()); expect(result.defaultArweaveGatewayUrl, equals('https://arweave.net')); - expect(result.enableQuickSyncAuthoring, equals(true)); }); }); @@ -98,7 +93,6 @@ void main() { expect(result, isInstanceOf()); expect(result.defaultArweaveGatewayUrl, equals('devGatewayUrl')); - expect(result.enableQuickSyncAuthoring, equals(false)); }); test('loads config from env and saves to local storage if not present', @@ -118,7 +112,6 @@ void main() { expect(result, isInstanceOf()); expect(result.defaultArweaveGatewayUrl, equals('gatewayUrl')); - expect(result.enableQuickSyncAuthoring, equals(true)); verify(() => localStore.putString('config', any())).called(1); }); @@ -140,7 +133,6 @@ void main() { expect(result, isInstanceOf()); expect(result.defaultArweaveGatewayUrl, equals('gatewayUrl')); - expect(result.enableQuickSyncAuthoring, equals(true)); verify(() => localStore.putString('config', any())).called(1); }); }); @@ -149,7 +141,6 @@ void main() { test('saves the config to local storage', () { final config = AppConfig( stripePublishableKey: '', - enableQuickSyncAuthoring: false, defaultArweaveGatewayUrl: '', allowedDataItemSizeForTurbo: 100, ); From c88187d20d299a751ea777028850715616e402e9 Mon Sep 17 00:00:00 2001 From: Thiago Carvalho <32248947+thiagocarvalhodev@users.noreply.github.com> Date: Wed, 31 Jul 2024 10:51:36 -0300 Subject: [PATCH 05/11] fix lint --- lib/authentication/login/blocs/login_bloc.dart | 4 ---- lib/authentication/login/views/login_page.dart | 2 -- test/authentication/login/blocs/login_bloc_test.dart | 7 ------- 3 files changed, 13 deletions(-) diff --git a/lib/authentication/login/blocs/login_bloc.dart b/lib/authentication/login/blocs/login_bloc.dart index a96b282d57..d481619321 100644 --- a/lib/authentication/login/blocs/login_bloc.dart +++ b/lib/authentication/login/blocs/login_bloc.dart @@ -12,7 +12,6 @@ import 'package:ardrive/entities/profile_types.dart'; import 'package:ardrive/services/arconnect/arconnect.dart'; import 'package:ardrive/services/arconnect/arconnect_wallet.dart'; import 'package:ardrive/services/arweave/arweave_service.dart'; -import 'package:ardrive/services/config/config_service.dart'; import 'package:ardrive/services/ethereum/ethereum_wallet.dart'; import 'package:ardrive/services/ethereum/provider/ethereum_provider.dart'; import 'package:ardrive/services/ethereum/provider/ethereum_provider_wallet.dart'; @@ -40,7 +39,6 @@ class LoginBloc extends Bloc { final TurboUploadService _turboUploadService; final ArweaveService _arweaveService; final DownloadService _downloadService; - final ConfigService _configService; final ProfileCubit _profileCubit; bool ignoreNextWaletSwitch = false; @@ -62,7 +60,6 @@ class LoginBloc extends Bloc { required ArweaveService arweaveService, required DownloadService downloadService, required UserRepository userRepository, - required ConfigService configService, required ProfileCubit profileCubit, }) : _arDriveAuth = arDriveAuth, _arConnectService = arConnectService, @@ -70,7 +67,6 @@ class LoginBloc extends Bloc { _arweaveService = arweaveService, _turboUploadService = turboUploadService, _downloadService = downloadService, - _configService = configService, _profileCubit = profileCubit, super(LoginLoading()) { on(_onLoginEvent); diff --git a/lib/authentication/login/views/login_page.dart b/lib/authentication/login/views/login_page.dart index fff781ca61..5aa85fb852 100644 --- a/lib/authentication/login/views/login_page.dart +++ b/lib/authentication/login/views/login_page.dart @@ -14,7 +14,6 @@ import 'package:ardrive/services/arconnect/arconnect.dart'; import 'package:ardrive/services/arweave/arweave_service.dart'; import 'package:ardrive/services/authentication/biometric_authentication.dart'; import 'package:ardrive/services/authentication/biometric_permission_dialog.dart'; -import 'package:ardrive/services/config/config_service.dart'; import 'package:ardrive/services/ethereum/provider/ethereum_provider.dart'; import 'package:ardrive/turbo/services/upload_service.dart'; import 'package:ardrive/user/repositories/user_repository.dart'; @@ -71,7 +70,6 @@ class _LoginPageState extends State { downloadService: downloadService, arDriveAuth: context.read(), userRepository: context.read(), - configService: context.read(), profileCubit: context.read(), )..add( CheckIfUserIsLoggedIn( diff --git a/test/authentication/login/blocs/login_bloc_test.dart b/test/authentication/login/blocs/login_bloc_test.dart index 2c28a52e09..0fae361e90 100644 --- a/test/authentication/login/blocs/login_bloc_test.dart +++ b/test/authentication/login/blocs/login_bloc_test.dart @@ -26,7 +26,6 @@ void main() { late DownloadService mockDownloadService; late ArweaveService mockArweaveService; late ProfileCubit mockProfileCubit; - late ConfigService mockConfigService; final wallet = getTestWallet(); @@ -42,7 +41,6 @@ void main() { arweaveService: mockArweaveService, downloadService: mockDownloadService, userRepository: mockUserRepository, - configService: mockConfigService, profileCubit: mockProfileCubit, ); } @@ -55,7 +53,6 @@ void main() { mockUserRepository = MockUserRepository(); mockDownloadService = MockDownloadService(); mockArweaveService = MockArweaveService(); - mockConfigService = MockConfigService(); mockProfileCubit = MockProfileCubit(); }); @@ -76,7 +73,6 @@ void main() { arweaveService: mockArweaveService, downloadService: mockDownloadService, userRepository: mockUserRepository, - configService: mockConfigService, profileCubit: mockProfileCubit, ); }, @@ -112,7 +108,6 @@ void main() { arweaveService: mockArweaveService, downloadService: mockDownloadService, userRepository: mockUserRepository, - configService: mockConfigService, profileCubit: mockProfileCubit, ); }, @@ -150,7 +145,6 @@ void main() { arweaveService: mockArweaveService, downloadService: mockDownloadService, userRepository: mockUserRepository, - configService: mockConfigService, profileCubit: mockProfileCubit, ); }, @@ -256,7 +250,6 @@ void main() { arweaveService: mockArweaveService, downloadService: mockDownloadService, userRepository: mockUserRepository, - configService: mockConfigService, profileCubit: mockProfileCubit, ); }, From db1907d045f151daeeba0acca87c670fd5a2c831 Mon Sep 17 00:00:00 2001 From: Thiago Carvalho <32248947+thiagocarvalhodev@users.noreply.github.com> Date: Fri, 2 Aug 2024 09:59:21 -0300 Subject: [PATCH 06/11] align toggle --- lib/components/profile_card.dart | 42 +++++++++++-------- .../lib/src/components/toggle_switch.dart | 24 +++++++---- 2 files changed, 39 insertions(+), 27 deletions(-) diff --git a/lib/components/profile_card.dart b/lib/components/profile_card.dart index 8a75e86615..5eef794966 100644 --- a/lib/components/profile_card.dart +++ b/lib/components/profile_card.dart @@ -112,6 +112,7 @@ class _ProfileCardState extends State { required bool isMobile, }) { final typography = ArDriveTypographyNew.of(context); + final colorTokens = ArDriveTheme.of(context).themeData.colorTokens; return ArDriveCard( contentPadding: const EdgeInsets.all(0), width: 281, @@ -257,21 +258,20 @@ class _ProfileCardState extends State { [ const SizedBox(height: 8), Padding( - padding: const EdgeInsets.only(left: 30.0), + padding: const EdgeInsets.only(left: 30.0, right: 16), child: ArDriveToggleSwitch( - value: context - .read() - .config - .enableSyncFromSnapshot, - text: 'Sync From Snapshots', + alignRight: true, + value: context.read().config.autoSync, + text: 'Automatic Sync', textStyle: typography.paragraphNormal( fontWeight: ArFontWeight.semiBold, + color: colorTokens.textLow, ), onChanged: (value) { final config = context.read().config; context.read().updateAppConfig( config.copyWith( - enableSyncFromSnapshot: value, + autoSync: value, ), ); }, @@ -279,18 +279,21 @@ class _ProfileCardState extends State { ), const SizedBox(height: 8), Padding( - padding: const EdgeInsets.only(left: 30.0), + padding: const EdgeInsets.only(left: 30.0, right: 16), child: ArDriveToggleSwitch( - value: context.read().config.autoSync, - text: 'Auto Sync', + alignRight: true, + value: + context.read().config.uploadThumbnails, + text: 'Upload with thumbnails', textStyle: typography.paragraphNormal( fontWeight: ArFontWeight.semiBold, + color: colorTokens.textLow, ), onChanged: (value) { final config = context.read().config; context.read().updateAppConfig( config.copyWith( - autoSync: value, + uploadThumbnails: value, ), ); }, @@ -298,19 +301,23 @@ class _ProfileCardState extends State { ), const SizedBox(height: 8), Padding( - padding: const EdgeInsets.only(left: 30.0), + padding: const EdgeInsets.only(left: 30.0, right: 16), child: ArDriveToggleSwitch( - value: - context.read().config.uploadThumbnails, - text: 'Upload Thumbnails', + alignRight: true, + value: context + .read() + .config + .enableSyncFromSnapshot, + text: 'Sync From Snapshots', textStyle: typography.paragraphNormal( fontWeight: ArFontWeight.semiBold, + color: colorTokens.textLow, ), onChanged: (value) { final config = context.read().config; context.read().updateAppConfig( config.copyWith( - uploadThumbnails: value, + enableSyncFromSnapshot: value, ), ); }, @@ -319,9 +326,8 @@ class _ProfileCardState extends State { ], ), ]), - const SizedBox(height: 8), Padding( - padding: const EdgeInsets.symmetric(horizontal: 16.0), + padding: const EdgeInsets.only(right: 12.0, left: 16, top: 12), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ diff --git a/packages/ardrive_ui/lib/src/components/toggle_switch.dart b/packages/ardrive_ui/lib/src/components/toggle_switch.dart index 4b1c90eaaa..12124e9068 100644 --- a/packages/ardrive_ui/lib/src/components/toggle_switch.dart +++ b/packages/ardrive_ui/lib/src/components/toggle_switch.dart @@ -13,6 +13,7 @@ class ArDriveToggleSwitch extends StatefulWidget { this.onChanged, this.value = false, this.isEnabled = true, + this.alignRight = false, }); final String text; @@ -20,6 +21,7 @@ class ArDriveToggleSwitch extends StatefulWidget { final bool value; final bool isEnabled; final FutureOr Function(bool value)? onChanged; + final bool alignRight; @override State createState() => ArDriveToggleSwitchState(); @@ -107,6 +109,11 @@ class ArDriveToggleSwitchState extends State { @override Widget build(BuildContext context) { + final textWidget = Text( + widget.text, + style: widget.textStyle ?? ArDriveTypography.body.bodyRegular(), + ); + return MouseRegion( cursor: SystemMouseCursors.click, child: GestureDetector( @@ -133,20 +140,19 @@ class ArDriveToggleSwitchState extends State { setState(() {}); }, child: Row( - mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Padding( - padding: const EdgeInsets.only(top: 4.0), - child: _toggle(), - ), + widget.alignRight + ? textWidget + : Padding( + padding: const EdgeInsets.only(top: 4.0), + child: _toggle(), + ), const SizedBox( width: 8, ), - Text( - widget.text, - style: widget.textStyle ?? ArDriveTypography.body.bodyRegular(), - ), + widget.alignRight ? const Spacer() : const SizedBox(), + widget.alignRight ? _toggle() : textWidget ], ), ), From 1b4ab123179b92995834846951881532278fba61 Mon Sep 17 00:00:00 2001 From: Thiago Carvalho <32248947+thiagocarvalhodev@users.noreply.github.com> Date: Tue, 6 Aug 2024 12:04:37 -0300 Subject: [PATCH 07/11] Update profile_card.dart change colors and indentation of items on the accordion --- lib/components/profile_card.dart | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/components/profile_card.dart b/lib/components/profile_card.dart index 5eef794966..3f1244d583 100644 --- a/lib/components/profile_card.dart +++ b/lib/components/profile_card.dart @@ -250,22 +250,22 @@ class _ProfileCardState extends State { ArDriveAccordion(backgroundColor: Colors.transparent, children: [ ArDriveAccordionItem( Text( - 'Advanced', + 'Advanced Settings', style: typography.paragraphNormal( fontWeight: ArFontWeight.semiBold, ), ), [ - const SizedBox(height: 8), + const SizedBox(height: 6), Padding( - padding: const EdgeInsets.only(left: 30.0, right: 16), + padding: const EdgeInsets.only(left: 16.0, right: 16), child: ArDriveToggleSwitch( alignRight: true, value: context.read().config.autoSync, text: 'Automatic Sync', textStyle: typography.paragraphNormal( fontWeight: ArFontWeight.semiBold, - color: colorTokens.textLow, + color: colorTokens.textMid, ), onChanged: (value) { final config = context.read().config; @@ -279,7 +279,7 @@ class _ProfileCardState extends State { ), const SizedBox(height: 8), Padding( - padding: const EdgeInsets.only(left: 30.0, right: 16), + padding: const EdgeInsets.only(left: 16.0, right: 16), child: ArDriveToggleSwitch( alignRight: true, value: @@ -287,7 +287,7 @@ class _ProfileCardState extends State { text: 'Upload with thumbnails', textStyle: typography.paragraphNormal( fontWeight: ArFontWeight.semiBold, - color: colorTokens.textLow, + color: colorTokens.textMid, ), onChanged: (value) { final config = context.read().config; @@ -301,7 +301,7 @@ class _ProfileCardState extends State { ), const SizedBox(height: 8), Padding( - padding: const EdgeInsets.only(left: 30.0, right: 16), + padding: const EdgeInsets.only(left: 16.0, right: 16), child: ArDriveToggleSwitch( alignRight: true, value: context @@ -311,7 +311,7 @@ class _ProfileCardState extends State { text: 'Sync From Snapshots', textStyle: typography.paragraphNormal( fontWeight: ArFontWeight.semiBold, - color: colorTokens.textLow, + color: colorTokens.textMid, ), onChanged: (value) { final config = context.read().config; @@ -520,16 +520,18 @@ class _ProfileMenuAccordionItem extends StatelessWidget { @override Widget build(BuildContext context) { final typography = ArDriveTypographyNew.of(context); + final colors = ArDriveTheme.of(context).themeData.colorTokens; return ArDriveClickArea( child: GestureDetector( onTap: onTap, child: Padding( - padding: const EdgeInsets.only(left: 30.0, right: 15), + padding: const EdgeInsets.only(left: 16.0, right: 15), child: Text( text, style: typography.paragraphNormal( fontWeight: ArFontWeight.semiBold, + color: colors.textMid, ), ), ), From ba567dfb6715bfde9a44de750f9cd9dac7280b91 Mon Sep 17 00:00:00 2001 From: Thiago Carvalho <32248947+thiagocarvalhodev@users.noreply.github.com> Date: Tue, 6 Aug 2024 15:50:17 -0300 Subject: [PATCH 08/11] feat(profile menu) - close already opened accordion item when another item is changed - update text for gift --- lib/components/profile_card.dart | 156 +++++++++--------- .../lib/src/components/accordion.dart | 15 ++ 2 files changed, 94 insertions(+), 77 deletions(-) diff --git a/lib/components/profile_card.dart b/lib/components/profile_card.dart index 3f1244d583..99c4f704ff 100644 --- a/lib/components/profile_card.dart +++ b/lib/components/profile_card.dart @@ -177,6 +177,7 @@ class _ProfileCardState extends State { ), ArDriveAccordion( backgroundColor: Colors.transparent, + automaticallyCloseWhenOpenAnotherItem: true, children: [ ArDriveAccordionItem( Text( @@ -187,13 +188,13 @@ class _ProfileCardState extends State { ), [ _ProfileMenuAccordionItem( - text: 'Gift', + text: 'Send', onTap: () { openUrl(url: Resources.sendGiftLink); }, ), _ProfileMenuAccordionItem( - text: 'Reedem Gift', + text: 'Reedem', onTap: () { showArDriveDialog( context, @@ -244,88 +245,89 @@ class _ProfileCardState extends State { ), ], ), - ], - ), - const SizedBox(height: 8), - ArDriveAccordion(backgroundColor: Colors.transparent, children: [ - ArDriveAccordionItem( - Text( - 'Advanced Settings', - style: typography.paragraphNormal( - fontWeight: ArFontWeight.semiBold, + ArDriveAccordionItem( + Text( + 'Advanced Settings', + style: typography.paragraphNormal( + fontWeight: ArFontWeight.semiBold, + ), ), - ), - [ - const SizedBox(height: 6), - Padding( - padding: const EdgeInsets.only(left: 16.0, right: 16), - child: ArDriveToggleSwitch( - alignRight: true, - value: context.read().config.autoSync, - text: 'Automatic Sync', - textStyle: typography.paragraphNormal( - fontWeight: ArFontWeight.semiBold, - color: colorTokens.textMid, + [ + const SizedBox(height: 6), + Padding( + padding: const EdgeInsets.only(left: 16.0, right: 16), + child: ArDriveToggleSwitch( + alignRight: true, + value: context.read().config.autoSync, + text: 'Automatic Sync', + textStyle: typography.paragraphNormal( + fontWeight: ArFontWeight.semiBold, + color: colorTokens.textMid, + ), + onChanged: (value) { + final config = context.read().config; + context.read().updateAppConfig( + config.copyWith( + autoSync: value, + ), + ); + }, ), - onChanged: (value) { - final config = context.read().config; - context.read().updateAppConfig( - config.copyWith( - autoSync: value, - ), - ); - }, ), - ), - const SizedBox(height: 8), - Padding( - padding: const EdgeInsets.only(left: 16.0, right: 16), - child: ArDriveToggleSwitch( - alignRight: true, - value: - context.read().config.uploadThumbnails, - text: 'Upload with thumbnails', - textStyle: typography.paragraphNormal( - fontWeight: ArFontWeight.semiBold, - color: colorTokens.textMid, + const SizedBox(height: 8), + Padding( + padding: const EdgeInsets.only(left: 16.0, right: 16), + child: ArDriveToggleSwitch( + alignRight: true, + value: + context.read().config.uploadThumbnails, + text: 'Upload with thumbnails', + textStyle: typography.paragraphNormal( + fontWeight: ArFontWeight.semiBold, + color: colorTokens.textMid, + ), + onChanged: (value) { + final config = context.read().config; + context.read().updateAppConfig( + config.copyWith( + uploadThumbnails: value, + ), + ); + }, ), - onChanged: (value) { - final config = context.read().config; - context.read().updateAppConfig( - config.copyWith( - uploadThumbnails: value, - ), - ); - }, ), - ), - const SizedBox(height: 8), - Padding( - padding: const EdgeInsets.only(left: 16.0, right: 16), - child: ArDriveToggleSwitch( - alignRight: true, - value: context - .read() - .config - .enableSyncFromSnapshot, - text: 'Sync From Snapshots', - textStyle: typography.paragraphNormal( - fontWeight: ArFontWeight.semiBold, - color: colorTokens.textMid, + const SizedBox(height: 8), + Padding( + padding: const EdgeInsets.only(left: 16.0, right: 16), + child: ArDriveToggleSwitch( + alignRight: true, + value: context + .read() + .config + .enableSyncFromSnapshot, + text: 'Sync From Snapshots', + textStyle: typography.paragraphNormal( + fontWeight: ArFontWeight.semiBold, + color: colorTokens.textMid, + ), + onChanged: (value) { + final config = context.read().config; + context.read().updateAppConfig( + config.copyWith( + enableSyncFromSnapshot: value, + ), + ); + }, ), - onChanged: (value) { - final config = context.read().config; - context.read().updateAppConfig( - config.copyWith( - enableSyncFromSnapshot: value, - ), - ); - }, ), - ), - ], - ), - ]), + ], + ), + ], + ), + const SizedBox(height: 8), + // ArDriveAccordion(backgroundColor: Colors.transparent, children: [ + + // ]), Padding( padding: const EdgeInsets.only(right: 12.0, left: 16, top: 12), child: Row( diff --git a/packages/ardrive_ui/lib/src/components/accordion.dart b/packages/ardrive_ui/lib/src/components/accordion.dart index 23f87b3dcb..d46354e3b1 100644 --- a/packages/ardrive_ui/lib/src/components/accordion.dart +++ b/packages/ardrive_ui/lib/src/components/accordion.dart @@ -22,12 +22,14 @@ class ArDriveAccordion extends StatefulWidget { final List children; final Color? backgroundColor; final EdgeInsetsGeometry? contentPadding; + final bool automaticallyCloseWhenOpenAnotherItem; const ArDriveAccordion({ super.key, required this.children, this.backgroundColor, this.contentPadding, + this.automaticallyCloseWhenOpenAnotherItem = false, }); @override @@ -36,10 +38,13 @@ class ArDriveAccordion extends StatefulWidget { class _ArDriveAccordionState extends State { late List tiles; + late List controller; @override void initState() { tiles = [...widget.children]; + controller = + List.generate(tiles.length, (index) => ExpansionTileController()); super.initState(); } @@ -76,8 +81,18 @@ class _ArDriveAccordionState extends State { expandedAlignment: Alignment.centerLeft, expandedCrossAxisAlignment: CrossAxisAlignment.start, onExpansionChanged: (value) { + if (widget.automaticallyCloseWhenOpenAnotherItem) { + for (var i = 0; i < tiles.length; i++) { + if (tiles[i] != tile) { + controller[i].collapse(); + } + } + } + if (value) controller[index].expand(); setState(() => tiles[tiles.indexOf(tile)].isExpanded = !value); }, + maintainState: false, + controller: controller[index], children: tile.children, ), ); From 883ccae27ed9977238fb2d2a5d89eac06dcae051 Mon Sep 17 00:00:00 2001 From: Thiago Carvalho <32248947+thiagocarvalhodev@users.noreply.github.com> Date: Tue, 6 Aug 2024 16:40:11 -0300 Subject: [PATCH 09/11] feat(profile menu) - auto sync disabled by default - bump version and release notes --- android/fastlane/metadata/android/en-US/changelogs/143.txt | 4 ++++ assets/config/dev.json | 3 ++- assets/config/prod.json | 3 ++- assets/config/staging.json | 3 ++- pubspec.yaml | 2 +- 5 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 android/fastlane/metadata/android/en-US/changelogs/143.txt diff --git a/android/fastlane/metadata/android/en-US/changelogs/143.txt b/android/fastlane/metadata/android/en-US/changelogs/143.txt new file mode 100644 index 0000000000..dece1ffee8 --- /dev/null +++ b/android/fastlane/metadata/android/en-US/changelogs/143.txt @@ -0,0 +1,4 @@ +- Revamped account menu with additional customization options +- Added option to enable/disable automatic sync +- Introduced setting to enable/disable sync from snapshots +- New feature to enable/disable upload with thumbnails diff --git a/assets/config/dev.json b/assets/config/dev.json index 69ff755df6..1456ef03ad 100644 --- a/assets/config/dev.json +++ b/assets/config/dev.json @@ -6,5 +6,6 @@ "defaultTurboPaymentUrl": "https://payment.ardrive.dev", "allowedDataItemSizeForTurbo": 100000, "stripePublishableKey": "pk_test_51JUAtwC8apPOWkDLh2FPZkQkiKZEkTo6wqgLCtQoClL6S4l2jlbbc5MgOdwOUdU9Tn93NNvqAGbu115lkJChMikG00XUfTmo2z", - "uploadThumbnails": true + "uploadThumbnails": true, + "autoSync": false } diff --git a/assets/config/prod.json b/assets/config/prod.json index 347cb3ffd4..5dee0e6521 100644 --- a/assets/config/prod.json +++ b/assets/config/prod.json @@ -6,5 +6,6 @@ "defaultTurboPaymentUrl": "https://payment.ardrive.io", "allowedDataItemSizeForTurbo": 100000, "stripePublishableKey": "pk_live_51JUAtwC8apPOWkDLMQqNF9sPpfneNSPnwX8YZ8y1FNDl6v94hZIwzgFSYl27bWE4Oos8CLquunUswKrKcaDhDO6m002Yj9AeKj", - "uploadThumbnails": true + "uploadThumbnails": true, + "autoSync": false } diff --git a/assets/config/staging.json b/assets/config/staging.json index 347cb3ffd4..5dee0e6521 100644 --- a/assets/config/staging.json +++ b/assets/config/staging.json @@ -6,5 +6,6 @@ "defaultTurboPaymentUrl": "https://payment.ardrive.io", "allowedDataItemSizeForTurbo": 100000, "stripePublishableKey": "pk_live_51JUAtwC8apPOWkDLMQqNF9sPpfneNSPnwX8YZ8y1FNDl6v94hZIwzgFSYl27bWE4Oos8CLquunUswKrKcaDhDO6m002Yj9AeKj", - "uploadThumbnails": true + "uploadThumbnails": true, + "autoSync": false } diff --git a/pubspec.yaml b/pubspec.yaml index 8ef75c195c..bc02c2526c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: Secure, permanent storage publish_to: 'none' -version: 2.49.6 +version: 2.50.0 environment: sdk: '>=3.2.0 <4.0.0' From 07ac72c1998dacb33de2323fcc0963be106bb09b Mon Sep 17 00:00:00 2001 From: Thiago Carvalho <32248947+thiagocarvalhodev@users.noreply.github.com> Date: Tue, 6 Aug 2024 16:42:54 -0300 Subject: [PATCH 10/11] feat(app banner) - remove banner for thumbnails --- lib/app_shell.dart | 76 -------------------- lib/shared/blocs/banner/app_banner_bloc.dart | 2 +- 2 files changed, 1 insertion(+), 77 deletions(-) diff --git a/lib/app_shell.dart b/lib/app_shell.dart index f0b7610f31..81efc58e8a 100644 --- a/lib/app_shell.dart +++ b/lib/app_shell.dart @@ -2,18 +2,15 @@ import 'package:ardrive/blocs/prompt_to_snapshot/prompt_to_snapshot_bloc.dart'; import 'package:ardrive/blocs/prompt_to_snapshot/prompt_to_snapshot_event.dart'; import 'package:ardrive/components/profile_card.dart'; import 'package:ardrive/components/side_bar.dart'; -import 'package:ardrive/drive_explorer/multi_thumbnail_creation/multi_thumbnail_creation_warn_modal.dart'; import 'package:ardrive/misc/misc.dart'; import 'package:ardrive/pages/drive_detail/components/hover_widget.dart'; import 'package:ardrive/shared/blocs/banner/app_banner_bloc.dart'; import 'package:ardrive/sync/domain/cubit/sync_cubit.dart'; import 'package:ardrive/sync/domain/sync_progress.dart'; import 'package:ardrive/utils/logger.dart'; -import 'package:ardrive/utils/show_general_dialog.dart'; import 'package:ardrive/utils/size_constants.dart'; import 'package:ardrive_ui/ardrive_ui.dart'; import 'package:ardrive_utils/ardrive_utils.dart'; -import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:responsive_builder/responsive_builder.dart'; @@ -176,84 +173,11 @@ class AppShellState extends State { ); return ScreenTypeLayout.builder( desktop: (context) { - final colorTokens = - ArDriveTheme.of(context).themeData.colorTokens; - final typography = ArDriveTypographyNew.of(context); - return buildPage( BlocBuilder( builder: (context, state) { return Column( children: [ - if (state is AppBannerVisible) - Container( - height: 45, - width: double.maxFinite, - color: colorTokens.buttonPrimaryDefault, - alignment: Alignment.center, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Spacer(), - ArDriveIcons.asc( - color: colorTokens.textOnPrimary, - size: 18, - ), - const SizedBox(width: 8), - // move two pixels above - Transform( - transform: - Matrix4.translationValues(0.0, -2.0, 0.0), - child: RichText( - text: TextSpan( - children: [ - TextSpan( - text: - 'ArDrive now supports thumbnails! You can ', - style: typography.paragraphNormal( - fontWeight: ArFontWeight.semiBold, - color: colorTokens.textOnPrimary), - ), - TextSpan( - text: 'add them now!', - recognizer: TapGestureRecognizer() - ..onTap = () { - showArDriveDialog(context, - content: - const MultiThumbnailCreationWarningModal()); - }, - style: typography - .paragraphNormal( - fontWeight: - ArFontWeight.semiBold, - color: - colorTokens.textOnPrimary) - .copyWith( - decoration: - TextDecoration.underline, - ), - ), - ], - ), - ), - ), - const Spacer(), - Padding( - padding: const EdgeInsets.only(right: 8.0), - child: GestureDetector( - onTap: () { - context - .read() - .add(const AppBannerCloseEvent()); - }, - child: ArDriveIcons.x( - color: colorTokens.textOnPrimary, - ), - ), - ), - ], - ), - ), Flexible( child: Row( children: [ diff --git a/lib/shared/blocs/banner/app_banner_bloc.dart b/lib/shared/blocs/banner/app_banner_bloc.dart index 2ebbbd36c9..d563d78fc0 100644 --- a/lib/shared/blocs/banner/app_banner_bloc.dart +++ b/lib/shared/blocs/banner/app_banner_bloc.dart @@ -5,7 +5,7 @@ part 'app_banner_event.dart'; part 'app_banner_state.dart'; class AppBannerBloc extends Bloc { - AppBannerBloc() : super(AppBannerVisible()) { + AppBannerBloc() : super(AppBannerHidden()) { on((event, emit) { if (event is AppBannerCloseEvent) { emit(AppBannerHidden()); From a6f92690210eba9814781585f7bd325ae25955ec Mon Sep 17 00:00:00 2001 From: Thiago Carvalho <32248947+thiagocarvalhodev@users.noreply.github.com> Date: Tue, 6 Aug 2024 16:50:35 -0300 Subject: [PATCH 11/11] leave banner --- lib/app_shell.dart | 76 ++++++++++++++++++++ lib/shared/blocs/banner/app_banner_bloc.dart | 2 +- 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/lib/app_shell.dart b/lib/app_shell.dart index 81efc58e8a..f0b7610f31 100644 --- a/lib/app_shell.dart +++ b/lib/app_shell.dart @@ -2,15 +2,18 @@ import 'package:ardrive/blocs/prompt_to_snapshot/prompt_to_snapshot_bloc.dart'; import 'package:ardrive/blocs/prompt_to_snapshot/prompt_to_snapshot_event.dart'; import 'package:ardrive/components/profile_card.dart'; import 'package:ardrive/components/side_bar.dart'; +import 'package:ardrive/drive_explorer/multi_thumbnail_creation/multi_thumbnail_creation_warn_modal.dart'; import 'package:ardrive/misc/misc.dart'; import 'package:ardrive/pages/drive_detail/components/hover_widget.dart'; import 'package:ardrive/shared/blocs/banner/app_banner_bloc.dart'; import 'package:ardrive/sync/domain/cubit/sync_cubit.dart'; import 'package:ardrive/sync/domain/sync_progress.dart'; import 'package:ardrive/utils/logger.dart'; +import 'package:ardrive/utils/show_general_dialog.dart'; import 'package:ardrive/utils/size_constants.dart'; import 'package:ardrive_ui/ardrive_ui.dart'; import 'package:ardrive_utils/ardrive_utils.dart'; +import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:responsive_builder/responsive_builder.dart'; @@ -173,11 +176,84 @@ class AppShellState extends State { ); return ScreenTypeLayout.builder( desktop: (context) { + final colorTokens = + ArDriveTheme.of(context).themeData.colorTokens; + final typography = ArDriveTypographyNew.of(context); + return buildPage( BlocBuilder( builder: (context, state) { return Column( children: [ + if (state is AppBannerVisible) + Container( + height: 45, + width: double.maxFinite, + color: colorTokens.buttonPrimaryDefault, + alignment: Alignment.center, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Spacer(), + ArDriveIcons.asc( + color: colorTokens.textOnPrimary, + size: 18, + ), + const SizedBox(width: 8), + // move two pixels above + Transform( + transform: + Matrix4.translationValues(0.0, -2.0, 0.0), + child: RichText( + text: TextSpan( + children: [ + TextSpan( + text: + 'ArDrive now supports thumbnails! You can ', + style: typography.paragraphNormal( + fontWeight: ArFontWeight.semiBold, + color: colorTokens.textOnPrimary), + ), + TextSpan( + text: 'add them now!', + recognizer: TapGestureRecognizer() + ..onTap = () { + showArDriveDialog(context, + content: + const MultiThumbnailCreationWarningModal()); + }, + style: typography + .paragraphNormal( + fontWeight: + ArFontWeight.semiBold, + color: + colorTokens.textOnPrimary) + .copyWith( + decoration: + TextDecoration.underline, + ), + ), + ], + ), + ), + ), + const Spacer(), + Padding( + padding: const EdgeInsets.only(right: 8.0), + child: GestureDetector( + onTap: () { + context + .read() + .add(const AppBannerCloseEvent()); + }, + child: ArDriveIcons.x( + color: colorTokens.textOnPrimary, + ), + ), + ), + ], + ), + ), Flexible( child: Row( children: [ diff --git a/lib/shared/blocs/banner/app_banner_bloc.dart b/lib/shared/blocs/banner/app_banner_bloc.dart index d563d78fc0..2ebbbd36c9 100644 --- a/lib/shared/blocs/banner/app_banner_bloc.dart +++ b/lib/shared/blocs/banner/app_banner_bloc.dart @@ -5,7 +5,7 @@ part 'app_banner_event.dart'; part 'app_banner_state.dart'; class AppBannerBloc extends Bloc { - AppBannerBloc() : super(AppBannerHidden()) { + AppBannerBloc() : super(AppBannerVisible()) { on((event, emit) { if (event is AppBannerCloseEvent) { emit(AppBannerHidden());