From c8d9de449eaf589e7be25786cf8c172f629212c9 Mon Sep 17 00:00:00 2001 From: prince Date: Tue, 12 Dec 2023 16:00:45 +0530 Subject: [PATCH] Dynamic resolution --- lib/view/home/components/container_list.dart | 18 +- lib/view/home/components/info_card.dart | 2 +- lib/view/home/home_screen.dart | 17 +- .../next-days/components/bottom_list.dart | 4 +- .../next-days/components/center_card.dart | 45 +++-- lib/view/next-days/next_14_days.dart | 170 +++++++----------- 6 files changed, 118 insertions(+), 138 deletions(-) diff --git a/lib/view/home/components/container_list.dart b/lib/view/home/components/container_list.dart index 67f3293..ff511c8 100644 --- a/lib/view/home/components/container_list.dart +++ b/lib/view/home/components/container_list.dart @@ -8,15 +8,19 @@ class ContainerList extends StatelessWidget { final controller=Get.put(HomeController()); @override Widget build(BuildContext context) { + var size=MediaQuery.sizeOf(context); return Padding( padding: const EdgeInsets.symmetric(horizontal: 30), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Obx(() => SmallContainer(text: '${controller.getCloudOver()}%', image: ImageAssets.heavyRain),), - Obx(() => SmallContainer(text : '${controller.getWindSpeed()}km/h',image : ImageAssets.wind),), - Obx(() => SmallContainer(text :'${controller.getHumidity()}%', image :ImageAssets.sun),), - ], + child: Container( + width: size.width > 700 ? size.width/1.7:size.width, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Obx(() => SmallContainer(text: '${controller.getCloudOver()}%', image: ImageAssets.heavyRain),), + Obx(() => SmallContainer(text : '${controller.getWindSpeed()}km/h',image : ImageAssets.wind),), + Obx(() => SmallContainer(text :'${controller.getHumidity()}%', image :ImageAssets.sun),), + ], + ), ), ); } diff --git a/lib/view/home/components/info_card.dart b/lib/view/home/components/info_card.dart index e557e50..f5076f0 100644 --- a/lib/view/home/components/info_card.dart +++ b/lib/view/home/components/info_card.dart @@ -12,7 +12,7 @@ class InfoCard extends StatelessWidget { var size=MediaQuery.sizeOf(context); return SizedBox( height: 240, - width: size.width, + width: size.width > 700 ? size.width/1.5:size.width, child: Stack( alignment: Alignment.bottomCenter, children: [ diff --git a/lib/view/home/home_screen.dart b/lib/view/home/home_screen.dart index 3dea78d..5c9f971 100644 --- a/lib/view/home/home_screen.dart +++ b/lib/view/home/home_screen.dart @@ -7,11 +7,13 @@ import 'package:wether_app/view/home/components/info_card.dart'; import 'package:wether_app/view/home/components/location.dart'; import 'package:wether_app/view/next-days/next_14_days.dart'; import 'package:wether_app/view_model/controllers/home_controller.dart'; + class HomeScreen extends StatefulWidget { const HomeScreen({super.key}); @override State createState() => _HomeScreenState(); } + class _HomeScreenState extends State { final controller = Get.put(HomeController()); @override @@ -21,7 +23,6 @@ class _HomeScreenState extends State { child: Padding( padding: const EdgeInsets.symmetric(horizontal: 20), child: SingleChildScrollView( - child: Column( children: [ const SizedBox( @@ -33,16 +34,18 @@ class _HomeScreenState extends State { // ), Location(), Hero( - tag: 'TAG', - child: Material( - color: Colors.transparent, - child: InfoCard())), + tag: 'TAG', + child: Material( + color: Colors.transparent, + child: InfoCard(), + ), + ), ContainerList(), const SizedBox( height: 20, ), GestureDetector( - onTap: () => Get.to(()=> NextDays()), + onTap: () => Get.to(() => NextDays()), child: const Padding( padding: EdgeInsets.symmetric(horizontal: 10), child: Row( @@ -67,8 +70,6 @@ class _HomeScreenState extends State { ), ), HoursList(), - - ], ), ), diff --git a/lib/view/next-days/components/bottom_list.dart b/lib/view/next-days/components/bottom_list.dart index 8fa3ce4..f7a922e 100644 --- a/lib/view/next-days/components/bottom_list.dart +++ b/lib/view/next-days/components/bottom_list.dart @@ -13,9 +13,11 @@ class BottomList extends StatelessWidget { Widget build(BuildContext context) { var size = MediaQuery.sizeOf(context); return SizedBox( - height: size.height / 2, + // height: size.height / 2, width: size.width, child: ListView.builder( + physics: const NeverScrollableScrollPhysics(), + shrinkWrap: true, itemCount: homeController.model.value!.days!.length, itemBuilder: (context, index) { return Card( diff --git a/lib/view/next-days/components/center_card.dart b/lib/view/next-days/components/center_card.dart index 4d2344b..0ba0c31 100644 --- a/lib/view/next-days/components/center_card.dart +++ b/lib/view/next-days/components/center_card.dart @@ -14,12 +14,16 @@ class CenterCard extends StatelessWidget { @override Widget build(BuildContext context) { var size = MediaQuery.sizeOf(context); + + // print(size); return Stack( children: [ - // SizedBox(height: 10,), Container( - height: 350, - width: size.width - 20, + height : size.height / 1.3 > 800 ? 350 : 250, + // height: 350, + // height: 250, + width: size.width >= 600 ? size.width/2 : size.width-20, + // width: size.width - 20, decoration: BoxDecoration( borderRadius: BorderRadius.circular(40), gradient: const LinearGradient( @@ -83,8 +87,11 @@ class CenterCard extends StatelessWidget { padding: const EdgeInsets.only(left: 30), child: Column( crossAxisAlignment: CrossAxisAlignment.start, + + //size.height >=250 ? :, children: [ - const Spacer(), + size.height/1.3 > 800 ? const Spacer() :SizedBox(height: 20,) , + Obx( () => Text( controller.day.value.conditions, @@ -111,6 +118,8 @@ class CenterCard extends StatelessWidget { ), ), ), + size.height / 1.3 < 800 + ? SizedBox(): Align( alignment: Alignment.centerRight, child: ShaderMask( @@ -133,26 +142,30 @@ class CenterCard extends StatelessWidget { Positioned( bottom: 30, child: SizedBox( - width: size.width - 60, + width: size.width >= 600 ? size.width/2 : size.width-60, child: SmallContainerList(), ), ) ], ), ), + size.height / 1.3 < 800 + ? SizedBox() + : + // const Spacer(), Positioned( - // left: 10, - // top: 0, - child: Obx( - () => Image.asset( - controller.getImage( - controller.currentDay.value, + // left: 10, + top: 0, + child: Obx( + () => Image.asset( + controller.getImage( + controller.currentDay.value, + ), + height: 150, + width: 150, + ), + ), ), - height: 190, - width: 190, - ), - ), - ), ], ); } diff --git a/lib/view/next-days/next_14_days.dart b/lib/view/next-days/next_14_days.dart index 5ffb733..5ca569f 100644 --- a/lib/view/next-days/next_14_days.dart +++ b/lib/view/next-days/next_14_days.dart @@ -16,106 +16,38 @@ class NextDays extends StatelessWidget { @override Widget build(BuildContext context) { var size = MediaQuery.sizeOf(context); + // print(size); return Scaffold( body: SafeArea( - child: SizedBox( - height: size.height, - width: size.width, - child: CustomScrollView( - slivers: [ - SliverAppBar( - automaticallyImplyLeading: false, - expandedHeight: 220, - // floating: false, - // pinned: true, - flexibleSpace: Container( - height: size.height / 1.8, - width: size.width, - decoration: const BoxDecoration( - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(40), - bottomRight: Radius.circular(40), - ), - gradient: LinearGradient( - begin: Alignment.centerLeft, - end: Alignment.centerRight, - colors: [ - Color(0xff6ac5fe), - Color(0xff45b6fe), - Color(0xff45b6fe), - // Colors.blue - ], - ), - ), - child: SingleChildScrollView( - child: Column( - children: [ - const SizedBox( - height: 20, - ), - const CustomAppBar(), - const SizedBox( - height: 20, - ), - DaysList(), - ], - ), - ), + child: CustomScrollView( + slivers: [ + SliverAppBar( + automaticallyImplyLeading: false, + // expandedHeight: size.height/1.5, + expandedHeight: size.height > 800 ?size.height / 1.9: size.height/1.5, + floating: false, + // pinned: true, + flexibleSpace: Container( + height: size.height > 800 ?size.height / 1.9: size.height/1.5, + width: size.width, + decoration: const BoxDecoration( + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(40), + bottomRight: Radius.circular(40), ), - ), - SliverList( - delegate: SliverChildListDelegate( - [ - Container( - decoration: const BoxDecoration( - // color: Colors.blue, - borderRadius: BorderRadius.only( - topLeft: Radius.circular(15.0), - bottomRight: Radius.circular(15.0), - ), - ), - child: Column( - children: [ - const SizedBox( - height: 10, - ), - Hero( - tag: 'TAG', - child: Material( - color: Colors.transparent, - child: CenterCard()), - ), - BottomList(), - ], - ), - ) - //DaysList(), + gradient: LinearGradient( + begin: Alignment.centerLeft, + end: Alignment.centerRight, + colors: [ + Color(0xff6ac5fe), + Color(0xff45b6fe), + Color(0xff45b6fe), + // Colors.blue ], ), ), - ], - ) - - /*Stack( - // alignment: Alignment.center, - children: [ - Positioned( - top: 1, - child: Container( - height: size.height / 1.8, - width: size.width, - decoration: const BoxDecoration( - gradient: LinearGradient( - begin: Alignment.centerLeft, - end: Alignment.centerRight, - colors: [ - Color(0xff6ac5fe), - Color(0xff45b6fe), - Color(0xff45b6fe), - // Colors.blue - ], - ), - ), + child: SingleChildScrollView( + physics: NeverScrollableScrollPhysics(), child: Column( children: [ const SizedBox( @@ -126,22 +58,50 @@ class NextDays extends StatelessWidget { height: 20, ), DaysList(), + const SizedBox( + height: 20, + ), + Container( + decoration: const BoxDecoration( + // color: Colors.blue, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(15.0), + bottomRight: Radius.circular(15.0), + ), + ), + child: Expanded( + child: Column( + children: [ + const SizedBox( + height: 10, + ), + Hero( + tag: 'TAG', + child: Material( + color: Colors.transparent, + child: CenterCard()), + ), + + ], + ), + ), + ) + ], ), ), ), - BottomList(), - Positioned( - top: 220, - left: 10, - child: Hero( - tag: 'TAG', - child: Material(color: Colors.transparent, child: CenterCard()), - ), - ) - ], - ),*/ ), + SliverList( + delegate: SliverChildListDelegate( + [ + BottomList(), + //DaysList(), + ], + ), + ), + ], + ), ), ); }