Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Banner redesign

laurenspriem1144b3a6a052
diff --git a/mobile/apps/photos/lib/ui/activity/activity_banner.dart b/mobile/apps/photos/lib/ui/activity/activity_banner.dart
index 8a582d4ad1..e74fa79e0a 100644
--- a/mobile/apps/photos/lib/ui/activity/activity_banner.dart
+++ b/mobile/apps/photos/lib/ui/activity/activity_banner.dart
@@ -1,7 +1,9 @@
import "package:flutter/material.dart";
import "package:photos/models/activity/activity_models.dart";
import "package:photos/service_locator.dart";
+import "package:photos/theme/colors.dart";
import "package:photos/theme/ente_theme.dart";
+import "package:photos/theme/text_style.dart";
import "package:photos/ui/activity/activity_screen.dart";
import "package:photos/utils/navigation_util.dart";
@@ -28,54 +30,107 @@ class ActivityBanner extends StatelessWidget {
final hasFire = summary?.hasSevenDayFire ?? false;
final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
child: Material(
- color: colorScheme.backgroundElevated,
+ color: Colors.transparent,
borderRadius: BorderRadius.circular(20),
child: InkWell(
borderRadius: BorderRadius.circular(20),
onTap: () {
routeToPage(context, const ActivityScreen());
},
- child: Padding(
+ child: Container(
+ decoration: BoxDecoration(
+ color: Theme.of(context).brightness == Brightness.dark
+ ? colorScheme.backgroundElevated2
+ : const Color(0xFFFAFAFA),
+ borderRadius: BorderRadius.circular(20),
+ border: Border.all(
+ color: colorScheme.strokeFaint,
+ width: 1,
+ ),
+ ),
padding:
const EdgeInsets.symmetric(horizontal: 12, vertical: 12),
child: Row(
+ crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(
- width: 48,
- height: 48,
+ width: 55,
+ height: 55,
child: Image.asset(
"assets/rituals/take_a_photo.png",
fit: BoxFit.contain,
),
),
- const SizedBox(width: 12),
+ const SizedBox(width: 10),
Expanded(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- ...seven.asMap().entries.map(
- (entry) {
- final isLast = entry.key == seven.length - 1;
- final active = entry.value.hasActivity;
- if (isLast && hasFire) {
- return _FireDot();
- }
- return _DayDot(
- label: _dayLabel(entry.value.date),
+ child: LayoutBuilder(
+ builder: (context, constraints) {
+ const double baseCell = 30;
+ const double minCell = baseCell * 0.8; // 24
+ const double maxCell = baseCell * 1.2; // 36
+ const double spacing = 4;
+ double cellWidth =
+ (constraints.maxWidth - (6 * spacing)) / 7;
+ cellWidth = cellWidth.clamp(minCell, maxCell);
+ final today = DateTime.now();
+
+ return Row(
+ mainAxisSize: MainAxisSize.max,
+ children: seven.asMap().entries.map((entry) {
+ final bool isLast = entry.key == seven.length - 1;
+ final bool active =
+ entry.value.hasActivity || hasFire;
+ final bool isToday =
+ _isSameDay(entry.value.date, today);
+ final String label = _dayLabel(entry.value.date);
+ final Widget pill = _DayPill(
+ label: label,
active: active,
+ width: cellWidth,
+ textTheme: textTheme,
+ colorScheme: colorScheme,
);
- },
- ),
- ],
+ return Padding(
+ padding: EdgeInsets.only(
+ right: isLast ? 0 : spacing,
+ ),
+ child: SizedBox(
+ width: cellWidth,
+ height: cellWidth,
+ child: Stack(
+ clipBehavior: Clip.none,
+ children: [
+ Positioned.fill(child: pill),
+ if (isToday)
+ Positioned(
+ bottom: -(cellWidth * 0.4),
+ left: (cellWidth - 6) / 2,
+ child: Container(
+ width: 6,
+ height: 6,
+ decoration: BoxDecoration(
+ color: colorScheme.primary500,
+ shape: BoxShape.circle,
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ );
+ }).toList(),
+ );
+ },
),
),
- const SizedBox(width: 8),
+ const SizedBox(width: 12),
Icon(
Icons.chevron_right_rounded,
- color: colorScheme.textMuted,
+ color: colorScheme.blurStrokePressed,
),
],
),
@@ -91,61 +146,55 @@ class ActivityBanner extends StatelessWidget {
const labels = ["S", "M", "T", "W", "T", "F", "S"];
return labels[date.weekday % 7];
}
+
+ bool _isSameDay(DateTime a, DateTime b) {
+ return a.year == b.year && a.month == b.month && a.day == b.day;
+ }
}
-class _DayDot extends StatelessWidget {
- const _DayDot({
+class _DayPill extends StatelessWidget {
+ const _DayPill({
required this.label,
required this.active,
+ required this.width,
+ required this.textTheme,
+ required this.colorScheme,
});
final String label;
final bool active;
+ final double width;
+ final EnteTextTheme textTheme;
+ final EnteColorScheme colorScheme;
@override
Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
final bool isDark = Theme.of(context).brightness == Brightness.dark;
- final Color inactiveTextColor =
- isDark ? colorScheme.textMuted : colorScheme.textBase;
+ final Color inactiveBackground =
+ isDark ? colorScheme.fillFaintPressed : colorScheme.fillFaint;
+ final Color backgroundColor =
+ active ? const Color(0xFF1DB954) : inactiveBackground;
+ final Color textColor = active ? Colors.white : colorScheme.textBase;
+
return Container(
- margin: const EdgeInsets.symmetric(horizontal: 2),
- width: 32,
+ width: width,
height: 32,
decoration: BoxDecoration(
- color: active ? colorScheme.primary500 : colorScheme.fillFaintPressed,
- shape: BoxShape.circle,
+ color: backgroundColor,
+ borderRadius: BorderRadius.circular(8),
+ border: Border.all(
+ color: active ? Colors.transparent : colorScheme.strokeFaint,
+ ),
),
alignment: Alignment.center,
child: Text(
label,
- style: TextStyle(
- color: active ? Colors.white : inactiveTextColor,
- fontWeight: FontWeight.w700,
- fontSize: 12,
+ style: textTheme.miniBold.copyWith(
+ color: textColor,
+ fontWeight: FontWeight.w900,
+ letterSpacing: -0.05,
),
),
);
}
}
-
-class _FireDot extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
- return Container(
- margin: const EdgeInsets.symmetric(horizontal: 2),
- width: 32,
- height: 32,
- decoration: BoxDecoration(
- color: colorScheme.warning500.withValues(alpha: 0.16),
- shape: BoxShape.circle,
- ),
- alignment: Alignment.center,
- child: Icon(
- Icons.local_fire_department_rounded,
- color: colorScheme.warning500,
- ),
- );
- }
-}