voyagehandbook/lib/views/search.dart
2023-03-18 16:55:08 +01:00

45 lines
1.3 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter/src/widgets/placeholder.dart';
import 'package:voyagehandbook/api/wikimedia.dart';
import '../util/drawer.dart';
class SearchView extends StatefulWidget {
const SearchView({super.key});
@override
State<SearchView> createState() => _SearchViewState();
}
class _SearchViewState extends State<SearchView> {
final _searchController = TextEditingController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text("Search WikiVoyage")),
drawer: genDrawer(2, context),
body: Center(
child: SizedBox(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width * 0.9,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextField(
controller: _searchController,
),
TextButton(
onPressed: () async {
if (_searchController.text == "") return;
var r = await WikiApi.search(_searchController.text);
print(r[0].excerpt);
},
child: const Text("Search"))
],
),
),
),
);
}
}