2023-03-09 12:06:09 +00:00
|
|
|
import "package:flutter/material.dart";
|
2023-03-10 13:05:02 +00:00
|
|
|
import "package:photos/theme/ente_theme.dart";
|
|
|
|
import "package:photos/ui/common/loading_widget.dart";
|
2023-03-10 08:08:51 +00:00
|
|
|
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;
|
2023-03-10 13:05:02 +00:00
|
|
|
final bool hasChipButtons;
|
2023-03-09 12:06:09 +00:00
|
|
|
const InfoItemWidget({
|
|
|
|
required this.leadingIcon,
|
2023-03-10 08:33:29 +00:00
|
|
|
this.editOnTap,
|
2023-03-09 12:06:09 +00:00
|
|
|
required this.title,
|
2023-03-10 13:09:38 +00:00
|
|
|
required this.subtitleSection,
|
2023-03-10 13:05:02 +00:00
|
|
|
this.hasChipButtons = false,
|
2023-03-09 12:06:09 +00:00
|
|
|
super.key,
|
|
|
|
});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-03-13 11:07:12 +00:00
|
|
|
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: [
|
2023-03-10 13:05:02 +00:00
|
|
|
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,
|
2023-03-10 13:05:02 +00:00
|
|
|
builder: (context, snapshot) {
|
2023-03-13 10:02:13 +00:00
|
|
|
Widget child;
|
2023-03-10 13:05:02 +00:00
|
|
|
if (snapshot.hasData) {
|
|
|
|
final subtitle = snapshot.data as List<Widget>;
|
|
|
|
if (subtitle.isNotEmpty) {
|
2023-03-13 10:02:13 +00:00
|
|
|
child = Wrap(
|
2023-03-10 13:05:02 +00:00
|
|
|
runSpacing: 8,
|
|
|
|
spacing: 8,
|
|
|
|
children: subtitle,
|
|
|
|
);
|
|
|
|
} else {
|
2023-03-13 10:02:13 +00:00
|
|
|
child = const SizedBox.shrink();
|
2023-03-10 13:05:02 +00:00
|
|
|
}
|
|
|
|
} else {
|
2023-03-13 10:02:13 +00:00
|
|
|
child = const EnteLoadingWidget(
|
|
|
|
padding: 3,
|
|
|
|
size: 11,
|
2023-03-10 13:05:02 +00:00
|
|
|
);
|
|
|
|
}
|
2023-03-13 10:02:13 +00:00
|
|
|
return AnimatedSwitcher(
|
|
|
|
duration: const Duration(milliseconds: 300),
|
|
|
|
switchInCurve: Curves.easeInOutExpo,
|
|
|
|
child: child,
|
|
|
|
);
|
2023-03-10 13:05:02 +00:00
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
2023-03-09 12:06:09 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
2023-03-10 08:33:29 +00:00
|
|
|
editOnTap != null
|
|
|
|
? IconButtonWidget(
|
|
|
|
icon: Icons.edit,
|
|
|
|
iconButtonType: IconButtonType.secondary,
|
|
|
|
onTap: editOnTap,
|
|
|
|
)
|
|
|
|
: const SizedBox.shrink(),
|
2023-03-09 12:06:09 +00:00
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|