Skip to content

armgit / ente

Public Imported from GitHub
0

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

Move component fonts into package

AmanRajSinghMouryae2b3192ce830
diff --git a/mobile/apps/photos/pubspec.yaml b/mobile/apps/photos/pubspec.yaml
index 37b4e7455c..ac5de4fea2 100644
--- a/mobile/apps/photos/pubspec.yaml
+++ b/mobile/apps/photos/pubspec.yaml
@@ -403,6 +403,8 @@ flutter:
- assets/icons/nav_bar/
- assets/launcher_icon/
fonts:
+ # TODO: Migrate legacy Photos text styles to ente_components fonts, then
+ # remove this app-local Inter declaration.
- family: Inter
fonts:
- asset: fonts/Inter-Regular.ttf
@@ -410,15 +412,6 @@ flutter:
- asset: fonts/Inter-Light.ttf
- asset: fonts/Inter-SemiBold.ttf
- asset: fonts/Inter-Bold.ttf
- - family: Outfit
- fonts:
- - asset: fonts/Outfit-Regular.ttf
- - asset: fonts/Outfit-Medium.ttf
- weight: 500
- - asset: fonts/Outfit-SemiBold.ttf
- weight: 600
- - asset: fonts/Outfit-Bold.ttf
- weight: 700
- family: Montserrat
fonts:
- asset: fonts/Montserrat-Bold.ttf
diff --git a/mobile/packages/ente_components/fonts/Inter-Bold.ttf b/mobile/packages/ente_components/fonts/Inter-Bold.ttf
new file mode 100644
index 0000000000..7e1deec31e
Binary files /dev/null and b/mobile/packages/ente_components/fonts/Inter-Bold.ttf differ
diff --git a/mobile/packages/ente_components/fonts/Inter-Light.ttf b/mobile/packages/ente_components/fonts/Inter-Light.ttf
new file mode 100644
index 0000000000..ebaa005740
Binary files /dev/null and b/mobile/packages/ente_components/fonts/Inter-Light.ttf differ
diff --git a/mobile/packages/ente_components/fonts/Inter-Medium.ttf b/mobile/packages/ente_components/fonts/Inter-Medium.ttf
new file mode 100644
index 0000000000..7e573f6498
Binary files /dev/null and b/mobile/packages/ente_components/fonts/Inter-Medium.ttf differ
diff --git a/mobile/packages/ente_components/fonts/Inter-Regular.ttf b/mobile/packages/ente_components/fonts/Inter-Regular.ttf
new file mode 100644
index 0000000000..012d1b470d
Binary files /dev/null and b/mobile/packages/ente_components/fonts/Inter-Regular.ttf differ
diff --git a/mobile/packages/ente_components/fonts/Inter-SemiBold.ttf b/mobile/packages/ente_components/fonts/Inter-SemiBold.ttf
new file mode 100644
index 0000000000..4be54399d6
Binary files /dev/null and b/mobile/packages/ente_components/fonts/Inter-SemiBold.ttf differ
diff --git a/mobile/apps/photos/fonts/Outfit-Bold.ttf b/mobile/packages/ente_components/fonts/Outfit-Bold.ttf
similarity index 100%
rename from mobile/apps/photos/fonts/Outfit-Bold.ttf
rename to mobile/packages/ente_components/fonts/Outfit-Bold.ttf
diff --git a/mobile/apps/photos/fonts/Outfit-Medium.ttf b/mobile/packages/ente_components/fonts/Outfit-Medium.ttf
similarity index 100%
rename from mobile/apps/photos/fonts/Outfit-Medium.ttf
rename to mobile/packages/ente_components/fonts/Outfit-Medium.ttf
diff --git a/mobile/apps/photos/fonts/Outfit-Regular.ttf b/mobile/packages/ente_components/fonts/Outfit-Regular.ttf
similarity index 100%
rename from mobile/apps/photos/fonts/Outfit-Regular.ttf
rename to mobile/packages/ente_components/fonts/Outfit-Regular.ttf
diff --git a/mobile/apps/photos/fonts/Outfit-SemiBold.ttf b/mobile/packages/ente_components/fonts/Outfit-SemiBold.ttf
similarity index 100%
rename from mobile/apps/photos/fonts/Outfit-SemiBold.ttf
rename to mobile/packages/ente_components/fonts/Outfit-SemiBold.ttf
diff --git a/mobile/packages/ente_components/lib/components/avatar_component.dart b/mobile/packages/ente_components/lib/components/avatar_component.dart
index b556e4e66f..0b328456dc 100644
--- a/mobile/packages/ente_components/lib/components/avatar_component.dart
+++ b/mobile/packages/ente_components/lib/components/avatar_component.dart
@@ -11,6 +11,7 @@ enum AvatarComponentSize {
iconSize: 12,
textStyle: TextStyle(
fontFamily: TextStyles.fontFamily,
+ package: TextStyles.fontPackage,
fontSize: 8,
height: 15 / 8,
fontWeight: FontWeight.w500,
@@ -23,6 +24,7 @@ enum AvatarComponentSize {
iconSize: 14,
textStyle: TextStyle(
fontFamily: TextStyles.fontFamily,
+ package: TextStyles.fontPackage,
fontSize: 10,
height: 15 / 10,
fontWeight: FontWeight.w500,
@@ -35,6 +37,7 @@ enum AvatarComponentSize {
iconSize: 16,
textStyle: TextStyle(
fontFamily: TextStyles.fontFamily,
+ package: TextStyles.fontPackage,
fontSize: 12,
height: 15 / 12,
fontWeight: FontWeight.w500,
@@ -48,6 +51,7 @@ enum AvatarComponentSize {
iconSize: 16,
textStyle: TextStyle(
fontFamily: TextStyles.fontFamily,
+ package: TextStyles.fontPackage,
fontSize: 12,
height: 15 / 12,
fontWeight: FontWeight.w500,
@@ -60,6 +64,7 @@ enum AvatarComponentSize {
iconSize: 18,
textStyle: TextStyle(
fontFamily: TextStyles.fontFamily,
+ package: TextStyles.fontPackage,
fontSize: 12,
height: 15 / 12,
fontWeight: FontWeight.w500,
@@ -72,6 +77,7 @@ enum AvatarComponentSize {
iconSize: 18,
textStyle: TextStyle(
fontFamily: TextStyles.fontFamily,
+ package: TextStyles.fontPackage,
fontSize: 12,
height: 15 / 12,
fontWeight: FontWeight.w500,
diff --git a/mobile/packages/ente_components/lib/components/selection_controls/labeled_control_component.dart b/mobile/packages/ente_components/lib/components/selection_controls/labeled_control_component.dart
index 66e3dfe8ef..559aaed53d 100644
--- a/mobile/packages/ente_components/lib/components/selection_controls/labeled_control_component.dart
+++ b/mobile/packages/ente_components/lib/components/selection_controls/labeled_control_component.dart
@@ -1,4 +1,5 @@
import 'package:ente_components/theme/spacing.dart';
+import 'package:ente_components/theme/text_styles.dart';
import 'package:ente_components/theme/theme.dart';
import 'package:flutter/material.dart';
@@ -25,9 +26,15 @@ class LabeledControlComponent extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- Text(label, style: TextStyle(color: colors.textBase)),
+ Text(
+ label,
+ style: TextStyles.body.copyWith(color: colors.textBase),
+ ),
if (subtitle != null)
- Text(subtitle!, style: TextStyle(color: colors.textLight)),
+ Text(
+ subtitle!,
+ style: TextStyles.mini.copyWith(color: colors.textLight),
+ ),
],
),
),
diff --git a/mobile/packages/ente_components/lib/theme/text_styles.dart b/mobile/packages/ente_components/lib/theme/text_styles.dart
index 789310d9c8..c1dcde9169 100644
--- a/mobile/packages/ente_components/lib/theme/text_styles.dart
+++ b/mobile/packages/ente_components/lib/theme/text_styles.dart
@@ -10,9 +10,11 @@ class TextStyles {
static const String fontFamily = 'Inter';
static const String outfitFontFamily = 'Outfit';
+ static const String fontPackage = 'ente_components';
static const display1 = TextStyle(
fontFamily: outfitFontFamily,
+ package: fontPackage,
fontSize: 32,
height: 40 / 32,
fontWeight: FontWeight.w600,
@@ -21,6 +23,7 @@ class TextStyles {
static const display2 = TextStyle(
fontFamily: outfitFontFamily,
+ package: fontPackage,
fontSize: 24,
height: 32 / 24,
fontWeight: FontWeight.w600,
@@ -29,6 +32,7 @@ class TextStyles {
static const h1 = TextStyle(
fontFamily: fontFamily,
+ package: fontPackage,
fontSize: 20,
height: 28 / 20,
fontWeight: FontWeight.w700,
@@ -37,6 +41,7 @@ class TextStyles {
static const h1Bold = TextStyle(
fontFamily: fontFamily,
+ package: fontPackage,
fontSize: 20,
height: 28 / 20,
fontWeight: FontWeight.w600,
@@ -45,6 +50,7 @@ class TextStyles {
static const h2 = TextStyle(
fontFamily: fontFamily,
+ package: fontPackage,
fontSize: 18,
height: 24 / 18,
fontWeight: FontWeight.w600,
@@ -53,6 +59,7 @@ class TextStyles {
static const large = TextStyle(
fontFamily: fontFamily,
+ package: fontPackage,
fontSize: 16,
height: 20 / 16,
fontWeight: FontWeight.w600,
@@ -61,6 +68,7 @@ class TextStyles {
static const display3 = TextStyle(
fontFamily: outfitFontFamily,
+ package: fontPackage,
fontSize: 20,
height: 28 / 20,
fontWeight: FontWeight.w600,
@@ -69,6 +77,7 @@ class TextStyles {
static const bodyBold = TextStyle(
fontFamily: fontFamily,
+ package: fontPackage,
fontSize: 14,
height: 20 / 14,
fontWeight: FontWeight.w600,
@@ -77,6 +86,7 @@ class TextStyles {
static const body = TextStyle(
fontFamily: fontFamily,
+ package: fontPackage,
fontSize: 14,
height: 20 / 14,
fontWeight: FontWeight.w500,
@@ -85,6 +95,7 @@ class TextStyles {
static const bodyLink = TextStyle(
fontFamily: fontFamily,
+ package: fontPackage,
fontSize: 14,
height: 20 / 14,
fontWeight: FontWeight.w500,
@@ -94,6 +105,7 @@ class TextStyles {
static const mini = TextStyle(
fontFamily: fontFamily,
+ package: fontPackage,
fontSize: 12,
height: 16 / 12,
fontWeight: FontWeight.w500,
@@ -102,6 +114,7 @@ class TextStyles {
static const tiny = TextStyle(
fontFamily: fontFamily,
+ package: fontPackage,
fontSize: 10,
height: 12 / 10,
fontWeight: FontWeight.w500,
diff --git a/mobile/packages/ente_components/pubspec.yaml b/mobile/packages/ente_components/pubspec.yaml
index 6b17a07f3f..fbbc96888f 100644
--- a/mobile/packages/ente_components/pubspec.yaml
+++ b/mobile/packages/ente_components/pubspec.yaml
@@ -18,3 +18,24 @@ dev_dependencies:
sdk: flutter
flutter:
+ fonts:
+ - family: Inter
+ fonts:
+ - asset: fonts/Inter-Regular.ttf
+ - asset: fonts/Inter-Medium.ttf
+ weight: 500
+ - asset: fonts/Inter-Light.ttf
+ weight: 300
+ - asset: fonts/Inter-SemiBold.ttf
+ weight: 600
+ - asset: fonts/Inter-Bold.ttf
+ weight: 700
+ - family: Outfit
+ fonts:
+ - asset: fonts/Outfit-Regular.ttf
+ - asset: fonts/Outfit-Medium.ttf
+ weight: 500
+ - asset: fonts/Outfit-SemiBold.ttf
+ weight: 600
+ - asset: fonts/Outfit-Bold.ttf
+ weight: 700
diff --git a/mobile/packages/ente_components/test/components/app_surface_widgets_test.dart b/mobile/packages/ente_components/test/components/app_surface_widgets_test.dart
index 636eee067d..6bbb21637a 100644
--- a/mobile/packages/ente_components/test/components/app_surface_widgets_test.dart
+++ b/mobile/packages/ente_components/test/components/app_surface_widgets_test.dart
@@ -605,14 +605,14 @@ void main() {
final title = tester.widget<Text>(find.text('Menu items'));
expect(title.style?.fontSize, greaterThan(16));
- expect(title.style?.fontFamily, TextStyles.outfitFontFamily);
+ expect(title.style?.fontFamily, TextStyles.display2.fontFamily);
scrollController.jumpTo(58);
await tester.pump();
final collapsedTitle = tester.widget<Text>(find.text('Menu items'));
expect(collapsedTitle.style?.fontSize, closeTo(20, 0.01));
- expect(collapsedTitle.style?.fontFamily, TextStyles.outfitFontFamily);
+ expect(collapsedTitle.style?.fontFamily, TextStyles.display3.fontFamily);
expect(tester.getTopLeft(find.text('Item 0')).dy, closeTo(56, 1));
},
);
@@ -646,7 +646,7 @@ void main() {
expect(scrollController.offset, closeTo(58, 1));
final collapsedTitle = tester.widget<Text>(find.text('Appearance'));
expect(collapsedTitle.style?.fontSize, closeTo(20, 0.01));
- expect(collapsedTitle.style?.fontFamily, TextStyles.outfitFontFamily);
+ expect(collapsedTitle.style?.fontFamily, TextStyles.display3.fontFamily);
expect(tester.getTopLeft(find.text('System theme')).dy, closeTo(56, 1));
await tester.drag(find.byType(CustomScrollView), const Offset(0, 32));
diff --git a/mobile/packages/ente_components/test/components/avatar_test.dart b/mobile/packages/ente_components/test/components/avatar_test.dart
index 89c6feec6b..e7ee054815 100644
--- a/mobile/packages/ente_components/test/components/avatar_test.dart
+++ b/mobile/packages/ente_components/test/components/avatar_test.dart
@@ -32,6 +32,9 @@ void main() {
expect(tester.getSize(surfaces.at(3)), const Size(28, 28));
expect(tester.getSize(surfaces.at(4)), const Size(32, 32));
expect(tester.getSize(surfaces.at(5)), const Size(56, 56));
+ for (final text in tester.widgetList<Text>(find.text('E'))) {
+ expect(text.style?.fontFamily, TextStyles.body.fontFamily);
+ }
});
testWidgets(
diff --git a/mobile/packages/ente_components/test/components/selection_controls_test.dart b/mobile/packages/ente_components/test/components/selection_controls_test.dart
index 7bcd5d494d..65150ab233 100644
--- a/mobile/packages/ente_components/test/components/selection_controls_test.dart
+++ b/mobile/packages/ente_components/test/components/selection_controls_test.dart
@@ -230,6 +230,14 @@ void main() {
expect(find.text("Back up automatically"), findsOneWidget);
expect(find.text("Includes new photos"), findsOneWidget);
expect(find.byIcon(Icons.check_rounded), findsOneWidget);
+ expect(
+ tester.widget<Text>(find.text("Back up automatically")).style?.fontFamily,
+ TextStyles.body.fontFamily,
+ );
+ expect(
+ tester.widget<Text>(find.text("Includes new photos")).style?.fontFamily,
+ TextStyles.mini.fontFamily,
+ );
});
testWidgets("FilterChipComponent renders selected state with token colors", (
diff --git a/mobile/packages/ente_components/test/theme/theme_tokens_test.dart b/mobile/packages/ente_components/test/theme/theme_tokens_test.dart
index ae8ef8a372..49bf442094 100644
--- a/mobile/packages/ente_components/test/theme/theme_tokens_test.dart
+++ b/mobile/packages/ente_components/test/theme/theme_tokens_test.dart
@@ -240,19 +240,21 @@ void main() {
test("match the published type scale", () {
expect(TextStyles.fontFamily, "Inter");
expect(TextStyles.outfitFontFamily, "Outfit");
+ expect(TextStyles.fontPackage, "ente_components");
- expect(TextStyles.display1.fontFamily, "Outfit");
+ expect(TextStyles.display1.fontFamily, "packages/ente_components/Outfit");
expect(TextStyles.display1.fontSize, 32);
expect(TextStyles.display1.height, 40 / 32);
expect(TextStyles.display1.fontWeight, FontWeight.w600);
expect(TextStyles.display1.letterSpacing, 0);
- expect(TextStyles.display2.fontFamily, "Outfit");
+ expect(TextStyles.display2.fontFamily, "packages/ente_components/Outfit");
expect(TextStyles.display2.fontSize, 24);
expect(TextStyles.display2.height, 32 / 24);
expect(TextStyles.display2.fontWeight, FontWeight.w600);
expect(TextStyles.display2.letterSpacing, 0);
+ expect(TextStyles.h1.fontFamily, "packages/ente_components/Inter");
expect(TextStyles.h1.fontSize, 20);
expect(TextStyles.h1.height, 28 / 20);
expect(TextStyles.h1.fontWeight, FontWeight.w700);
@@ -262,11 +264,12 @@ void main() {
expect(TextStyles.h2.height, 24 / 18);
expect(TextStyles.h2.fontWeight, FontWeight.w600);
- expect(TextStyles.display3.fontFamily, "Outfit");
+ expect(TextStyles.display3.fontFamily, "packages/ente_components/Outfit");
expect(TextStyles.display3.fontSize, 20);
expect(TextStyles.display3.height, 28 / 20);
expect(TextStyles.display3.fontWeight, FontWeight.w600);
+ expect(TextStyles.body.fontFamily, "packages/ente_components/Inter");
expect(TextStyles.body.fontSize, 14);
expect(TextStyles.body.height, 20 / 14);
expect(TextStyles.body.fontWeight, FontWeight.w500);
@@ -285,13 +288,19 @@ void main() {
expect(theme.scaffoldBackgroundColor, ColorTokens.light.backgroundBase);
expect(theme.colorScheme.primary, ColorTokens.light.primary);
expect(theme.colorScheme.error, ColorTokens.light.warning);
- expect(theme.textTheme.headlineLarge?.fontFamily, TextStyles.fontFamily);
+ expect(
+ theme.textTheme.headlineLarge?.fontFamily,
+ TextStyles.h1.fontFamily,
+ );
expect(theme.textTheme.headlineLarge?.fontSize, TextStyles.h1.fontSize);
expect(
theme.textTheme.headlineLarge?.fontWeight,
TextStyles.h1.fontWeight,
);
- expect(theme.textTheme.bodyMedium?.fontFamily, TextStyles.fontFamily);
+ expect(
+ theme.textTheme.bodyMedium?.fontFamily,
+ TextStyles.body.fontFamily,
+ );
expect(theme.textTheme.bodyMedium?.fontSize, TextStyles.body.fontSize);
});
@@ -302,7 +311,10 @@ void main() {
expect(theme.scaffoldBackgroundColor, ColorTokens.dark.backgroundBase);
expect(theme.colorScheme.primary, ColorTokens.dark.primary);
expect(theme.colorScheme.error, ColorTokens.dark.warning);
- expect(theme.textTheme.labelSmall?.fontFamily, TextStyles.fontFamily);
+ expect(
+ theme.textTheme.labelSmall?.fontFamily,
+ TextStyles.tiny.fontFamily,
+ );
expect(theme.textTheme.labelSmall?.fontSize, TextStyles.tiny.fontSize);
expect(
theme.textTheme.labelSmall?.fontWeight,