|
|
|
|
@ -22,7 +22,7 @@ class AppTimer extends StatefulWidget {
|
|
|
|
|
final TextStyle? style;
|
|
|
|
|
final BoxDecoration? decoration;
|
|
|
|
|
final bool enabled;
|
|
|
|
|
final bool showPicker;
|
|
|
|
|
final bool showTimer;
|
|
|
|
|
final String? label;
|
|
|
|
|
final double? width;
|
|
|
|
|
|
|
|
|
|
@ -41,7 +41,7 @@ class AppTimer extends StatefulWidget {
|
|
|
|
|
this.onPick,
|
|
|
|
|
this.timerProgress,
|
|
|
|
|
this.enabled = true,
|
|
|
|
|
this.showPicker = true,
|
|
|
|
|
this.showTimer = true,
|
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
@ -128,8 +128,8 @@ class _AppTimerState extends State<AppTimer> {
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
///this is temp check for internal audit
|
|
|
|
|
canPickTime = widget.showPicker == false ? false : ApiManager.instance.assetGroup?.enabledEngineerTimer ?? false;
|
|
|
|
|
///this is temp check for internal audit to always show picker.
|
|
|
|
|
canPickTime = widget.showTimer == false ? true : ApiManager.instance.assetGroup?.enabledEngineerTimer ?? false;
|
|
|
|
|
_startAt = widget.timer?.startAt;
|
|
|
|
|
_endAt = widget.timer?.endAt;
|
|
|
|
|
_running = _startAt != null && _endAt == null;
|
|
|
|
|
@ -286,50 +286,51 @@ class _AppTimerState extends State<AppTimer> {
|
|
|
|
|
],
|
|
|
|
|
8.height,
|
|
|
|
|
],
|
|
|
|
|
Container(
|
|
|
|
|
// width: widget.width ?? 100 * AppStyle.getScaleFactor(context),
|
|
|
|
|
height: 56.toScreenHeight,
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth),
|
|
|
|
|
decoration: widget.decoration ??
|
|
|
|
|
BoxDecoration(
|
|
|
|
|
color: context.isDark && !widget.enabled
|
|
|
|
|
? AppColor.neutral60
|
|
|
|
|
: !widget.enabled
|
|
|
|
|
// backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral90,
|
|
|
|
|
? AppColor.neutral40
|
|
|
|
|
: AppColor.fieldBgColor(context),
|
|
|
|
|
borderRadius: BorderRadius.circular(10),
|
|
|
|
|
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)],
|
|
|
|
|
),
|
|
|
|
|
child: _loading
|
|
|
|
|
? const SizedBox.square(dimension: 18, child: CircularProgressIndicator(color: Colors.white))
|
|
|
|
|
: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: ValueListenableBuilder<String>(
|
|
|
|
|
valueListenable: _period,
|
|
|
|
|
builder: (context, value, _) {
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
(widget.label ?? "Timer").tinyFont(context),
|
|
|
|
|
value.bodyText(context).custom(
|
|
|
|
|
color: widget.enabled
|
|
|
|
|
? context.isDark
|
|
|
|
|
? AppColor.neutral30
|
|
|
|
|
: AppColor.neutral50
|
|
|
|
|
: AppColor.neutral20,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
if (widget.enabled) Icon(_running ? Icons.pause : Icons.play_arrow),
|
|
|
|
|
],
|
|
|
|
|
if (widget.showTimer)
|
|
|
|
|
Container(
|
|
|
|
|
// width: widget.width ?? 100 * AppStyle.getScaleFactor(context),
|
|
|
|
|
height: 56.toScreenHeight,
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth),
|
|
|
|
|
decoration: widget.decoration ??
|
|
|
|
|
BoxDecoration(
|
|
|
|
|
color: context.isDark && !widget.enabled
|
|
|
|
|
? AppColor.neutral60
|
|
|
|
|
: !widget.enabled
|
|
|
|
|
// backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral90,
|
|
|
|
|
? AppColor.neutral40
|
|
|
|
|
: AppColor.fieldBgColor(context),
|
|
|
|
|
borderRadius: BorderRadius.circular(10),
|
|
|
|
|
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)],
|
|
|
|
|
),
|
|
|
|
|
).onPress(_loading || !widget.enabled ? null : _onPressed),
|
|
|
|
|
child: _loading
|
|
|
|
|
? const SizedBox.square(dimension: 18, child: CircularProgressIndicator(color: Colors.white))
|
|
|
|
|
: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: ValueListenableBuilder<String>(
|
|
|
|
|
valueListenable: _period,
|
|
|
|
|
builder: (context, value, _) {
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
(widget.label ?? "Timer").tinyFont(context),
|
|
|
|
|
value.bodyText(context).custom(
|
|
|
|
|
color: widget.enabled
|
|
|
|
|
? context.isDark
|
|
|
|
|
? AppColor.neutral30
|
|
|
|
|
: AppColor.neutral50
|
|
|
|
|
: AppColor.neutral20,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
if (widget.enabled) Icon(_running ? Icons.pause : Icons.play_arrow),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
).onPress(_loading || !widget.enabled ? null : _onPressed),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|