dreampad/lib/app/modules/home/widgets/explore_widget.dart
2023-11-30 01:11:52 +08:00

88 lines
2.6 KiB
Dart

import 'package:dreampad/app/shared/shared.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class ExploreWidget extends StatefulWidget {
const ExploreWidget({
super.key,
required this.explored,
required this.exploreCount,
this.onPressed,
this.remainTime,
});
final bool explored;
final int exploreCount;
final String? remainTime;
final VoidCallback? onPressed;
@override
State<ExploreWidget> createState() => _ExploreWidgetState();
}
class _ExploreWidgetState extends State<ExploreWidget> {
late bool suspend = false;
@override
Widget build(BuildContext context) {
return Container(
height: 67.h,
width: 201.w,
decoration: BoxDecoration(
image: DecorationImage(
image: widget.explored
? Images.homeExplorePre
: Images.homeExploreDefault,
fit: BoxFit.fill,
),
),
child: Row(
children: [
const RSizedBox(width: 10.0),
GestureDetector(
onTap: () {
if (widget.explored) {
setState(() {
suspend = !suspend;
});
widget.onPressed?.call();
}
},
child: widget.explored
? suspend
? Images.homeExploreCountdown
: Images.homeExploreBegin
: Images.homeBeginGray,
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'自由探索',
style: widget.explored
? TextStyles.boldWhiteShadow22_101
: TextStyles.boldWhiteShadow22_100,
),
const RSizedBox(height: 4.0),
widget.explored
? Text(
'剩余时间:${widget.remainTime}',
style: TextStyles.mediumWhiteShadow14_101,
)
: Row(
children: [
widget.exploreCount == 0
? Images.homeProgressBar
: Images.homeProgressBarIn,
const RSizedBox(width: 1.0),
widget.exploreCount >= 2
? Images.homeProgressBarIn
: Images.homeProgressBar,
],
),
],
),
],
),
);
}
}