You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cloudsolutions-atoms/old_lib/views/widgets/titles/expandable_info_row.dart

104 lines
3.2 KiB
Dart

3 years ago
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import '../../app_style/sizing.dart';
3 years ago
class ExpandableInfoRow extends StatefulWidget {
final IconData? iconData;
3 years ago
final String title;
final Widget child;
const ExpandableInfoRow({
Key? key,
this.iconData,
required this.title,
required this.child,
}) : super(key: key);
3 years ago
@override
ExpandableInfoRowState createState() => ExpandableInfoRowState();
3 years ago
}
class ExpandableInfoRowState extends State<ExpandableInfoRow>
with TickerProviderStateMixin {
3 years ago
bool _isExpanded = false;
3 years ago
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
3 years ago
_isExpanded = !_isExpanded;
setState(() {});
},
child: Column(
children: [
Row(
children: <Widget>[
widget.iconData != null
? Padding(
padding: EdgeInsets.symmetric(
horizontal: 8 * AppStyle.getScaleFactor(context),
vertical: 2 * AppStyle.getScaleFactor(context),
),
child: FaIcon(
widget.iconData,
color: Theme.of(context).primaryColor,
size: 20 * AppStyle.getScaleFactor(context),
),
)
: const SizedBox.shrink(),
3 years ago
Expanded(
flex: 2,
child: Text(
widget.title,
style: const TextStyle(
3 years ago
//color: Theme.of(context).dividerColor,
fontSize: 14,
fontWeight: FontWeight.bold,
),
textScaleFactor: AppStyle.getScaleFactor(context),
3 years ago
),
),
AnimatedSwitcher(
duration: const Duration(milliseconds: 400),
3 years ago
transitionBuilder: (Widget child, Animation<double> animation) {
return FadeTransition(
opacity: animation,
child: ScaleTransition(scale: animation, child: child),
3 years ago
);
},
child: Icon(
_isExpanded
? Icons.keyboard_arrow_up
: Icons.keyboard_arrow_down,
key: ValueKey(_isExpanded
? "Icons.keyboard_arrow_up"
: "Icons.keyboard_arrow_down"),
color: Theme.of(context).primaryColor,
size: 24 * AppStyle.getScaleFactor(context),
),
),
],
),
AnimatedSize(
duration: const Duration(milliseconds: 300),
3 years ago
child: Visibility(
visible: _isExpanded,
child: Padding(
padding: EdgeInsets.symmetric(
vertical: 8 * AppStyle.getScaleFactor(context)),
child: widget.child,
)),
),
Divider(
height: 2 * AppStyle.getScaleFactor(context),
),
SizedBox(
height: 8 * AppStyle.getScaleFactor(context),
3 years ago
),
],
),
);
}
}