// ignore_for_file: unused_local_variable import 'package:eatvio_app/features/diary/models/portion.dart'; import 'package:eatvio_app/features/diary/presentation/bloc/diary_bloc.dart'; import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:rive/rive.dart'; // ignore: must_be_immutable class DiaryRecommendationsScreen extends StatelessWidget { final String? diary_recommendationsID; const DiaryRecommendationsScreen({ this.diary_recommendationsID, super.key, }); Widget build(BuildContext context) { if (diary_recommendationsID != "0") { context.read().add(LoadDiaryById(diary_recommendationsID)); } return BlocBuilder( builder: (context, state) { if (state is DiaryStateLoaded) { return _buildDiaryRecommendations(context, state); } else if (state is DiaryStateLoading) { return Scaffold( body: Center( child: SizedBox( height: 32, width: 32, child: RiveAnimation.asset( 'assets/rive_animations/loading.riv', ), ), ), ); } else if (state is DiaryStateError) { return Scaffold( body: Padding( padding: const EdgeInsets.all(16), child: Center( child: Text(state.errorMessage), ), ), ); } else return Scaffold( body: Padding( padding: const EdgeInsets.all(16), child: Center( child: Text("Неопределенная ошибка"), ), ), ); }, ); } Widget _buildDiaryRecommendations(BuildContext context, DiaryStateLoaded state) { final Portion product = new Portion(id: 1, product_name: "", quantity: 1, portion: "", from_diet: true); return Stack( alignment: Alignment.bottomCenter, children: [ FormBuilder( child: Scaffold( appBar: AppBar( toolbarHeight: 0, automaticallyImplyLeading: false, ), backgroundColor: Color.fromARGB(255, 240, 242, 245), resizeToAvoidBottomInset: true, body: SizedBox( width: double.maxFinite, child: Column( children: [ Expanded( child: SingleChildScrollView( child: Padding( padding: EdgeInsets.only(bottom: 9), child: Column( children: [ Scaffold( appBar: AppBar( title: Text(product.product_name), ), body: Padding( padding: const EdgeInsets.all(16.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('Название продукта: ${product.product_name}', style: TextStyle(fontSize: 24)), SizedBox(height: 16), Text('Количество: ${product.quantity} ${product.portion}', style: TextStyle(fontSize: 18)), // Добавьте другие детали о продукте по необходимости ], ), ), ) ], ), ), ), ), ], ), ), ), ), ], ); } }