Skip to content
Snippets Groups Projects
Commit a143a8fb authored by Chaitanya's avatar Chaitanya
Browse files

Scrollable homepage and drawer

parent 431c77cc
No related branches found
No related tags found
1 merge request!2Home page chaitanya
import 'package:deggendorf_app/bottom_navigation_bar_buttons/home_page/list_of_widgets_for_home_page.dart';
import 'package:deggendorf_app/bottom_navigation_bar_buttons/home_page/weather/current_weather.dart';
import 'package:deggendorf_app/main.dart';
import 'package:flutter/material.dart';
class HomePage extends StatelessWidget {
const HomePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: MyStatefulWidget(),
);
}
}
class MyStatefulWidget extends StatefulWidget {
const MyStatefulWidget({Key? key}) : super(key: key);
@override
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
}
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
List<int> bottom = <int>[0];
@override
Widget build(BuildContext context) {
const Key centerKey = ValueKey<String>('bottom-sliver-list');
return Scaffold(
appBar: AppBar(
title: const Text('Deggendorf App'),
),
drawer: Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: [
const DrawerHeader(
decoration: BoxDecoration(
color: Colors.blue,
),
child: Text('Drawer Header'),
),
ListTile(
title: const Text('Option 1'),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const SecondRoute()));
},
),
ListTile(
title: const Text('Option 2'),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const SecondRoute()));
},
),
],
),
),
body: CustomScrollView(
center: centerKey,
slivers: <Widget>[
SliverList(
key: centerKey,
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return new InkWell(
onTap: () {
if (index == 0) {
//If the widget tapped is the weather widget, then open weather page :)
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const CurrentWeather()),
);
}
},
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20)),
height: 125,
child: new MyList(context).myList[index],
));
},
childCount: new MyList(context).myList.length,
),
),
],
),
);
}
}
import 'package:deggendorf_app/bottom_navigation_bar_buttons/home_page/weather/current_weather.dart';
import 'package:flutter/cupertino.dart';
class MyList {
List<Widget> myList = [];
MyList(BuildContext buildContext) {
myList = [
actualWeatherContainer(buildContext),
Text("Input your widget here"),
Text("Input your widget here"),
Text("Input your widget here"),
Text("Input your widget here"),
Text("Input your widget here"),
Text("Input your widget here"),
Text("Input your widget here"),
Text("Input your widget here"),
];
}
}
......@@ -22,50 +22,65 @@ class _CurrentWeatherState extends State<CurrentWeather> {
appBar: AppBar(
title: const Text("Deggendorf"),
),
body:
Column(mainAxisAlignment: MainAxisAlignment.center, children: [
Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height - 56,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage(
'assets/chuttersnap-TSgwbumanuE-unsplash1.jpg'),
fit: BoxFit.cover)),
child: FutureBuilder(
builder: (buildContext, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
weather = snapshot.data as WeatherData;
if (weather == null) {
return const Text("Error getting weather");
} else {
return weatherBox(weather);
}
} else {
return const CircularProgressIndicator();
}
},
future: getCurrentWeather(),
),
)
])));
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Flexible(
flex: 1,
fit: FlexFit.loose,
child: actualWeatherContainer(context))
])));
}
}
Container actualWeatherContainer(BuildContext context) {
late WeatherData weather;
return Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/chuttersnap-TSgwbumanuE-unsplash1.jpg'),
fit: BoxFit.cover)),
child: FutureBuilder(
builder: (buildContext, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
weather = snapshot.data as WeatherData;
if (weather == null) {
return const Text("Error getting weather");
} else {
return weatherBox(weather);
}
} else {
return const CircularProgressIndicator();
}
},
future: getCurrentWeather(),
),
);
}
Widget weatherBox(WeatherData weather) {
return Column(children: <Widget>[
Padding(
padding: const EdgeInsets.fromLTRB(0, 150, 0, 0),
child: Text("${weather.temperature}°C",
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
//padding: const EdgeInsets.fromLTRB(0, 150, 0, 0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text("${weather.temperature}°C",
style: GoogleFonts.dancingScript(
fontSize: 65,
color: Color.fromRGBO(0, 0, 139, 0.7),
fontWeight: FontWeight.bold))),
Text("${weather.description}",
style: GoogleFonts.pacifico(
fontSize: 30, color: Color.fromRGBO(0, 0, 139, 0.7))),
fontWeight: FontWeight.bold)),
Text("${weather.description}",
style: GoogleFonts.pacifico(
fontSize: 30, color: Color.fromRGBO(0, 0, 139, 0.7)))
],
),
Padding(
padding: const EdgeInsets.fromLTRB(0, 50, 0, 0),
padding: const EdgeInsets.fromLTRB(0, 10, 0, 0),
child: Text("Feels:${weather.feelsLike}°C",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15))),
Text("Highest: ${weather.high}°C Lowest: ${weather.low}°C",
......
import 'package:deggendorf_app/bottom_navigation_bar_buttons/weather/current_weather.dart';
import 'package:deggendorf_app/bottom_navigation_bar_buttons/home_page/home_page.dart';
import 'package:flutter/material.dart';
import 'bottom_navigation_bar_buttons/forum/forum.dart';
import 'bottom_navigation_bar_buttons/home_page/weather/current_weather.dart';
void main() {
runApp(const MyApp());
......@@ -43,7 +44,7 @@ class _MyHomePageState extends State<MyHomePage> {
*/
static const List<Widget> _widgetOptions = <Widget>[
//Index: 0
CurrentWeather(),
HomePage(),
//Index: 1,
SecondRoute(),
//Index: 2,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment