added cargo files

This commit is contained in:
2026-03-03 10:57:43 -05:00
parent 478a90e01b
commit 169df46bc2
813 changed files with 227273 additions and 9 deletions

View File

@@ -0,0 +1,111 @@
// Copyright 2020 Ben Hills and the project contributors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:io';
import 'package:pinepods_mobile/bloc/search/search_bloc.dart';
import 'package:pinepods_mobile/bloc/search/search_state_event.dart';
import 'package:pinepods_mobile/l10n/L.dart';
import 'package:pinepods_mobile/ui/search/search_results.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
/// This widget renders the search bar and allows the user to search for podcasts.
class Search extends StatefulWidget {
final String? searchTerm;
const Search({
super.key,
this.searchTerm,
});
@override
State<Search> createState() => _SearchState();
}
class _SearchState extends State<Search> {
late TextEditingController _searchController;
late FocusNode _searchFocusNode;
@override
void initState() {
super.initState();
final bloc = Provider.of<SearchBloc>(context, listen: false);
bloc.search(SearchClearEvent());
_searchFocusNode = FocusNode();
_searchController = TextEditingController();
if (widget.searchTerm != null) {
bloc.search(SearchTermEvent(widget.searchTerm!));
_searchController.text = widget.searchTerm!;
}
}
@override
void dispose() {
_searchFocusNode.dispose();
_searchController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final bloc = Provider.of<SearchBloc>(context);
return Scaffold(
body: CustomScrollView(
slivers: <Widget>[
SliverAppBar(
leading: IconButton(
tooltip: L.of(context)!.search_back_button_label,
icon: Platform.isAndroid
? Icon(Icons.arrow_back, color: Theme.of(context).appBarTheme.foregroundColor)
: const Icon(Icons.arrow_back_ios),
onPressed: () => Navigator.pop(context),
),
title: TextField(
controller: _searchController,
focusNode: _searchFocusNode,
autofocus: widget.searchTerm != null ? false : true,
keyboardType: TextInputType.text,
textInputAction: TextInputAction.search,
decoration: InputDecoration(
hintText: L.of(context)!.search_for_podcasts_hint,
border: InputBorder.none,
),
style: TextStyle(
color: Theme.of(context).primaryIconTheme.color,
fontSize: 18.0,
decorationColor: Theme.of(context).scaffoldBackgroundColor),
onSubmitted: ((value) {
SemanticsService.announce(L.of(context)!.semantic_announce_searching, TextDirection.ltr);
bloc.search(SearchTermEvent(value));
})),
floating: false,
pinned: true,
snap: false,
actions: <Widget>[
IconButton(
tooltip: L.of(context)!.clear_search_button_label,
icon: const Icon(Icons.clear),
onPressed: () {
_searchController.clear();
FocusScope.of(context).requestFocus(_searchFocusNode);
SystemChannels.textInput.invokeMethod<String>('TextInput.show');
},
),
],
),
SearchResults(data: bloc.results!),
],
),
);
}
}

View File

@@ -0,0 +1,78 @@
// Copyright 2020 Ben Hills and the project contributors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:pinepods_mobile/l10n/L.dart';
import 'package:pinepods_mobile/ui/widgets/search_slide_route.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'search.dart';
class SearchBar extends StatefulWidget {
const SearchBar({super.key});
@override
State<SearchBar> createState() => _SearchBarState();
}
class _SearchBarState extends State<SearchBar> {
late TextEditingController _searchController;
late FocusNode _searchFocusNode;
@override
void initState() {
super.initState();
_searchController = TextEditingController();
_searchController.addListener(() {
setState(() {});
});
_searchFocusNode = FocusNode();
}
@override
void dispose() {
_searchFocusNode.dispose();
_searchController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return ListTile(
contentPadding: const EdgeInsets.only(left: 16, right: 16),
title: TextField(
controller: _searchController,
focusNode: _searchFocusNode,
keyboardType: TextInputType.text,
textInputAction: TextInputAction.search,
decoration: InputDecoration(hintText: L.of(context)!.search_for_podcasts_hint, border: InputBorder.none),
style: TextStyle(
color: Theme.of(context).primaryIconTheme.color,
fontSize: 18.0,
decorationColor: Theme.of(context).scaffoldBackgroundColor),
onSubmitted: (value) async {
await Navigator.push(
context,
SlideRightRoute(
widget: Search(searchTerm: value),
settings: const RouteSettings(name: 'search'),
));
_searchController.clear();
},
),
trailing: IconButton(
padding: EdgeInsets.zero,
tooltip: _searchFocusNode.hasFocus ? L.of(context)!.clear_search_button_label : null,
color: _searchFocusNode.hasFocus ? Theme.of(context).iconTheme.color : null,
splashColor: _searchFocusNode.hasFocus ? Theme.of(context).splashColor : Colors.transparent,
highlightColor: _searchFocusNode.hasFocus ? Theme.of(context).highlightColor : Colors.transparent,
icon: Icon(_searchController.text.isEmpty && !_searchFocusNode.hasFocus ? Icons.search : Icons.clear),
onPressed: () {
_searchController.clear();
FocusScope.of(context).requestFocus(FocusNode());
SystemChannels.textInput.invokeMethod<String>('TextInput.show');
}),
);
}
}

View File

@@ -0,0 +1,74 @@
// Copyright 2020 Ben Hills and the project contributors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:pinepods_mobile/l10n/L.dart';
import 'package:pinepods_mobile/state/bloc_state.dart';
import 'package:pinepods_mobile/ui/widgets/platform_progress_indicator.dart';
import 'package:pinepods_mobile/ui/widgets/podcast_list.dart';
import 'package:flutter/material.dart';
import 'package:podcast_search/podcast_search.dart' as search;
class SearchResults extends StatelessWidget {
final Stream<BlocState> data;
const SearchResults({
super.key,
required this.data,
});
@override
Widget build(BuildContext context) {
return StreamBuilder<BlocState>(
stream: data,
builder: (BuildContext context, AsyncSnapshot<BlocState> snapshot) {
final state = snapshot.data;
if (state is BlocPopulatedState) {
return PodcastList(results: state.results as search.SearchResult);
} else {
if (state is BlocLoadingState) {
return const SliverFillRemaining(
hasScrollBody: false,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
PlatformProgressIndicator(),
],
),
);
} else if (state is BlocErrorState) {
return SliverFillRemaining(
hasScrollBody: false,
child: Padding(
padding: const EdgeInsets.all(32.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Icon(
Icons.search,
size: 75,
color: Theme.of(context).primaryColor,
),
Text(
L.of(context)!.no_search_results_message,
style: Theme.of(context).textTheme.titleLarge,
textAlign: TextAlign.center,
),
],
),
),
);
}
return SliverFillRemaining(
hasScrollBody: false,
child: Container(),
);
}
},
);
}
}