home_page.dart
3.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import 'package:like/widgets/bottom_bar.dart';
import 'package:like/widgets/carousel.dart';
import 'package:like/widgets/destination_heading.dart';
import 'package:like/widgets/explore_drawer.dart';
import 'package:like/widgets/featured_heading.dart';
import 'package:like/widgets/featured_tiles.dart';
import 'package:like/widgets/floating_quick_access_bar.dart';
import 'package:like/widgets/responsive.dart';
import 'package:like/widgets/top_bar_contents.dart';
import 'package:flutter/material.dart';
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
final ScrollController _scrollController = ScrollController();
double _scrollPosition = 0;
double _opacity = 0;
_scrollListener() {
setState(() {
_scrollPosition = _scrollController.position.pixels;
});
}
@override
void initState() {
_scrollController.addListener(_scrollListener);
super.initState();
}
@override
Widget build(BuildContext context) {
var screenSize = MediaQuery.of(context).size;
_opacity = _scrollPosition < screenSize.height * 0.40
? _scrollPosition / (screenSize.height * 0.40)
: 1;
return Scaffold(
extendBodyBehindAppBar: true,
appBar: ResponsiveWidget.isSmallScreen(context)
? AppBar(
backgroundColor: Colors.blueGrey.shade900.withOpacity(_opacity),
elevation: 0,
title: Text(
'EXPLORE',
style: TextStyle(
color: Colors.blueGrey.shade100,
fontSize: 20,
fontFamily: 'Montserrat',
fontWeight: FontWeight.w400,
letterSpacing: 3,
),
),
)
: PreferredSize(
preferredSize: Size(screenSize.width, 1000),
child: TopBarContents(_opacity),
),
drawer: ExploreDrawer(),
body: SingleChildScrollView(
controller: _scrollController,
physics: ClampingScrollPhysics(),
child: Column(
children: [
Stack(
children: [
Container(
child: SizedBox(
height: screenSize.height * 0.45,
width: screenSize.width,
child: Image.asset(
'assets/images/cover.jpg',
fit: BoxFit.cover,
),
),
),
Column(
children: [
FloatingQuickAccessBar(screenSize: screenSize),
Container(
child: Column(
children: [
FeaturedHeading(
screenSize: screenSize,
),
FeaturedTiles(screenSize: screenSize)
],
),
),
],
)
],
),
DestinationHeading(screenSize: screenSize),
DestinationCarousel(),
SizedBox(height: screenSize.height / 10),
BottomBar(),
],
),
),
);
}
}