Skip to content

Commit

Permalink
Merge pull request #1738 from ardriveapp/dev
Browse files Browse the repository at this point in the history
PE-6114: Release ArDrive App v2.44.0
  • Loading branch information
thiagocarvalhodev authored May 8, 2024
2 parents d804d3b + ce7a57d commit ef6b864
Show file tree
Hide file tree
Showing 8 changed files with 222 additions and 75 deletions.
1 change: 1 addition & 0 deletions android/fastlane/metadata/android/en-US/changelogs/126.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- New Feature: Search (for quickly locating files and navigating through folders and drives)
29 changes: 15 additions & 14 deletions lib/app_shell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -222,20 +222,6 @@ class MobileAppBar extends StatelessWidget implements PreferredSizeWidget {
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(
left: 24.0,
),
child: ArDriveImage(
image: AssetImage(
isLightMode
? Resources.images.brand.blackLogo1
: Resources.images.brand.whiteLogo1,
),
width: 128,
height: 28,
),
),
Padding(
padding: const EdgeInsets.only(left: 7.0),
child: leading ??
Expand All @@ -252,6 +238,21 @@ class MobileAppBar extends StatelessWidget implements PreferredSizeWidget {
)
: Container()),
),
if (!showDrawerButton)
Padding(
padding: const EdgeInsets.only(
left: 24.0,
),
child: ArDriveImage(
image: AssetImage(
isLightMode
? Resources.images.brand.blackLogo1
: Resources.images.brand.whiteLogo1,
),
width: 128,
height: 28,
),
),
const Spacer(),
const SyncButton(),
const SizedBox(
Expand Down
14 changes: 4 additions & 10 deletions lib/components/app_top_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ 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';
import 'package:ardrive/utils/plausible_event_tracker/plausible_event_tracker.dart';
import 'package:ardrive/utils/show_general_dialog.dart';
import 'package:ardrive_ui/ardrive_ui.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
Expand All @@ -21,7 +20,6 @@ class AppTopBar extends StatelessWidget {
@override
Widget build(BuildContext context) {
final enableSearch = context.read<ConfigService>().config.enableSearch;
final colorTokens = ArDriveTheme.of(context).themeData.colorTokens;
final controller = TextEditingController();

return SizedBox(
Expand All @@ -40,14 +38,10 @@ class AppTopBar extends StatelessWidget {
child: SearchTextField(
controller: controller,
onFieldSubmitted: (query) {
showArDriveDialog(
context,
content: FileSearchModal(
initialQuery: query,
driveDetailCubit: context.read<DriveDetailCubit>(),
controller: controller,
),
barrierColor: colorTokens.containerL1.withOpacity(0.8),
showSearchModalDesktop(
context: context,
driveDetailCubit: context.read<DriveDetailCubit>(),
controller: controller,
);
},
),
Expand Down
112 changes: 82 additions & 30 deletions lib/pages/drive_detail/drive_detail_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import 'package:ardrive/pages/drive_detail/components/dropdown_item.dart';
import 'package:ardrive/pages/drive_detail/components/file_icon.dart';
import 'package:ardrive/pages/drive_detail/components/hover_widget.dart';
import 'package:ardrive/pages/drive_detail/components/unpreviewable_content.dart';
import 'package:ardrive/search/search_modal.dart';
import 'package:ardrive/search/search_text_field.dart';
import 'package:ardrive/services/services.dart';
import 'package:ardrive/sharing/sharing_file_listener.dart';
import 'package:ardrive/sync/domain/cubit/sync_cubit.dart';
Expand Down Expand Up @@ -83,6 +85,7 @@ class DriveDetailPage extends StatefulWidget {
class _DriveDetailPageState extends State<DriveDetailPage> {
bool checkboxEnabled = false;
final _scrollController = ScrollController();
final controller = TextEditingController();

@override
void initState() {
Expand Down Expand Up @@ -742,8 +745,47 @@ class _DriveDetailPageState extends State<DriveDetailPage> {
filteredItems = items.where((item) => item.isHidden == false).toList();
}

final colorTokens = ArDriveTheme.of(context).themeData.colorTokens;
return Column(
children: [
Padding(
padding: const EdgeInsets.all(16.0),
child: SearchTextField(
controller: controller,
onFieldSubmitted: (query) {
if (query.isEmpty) {
return;
}

showModalBottomSheet(
isScrollControlled: true,
context: context,
backgroundColor: Colors.transparent,
builder: (_) => Container(
height: MediaQuery.of(context).size.height * 0.85,
decoration: BoxDecoration(
color: colorTokens.containerL2,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(6.0),
topRight: Radius.circular(6.0),
),
),
child: Padding(
padding: MediaQuery.of(context).viewInsets,
child: BlocProvider.value(
value: context.read<DriveDetailCubit>(),
child: FileSearchModal(
initialQuery: query,
driveDetailCubit: context.read<DriveDetailCubit>(),
controller: controller,
),
),
),
),
);
},
),
),
Padding(
padding: const EdgeInsets.only(top: 8),
child: Row(
Expand Down Expand Up @@ -924,42 +966,52 @@ class MobileFolderNavigation extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: InkWell(
onTap: () {
String? targetId;
child: SizedBox(
height: 45,
child: InkWell(
onTap: () {
if (path.length == 1) {
// If we are at the root folder, open the drive
context.read<DriveDetailCubit>().openFolder();
return;
}
String? targetId;

if (path.isNotEmpty) {
targetId = path.first.targetId;
}
if (path.isNotEmpty) {
targetId = path.first.targetId;
}

context.read<DriveDetailCubit>().openFolder(folderId: targetId);
},
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
if (path.isNotEmpty)
Padding(
padding: const EdgeInsets.only(
left: 16,
right: 8,
top: 4,
context
.read<DriveDetailCubit>()
.openFolder(folderId: targetId);
},
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
if (path.isNotEmpty)
Padding(
padding: const EdgeInsets.only(
left: 16,
right: 8,
top: 4,
),
child: ArDriveIcons.arrowLeft(),
),
child: ArDriveIcons.arrowLeft(),
),
Expanded(
child: Padding(
padding: path.isEmpty
? const EdgeInsets.only(left: 16, top: 6, bottom: 6)
: EdgeInsets.zero,
child: Text(
_pathToName(
path.isEmpty ? driveName : path.last.text,
Expanded(
child: Padding(
padding: path.isEmpty
? const EdgeInsets.only(left: 16, top: 6, bottom: 6)
: EdgeInsets.zero,
child: Text(
_pathToName(
path.isEmpty ? driveName : path.last.text,
),
style: ArDriveTypography.body.buttonNormalBold(),
),
style: ArDriveTypography.body.buttonNormalBold(),
),
),
),
],
],
),
),
),
),
Expand Down
133 changes: 113 additions & 20 deletions lib/search/search_modal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,68 @@ import 'package:ardrive/search/domain/bloc/search_bloc.dart';
import 'package:ardrive/search/domain/repository/search_repository.dart';
import 'package:ardrive/search/search_result.dart';
import 'package:ardrive/search/search_text_field.dart';
import 'package:ardrive/utils/show_general_dialog.dart';
import 'package:ardrive_ui/ardrive_ui.dart';
import 'package:ardrive_utils/ardrive_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:responsive_builder/responsive_builder.dart';

import '../models/models.dart';

Future<void> showSearchModalBottomSheet({
required BuildContext context,
required DriveDetailCubit driveDetailCubit,
required TextEditingController controller,
String? query,
}) {
final colorTokens = ArDriveTheme.of(context).themeData.colorTokens;
return showModalBottomSheet(
isScrollControlled: true,
context: context,
backgroundColor: Colors.transparent,
builder: (_) => Container(
height: MediaQuery.of(context).size.height * 0.85,
decoration: BoxDecoration(
color: colorTokens.containerL2,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(6.0),
topRight: Radius.circular(6.0),
),
),
child: Padding(
padding: MediaQuery.of(context).viewInsets,
child: BlocProvider.value(
value: context.read<DriveDetailCubit>(),
child: FileSearchModal(
initialQuery: query,
driveDetailCubit: context.read<DriveDetailCubit>(),
controller: controller,
),
),
),
),
);
}

Future<void> showSearchModalDesktop({
required BuildContext context,
required DriveDetailCubit driveDetailCubit,
required TextEditingController controller,
String? query,
}) {
final colorTokens = ArDriveTheme.of(context).themeData.colorTokens;
return showArDriveDialog(
context,
content: FileSearchModal(
initialQuery: query,
driveDetailCubit: context.read<DriveDetailCubit>(),
controller: controller,
),
barrierColor: colorTokens.containerL1.withOpacity(0.8),
);
}

class FileSearchModal extends StatelessWidget {
const FileSearchModal({
super.key,
Expand Down Expand Up @@ -85,32 +140,71 @@ class _FileSearchModalState extends State<_FileSearchModal> {
}

Future<void> searchFiles(String query) async {
context.read<SearchBloc>().add(SearchQueryChanged(query));
if (mounted) {
context.read<SearchBloc>().add(SearchQueryChanged(query));
}
}

@override
Widget build(BuildContext context) {
final typography = ArDriveTypographyNew.of(context);
final colorTokens = ArDriveTheme.of(context).themeData.colorTokens;
return ArDriveLoginModal(
width: MediaQuery.of(context).size.width * 0.6,
content: SizedBox(
height: MediaQuery.of(context).size.height * 0.7,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
_buildSearchHeader(typography, colorTokens),
const SizedBox(height: 16),
SearchTextField(
controller: widget.controller,
onFieldSubmitted: (_) => searchFiles(widget.controller.text),
return ScreenTypeLayout.builder(mobile: (context) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
clipBehavior: Clip.hardEdge,
decoration: BoxDecoration(
color: colorTokens.containerRed,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(9),
topRight: Radius.circular(9),
),
),
const SizedBox(height: 16),
_buildSearchResults(context, typography, colorTokens),
],
height: 6,
),
Expanded(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
_buildSearchHeader(typography, colorTokens),
const SizedBox(height: 16),
SearchTextField(
controller: widget.controller,
onFieldSubmitted: (_) =>
searchFiles(widget.controller.text),
),
const SizedBox(height: 16),
_buildSearchResults(context, typography, colorTokens),
],
),
),
),
],
);
}, desktop: (context) {
return ArDriveLoginModal(
width: MediaQuery.of(context).size.width * 0.6,
content: SizedBox(
height: MediaQuery.of(context).size.height * 0.7,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
_buildSearchHeader(typography, colorTokens),
const SizedBox(height: 16),
SearchTextField(
controller: widget.controller,
onFieldSubmitted: (_) => searchFiles(widget.controller.text),
),
const SizedBox(height: 16),
_buildSearchResults(context, typography, colorTokens),
],
),
),
),
);
);
});
}

Widget _buildSearchHeader(
Expand Down Expand Up @@ -192,8 +286,7 @@ class _FileSearchModalState extends State<_FileSearchModal> {
child: ListTile(
onTap: () => _handleNavigation(context, searchResult),
leading: leadingIcon,
title: Row(
mainAxisSize: MainAxisSize.min,
title: Wrap(
children: [
Text(
name,
Expand Down
Loading

0 comments on commit ef6b864

Please sign in to comment.