2020-12-01 19:08:19 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:selfprivacy/config/brand_colors.dart';
|
2020-12-10 20:33:19 +00:00
|
|
|
import 'package:selfprivacy/logic/models/state_types.dart';
|
2020-12-01 19:08:19 +00:00
|
|
|
|
2021-01-06 17:35:57 +00:00
|
|
|
class IconStatusMask extends StatelessWidget {
|
2022-05-25 12:21:56 +00:00
|
|
|
const IconStatusMask({
|
2022-10-04 18:58:25 +00:00
|
|
|
required this.icon,
|
2022-05-25 12:21:56 +00:00
|
|
|
required this.status,
|
2022-10-26 16:26:09 +00:00
|
|
|
super.key,
|
2022-06-05 19:36:32 +00:00
|
|
|
});
|
2022-10-04 18:58:25 +00:00
|
|
|
final Widget icon;
|
2020-12-01 19:08:19 +00:00
|
|
|
|
2020-12-10 20:33:19 +00:00
|
|
|
final StateType status;
|
2020-12-01 19:08:19 +00:00
|
|
|
|
|
|
|
@override
|
2022-06-05 19:36:32 +00:00
|
|
|
Widget build(final BuildContext context) {
|
2021-03-15 15:39:44 +00:00
|
|
|
late List<Color> colors;
|
2020-12-01 19:08:19 +00:00
|
|
|
switch (status) {
|
2020-12-10 20:33:19 +00:00
|
|
|
case StateType.uninitialized:
|
2020-12-01 19:08:19 +00:00
|
|
|
colors = BrandColors.uninitializedGradientColors;
|
|
|
|
break;
|
2020-12-10 20:33:19 +00:00
|
|
|
case StateType.stable:
|
2022-05-30 16:55:09 +00:00
|
|
|
colors = [
|
|
|
|
Theme.of(context).colorScheme.primary,
|
|
|
|
Theme.of(context).colorScheme.tertiary,
|
|
|
|
];
|
2020-12-01 19:08:19 +00:00
|
|
|
break;
|
2020-12-10 20:33:19 +00:00
|
|
|
case StateType.warning:
|
2020-12-01 19:08:19 +00:00
|
|
|
colors = BrandColors.warningGradientColors;
|
|
|
|
break;
|
2022-07-29 05:38:21 +00:00
|
|
|
case StateType.error:
|
|
|
|
colors = [
|
|
|
|
Theme.of(context).colorScheme.error,
|
|
|
|
Theme.of(context).colorScheme.error,
|
|
|
|
];
|
|
|
|
break;
|
2020-12-01 19:08:19 +00:00
|
|
|
}
|
|
|
|
return ShaderMask(
|
2022-06-05 19:36:32 +00:00
|
|
|
shaderCallback: (final bounds) => LinearGradient(
|
2022-05-24 18:55:39 +00:00
|
|
|
begin: const Alignment(-1, -0.8),
|
|
|
|
end: const Alignment(0.9, 0.9),
|
2020-12-01 19:08:19 +00:00
|
|
|
colors: colors,
|
|
|
|
tileMode: TileMode.mirror,
|
|
|
|
).createShader(bounds),
|
2022-10-04 18:58:25 +00:00
|
|
|
child: icon,
|
2020-12-01 19:08:19 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|