2022-11-25 19:24:01 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_svg/svg.dart';
|
|
|
|
import 'package:stackwallet/utilities/assets.dart';
|
|
|
|
import 'package:stackwallet/utilities/theme/color_theme.dart';
|
|
|
|
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
|
|
|
import 'package:stackwallet/widgets/conditional_parent.dart';
|
|
|
|
|
2022-11-25 23:49:47 +00:00
|
|
|
class Background extends StatelessWidget {
|
2022-11-25 19:24:01 +00:00
|
|
|
const Background({
|
|
|
|
Key? key,
|
|
|
|
required this.child,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
final Widget child;
|
|
|
|
|
|
|
|
@override
|
2022-11-25 23:49:47 +00:00
|
|
|
Widget build(BuildContext context) {
|
2022-11-25 19:24:01 +00:00
|
|
|
Color? color;
|
|
|
|
|
2023-01-24 18:17:36 +00:00
|
|
|
bool shouldPad = false;
|
|
|
|
|
2022-11-25 23:49:47 +00:00
|
|
|
switch (Theme.of(context).extension<StackColors>()!.themeType) {
|
2022-11-25 19:24:01 +00:00
|
|
|
case ThemeType.light:
|
|
|
|
case ThemeType.dark:
|
2023-01-06 16:12:01 +00:00
|
|
|
case ThemeType.oledBlack:
|
2023-02-13 16:25:45 +00:00
|
|
|
color = Theme.of(context).extension<StackColors>()!.background;
|
|
|
|
break;
|
2023-02-10 16:36:15 +00:00
|
|
|
case ThemeType.forest:
|
2022-11-25 19:24:01 +00:00
|
|
|
color = Theme.of(context).extension<StackColors>()!.background;
|
|
|
|
break;
|
|
|
|
case ThemeType.oceanBreeze:
|
2023-01-24 18:17:36 +00:00
|
|
|
shouldPad = true;
|
|
|
|
color = null;
|
|
|
|
break;
|
2023-01-23 22:36:13 +00:00
|
|
|
case ThemeType.fruitSorbet:
|
2022-11-25 19:24:01 +00:00
|
|
|
color = null;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
final bgAsset = Assets.svg.background(context);
|
|
|
|
|
|
|
|
return Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: color,
|
|
|
|
gradient:
|
|
|
|
Theme.of(context).extension<StackColors>()!.gradientBackground,
|
|
|
|
),
|
|
|
|
child: ConditionalParent(
|
|
|
|
condition: bgAsset != null,
|
|
|
|
builder: (child) => Stack(
|
|
|
|
children: [
|
|
|
|
Positioned.fill(
|
|
|
|
child: Padding(
|
2023-01-24 18:17:36 +00:00
|
|
|
padding: shouldPad
|
|
|
|
? EdgeInsets.only(
|
|
|
|
top: MediaQuery.of(context).size.height * (1 / 8),
|
|
|
|
bottom: MediaQuery.of(context).size.height * (1 / 12),
|
|
|
|
)
|
|
|
|
: const EdgeInsets.all(0),
|
2022-11-25 19:24:01 +00:00
|
|
|
child: SvgPicture.asset(
|
|
|
|
bgAsset!,
|
|
|
|
fit: BoxFit.fill,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Positioned.fill(
|
|
|
|
child: child,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
child: child,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|