filter_box
This commit is contained in:
@@ -0,0 +1,57 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class CheckboxWithLabel extends StatefulWidget {
|
||||||
|
const CheckboxWithLabel({
|
||||||
|
super.key,
|
||||||
|
required String this.label,
|
||||||
|
required this.callback,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String label;
|
||||||
|
final Function(bool state) callback;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<CheckboxWithLabel> createState() => _CheckboxWithLabelState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CheckboxWithLabelState extends State<CheckboxWithLabel> {
|
||||||
|
bool isChecked = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
Color getColor(Set<WidgetState> states) {
|
||||||
|
const Set<WidgetState> interactiveStates = <WidgetState>{
|
||||||
|
WidgetState.pressed,
|
||||||
|
WidgetState.hovered,
|
||||||
|
WidgetState.focused,
|
||||||
|
};
|
||||||
|
if (states.any(interactiveStates.contains)) {
|
||||||
|
return Colors.blue;
|
||||||
|
}
|
||||||
|
return Colors.black54;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
Checkbox(
|
||||||
|
checkColor: Colors.white,
|
||||||
|
fillColor: WidgetStateProperty.resolveWith(getColor),
|
||||||
|
side: WidgetStateBorderSide.resolveWith(
|
||||||
|
(states) => BorderSide(width: 1.0, color: Colors.grey),
|
||||||
|
),
|
||||||
|
value: isChecked,
|
||||||
|
onChanged: (bool? value) {
|
||||||
|
setState(() {
|
||||||
|
isChecked = value!;
|
||||||
|
widget.callback(isChecked);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
widget.label,
|
||||||
|
style: TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:multimedia/widgets/checkbox_with_label.dart';
|
||||||
|
|
||||||
|
import 'package:logger/logger.dart';
|
||||||
|
import 'package:multimedia/log_printer.dart';
|
||||||
|
|
||||||
|
// ignore: must_be_immutable
|
||||||
|
class MovieFilterBox extends StatelessWidget {
|
||||||
|
MovieFilterBox({
|
||||||
|
super.key,
|
||||||
|
required this.setFilter,
|
||||||
|
});
|
||||||
|
|
||||||
|
final Function(
|
||||||
|
String text,
|
||||||
|
bool showInit,
|
||||||
|
bool showProg,
|
||||||
|
bool showDone,
|
||||||
|
) setFilter;
|
||||||
|
|
||||||
|
bool initState = false;
|
||||||
|
bool progState = false;
|
||||||
|
bool doneState = false;
|
||||||
|
String searchText = '';
|
||||||
|
|
||||||
|
Logger logger = getLogger();
|
||||||
|
|
||||||
|
void initCallback(bool state) {
|
||||||
|
initState = state;
|
||||||
|
callSetFilter();
|
||||||
|
}
|
||||||
|
|
||||||
|
void progCallback(bool state) {
|
||||||
|
progState = state;
|
||||||
|
callSetFilter();
|
||||||
|
}
|
||||||
|
|
||||||
|
void doneCallback(bool state) {
|
||||||
|
doneState = state;
|
||||||
|
callSetFilter();
|
||||||
|
}
|
||||||
|
|
||||||
|
void textCallback(String text) {
|
||||||
|
searchText = text;
|
||||||
|
callSetFilter();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
const SizedBox(
|
||||||
|
width: 20,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: 250,
|
||||||
|
child: TextField(
|
||||||
|
style: TextStyle(color: Colors.white),
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: 'Movie Title',
|
||||||
|
),
|
||||||
|
onChanged: (text) {
|
||||||
|
textCallback(text);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 20,
|
||||||
|
),
|
||||||
|
CheckboxWithLabel(
|
||||||
|
label: 'Init',
|
||||||
|
callback: initCallback,
|
||||||
|
),
|
||||||
|
CheckboxWithLabel(
|
||||||
|
label: 'Progress',
|
||||||
|
callback: progCallback,
|
||||||
|
),
|
||||||
|
CheckboxWithLabel(
|
||||||
|
label: 'Done',
|
||||||
|
callback: doneCallback,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void callSetFilter() {
|
||||||
|
setFilter(searchText, initState, progState, doneState);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:multimedia/widgets/checkbox_with_label.dart';
|
||||||
|
|
||||||
|
import 'package:logger/logger.dart';
|
||||||
|
import 'package:multimedia/log_printer.dart';
|
||||||
|
|
||||||
|
// ignore: must_be_immutable
|
||||||
|
class TVShowFilterBox extends StatelessWidget {
|
||||||
|
TVShowFilterBox({
|
||||||
|
super.key,
|
||||||
|
required this.setFilter,
|
||||||
|
});
|
||||||
|
|
||||||
|
final Function(
|
||||||
|
String text,
|
||||||
|
bool showInit,
|
||||||
|
bool showProg,
|
||||||
|
bool showDone,
|
||||||
|
) setFilter;
|
||||||
|
|
||||||
|
bool initState = false;
|
||||||
|
bool progState = false;
|
||||||
|
bool doneState = false;
|
||||||
|
String searchText = '';
|
||||||
|
|
||||||
|
Logger logger = getLogger();
|
||||||
|
|
||||||
|
void initCallback(bool state) {
|
||||||
|
initState = state;
|
||||||
|
callSetFilter();
|
||||||
|
}
|
||||||
|
|
||||||
|
void progCallback(bool state) {
|
||||||
|
progState = state;
|
||||||
|
callSetFilter();
|
||||||
|
}
|
||||||
|
|
||||||
|
void doneCallback(bool state) {
|
||||||
|
doneState = state;
|
||||||
|
callSetFilter();
|
||||||
|
}
|
||||||
|
|
||||||
|
void textCallback(String text) {
|
||||||
|
searchText = text;
|
||||||
|
callSetFilter();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
const SizedBox(
|
||||||
|
width: 20,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: 250,
|
||||||
|
child: TextField(
|
||||||
|
style: TextStyle(color: Colors.white),
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: 'TVShow Title',
|
||||||
|
),
|
||||||
|
onChanged: (text) {
|
||||||
|
textCallback(text);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 20,
|
||||||
|
),
|
||||||
|
CheckboxWithLabel(
|
||||||
|
label: 'Init',
|
||||||
|
callback: initCallback,
|
||||||
|
),
|
||||||
|
CheckboxWithLabel(
|
||||||
|
label: 'Progress',
|
||||||
|
callback: progCallback,
|
||||||
|
),
|
||||||
|
CheckboxWithLabel(
|
||||||
|
label: 'Done',
|
||||||
|
callback: doneCallback,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void callSetFilter() {
|
||||||
|
setFilter(searchText, initState, progState, doneState);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user