Created
September 20, 2020 18:28
-
-
Save Mari88888888/2de7ebb5749e5076d7b0d78fced628f9 to your computer and use it in GitHub Desktop.
Домашнее задание 6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() { | |
runApp( | |
mainLayout(), | |
); | |
} | |
Widget mainLayout() { | |
return MaterialApp( | |
home: Container( | |
color: Colors.white, | |
child: Column(children: [ | |
Container( | |
height: 80, | |
padding: EdgeInsets.symmetric(horizontal: 16), | |
child: menuBar(), | |
), | |
Container( | |
height: 188, | |
margin: EdgeInsets.symmetric(vertical: 24), | |
child: productBanners(), | |
), | |
Container( | |
height: 44, | |
alignment: Alignment.topLeft, | |
padding: EdgeInsets.only(left: 16), | |
child: catalogHeader(), | |
), | |
Expanded( | |
child: catalogGrid(), | |
) | |
]), | |
), | |
); | |
} | |
Widget menuBar() { | |
return Row( | |
mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
children: [ | |
icon('https://i.pinimg.com/originals/da/3c/b2/da3cb24e6df4b707b78a8cf0870569db.png', 40.0), | |
icon('https://i.pinimg.com/originals/a2/7d/61/a27d6110cfa095cc73e60b0d7b80ada2.png', 40.0), | |
], | |
); | |
} | |
Widget icon(name, size, {padding = 8.0}) { | |
return Container( | |
width: size, | |
height: size, | |
margin: EdgeInsets.all(padding), | |
child: Image.network('$name'), | |
); | |
} | |
Widget productBanners() { | |
return ListView( | |
scrollDirection: Axis.horizontal, | |
children: [ | |
product('https://i.pinimg.com/originals/8a/8d/28/8a8d284f0396f8f9844221ef63fe45dd.png', Colors.cyan, "Origami\nChair"), | |
product('https://i.pinimg.com/originals/ba/92/1a/ba921a219b814312f3f0b7db9d5d7e9f.png', Colors.indigo, "Adirondak\nChair"), | |
product('https://i.pinimg.com/originals/8a/8d/28/8a8d284f0396f8f9844221ef63fe45dd.png', Colors.red, "Origami\nChair"), | |
product('https://i.pinimg.com/originals/ba/92/1a/ba921a219b814312f3f0b7db9d5d7e9f.png', Colors.green, "Adirondak\nChair"), | |
], | |
); | |
} | |
Widget product( | |
String iconName, | |
Color backgroundColor, | |
String title, | |
) { | |
return Material( | |
child: Container( | |
width: 188, | |
height: 188, | |
margin: EdgeInsets.only(left: 24), | |
decoration: BoxDecoration( | |
borderRadius: BorderRadius.all(Radius.circular(32)), | |
color: backgroundColor, | |
), | |
child: Stack( | |
children: [ | |
Positioned( | |
left: 20, | |
top: 20, | |
child: Text( | |
title, | |
style: TextStyle( | |
color: Colors.white, | |
fontSize: 24, | |
decoration: null, | |
decorationStyle: null, | |
), | |
), | |
), | |
Positioned( | |
bottom: 0, | |
right: 0, | |
child: icon(iconName, 140.0), | |
) | |
], | |
), | |
), | |
); | |
} | |
Widget catalogHeader() { | |
return Material( | |
child: Text( | |
'Browse Furniture', | |
style: TextStyle(color: Colors.black, fontSize: 32.0), | |
), | |
); | |
} | |
Widget catalogGrid() { | |
return SingleChildScrollView( | |
child: Container( | |
padding: EdgeInsets.symmetric(horizontal: 16), | |
child: Column( | |
children: <Widget>[ | |
catalogFirstRow(), | |
catalogSecondRow(), | |
catalogThirdRow(), | |
], | |
), | |
), | |
); | |
} | |
Widget catalogFirstRow() { | |
return Row( | |
mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
children: <Widget>[ | |
category('https://i.pinimg.com/originals/8c/b7/bb/8cb7bb6c947917d19f524645acc76bf5.png', 'Chairs'), | |
category('https://i.pinimg.com/originals/21/32/e7/2132e77840c1580324576d4ad23622bd.png', 'Sofa'), | |
category('https://i.pinimg.com/originals/5b/c5/6f/5bc56fa8a546bdea79e01c9f83176388.png', 'Racks'), | |
], | |
); | |
} | |
Widget catalogSecondRow() { | |
return Row( | |
mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
children: <Widget>[ | |
category('https://i.pinimg.com/originals/f6/9e/ca/f69eca593ef9d383fdba38929f383843.png', 'Carpet'), | |
category('https://i.pinimg.com/originals/11/07/85/110785598d013cc44ab15dc9e3557609.png', 'Chandelier'), | |
category('https://i.pinimg.com/originals/c2/a1/54/c2a1543e3cdfc6a112e542409e41ca2d.png', 'Bed'), | |
], | |
); | |
} | |
Widget catalogThirdRow() { | |
return Row( | |
mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
children: <Widget>[ | |
category('https://i.pinimg.com/originals/1b/57/34/1b57348a6b21b7c03ff9862a3a21fc77.png', 'Workstation'), | |
category('https://i.pinimg.com/originals/99/a7/65/99a765791c1751b6aae3ffcf95498ce6.png', 'Book Shelf'), | |
category('https://i.pinimg.com/originals/cb/7f/97/cb7f978ad16580ff4c26cf28288b11c4.png', 'Bean Bag'), | |
], | |
); | |
} | |
Widget category(String iconName, String name) { | |
return Material( | |
child: Column( | |
children: <Widget>[ | |
icon(iconName, 60.0), | |
Text( | |
name, | |
style: TextStyle( | |
color: Colors.black, | |
fontSize: 12, | |
), | |
), | |
], | |
), | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment