ente/lib/ui/components/info_item_widget.dart

100 lines
3.6 KiB
Dart
Raw Normal View History

2023-03-09 12:06:09 +00:00
import "package:flutter/material.dart";
import "package:photos/theme/ente_theme.dart";
import "package:photos/ui/common/loading_widget.dart";
import 'package:photos/ui/components/buttons/icon_button_widget.dart';
2023-03-09 12:06:09 +00:00
///https://www.figma.com/file/SYtMyLBs5SAOkTbfMMzhqt/ente-Visual-Design?node-id=8113-59605&t=OMX5f5KdDJYWSQQN-4
class InfoItemWidget extends StatelessWidget {
final IconData leadingIcon;
final VoidCallback? editOnTap;
final String title;
2023-03-10 13:09:38 +00:00
final Future<List<Widget>> subtitleSection;
final bool hasChipButtons;
2023-03-09 12:06:09 +00:00
const InfoItemWidget({
required this.leadingIcon,
this.editOnTap,
2023-03-09 12:06:09 +00:00
required this.title,
2023-03-10 13:09:38 +00:00
required this.subtitleSection,
this.hasChipButtons = false,
2023-03-09 12:06:09 +00:00
super.key,
});
@override
Widget build(BuildContext context) {
debugPrint("InfoItemWidget.build -------");
2023-03-09 12:06:09 +00:00
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Flexible(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
IconButtonWidget(
icon: leadingIcon,
iconButtonType: IconButtonType.secondary,
),
Flexible(
child: Padding(
padding: const EdgeInsets.fromLTRB(12, 3.5, 16, 3.5),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: hasChipButtons
? getEnteTextTheme(context).smallMuted
: getEnteTextTheme(context).body,
),
SizedBox(height: hasChipButtons ? 8 : 4),
Flexible(
child: FutureBuilder(
2023-03-10 13:09:38 +00:00
future: subtitleSection,
builder: (context, snapshot) {
Widget child;
if (snapshot.hasData) {
final subtitle = snapshot.data as List<Widget>;
if (subtitle.isNotEmpty) {
child = Wrap(
runSpacing: 8,
spacing: 8,
children: subtitle,
);
} else {
child = const SizedBox.shrink();
}
} else {
child = EnteLoadingWidget(
padding: 3,
size: 11,
color: getEnteColorScheme(context).strokeMuted,
);
}
return AnimatedSwitcher(
duration: const Duration(milliseconds: 300),
switchInCurve: Curves.easeInOutExpo,
child: child,
);
},
),
),
2023-03-09 12:06:09 +00:00
],
),
),
),
],
),
),
editOnTap != null
? IconButtonWidget(
icon: Icons.edit,
iconButtonType: IconButtonType.secondary,
onTap: editOnTap,
)
: const SizedBox.shrink(),
2023-03-09 12:06:09 +00:00
],
);
}
}