ente/mobile/lib/ui/tabs/section_title.dart

97 lines
2.3 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
2023-04-21 14:47:47 +00:00
import "package:photos/generated/l10n.dart";
2022-10-19 14:24:20 +00:00
import 'package:photos/theme/ente_theme.dart';
import 'package:photos/theme/text_style.dart';
2023-04-21 14:47:47 +00:00
import "package:styled_text/styled_text.dart";
class SectionTitle extends StatelessWidget {
final String? title;
final bool mutedTitle;
2023-04-21 14:47:47 +00:00
final Widget? titleWithBrand;
2023-06-23 13:43:15 +00:00
final EdgeInsetsGeometry? padding;
const SectionTitle({
this.title,
this.titleWithBrand,
this.mutedTitle = false,
Key? key,
2023-06-23 13:43:15 +00:00
this.padding,
}) : super(key: key);
@override
Widget build(BuildContext context) {
2022-10-19 14:24:20 +00:00
final enteTextTheme = getEnteTextTheme(context);
Widget child;
if (titleWithBrand != null) {
child = titleWithBrand!;
} else if (title != null) {
child = Text(
title!,
style: mutedTitle ? enteTextTheme.bodyMuted : enteTextTheme.largeBold,
);
} else {
child = const SizedBox.shrink();
}
2023-06-23 13:43:15 +00:00
return Container(
2023-07-19 10:11:36 +00:00
constraints: const BoxConstraints(minHeight: 48),
2023-06-23 13:43:15 +00:00
alignment: Alignment.centerLeft,
padding: padding,
child: child,
);
2023-06-23 12:24:26 +00:00
}
}
2023-07-03 08:24:49 +00:00
class SectionOptions extends StatelessWidget {
final Widget title;
2023-06-23 12:24:26 +00:00
final Widget? trailingWidget;
final EdgeInsetsGeometry? padding;
2023-07-03 08:24:49 +00:00
const SectionOptions(
2023-06-23 12:24:26 +00:00
this.title, {
this.trailingWidget,
this.padding = const EdgeInsets.only(left: 12, right: 0),
2023-06-23 12:24:26 +00:00
super.key,
});
@override
Widget build(BuildContext context) {
if (trailingWidget != null) {
return Container(
padding: padding,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(alignment: Alignment.centerLeft, child: title),
trailingWidget!,
],
),
);
} else {
return Container(
alignment: Alignment.centerLeft,
padding: padding,
child: title,
);
}
}
}
2023-04-21 14:47:47 +00:00
Widget getOnEnteSection(BuildContext context) {
final EnteTextTheme textTheme = getEnteTextTheme(context);
2023-04-21 14:47:47 +00:00
return StyledText(
text: S.of(context).onEnte,
style: TextStyle(
fontWeight: FontWeight.w600,
fontFamily: 'Inter',
fontSize: 21,
color: textTheme.brandSmall.color,
),
2023-04-21 14:47:47 +00:00
tags: {
'branding': StyledTextTag(
style: textTheme.brandSmall,
),
},
);
}