Skip to content

Commit

Permalink
Dynamic resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
prince089 committed Dec 12, 2023
1 parent 8c1da25 commit c8d9de4
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 138 deletions.
18 changes: 11 additions & 7 deletions lib/view/home/components/container_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),),
],
),
),
);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/view/home/components/info_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
17 changes: 9 additions & 8 deletions lib/view/home/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<HomeScreen> createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {
final controller = Get.put(HomeController());
@override
Expand All @@ -21,7 +23,6 @@ class _HomeScreenState extends State<HomeScreen> {
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: SingleChildScrollView(

child: Column(
children: [
const SizedBox(
Expand All @@ -33,16 +34,18 @@ class _HomeScreenState extends State<HomeScreen> {
// ),
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(
Expand All @@ -67,8 +70,6 @@ class _HomeScreenState extends State<HomeScreen> {
),
),
HoursList(),


],
),
),
Expand Down
4 changes: 3 additions & 1 deletion lib/view/next-days/components/bottom_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
45 changes: 29 additions & 16 deletions lib/view/next-days/components/center_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand All @@ -111,6 +118,8 @@ class CenterCard extends StatelessWidget {
),
),
),
size.height / 1.3 < 800
? SizedBox():
Align(
alignment: Alignment.centerRight,
child: ShaderMask(
Expand All @@ -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,
),
),
),
],
);
}
Expand Down
170 changes: 65 additions & 105 deletions lib/view/next-days/next_14_days.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(),
],
),
),
],
),
),
);
}
Expand Down

0 comments on commit c8d9de4

Please sign in to comment.