2021-11-23 04:11:45 +01:00
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:gecko/globals.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
2021-12-23 15:13:58 +01:00
|
|
|
import 'package:gecko/providers/search.dart';
|
2021-11-23 04:11:45 +01:00
|
|
|
import 'package:gecko/screens/search_result.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
// import 'package:gecko/models/home.dart';
|
|
|
|
// import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
class SearchScreen extends StatelessWidget {
|
2021-12-23 12:36:09 +01:00
|
|
|
const SearchScreen({Key? key}) : super(key: key);
|
2021-11-23 04:11:45 +01:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
|
|
|
SearchProvider _searchProvider = Provider.of<SearchProvider>(context);
|
2021-12-23 21:44:24 +01:00
|
|
|
final double screenHeight = MediaQuery.of(context).size.height;
|
2021-11-23 04:11:45 +01:00
|
|
|
|
2022-05-27 16:58:03 +02:00
|
|
|
|
2021-11-23 04:11:45 +01:00
|
|
|
return WillPopScope(
|
|
|
|
onWillPop: () {
|
|
|
|
_searchProvider.searchController.text = '';
|
|
|
|
return Future<bool>.value(true);
|
|
|
|
},
|
|
|
|
child: Scaffold(
|
|
|
|
appBar: AppBar(
|
|
|
|
toolbarHeight: 60 * ratio,
|
|
|
|
title: const SizedBox(
|
|
|
|
height: 22,
|
|
|
|
child: Text('Rechercher'),
|
|
|
|
),
|
|
|
|
leading: IconButton(
|
|
|
|
icon: const Icon(Icons.arrow_back, color: Colors.black),
|
|
|
|
onPressed: () {
|
|
|
|
_searchProvider.searchController.text = '';
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
}),
|
|
|
|
),
|
|
|
|
body: SafeArea(
|
|
|
|
child: Column(children: <Widget>[
|
|
|
|
SizedBox(height: isTall ? 200 : 100),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 17),
|
|
|
|
child: TextField(
|
|
|
|
controller: _searchProvider.searchController,
|
|
|
|
autofocus: true,
|
|
|
|
maxLines: 1,
|
|
|
|
textAlign: TextAlign.left,
|
|
|
|
onChanged: (v) => _searchProvider.rebuildWidget(),
|
|
|
|
decoration: InputDecoration(
|
|
|
|
filled: true,
|
|
|
|
fillColor: Colors.white,
|
|
|
|
prefixIconConstraints: const BoxConstraints(
|
|
|
|
minHeight: 32,
|
|
|
|
),
|
|
|
|
prefixIcon: const Padding(
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 17),
|
|
|
|
child: Image(
|
|
|
|
image: AssetImage('assets/loupe-noire.png'),
|
|
|
|
height: 35),
|
|
|
|
),
|
|
|
|
border: OutlineInputBorder(
|
|
|
|
borderSide:
|
2021-12-23 12:36:09 +01:00
|
|
|
BorderSide(color: Colors.grey[500]!, width: 2),
|
2021-11-23 04:11:45 +01:00
|
|
|
borderRadius: BorderRadius.circular(8)),
|
|
|
|
focusedBorder: OutlineInputBorder(
|
|
|
|
borderSide:
|
2021-12-23 12:36:09 +01:00
|
|
|
BorderSide(color: Colors.grey[500]!, width: 2.5),
|
2021-11-23 04:11:45 +01:00
|
|
|
borderRadius: BorderRadius.circular(8),
|
|
|
|
),
|
|
|
|
contentPadding: const EdgeInsets.all(20),
|
|
|
|
),
|
|
|
|
style: const TextStyle(
|
|
|
|
fontSize: 20,
|
|
|
|
color: Colors.black,
|
|
|
|
fontWeight: FontWeight.w400,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const Spacer(flex: 1),
|
|
|
|
SizedBox(
|
|
|
|
width: 410,
|
|
|
|
height: 70,
|
|
|
|
child: ElevatedButton(
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
elevation: 4,
|
|
|
|
primary: orangeC, // background
|
|
|
|
onPrimary: Colors.white, // foreground
|
|
|
|
),
|
|
|
|
onPressed: _searchProvider.searchController.text.length >= 2
|
|
|
|
? () {
|
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(builder: (context) {
|
|
|
|
return const SearchResultScreen();
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
: null,
|
|
|
|
child: const Text(
|
|
|
|
'Rechercher',
|
|
|
|
style: TextStyle(fontSize: 24, fontWeight: FontWeight.w600),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2021-12-23 21:44:24 +01:00
|
|
|
Spacer(flex: screenHeight <= 800 ? 1 : 2),
|
2021-11-23 04:11:45 +01:00
|
|
|
]),
|
|
|
|
),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|