Skip to content

Commit

Permalink
chore: Rename EventsSearchButton to SearchToggleButton; Rename Events…
Browse files Browse the repository at this point in the history
…SearchBar to ToggleSearcbBar
  • Loading branch information
bdlukaa committed Jan 30, 2024
1 parent a8854da commit b8c47d5
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 121 deletions.
36 changes: 8 additions & 28 deletions lib/widgets/device_grid/desktop/layout_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import 'package:bluecherry_client/providers/settings_provider.dart';
import 'package:bluecherry_client/utils/methods.dart';
import 'package:bluecherry_client/utils/widgets/squared_icon_button.dart';
import 'package:bluecherry_client/utils/window.dart';
import 'package:bluecherry_client/widgets/events_timeline/desktop/timeline_sidebar.dart';
import 'package:bluecherry_client/widgets/hover_button.dart';
import 'package:bluecherry_client/widgets/misc.dart';
import 'package:bluecherry_client/widgets/search.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -109,7 +109,7 @@ class _LayoutManagerState extends State<LayoutManager> {
widget.collapseButton,
const SizedBox(width: 5.0),
Expanded(child: Text(loc.view, maxLines: 1)),
EventsSearchButton(
SearchToggleButton(
searchVisible: searchVisible,
iconSize: 18.0,
onPressed: () {
Expand Down Expand Up @@ -164,32 +164,12 @@ class _LayoutManagerState extends State<LayoutManager> {
},
),
),
AnimatedSlide(
offset: searchVisible ? Offset.zero : const Offset(0, 1),
duration: kThemeChangeDuration,
curve: Curves.easeInOut,
child: Column(children: [
const Divider(height: 1.0),
Padding(
padding: const EdgeInsets.all(8.0),
child: TextField(
controller: searchController,
focusNode: searchFocusNode,
decoration: InputDecoration(
hintText: MaterialLocalizations.of(context).searchFieldLabel,
isDense: true,
border: InputBorder.none,
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
contentPadding: const EdgeInsetsDirectional.symmetric(
horizontal: 8.0,
vertical: 4.0,
),
),
onChanged: widget.onSearchChanged,
),
)
]),
ToggleSearchBar(
searchVisible: searchVisible,
searchController: searchController,
searchFocusNode: searchFocusNode,
onSearchChanged: widget.onSearchChanged,
showBottomDivider: false,
),
const Divider(height: 1.0),
]),
Expand Down
6 changes: 3 additions & 3 deletions lib/widgets/direct_camera.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import 'package:bluecherry_client/utils/extensions.dart';
import 'package:bluecherry_client/utils/theme.dart';
import 'package:bluecherry_client/utils/video_player.dart';
import 'package:bluecherry_client/widgets/error_warning.dart';
import 'package:bluecherry_client/widgets/events_timeline/desktop/timeline_sidebar.dart';
import 'package:bluecherry_client/widgets/misc.dart';
import 'package:bluecherry_client/widgets/search.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:provider/provider.dart';
Expand Down Expand Up @@ -70,7 +70,7 @@ class DirectCameraScreenState extends State<DirectCameraScreen> {
final loc = AppLocalizations.of(context);
final hasDrawer = Scaffold.hasDrawer(context);

final searchBar = EventsSearchBar(
final searchBar = ToggleSearchBar(
searchController: _searchController,
searchFocusNode: _searchFocusNode,
searchVisible: _searchVisible,
Expand All @@ -88,7 +88,7 @@ class DirectCameraScreenState extends State<DirectCameraScreen> {
actions: [
Padding(
padding: const EdgeInsetsDirectional.only(end: 12.0),
child: EventsSearchButton(
child: SearchToggleButton(
searchVisible: _searchVisible,
onPressed: toggleSearch,
),
Expand Down
6 changes: 3 additions & 3 deletions lib/widgets/events/events_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ import 'package:bluecherry_client/widgets/downloads_manager.dart';
import 'package:bluecherry_client/widgets/error_warning.dart';
import 'package:bluecherry_client/widgets/events/event_player_desktop.dart';
import 'package:bluecherry_client/widgets/events/filter.dart';
import 'package:bluecherry_client/widgets/events_timeline/desktop/timeline_sidebar.dart';
import 'package:bluecherry_client/widgets/misc.dart';
import 'package:bluecherry_client/widgets/search.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
Expand Down Expand Up @@ -216,7 +216,7 @@ class EventsScreenState<T extends StatefulWidget> extends State<T> {
children: [
Padding(
padding: const EdgeInsetsDirectional.only(end: 6.0),
child: EventsSearchButton(
child: SearchToggleButton(
searchVisible: searchVisible,
onPressed: () {
setState(() => searchVisible = !searchVisible);
Expand All @@ -232,7 +232,7 @@ class EventsScreenState<T extends StatefulWidget> extends State<T> {
],
),
),
EventsSearchBar(
ToggleSearchBar(
searchVisible: searchVisible,
searchController: searchController,
searchFocusNode: searchFocusNode,
Expand Down
6 changes: 3 additions & 3 deletions lib/widgets/events/filter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import 'package:bluecherry_client/providers/server_provider.dart';
import 'package:bluecherry_client/utils/extensions.dart';
import 'package:bluecherry_client/utils/widgets/tree_view.dart';
import 'package:bluecherry_client/widgets/events/events_screen.dart';
import 'package:bluecherry_client/widgets/events_timeline/desktop/timeline_sidebar.dart';
import 'package:bluecherry_client/widgets/misc.dart';
import 'package:bluecherry_client/widgets/search.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:provider/provider.dart';
Expand Down Expand Up @@ -207,12 +207,12 @@ class _MobileFilterSheetState extends State<MobileFilterSheet> {
SubHeader(
loc.servers,
height: 38.0,
trailing: EventsSearchButton(
trailing: SearchToggleButton(
searchVisible: searchVisible,
onPressed: () => setState(() => searchVisible = !searchVisible),
),
),
EventsSearchBar(
ToggleSearchBar(
searchVisible: searchVisible,
searchController: searchController,
searchFocusNode: searchFocusNode,
Expand Down
85 changes: 3 additions & 82 deletions lib/widgets/events_timeline/desktop/timeline_sidebar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
*/

import 'package:auto_size_text/auto_size_text.dart';
import 'package:bluecherry_client/utils/widgets/squared_icon_button.dart';
import 'package:bluecherry_client/widgets/collapsable_sidebar.dart';
import 'package:bluecherry_client/widgets/events/filter.dart';
import 'package:bluecherry_client/widgets/events_timeline/events_playback.dart';
import 'package:bluecherry_client/widgets/misc.dart';
import 'package:bluecherry_client/widgets/search.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:intl/intl.dart';
Expand Down Expand Up @@ -86,7 +86,7 @@ class _TimelineSidebarState extends State<TimelineSidebar> {
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
EventsSearchButton(
SearchToggleButton(
searchVisible: searchVisible,
iconSize: 22.0,
onPressed: () {
Expand All @@ -101,7 +101,7 @@ class _TimelineSidebarState extends State<TimelineSidebar> {
),
padding: const EdgeInsetsDirectional.only(start: 16.0, end: 4.0),
),
EventsSearchBar(
ToggleSearchBar(
searchVisible: searchVisible,
searchController: searchController,
searchFocusNode: searchFocusNode,
Expand Down Expand Up @@ -155,82 +155,3 @@ class _TimelineSidebarState extends State<TimelineSidebar> {
);
}
}

class EventsSearchButton extends StatelessWidget {
final bool searchVisible;
final VoidCallback onPressed;

final double iconSize;

const EventsSearchButton({
super.key,
required this.searchVisible,
required this.onPressed,
this.iconSize = 20.0,
});

@override
Widget build(BuildContext context) {
final loc = AppLocalizations.of(context);
return SquaredIconButton(
icon: Icon(
searchVisible ? Icons.search_off : Icons.search,
size: iconSize,
),
tooltip: searchVisible
? loc.disableSearch
: MaterialLocalizations.of(context).searchFieldLabel,
onPressed: onPressed,
);
}
}

class EventsSearchBar extends StatelessWidget {
final bool searchVisible;
final TextEditingController searchController;
final FocusNode searchFocusNode;
final ValueChanged<String> onSearchChanged;

const EventsSearchBar({
super.key,
required this.searchVisible,
required this.searchController,
required this.searchFocusNode,
required this.onSearchChanged,
});

@override
Widget build(BuildContext context) {
return AnimatedSize(
duration: kThemeChangeDuration,
curve: Curves.easeInOut,
child: Builder(builder: (context) {
if (!searchVisible) return const SizedBox.shrink();
return Column(children: [
const Divider(height: 1.0),
Padding(
padding: const EdgeInsets.all(8.0),
child: TextField(
controller: searchController,
focusNode: searchFocusNode,
decoration: InputDecoration(
hintText: MaterialLocalizations.of(context).searchFieldLabel,
isDense: true,
border: InputBorder.none,
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
contentPadding: const EdgeInsetsDirectional.symmetric(
horizontal: 8.0,
vertical: 4.0,
),
),
onChanged: onSearchChanged,
),
),
const Divider(height: 1.0),
const SizedBox(height: 8.0),
]);
}),
);
}
}
4 changes: 2 additions & 2 deletions lib/widgets/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import 'package:bluecherry_client/widgets/device_grid/device_grid.dart';
import 'package:bluecherry_client/widgets/direct_camera.dart';
import 'package:bluecherry_client/widgets/downloads_manager.dart';
import 'package:bluecherry_client/widgets/events/events_screen.dart';
import 'package:bluecherry_client/widgets/events_timeline/desktop/timeline_sidebar.dart';
import 'package:bluecherry_client/widgets/events_timeline/events_playback.dart';
import 'package:bluecherry_client/widgets/search.dart';
import 'package:bluecherry_client/widgets/servers/add_server.dart';
import 'package:bluecherry_client/widgets/settings/settings.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -339,7 +339,7 @@ class _MobileHomeState extends State<Home> {
),
),
if (directCameraKey.currentState != null)
EventsSearchButton(
SearchToggleButton(
searchVisible: directCameraKey.currentState!.searchVisible,
onPressed: () {
directCameraKey.currentState!.toggleSearch();
Expand Down
87 changes: 87 additions & 0 deletions lib/widgets/search.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import 'package:bluecherry_client/utils/widgets/squared_icon_button.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

class SearchToggleButton extends StatelessWidget {
final bool searchVisible;
final VoidCallback onPressed;

final double iconSize;

const SearchToggleButton({
super.key,
required this.searchVisible,
required this.onPressed,
this.iconSize = 20.0,
});

@override
Widget build(BuildContext context) {
final loc = AppLocalizations.of(context);
return SquaredIconButton(
icon: Icon(
searchVisible ? Icons.search_off : Icons.search,
size: iconSize,
),
tooltip: searchVisible
? loc.disableSearch
: MaterialLocalizations.of(context).searchFieldLabel,
onPressed: onPressed,
);
}
}

class ToggleSearchBar extends StatelessWidget {
final bool searchVisible;
final TextEditingController searchController;
final FocusNode searchFocusNode;
final ValueChanged<String> onSearchChanged;

final bool showBottomDivider;

const ToggleSearchBar({
super.key,
required this.searchVisible,
required this.searchController,
required this.searchFocusNode,
required this.onSearchChanged,
this.showBottomDivider = true,
});

@override
Widget build(BuildContext context) {
return AnimatedSize(
duration: kThemeChangeDuration,
curve: Curves.easeInOut,
child: Builder(builder: (context) {
if (!searchVisible) return const SizedBox.shrink();
return Column(children: [
const Divider(height: 1.0),
Padding(
padding: const EdgeInsets.all(8.0),
child: TextField(
controller: searchController,
focusNode: searchFocusNode,
decoration: InputDecoration(
hintText: MaterialLocalizations.of(context).searchFieldLabel,
isDense: true,
border: InputBorder.none,
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
contentPadding: const EdgeInsetsDirectional.symmetric(
horizontal: 8.0,
vertical: 4.0,
),
),
onChanged: onSearchChanged,
),
),
if (showBottomDivider) ...[
const Divider(height: 1.0),
const SizedBox(height: 8.0),
],
]);
}),
);
}
}

0 comments on commit b8c47d5

Please sign in to comment.