fix bottomsheel

This commit is contained in:
Mohamed Nouffer
2023-09-06 21:36:11 +05:30
parent 36751f6ef7
commit 44a3fc21fb
7 changed files with 676 additions and 547 deletions

View File

@ -7,22 +7,24 @@ import 'package:rogapp/pages/search/search_controller.dart';
import 'package:rogapp/widgets/bottom_sheet_new.dart';
class SearchPage extends StatelessWidget {
SearchPage({Key? key}) : super(key: key);
SearchPage({Key? key}) : super(key: key);
SearchBarController searchController = Get.find<SearchBarController>();
IndexController indexController = Get.find<IndexController>();
Image getImage(int index){
if(searchController.searchResults[index].properties!["photos"] == null || searchController.searchResults[index].properties!["photos"] == ""){
Image getImage(int index) {
if (searchController.searchResults[index].properties!["photos"] == null ||
searchController.searchResults[index].properties!["photos"] == "") {
return const Image(image: AssetImage('assets/images/empty_image.png'));
}
else{
} else {
return Image(
image: NetworkImage(searchController.searchResults[index].properties!["photos"]),
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
image: NetworkImage(
searchController.searchResults[index].properties!["photos"]),
errorBuilder:
(BuildContext context, Object exception, StackTrace? stackTrace) {
return Image.asset("assets/images/empty_image.png");
},
);
);
}
}
@ -33,60 +35,67 @@ class SearchPage extends StatelessWidget {
elevation: 0,
backgroundColor: Colors.white,
leading: IconButton(
onPressed:(){
Get.back();
},
icon: const Icon(Icons.arrow_back_ios_new, color: Colors.black,)
),
onPressed: () {
Get.back();
},
icon: const Icon(
Icons.arrow_back_ios_new,
color: Colors.black,
)),
centerTitle: true,
//title: const CupertinoSearchTextField(),
),
body: SingleChildScrollView(
child: TypeAheadField(
textFieldConfiguration: TextFieldConfiguration(
autofocus: true,
style: DefaultTextStyle.of(context).style.copyWith(
fontStyle: FontStyle.normal,
fontSize: 15.0,
),
decoration: InputDecoration(
border: const OutlineInputBorder(),
hintText: "検索",
prefixIcon: const Icon(Icons.search),
suffixIcon: IconButton(
icon: const Icon(Icons.clear),
onPressed: () {
// clear the text field
},
textFieldConfiguration: TextFieldConfiguration(
autofocus: true,
style: DefaultTextStyle.of(context).style.copyWith(
fontStyle: FontStyle.normal,
fontSize: 15.0,
),
decoration: InputDecoration(
border: const OutlineInputBorder(),
hintText: "検索",
prefixIcon: const Icon(Icons.search),
suffixIcon: IconButton(
icon: const Icon(Icons.clear),
onPressed: () {
// clear the text field
},
),
),
suggestionsCallback: (pattern) async{
return searchController.searchResults.where((GeoJsonFeature element) => element.properties!["location_name"].toString().contains(pattern));
//return await
},
itemBuilder: (context, GeoJsonFeature suggestion){
return ListTile(
title: Text(suggestion.properties!["location_name"]),
subtitle: suggestion.properties!["category"] != null ? Text(suggestion.properties!["category"]) : const Text(""),
//leading: getImage(index),
);
},
onSuggestionSelected: (GeoJsonFeature suggestion){
indexController.currentFeature.clear();
indexController.currentFeature.add(suggestion);
Get.back();
showModalBottomSheet(
isScrollControlled: true,
context: context,
//builder: (context) => BottomSheetWidget(),
builder:((context) => BottomSheetNew())
);
},
),
suggestionsCallback: (pattern) async {
return searchController.searchResults.where(
(GeoJsonFeature element) => element.properties!["location_name"]
.toString()
.contains(pattern));
//return await
},
itemBuilder: (context, GeoJsonFeature suggestion) {
return ListTile(
title: Text(suggestion.properties!["location_name"]),
subtitle: suggestion.properties!["category"] != null
? Text(suggestion.properties!["category"])
: const Text(""),
//leading: getImage(index),
);
},
onSuggestionSelected: (GeoJsonFeature suggestion) {
indexController.currentFeature.clear();
indexController.currentFeature.add(suggestion);
Get.back();
showModalBottomSheet(
constraints:
BoxConstraints.loose(Size(Get.width, Get.height * 0.75)),
isScrollControlled: true,
context: context,
//builder: (context) => BottomSheetWidget(),
builder: ((context) => BottomSheetNew()));
},
),
),
// Obx(() =>
// Obx(() =>
// ListView.builder(
// itemCount: searchController.searchResults.length,
// itemBuilder: (context, index){
@ -111,4 +120,4 @@ class SearchPage extends StatelessWidget {
// )
);
}
}
}