Skip to content

Commit

Permalink
🔀 Merge pull request #27 from Fedodo/dev
Browse files Browse the repository at this point in the history
✨ Added search
  • Loading branch information
LNA-DEV authored Jul 1, 2023
2 parents 0992973 + d3725db commit 91f6a4f
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"cSpell.words": [
"activitypub"
]
}
73 changes: 73 additions & 0 deletions lib/Widgets/search.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import 'package:activitypub/APIs/ActivityPubRelated/webfinger_api.dart';
import 'package:flutter/material.dart';

class Search extends StatelessWidget {
Search({
Key? key,
required this.appTitle,
required this.getProfile,
}) : super(key: key);

final searchTextEditingController = TextEditingController();
final String appTitle;
final Function(String profileId) getProfile;

@override
Widget build(BuildContext context) {
return Column(
children: [
Form(
child: Row(
children: [
Expanded(
child: TextFormField(
controller: searchTextEditingController,
decoration: const InputDecoration(
hintText: 'Search',
),
validator: (String? value) {
if (value == null || value.isEmpty) {
return 'Please enter some text';
}
return null;
},
),
),
IconButton(
onPressed: () async {
String input = searchTextEditingController.text;

if (input.contains("@")) {
WebfingerApi webfingerApi = WebfingerApi();
String profileId = await webfingerApi.getUser(input);

// ignore: use_build_context_synchronously
Navigator.push(
context,
PageRouteBuilder(
transitionDuration: const Duration(milliseconds: 300),
reverseTransitionDuration:
const Duration(milliseconds: 300),
pageBuilder: (context, animation, animation2) =>
getProfile(profileId),
transitionsBuilder:
(context, animation, animation2, widget) =>
SlideTransition(
position: Tween(
begin: const Offset(1.0, 0.0),
end: const Offset(0.0, 0.0),
).animate(animation),
child: widget),
),
);
}
},
icon: const Icon(Icons.search),
),
],
),
),
],
);
}
}
4 changes: 3 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: fedodo_general
description: A flutter package which contains general components of the Fedodo-UIs.
version: 1.6.3
version: 1.6.4
homepage: https://fedodo.org

environment:
Expand All @@ -10,6 +10,8 @@ environment:
dependencies:
flutter:
sdk: flutter
activitypub: ^1.2.0

shared_preferences: ^2.0.17
oauth2_client: ^3.0.0
flutter_guid: ^0.3.1
Expand Down

0 comments on commit 91f6a4f

Please sign in to comment.