Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

feat: app UI fonts #11

Merged
merged 6 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions lib/app/view/app.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:api_client/api_client.dart';
import 'package:app_ui/app_ui.dart';
import 'package:dash_ai_search/home/home.dart';
import 'package:dash_ai_search/l10n/l10n.dart';
import 'package:flutter/material.dart';
Expand All @@ -14,12 +15,7 @@ class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
appBarTheme: AppBarTheme(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
),
useMaterial3: true,
),
theme: VertexTheme.standard,
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: const HomePage(),
Expand Down
9 changes: 3 additions & 6 deletions lib/home/widgets/logo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ class Logo extends StatelessWidget {

@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final l10n = context.l10n;

return Row(
children: [
Text(
l10n.vertexAI,
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.w400,
style: theme.textTheme.bodyLarge?.copyWith(
color: Colors.black,
),
),
Expand All @@ -24,9 +23,7 @@ class Logo extends StatelessWidget {
const SizedBox(width: 4),
Text(
l10n.flutter,
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.w400,
style: theme.textTheme.bodyLarge?.copyWith(
color: Colors.black,
),
),
Expand Down
7 changes: 3 additions & 4 deletions lib/home/widgets/welcome_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class WelcomeView extends StatelessWidget {

@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final l10n = context.l10n;

return Center(
Expand All @@ -17,10 +18,8 @@ class WelcomeView extends StatelessWidget {
Text(
l10n.initialScreenTitle,
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 72,
fontWeight: FontWeight.w700,
color: Color(0xFF020F30),
style: theme.textTheme.displayLarge?.copyWith(
color: Colors.black,
),
),
const SizedBox(height: 40),
Expand Down
Binary file not shown.
Binary file not shown.
5 changes: 5 additions & 0 deletions packages/app_ui/lib/app_ui.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/// UI Toolkit
library app_ui;

import 'package:app_ui/src/generated/assets.gen.dart';

export 'src/theme/vertex_theme.dart';
export 'src/typography/vertex_text_styles.dart';
export 'src/widgets/widgets.dart';

/// Global reference to actual app_ui icons.
Expand Down
23 changes: 23 additions & 0 deletions packages/app_ui/lib/src/theme/vertex_theme.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:app_ui/src/typography/vertex_text_styles.dart';
import 'package:flutter/material.dart';

/// {@template vertex_theme}
/// The default [ThemeData].
/// {@endtemplate}
class VertexTheme {
/// Standard `ThemeData` for VertexAI UI.
static ThemeData get standard {
return ThemeData(
textTheme: _textTheme,
useMaterial3: true,
);
}

static TextTheme get _textTheme {
return TextTheme(
displayLarge: VertexTextStyles.display,
bodyLarge: VertexTextStyles.body,
labelLarge: VertexTextStyles.label,
);
}
}
1 change: 1 addition & 0 deletions packages/app_ui/lib/src/typography/typography.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'vertex_text_styles.dart';
38 changes: 38 additions & 0 deletions packages/app_ui/lib/src/typography/vertex_text_styles.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import 'package:flutter/material.dart';

/// {@template vertex_text_styles}
/// App Text Style Definitions
/// {@endtemplate}
class VertexTextStyles {
/// {@macro vertex_text_styles}

static TextStyle get _baseTextStyle => const TextStyle(
fontWeight: FontWeight.w400,
package: 'app_ui',
fontFamily: 'GoogleSans',
color: Colors.black,
);

/// Title Style
static TextStyle get display => _baseTextStyle.copyWith(
fontSize: 72,
fontWeight: FontWeight.bold,
height: 1.11,
letterSpacing: -2,
);

/// Button Style
static TextStyle get body => _baseTextStyle.copyWith(
fontSize: 18,
height: 1.3,
letterSpacing: -0.5,
);

/// Label Style
static TextStyle get label => _baseTextStyle.copyWith(
fontSize: 14,
fontWeight: FontWeight.bold,
height: 1.7,
letterSpacing: 2,
);
}
21 changes: 14 additions & 7 deletions packages/app_ui/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,27 @@ dependencies:

dev_dependencies:
build_runner: ^2.4.6
flutter_gen_runner: ^5.3.2
flutter_test:
sdk: flutter
flutter_gen_runner: ^5.3.2
mocktail: ^1.0.0
very_good_analysis: ^5.1.0

flutter:
assets:
- assets/icons/
fonts:
- family: GoogleSans
fonts:
- asset: assets/fonts/GoogleSansText-Bold.ttf
weight: 700
- asset: assets/fonts/GoogleSansText-Regular.ttf
weight: 400

flutter_gen:
uses-material-design: true
assets:
outputs:
package_parameter_enabled: true
output: lib/src/generated/
line_length: 80

flutter:
uses-material-design: true
assets:
- assets/icons/
line_length: 80
11 changes: 11 additions & 0 deletions packages/app_ui/test/src/theme/vertex_theme_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import 'package:app_ui/app_ui.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
group('VertexTheme themeData', () {
test('is defined for standard', () {
expect(VertexTheme.standard, isA<ThemeData>());
});
});
}
13 changes: 13 additions & 0 deletions packages/app_ui/test/src/typography/vertex_text_styles_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import 'package:app_ui/app_ui.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
group('VertexTextStyles', () {
test('is defined for both display, body, and label', () {
expect(VertexTextStyles.display, isA<TextStyle>());
expect(VertexTextStyles.body, isA<TextStyle>());
expect(VertexTextStyles.label, isA<TextStyle>());
});
});
}