Fix refresh

This commit is contained in:
Yoshi 2024-07-07 15:01:58 +03:00
parent aa125fcdc1
commit 6d0d0efe36

View file

@ -32,72 +32,72 @@ class _ListWeatherCardState extends State<ListWeatherCard> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final textTheme = context.textTheme; final textTheme = context.textTheme;
final titleMedium = textTheme.titleMedium; final titleMedium = textTheme.titleMedium;
return RefreshIndicator( return Obx(
onRefresh: () async { () => weatherController.weatherCards.isEmpty
await weatherController.updateCacheCard(true); ? Center(
setState(() {}); child: SingleChildScrollView(
}, child: Column(
child: Obx( children: [
() => weatherController.weatherCards.isEmpty Image.asset(
? Center( 'assets/icons/City.png',
child: SingleChildScrollView( scale: 6,
child: Column( ),
children: [ SizedBox(
Image.asset( width: Get.size.width * 0.8,
'assets/icons/City.png', child: Text(
scale: 6, 'noWeatherCard'.tr,
), textAlign: TextAlign.center,
SizedBox( style: titleMedium?.copyWith(
width: Get.size.width * 0.8, fontWeight: FontWeight.w600,
child: Text( fontSize: 18,
'noWeatherCard'.tr,
textAlign: TextAlign.center,
style: titleMedium?.copyWith(
fontWeight: FontWeight.w600,
fontSize: 18,
),
), ),
), ),
],
),
),
)
: NestedScrollView(
physics: const NeverScrollableScrollPhysics(),
headerSliverBuilder: (context, innerBoxIsScrolled) {
return [
SliverToBoxAdapter(
child: MyTextForm(
labelText: 'search'.tr,
type: TextInputType.text,
icon: const Icon(
Iconsax.search_normal_1,
size: 20,
),
controller: searchTasks,
margin: const EdgeInsets.symmetric(
horizontal: 10, vertical: 5),
onChanged: applyFilter,
iconButton: searchTasks.text.isNotEmpty
? IconButton(
onPressed: () {
searchTasks.clear();
applyFilter('');
},
icon: const Icon(
Iconsax.close_circle,
color: Colors.grey,
size: 20,
),
)
: null,
),
), ),
]; ],
}, ),
body: WeatherCardList(searchCity: filter),
), ),
), )
: NestedScrollView(
physics: const NeverScrollableScrollPhysics(),
headerSliverBuilder: (context, innerBoxIsScrolled) {
return [
SliverToBoxAdapter(
child: MyTextForm(
labelText: 'search'.tr,
type: TextInputType.text,
icon: const Icon(
Iconsax.search_normal_1,
size: 20,
),
controller: searchTasks,
margin: const EdgeInsets.symmetric(
horizontal: 10, vertical: 5),
onChanged: applyFilter,
iconButton: searchTasks.text.isNotEmpty
? IconButton(
onPressed: () {
searchTasks.clear();
applyFilter('');
},
icon: const Icon(
Iconsax.close_circle,
color: Colors.grey,
size: 20,
),
)
: null,
),
),
];
},
body: RefreshIndicator(
onRefresh: () async {
await weatherController.updateCacheCard(true);
setState(() {});
},
child: WeatherCardList(searchCity: filter),
),
),
); );
} }
} }