feature(training): Добавлен состояния загрузки, пустоты и наличие данных на экране тренировки
This commit is contained in:
124
lib/screens/training/widgets/training_ticket.dart
Normal file
124
lib/screens/training/widgets/training_ticket.dart
Normal file
@@ -0,0 +1,124 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:remever/common/resources.dart';
|
||||
import 'package:remever/common/widgets/typography.dart';
|
||||
import 'package:remever/common/widgets/w_if.dart';
|
||||
import 'package:remever/common/widgets/wspace.dart';
|
||||
import 'package:remever/components/extensions/context.dart';
|
||||
|
||||
class TrainingTicket extends StatelessWidget {
|
||||
const TrainingTicket({super.key, this.isAnswer = false});
|
||||
|
||||
final bool isAnswer;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12).r,
|
||||
color: Colors.white,
|
||||
),
|
||||
constraints: BoxConstraints(minHeight: 50.h),
|
||||
child: Stack(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 90.h,
|
||||
width: double.infinity,
|
||||
child: DecoratedBox(decoration: getDecoration()),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(12).r,
|
||||
child: Column(
|
||||
children: [
|
||||
_buildCollectionInfo(),
|
||||
_buildImage(),
|
||||
HSpace(4),
|
||||
_buildText(context),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCollectionInfo() {
|
||||
return Wif(
|
||||
condition: !isAnswer,
|
||||
builder: (context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8).r,
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 24.h,
|
||||
width: 24.w,
|
||||
child: ClipOval(
|
||||
child: Image.network(
|
||||
'https://avatars.mds.yandex.net/i?id=56429b65e9098a58fcd538387d43bcbb_l-5384017-images-thumbs&n=13',
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
WSpace(4),
|
||||
AppTypography(
|
||||
'Астрология и астрофизика',
|
||||
type: Regular14px(),
|
||||
color: AppColors.disabled,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// Декорирование контейнера
|
||||
BoxDecoration getDecoration() {
|
||||
return BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12).r,
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
isAnswer ? AppColors.answer : AppColors.question,
|
||||
Colors.white,
|
||||
],
|
||||
begin: Alignment.topLeft,
|
||||
end: const Alignment(-0.5, 1),
|
||||
stops: const [0.25, 0.25],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildText(BuildContext context) {
|
||||
return AppTypography(
|
||||
'Родился 19 февраля 1473 года в Торуне в семье купца. После смерти отца воспитывался у дяди, епископа Вармийской епархии. Коперник изложил свои идеи в сочинении «Commentariolus» («Малый комментарий»), в котором сформулировал основные положения гелиоцентрической системы мира в виде 6 аксиом. Их смысл состоит в том, что Земля, как и другие планеты,'
|
||||
'Родился 19 февраля 1473 года в Торуне в семье купца. После смерти отца воспитывался у дяди, епископа Вармийской епархии. Коперник изложил свои идеи в сочинении «Commentariolus» («Малый комментарий»), в котором сформулировал основные положения гелиоцентрической системы мира в виде 6 аксиом. Их смысл состоит в том, что Земля, как и другие планеты,',
|
||||
maxLines: 99,
|
||||
type: Regular14px(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildImage() {
|
||||
// final imageBytes =
|
||||
// isAnswer ? ticket.answerImage : ticket.questionImage;
|
||||
|
||||
return Wif(
|
||||
condition: true, // imageBytes != null,
|
||||
builder:
|
||||
(context) => Padding(
|
||||
padding: const EdgeInsets.only(right: 8).r,
|
||||
child: SizedBox.square(
|
||||
dimension: 100.r,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8).r,
|
||||
// child: Image.memory(imageBytes!, fit: BoxFit.cover),
|
||||
child: Image.network(
|
||||
'https://avatars.mds.yandex.net/i?id=56429b65e9098a58fcd538387d43bcbb_l-5384017-images-thumbs&n=13',
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user