1
0
mirror of https://github.com/nrop19/weiman_app.git synced 2025-08-03 07:15:45 +08:00
weiman_app/lib/activities/book/tapToSearch.dart
2020-11-07 21:18:42 +00:00

99 lines
2.5 KiB
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:flutter/material.dart';
import 'package:weiman/activities/search/search.dart';
class TapToSearchWidget extends StatelessWidget {
final String leading;
final List<String> items;
const TapToSearchWidget({
Key key,
this.leading,
this.items,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextButton(
child: Text('$leading'),
onPressed: null,
style: ButtonStyle(
foregroundColor: MaterialStateProperty.all<Color>(Colors.white),
overlayColor:
MaterialStateProperty.all<Color>(Colors.white.withOpacity(0.3)),
visualDensity: VisualDensity.comfortable,
),
),
Expanded(
child: Wrap(
spacing: 10,
crossAxisAlignment: WrapCrossAlignment.center,
children: items.map((e) => _Item(string: e)).toList(),
),
),
],
);
}
}
class _Item extends StatelessWidget {
final String string;
const _Item({Key key, @required this.string})
: assert(string != null),
super(key: key);
@override
Widget build(BuildContext context) {
return TextButton.icon(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => ActivitySearch(
search: string,
)));
},
icon: Icon(Icons.search, size: 14),
label: Text(string),
style: ButtonStyle(
foregroundColor: MaterialStateProperty.all<Color>(Colors.white),
overlayColor:
MaterialStateProperty.all<Color>(Colors.white.withOpacity(0.3)),
visualDensity: VisualDensity.comfortable,
),
);
return GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => ActivitySearch(
search: string,
)));
},
child: Text.rich(
TextSpan(
children: [
TextSpan(
text: string,
style: TextStyle(decoration: TextDecoration.underline)),
WidgetSpan(
child: Icon(
Icons.search,
color: Colors.white,
size: 14,
)),
],
),
style: TextStyle(
color: Colors.white,
textBaseline: TextBaseline.ideographic,
),
),
);
}
}