-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
439 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:jasmine/basic/methods.dart'; | ||
import 'package:jasmine/screens/components/floating_search_bar.dart'; | ||
|
||
import 'components/browser_bottom_sheet.dart'; | ||
import 'components/comic_floating_search_bar.dart'; | ||
import 'components/comic_pager.dart'; | ||
import 'components/actions.dart'; | ||
|
||
class ComicSearchScreen extends StatefulWidget { | ||
final String initKeywords; | ||
|
||
const ComicSearchScreen({required this.initKeywords, Key? key}) | ||
: super(key: key); | ||
|
||
@override | ||
State<StatefulWidget> createState() => _ComicSearchScreenState(); | ||
} | ||
|
||
class _ComicSearchScreenState extends State<ComicSearchScreen> { | ||
final _controller = FloatingSearchBarController(); | ||
late var _keywords = widget.initKeywords; | ||
SortBy _sortBy = sortByDefault; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return ComicFloatingSearchBarScreen( | ||
controller: _controller, | ||
onQuery: (value) { | ||
setState(() { | ||
_keywords = value; | ||
}); | ||
}, | ||
child: Scaffold( | ||
appBar: AppBar( | ||
title: Text(_keywords), | ||
actions: [ | ||
IconButton( | ||
onPressed: () { | ||
_controller.display(modifyInput: _keywords); | ||
}, | ||
icon: const Icon(Icons.search), | ||
), | ||
const BrowserBottomSheetAction(), | ||
buildOrderSwitch(context, _sortBy, (value) { | ||
setState(() { | ||
_sortBy = value; | ||
}); | ||
}), | ||
], | ||
), | ||
body: ComicPager( | ||
key: Key("$_keywords:$_sortBy"), | ||
onPage: (int page) async { | ||
final response = await methods.comicSearch( | ||
_keywords, | ||
_sortBy, | ||
page, | ||
); | ||
return response; | ||
}, | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:jasmine/basic/commons.dart'; | ||
import 'package:jasmine/basic/entities.dart'; | ||
|
||
Widget buildOrderSwitch( | ||
BuildContext context, | ||
SortBy value, | ||
ValueChanged<SortBy> valueChanged, | ||
) { | ||
final iconColor = Theme.of(context).appBarTheme.iconTheme?.color; | ||
return MaterialButton( | ||
onPressed: () async { | ||
final target = await chooseSortBy(context); | ||
if (target != null) { | ||
valueChanged(target); | ||
} | ||
}, | ||
child: Column( | ||
children: [ | ||
Expanded(child: Container()), | ||
Icon( | ||
Icons.sort, | ||
color: iconColor, | ||
), | ||
Expanded(child: Container()), | ||
Text(value.toString(), style: TextStyle(color: iconColor)), | ||
Expanded(child: Container()), | ||
], | ||
), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
import '../comic_search_screen.dart'; | ||
import 'floating_search_bar.dart'; | ||
|
||
class ComicFloatingSearchBarScreen extends StatefulWidget { | ||
final FloatingSearchBarController controller; | ||
final Widget child; | ||
final ValueChanged<String>? onQuery; | ||
|
||
const ComicFloatingSearchBarScreen({ | ||
Key? key, | ||
required this.controller, | ||
required this.child, | ||
this.onQuery, | ||
}) : super(key: key); | ||
|
||
@override | ||
State<StatefulWidget> createState() => _ComicFloatingSearchBarScreenState(); | ||
} | ||
|
||
class _ComicFloatingSearchBarScreenState | ||
extends State<ComicFloatingSearchBarScreen> { | ||
@override | ||
Widget build(BuildContext context) { | ||
return FloatingSearchBarScreen( | ||
controller: widget.controller, | ||
child: widget.child, | ||
onSubmitted: _onSubmitted, | ||
); | ||
} | ||
|
||
void _onSubmitted(String value) { | ||
widget.controller.hide(); | ||
if (value.isNotEmpty && widget.onQuery != null) { | ||
widget.onQuery!(value); | ||
} | ||
} | ||
} |
Oops, something went wrong.