forked from firka/firka
@@ -1,5 +1,7 @@
|
||||
import 'package:firka/helpers/ui/firka_shadow.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../main.dart';
|
||||
import '../../ui/model/style.dart';
|
||||
|
||||
enum Attach { none, bottom, top }
|
||||
@@ -37,29 +39,73 @@ class FirkaCard extends StatelessWidget {
|
||||
return SizedBox(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: height,
|
||||
child: Card(
|
||||
color: color ?? appStyle.colors.card,
|
||||
shadowColor: shadow ? null : Colors.transparent,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(attached == Attach.top
|
||||
? attachedRounding
|
||||
: defaultRounding),
|
||||
topRight: Radius.circular(attached == Attach.top
|
||||
? attachedRounding
|
||||
: defaultRounding),
|
||||
bottomLeft: Radius.circular(attached == Attach.bottom
|
||||
? attachedRounding
|
||||
: defaultRounding),
|
||||
bottomRight: Radius.circular(attached == Attach.bottom
|
||||
? attachedRounding
|
||||
: defaultRounding)),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
child: FirkaShadow(
|
||||
shadow: shadow,
|
||||
child: Card(
|
||||
color: color ?? appStyle.colors.card,
|
||||
shadowColor:
|
||||
isLightMode.value && shadow ? null : Colors.transparent,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(attached == Attach.top
|
||||
? attachedRounding
|
||||
: defaultRounding),
|
||||
topRight: Radius.circular(attached == Attach.top
|
||||
? attachedRounding
|
||||
: defaultRounding),
|
||||
bottomLeft: Radius.circular(attached == Attach.bottom
|
||||
? attachedRounding
|
||||
: defaultRounding),
|
||||
bottomRight: Radius.circular(attached == Attach.bottom
|
||||
? attachedRounding
|
||||
: defaultRounding)),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(children: left),
|
||||
Row(children: center ?? []),
|
||||
Row(children: right),
|
||||
],
|
||||
),
|
||||
extra ?? SizedBox(),
|
||||
],
|
||||
),
|
||||
),
|
||||
)),
|
||||
);
|
||||
} else {
|
||||
return SizedBox(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: height,
|
||||
child: FirkaShadow(
|
||||
shadow: shadow,
|
||||
child: Card(
|
||||
color: color ?? appStyle.colors.card,
|
||||
shadowColor:
|
||||
isLightMode.value && shadow ? null : Colors.transparent,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(attached == Attach.top
|
||||
? attachedRounding
|
||||
: defaultRounding),
|
||||
topRight: Radius.circular(attached == Attach.top
|
||||
? attachedRounding
|
||||
: defaultRounding),
|
||||
bottomLeft: Radius.circular(attached == Attach.bottom
|
||||
? attachedRounding
|
||||
: defaultRounding),
|
||||
bottomRight: Radius.circular(attached == Attach.bottom
|
||||
? attachedRounding
|
||||
: defaultRounding)),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(children: left),
|
||||
@@ -67,46 +113,8 @@ class FirkaCard extends StatelessWidget {
|
||||
Row(children: right),
|
||||
],
|
||||
),
|
||||
extra ?? SizedBox(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return SizedBox(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: height,
|
||||
child: Card(
|
||||
color: color ?? appStyle.colors.card,
|
||||
shadowColor: shadow ? null : Colors.transparent,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(attached == Attach.top
|
||||
? attachedRounding
|
||||
: defaultRounding),
|
||||
topRight: Radius.circular(attached == Attach.top
|
||||
? attachedRounding
|
||||
: defaultRounding),
|
||||
bottomLeft: Radius.circular(attached == Attach.bottom
|
||||
? attachedRounding
|
||||
: defaultRounding),
|
||||
bottomRight: Radius.circular(attached == Attach.bottom
|
||||
? attachedRounding
|
||||
: defaultRounding)),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(children: left),
|
||||
Row(children: center ?? []),
|
||||
Row(children: right),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
41
firka/lib/helpers/ui/firka_shadow.dart
Normal file
41
firka/lib/helpers/ui/firka_shadow.dart
Normal file
@@ -0,0 +1,41 @@
|
||||
import 'package:firka/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../ui/model/style.dart';
|
||||
|
||||
class FirkaShadow extends StatelessWidget {
|
||||
final Widget child;
|
||||
final bool shadow;
|
||||
|
||||
const FirkaShadow({required this.shadow, required this.child, super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final borderRadius = BorderRadius.circular(8.0);
|
||||
|
||||
final shadowBox = BoxDecoration(
|
||||
color: Colors.transparent,
|
||||
shape: BoxShape.rectangle,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: appStyle.colors.shadowColor,
|
||||
spreadRadius: -4,
|
||||
blurRadius: 0,
|
||||
offset: Offset(0, 2))
|
||||
],
|
||||
borderRadius: BorderRadius.all(Radius.circular(16)));
|
||||
|
||||
if (!shadow) {
|
||||
return ClipRRect(borderRadius: borderRadius, child: child);
|
||||
}
|
||||
|
||||
if (isLightMode.value) {
|
||||
return child;
|
||||
} else {
|
||||
return Container(
|
||||
decoration: shadowBox,
|
||||
child: ClipRRect(borderRadius: borderRadius, child: child),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user