import 'package:aman_kassa_flutter/shared/app_colors.dart'; import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; class TextStateView extends StatelessWidget { final int? status; final String text; const TextStateView({Key? key, this.status, this.text = ''}) : super(key: key); @override Widget build(BuildContext context) { return Positioned( bottom: ScreenUtil().setSp(25), left: ScreenUtil().setSp(25), right: ScreenUtil().setSp(25), child: AnimatedSwitcher( duration: const Duration(milliseconds: 300), child: buildAutoSizeText())); } AutoSizeText buildAutoSizeText() { switch(status) { case 0: return AutoSizeText( 'Инициализация', key: UniqueKey(), style: TextStyle( fontSize: ScreenUtil().setSp(25.0), color: whiteColor), ); break; case 1: return AutoSizeText( 'Сканирование', key: UniqueKey(), style: TextStyle( fontSize: ScreenUtil().setSp(25.0), color: whiteColor), ); break; case 2: return AutoSizeText( 'Проверка данных', key: UniqueKey(), style: TextStyle( fontSize: ScreenUtil().setSp(25.0), color: whiteColor), ); break; case 3: return AutoSizeText( 'Платеж прошел успешно', key: UniqueKey(), style: TextStyle( fontSize: ScreenUtil().setSp(25.0), color: whiteColor), ); break; case 4: return AutoSizeText( 'Ошибка', key: UniqueKey(), style: TextStyle( fontSize: ScreenUtil().setSp(25.0), color: whiteColor), ); break; default: return AutoSizeText( text, key: UniqueKey(), style: TextStyle( fontSize: ScreenUtil().setSp(25.0), color: whiteColor), ); } } }