Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ignore_for_file: prefer_const_constructors
- import 'package:cloud_firestore/cloud_firestore.dart';
- import 'package:plantual_1/utils/utils.dart';
- import 'package:firebase_core/firebase_core.dart';
- import 'package:firebase_auth/firebase_auth.dart';
- import 'package:flutter/material.dart';
- import 'package:insta_image_viewer/insta_image_viewer.dart';
- import 'package:plantual_1/icons.dart';
- Map<String, String> _mapPlantInfo = {
- 'name': 'Цимбидиум мечелистный',
- 'sort': 'Цимбидиум',
- 'subName': 'Cymbidium aloifolium',
- 'imagePlant1': 'https://chto-posadit.ru/wp-content/uploads/TSimbidium-mechelistnyy-Cymbidium-ensifolium-foto.jpg',
- 'imagePlant2': 'https://www.picturethisai.com/image-handle/website_cmsname/image/1080/157555734219849732.jpeg?x-oss-process=image/format,webp&v=1.0',
- 'imagePlant3': 'https://passiflora.ru/images/_products/orchidgart/1128.jpg',
- 'imagePlant4': 'https://passiflora.ru/images/_products/tenshinorchids/1304.jpg',
- 'description': 'Цимбидиум мечелистный — это популярный вид орхидей с плотными, блестящими листьями, которые растут в форме меча. Цветы крупные, с приятным ароматом, появляются на длинных цветоносах. Окраска цветов варьируется от белого до кремово-желтого с красноватыми пятнами. Растение устойчиво и адаптируется к условиям средней освещенности и умеренной влажности.',
- 'toxic': 'Нет',
- 'type': 'Эпифитное растение',
- 'lifespan': '15-20 лет',
- 'plantHeigh': '30-50 см',
- 'crownDiameter': '30-40 см',
- 'leafsColor': 'Зеленый',
- 'floweringTime': 'Весна, лето',
- 'flowerDiameter': '5-8 см',
- 'flowerColor': 'Белый, кремово-желтый с красноватыми пятнами',
- 'harvestTime': '',
- 'fruitColor': '',
- 'genus': 'Cymbidium',
- 'family': 'Орхидные',
- 'order': 'Лилиецветные',
- 'class': 'Однодольные',
- 'phylum': 'Покрытосеменные',
- 'temperature': '18-25°C',
- 'sun': 'Яркий рассеянный свет',
- 'dirt': 'Субстрат для орхидей',
- 'locate': 'Светлое место с частичной тенью',
- 'watering': '2-3 раза в неделю',
- 'cut': 'По мере необходимости',
- 'spreading': 'Делением куста',
- 'repotting': '1 раз в 2-3 года',
- 'date': '3',
- };
- void _main() async{
- WidgetsFlutterBinding.ensureInitialized();
- await Firebase.initializeApp();
- }
- class cymbidiumEnsifolium extends StatefulWidget {
- cymbidiumEnsifolium({super.key});
- @override
- State<cymbidiumEnsifolium> createState() => _cymbidiumEnsifoliumState();
- }
- class _cymbidiumEnsifoliumState extends State<cymbidiumEnsifolium> {
- @override
- void initState(){
- super.initState();
- }
- final _auth = FirebaseAuth.instance;
- var buttonText = 'Добавить в мой сад';
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(),
- bottomNavigationBar: BottomAppBar(child: FloatingActionButton.extended(onPressed: ()async{
- final userRef = FirebaseFirestore.instance.collection(_auth.currentUser!.uid.toString());
- userRef.get().then((snapshot) {
- snapshot.docs.forEach((doc) {
- print(doc);
- });
- });
- DateTime now = DateTime.now();
- var date = int.parse(_mapPlantInfo['date']!);
- var dateN = new DateTime.now().add(Duration(days: date)).toString();
- var dateNext = DateTime.parse(dateN);
- var asd = DateTime.now().difference(dateNext);
- assert(date is int);
- String user = _auth.currentUser!.uid.toString();
- CollectionReference collectionReference = FirebaseFirestore.instance.collection(user);
- if((dateNext.hour + 5) > 24){
- collectionReference.doc(_mapPlantInfo['name']).set({
- 'name': '${_mapPlantInfo['name']}',
- 'image': '${_mapPlantInfo['imagePlant1']}',
- 'dateDay': '${dateNext.day}',
- 'dateMonth': '${dateNext.month}',
- 'dateYear': '${dateNext.year}',
- 'dateHour': '${24 - (dateNext.hour + 5)}',
- 'dateMinute': '${dateNext.minute}',
- 'step': '${_mapPlantInfo['date']}'
- });
- }else{
- collectionReference.doc(_mapPlantInfo['name']).set({
- 'name': '${_mapPlantInfo['name']}',
- 'image': '${_mapPlantInfo['imagePlant1']}',
- 'dateDay': '${dateNext.day}',
- 'dateMonth': '${dateNext.month}',
- 'dateYear': '${dateNext.year}',
- 'dateHour': '${dateNext.hour + 5}',
- 'dateMinute': '${dateNext.minute}',
- 'step': '${_mapPlantInfo['date']}'
- });
- }
- utilsDone().toastMessage('Растение добавлено');
- },
- label: Row(
- children: [
- Text(buttonText),
- Icon(Icons.add)
- ],
- )
- ),
- ),
- body: SingleChildScrollView(
- scrollDirection: Axis.vertical,
- child: Column(
- children: [
- _naming(),
- _plantImages(),
- _description(),
- _weedEtc(),
- _characteristics(),
- _scientificClassification(),
- _conditions(),
- _guide(),
- ],
- ),
- ),
- );
- }
- }
- class _naming extends StatelessWidget {
- _naming({super.key});
- @override
- Widget build(BuildContext context) {
- return Container(
- width: double.infinity,
- child: Column(
- children: [
- Row(
- children: [
- Padding(padding: EdgeInsets.only(left: 10)),
- Flexible(child: Text('${_mapPlantInfo['name']}, вид ${_mapPlantInfo['sort']}', softWrap: true, style: TextStyle(fontSize: 30))),
- Padding(padding: EdgeInsets.fromLTRB(0, 0, 10, 0)),
- ],
- ),
- Row(
- children: [
- Padding(padding: EdgeInsets.only(left: 10)),
- Flexible(child: Text('Ботаническое название: ${_mapPlantInfo['subName']}', softWrap: true, style: TextStyle(fontSize: 22, color: Colors.grey[800]))),
- Padding(padding: EdgeInsets.fromLTRB(0, 0, 10, 0)),
- ],
- )
- ]
- ),
- );
- }
- }
- class _plantImages extends StatelessWidget {
- _plantImages({super.key});
- @override
- Widget build(BuildContext context) {
- return Container(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Container(
- width: double.infinity,
- height: 10,
- color: Colors.grey[200],
- ),
- Padding(padding: EdgeInsets.only(top: 10)),
- const Row(children: [
- Padding(padding: EdgeInsets.only(left: 10)),
- Icon(Icons.image_outlined),
- Padding(padding: EdgeInsets.only(right: 10)),
- Text('Изображения',style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),),
- ],
- ),
- Padding(padding: EdgeInsets.only(bottom: 10)),
- Container(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceAround,
- children: [
- Column(
- children: <Widget>[
- _plantImage(imageUrl: '${_mapPlantInfo['imagePlant1']}',),
- Padding(padding: EdgeInsets.only(top: 10)),
- _plantImage(imageUrl: '${_mapPlantInfo['imagePlant2']}',),
- ],
- ),
- Column(
- children: <Widget>[
- _plantImage(imageUrl: '${_mapPlantInfo['imagePlant3']}',),
- Padding(padding: EdgeInsets.only(top: 10)),
- _plantImage(imageUrl: '${_mapPlantInfo['imagePlant4']}',),
- ],
- ),
- ],
- ),
- ),
- Padding(padding: EdgeInsets.only(bottom: 10))
- ],
- ),
- );
- }
- }
- class _plantImage extends StatelessWidget {
- final String imageUrl;
- const _plantImage({super.key, required this.imageUrl});
- @override
- Widget build(BuildContext context) {
- return InkWell(
- child: Container(
- child: Container(
- child: InstaImageViewer(
- child: Image(
- fit: BoxFit.fitWidth,
- image: NetworkImage(imageUrl),
- ),
- ),
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(17),
- image: DecorationImage(image: NetworkImage(imageUrl))
- ),
- ),
- width: MediaQuery.of(context).size.width * 0.45,
- height: MediaQuery.of(context).size.width * 0.3,
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(17),
- image: DecorationImage(image: NetworkImage(imageUrl))
- ),
- ),
- );
- }
- }
- class _description extends StatelessWidget {
- const _description({ super.key });
- @override
- Widget build(BuildContext context) {
- return Container(
- child: Column(
- children: [
- Container(
- width: double.infinity,
- height: 10,
- color: Colors.grey[200],
- ),
- Padding(padding: EdgeInsets.only(top: 10)),
- Row(
- children: [
- Padding(padding: EdgeInsets.only(left: 10)),
- Icon(Icons.align_vertical_bottom_rounded),
- Padding(padding: EdgeInsets.only(right: 10)),
- Text('Описание', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold))]
- ),
- Padding(padding: EdgeInsets.only(top: 10)),
- Row(
- children: [
- Padding(padding: EdgeInsets.only(left: 10)),
- Flexible(child: Text('${_mapPlantInfo['description']}', style: TextStyle(fontSize: 16), softWrap: true,)),
- Padding(padding: EdgeInsets.only(right: 10)),
- ],
- ),
- Padding(padding: EdgeInsets.only(bottom: 10))
- ]
- )
- );
- }
- }
- class _weedEtc extends StatelessWidget {
- const _weedEtc({super.key});
- @override
- Widget build(BuildContext context) {
- return Container(
- child: Column(
- children: [
- Container(
- width: double.infinity,
- height: 10,
- color: Colors.grey[200],
- ),
- Padding(padding: EdgeInsets.only(top: 10)),
- Row(
- children: [
- Padding(padding: EdgeInsets.only(left: 10)),
- Icon(Icons.lightbulb),
- Padding(padding: EdgeInsets.only(right: 10)),
- Text('Ключевые факты', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold))]
- ),
- Padding(padding: EdgeInsets.only(top: 10)),
- Padding(
- padding: EdgeInsets.symmetric(horizontal: 20),
- child: Column(
- children: [
- _linee(lineName: 'Токсичность', lineId: 'toxic', lineWidth: 100),
- _linee(lineName: 'Тип растения', lineId: 'type', lineWidth: 100),
- _linee(lineName: 'Продолжительность жизни', lineId: 'lifespan', lineWidth: 10),
- ],
- ),
- ),
- Padding(padding: EdgeInsets.only(bottom: 10))
- ],
- ),
- );
- }
- }
- class _linee extends StatelessWidget {
- final String lineName;
- final String lineId;
- final double lineWidth;
- const _linee({super.key, required this.lineName, required this.lineId, required this.lineWidth});
- @override
- Widget build(BuildContext context) {
- if(_mapPlantInfo['${lineId}'] == ''){
- return Container();
- }else{
- return Container(
- child: Column(
- children: [
- _otstup(),
- _line(lineId: lineId, lineWidth: lineWidth, lineName: lineName)
- ],
- ),
- );
- }}
- }
- class _line extends StatelessWidget {
- final String lineName;
- final String lineId;
- final double lineWidth;
- const _line({super.key, required this.lineName, required this.lineId, required this.lineWidth});
- @override
- Widget build(BuildContext context) {
- if(_mapPlantInfo['${lineId}'] == '') {
- return Container();
- }else{
- return Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Text('$lineName', style: TextStyle(fontSize: 16),),
- Padding(padding: EdgeInsets.only(right: lineWidth)),
- Container(child: Flexible(child: Text('${_mapPlantInfo[lineId]}', softWrap: true, style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15)))),
- ],
- );
- }}
- }
- class _lineWithIcon extends StatelessWidget {
- final Color? lineIconColor;
- final IconData lineIcon;
- final String lineWithIconName;
- final String lineWithIconId;
- const _lineWithIcon({super.key, required this.lineIconColor, required this.lineIcon, required this.lineWithIconName, required this.lineWithIconId});
- @override
- Widget build(BuildContext context) {
- if(_mapPlantInfo['${lineWithIconId}'] == ''){
- return Container();
- }else{
- return Column(
- children: [
- _otstup(),
- _lineWithIco(lineIconColor: lineIconColor, lineIcon: lineIcon, lineWithIconName: lineWithIconName, lineWithIconId: lineWithIconId)
- ],
- );
- }}
- }
- class _lineWithIco extends StatelessWidget {
- final Color? lineIconColor;
- final IconData lineIcon;
- final String lineWithIconName;
- final String lineWithIconId;
- const _lineWithIco({super.key, required this.lineIconColor, required this.lineIcon, required this.lineWithIconName, required this.lineWithIconId});
- @override
- Widget build(BuildContext context) {
- if(_mapPlantInfo['${lineWithIconId}'] == ''){
- return Container();
- }else{
- return Row(
- mainAxisAlignment: MainAxisAlignment.start,
- children: [
- Icon(lineIcon, color: lineIconColor,),
- Padding(padding: EdgeInsets.only(right: 10)),
- Flexible(
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(lineWithIconName, style: TextStyle(fontSize: 16, color: Colors.grey[850]),),
- Text('${_mapPlantInfo[lineWithIconId]}', style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold))
- ],
- )
- )
- ],
- );
- }}
- }
- class _characteristics extends StatelessWidget {
- const _characteristics({super.key});
- @override
- Widget build(BuildContext context) {
- return Container(
- child: Column(
- children: [
- Container(
- width: double.infinity,
- height: 10,
- color: Colors.grey[200],
- ),
- Padding(padding: EdgeInsets.only(top: 10)),
- Row(
- children: [
- Padding(padding: EdgeInsets.only(left: 10)),
- Icon(Icons.spa),
- Padding(padding: EdgeInsets.only(right: 10)),
- Text('Внешние характеристики', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold))]
- ),
- Padding(padding: EdgeInsets.only(top: 10)),
- Padding(
- padding: EdgeInsets.symmetric(horizontal: 20),
- child: Column(
- children: [
- _linee(lineName: 'Высота растения', lineId: 'plantHeigh', lineWidth: 100),
- _linee(lineName: 'Диаметр короны', lineId: 'crownDiameter', lineWidth: 90),
- _linee(lineName: 'Цвет листьев', lineId: 'leafsColor', lineWidth: 100),
- _linee(lineName: 'Время цветенния', lineId: 'floweringTime', lineWidth: 10),
- _linee(lineName: 'Диаметр цветка', lineId: 'flowerDiameter', lineWidth: 95),
- _linee(lineName: 'Цвет цветка', lineId: 'flowerColor', lineWidth: 95),
- _linee(lineName: 'Время сбора урожая', lineId: 'harvestTime', lineWidth: 65),
- _linee(lineName: 'Цвет фрукта', lineId: 'fruitColor', lineWidth: 95),
- Padding(padding: EdgeInsets.only(top: 10)),
- ],
- ),
- ),
- Padding(padding: EdgeInsets.only(bottom: 10))
- ],
- ),
- );
- }
- }
- class _otstup extends StatelessWidget {
- const _otstup({super.key});
- @override
- Widget build(BuildContext context) {
- return Container(
- child: Column(
- children: [
- Padding(padding: EdgeInsets.only(bottom: 5)),
- Container(width: double.infinity, height: 0.5, color: Colors.grey),
- Padding(padding: EdgeInsets.only(top: 5)),
- ],
- ),
- );
- }
- }
- class _scientificClassification extends StatelessWidget {
- const _scientificClassification({super.key});
- @override
- Widget build(BuildContext context) {
- return Container(
- child: Column(
- children: [
- Container(
- width: double.infinity,
- height: 10,
- color: Colors.grey[200],
- ),
- Padding(padding: EdgeInsets.only(top: 10)),
- Row(
- children: [
- Padding(padding: EdgeInsets.only(left: 10)),
- Icon(Icons.category),
- Padding(padding: EdgeInsets.only(right: 10)),
- Text('Научная классификация', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold))]
- ),
- Padding(padding: EdgeInsets.only(top: 10)),
- Padding(
- padding: EdgeInsets.symmetric(horizontal: 20),
- child: Column(
- children: [
- _linee(lineName: 'Род', lineId: 'genus', lineWidth: 90),
- _linee(lineName: 'Семейство', lineId: 'family', lineWidth: 100),
- _linee(lineName: 'Порядок', lineId: 'order', lineWidth: 105),
- _linee(lineName: 'Класс', lineId: 'class', lineWidth: 110),
- _linee(lineName: 'Отдел', lineId: 'phylum', lineWidth: 110),
- Padding(padding: EdgeInsets.only(top: 10)),
- ],
- ),
- ),
- Padding(padding: EdgeInsets.only(bottom: 10))
- ],
- ),
- );
- }
- }
- class _conditions extends StatelessWidget {
- const _conditions({super.key});
- @override
- Widget build(BuildContext context) {
- return Container(
- child: Column(
- children: [
- Container(
- width: double.infinity,
- height: 10,
- color: Colors.grey[200],
- ),
- Padding(padding: EdgeInsets.only(top: 10)),
- Row(
- children: [
- Padding(padding: EdgeInsets.only(left: 10)),
- Icon(Icons.flare),
- Padding(padding: EdgeInsets.only(right: 10)),
- Text('Условия', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold))]
- ),
- Padding(padding: EdgeInsets.only(top: 10)),
- Padding(
- padding: EdgeInsets.symmetric(horizontal: 20),
- child: Column(
- children: [
- _lineWithIcon(lineIconColor: Colors.blue, lineIcon: Icons.thermostat, lineWithIconName: 'Температура', lineWithIconId: 'temperature'),
- _lineWithIcon(lineIconColor: Colors.green, lineIcon: Icons.location_on, lineWithIconName: 'Расположение', lineWithIconId: 'locate'),
- _lineWithIcon(lineIconColor: Colors.orange[400], lineIcon: Icons.sunny, lineWithIconName: 'Солнечный свет', lineWithIconId: 'sun'),
- _lineWithIcon(lineIconColor: Colors.brown, lineIcon: MyFlutterApp.pot, lineWithIconName: 'Земля', lineWithIconId: 'dirt'),
- Padding(padding: EdgeInsets.only(top: 10)),
- ],
- ),
- ),
- Padding(padding: EdgeInsets.only(bottom: 10))
- ],
- ),
- );
- }
- }
- class _guide extends StatelessWidget {
- const _guide({super.key});
- @override
- Widget build(BuildContext context) {
- return Container(
- child: Column(
- children: [
- Container(
- width: double.infinity,
- height: 10,
- color: Colors.grey[200],
- ),
- Padding(padding: EdgeInsets.only(top: 10)),
- Row(
- children: [
- Padding(padding: EdgeInsets.only(left: 10)),
- Icon(MyFlutterApp.guidebook),
- Padding(padding: EdgeInsets.only(right: 10)),
- Text('Гид', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold))]
- ),
- Padding(padding: EdgeInsets.only(top: 10)),
- Padding(
- padding: EdgeInsets.symmetric(horizontal: 20),
- child: Column(
- children: [
- _lineWithIcon(lineIconColor: Colors.blue, lineIcon: Icons.water_drop, lineWithIconName: 'Полив', lineWithIconId: 'watering'),
- _lineWithIcon(lineIconColor: Colors.orange, lineIcon: Icons.cut, lineWithIconName: 'Обрезка', lineWithIconId: 'cut'),
- _lineWithIcon(lineIconColor: Colors.green[600], lineIcon: MyFlutterApp.spread, lineWithIconName: 'Распространение', lineWithIconId: 'spreading'),
- _lineWithIcon(lineIconColor: Colors.orange, lineIcon: MyFlutterApp.upgrade, lineWithIconName: 'Преувеличение', lineWithIconId: 'repotting'),
- Padding(padding: EdgeInsets.only(top: 10)),
- ],
- ),
- ),
- Padding(padding: EdgeInsets.only(bottom: 10))
- ],
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement