GardenPlanner/lib/widgets/content_widgets/dashboard.dart

87 lines
3.0 KiB
Dart

import 'package:flutter/material.dart';
import '../../entities/plant.dart';
import '../../entities/plant_in_row.dart';
import '../../repositories/beet.repositories.dart';
import 'dashboard_widgets/plant_row.dart';
import 'dashboard_widgets/space/plant_row_horizontal_space.dart';
class Dashboard extends StatelessWidget {
final bool showSpaceRequirement;
final DateTime currentDate;
final Function(int, Plant) onPlantDroppedToRow;
final Function(int, PlantInRow) onPlantRemoveFromRow;
final bool showImages;
final BeetRepository beetRepository;
const Dashboard({
Key? key,
required this.onPlantDroppedToRow,
required this.beetRepository,
required this.showSpaceRequirement,
required this.showImages,
required this.currentDate,
required this.onPlantRemoveFromRow,
}) : super(key: key);
@override
Widget build(BuildContext context) {
var verticalSpace = beetRepository.getVerticalSpaceValue();
return Container(
alignment: Alignment.topLeft,
margin: const EdgeInsets.only(left: 10),
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
primary: true,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
for (int rowIndex = 0;
rowIndex < beetRepository.beet.beetRows.length;
rowIndex++)
SizedBox(
height: showSpaceRequirement &&
beetRepository.getRow(rowIndex).plants.isNotEmpty
? 170
: 120,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (showSpaceRequirement &&
beetRepository.getRow(rowIndex).plants.isNotEmpty)
PlantRowHorizontalSpace(
plantingPositions:
beetRepository.getHorizontalPlantingPositionForRow(
beetRepository.getRow(rowIndex)),
),
PlantRow(
showSpaceRequirement: showSpaceRequirement,
row: beetRepository.getRow(rowIndex),
verticalSpace: verticalSpace[rowIndex],
beetRepository: beetRepository,
showImages: showImages,
date: currentDate,
onPlantRemove: (PlantInRow plantInRow) {
onPlantRemoveFromRow(
beetRepository.getRow(rowIndex).id,
plantInRow,
);
},
onPlantDropped: (Plant plant) {
onPlantDroppedToRow(
beetRepository.getRow(rowIndex).id,
plant,
);
},
),
],
),
),
],
),
),
);
}
}