This repository has been archived by the owner on Jan 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
31 changed files
with
835 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export 'view/home_page.dart'; | ||
export 'widgets/widgets.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import 'package:app_ui/app_ui.dart'; | ||
import 'package:dash_ai_search/home/home.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class HomePage extends StatelessWidget { | ||
const HomePage({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return const Scaffold( | ||
backgroundColor: Color(0xFFF8FAFF), | ||
body: Stack( | ||
children: [ | ||
Positioned( | ||
top: 0, | ||
bottom: 0, | ||
child: Background(), | ||
), | ||
Positioned( | ||
top: 40, | ||
left: 48, | ||
child: Logo(), | ||
), | ||
WelcomeView(), | ||
Positioned( | ||
bottom: 50, | ||
left: 50, | ||
child: DashAnimation(), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} | ||
|
||
class DashAnimation extends StatelessWidget { | ||
@visibleForTesting | ||
const DashAnimation({super.key}); | ||
|
||
static const dashSize = Size(800, 800); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final screenSize = MediaQuery.sizeOf(context); | ||
|
||
return Container( | ||
alignment: Alignment.center, | ||
height: screenSize.height / 3, | ||
width: screenSize.height / 3, | ||
child: const AnimatedSprite( | ||
showLoadingIndicator: false, | ||
sprites: Sprites( | ||
asset: 'dash_animation.png', | ||
size: dashSize, | ||
frames: 34, | ||
stepTime: 0.07, | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:path_drawing/path_drawing.dart'; | ||
|
||
class Background extends StatelessWidget { | ||
const Background({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
const leftOffset = -50.0; | ||
const baseRadius = 303.0; | ||
const baseMediumRadius = 255.0; | ||
const baseSmallRadius = 185.0; | ||
const horizontalOffset = baseRadius * 2; | ||
|
||
return const SingleChildScrollView( | ||
scrollDirection: Axis.horizontal, | ||
child: Row( | ||
children: [ | ||
Circle( | ||
offset: Offset(leftOffset, 0), | ||
), | ||
Circle( | ||
offset: Offset(horizontalOffset + leftOffset, 0), | ||
child: Circle( | ||
offset: Offset(horizontalOffset + leftOffset, 0), | ||
radius: baseMediumRadius, | ||
borderColor: Color(0xFFDDE2F6), | ||
child: Circle( | ||
offset: Offset(horizontalOffset + leftOffset, 0), | ||
radius: baseSmallRadius, | ||
borderColor: Color(0xFFDDE2F6), | ||
dotted: true, | ||
), | ||
), | ||
), | ||
Circle( | ||
offset: Offset(horizontalOffset * 2 + leftOffset, 0), | ||
), | ||
Circle( | ||
offset: Offset(horizontalOffset * 3 + leftOffset, 0), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} | ||
|
||
class Circle extends StatelessWidget { | ||
@visibleForTesting | ||
const Circle({ | ||
this.offset = Offset.zero, | ||
this.radius = 303, | ||
this.borderColor = Colors.white, | ||
this.dotted = false, | ||
this.child, | ||
super.key, | ||
}); | ||
|
||
final Offset offset; | ||
final double radius; | ||
final Color borderColor; | ||
final bool dotted; | ||
final Widget? child; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return CustomPaint( | ||
painter: CirclePainter( | ||
offset: offset, | ||
radius: radius, | ||
borderColor: borderColor, | ||
dotted: dotted, | ||
), | ||
child: child, | ||
); | ||
} | ||
} | ||
|
||
class CirclePainter extends CustomPainter { | ||
CirclePainter({ | ||
required this.offset, | ||
required this.radius, | ||
required this.borderColor, | ||
required this.dotted, | ||
}) { | ||
_paintCircle = Paint() | ||
..color = Colors.white | ||
..style = PaintingStyle.fill; | ||
_paintBorder = Paint() | ||
..color = borderColor | ||
..strokeWidth = 2 | ||
..strokeCap = StrokeCap.butt | ||
..style = PaintingStyle.stroke; | ||
} | ||
|
||
final Offset offset; | ||
final double radius; | ||
final Color borderColor; | ||
final bool dotted; | ||
|
||
late final Paint _paintCircle; | ||
late final Paint _paintBorder; | ||
|
||
@override | ||
void paint(Canvas canvas, Size size) { | ||
canvas.drawCircle( | ||
offset, | ||
radius, | ||
_paintCircle, | ||
); | ||
|
||
if (dotted) { | ||
const dashPattern = <double>[4, 4]; | ||
final s = radius * 2; | ||
|
||
var path = Path() | ||
..addRRect( | ||
RRect.fromRectAndRadius( | ||
Rect.fromLTWH( | ||
offset.dx - s / 2, | ||
offset.dy / 2 - s / 2, | ||
s, | ||
s, | ||
), | ||
Radius.circular(s / 2), | ||
), | ||
); | ||
path = dashPath(path, dashArray: CircularIntervalList(dashPattern)); | ||
canvas.drawPath(path, _paintBorder); | ||
} else { | ||
canvas.drawCircle( | ||
offset, | ||
radius, | ||
_paintBorder, | ||
); | ||
} | ||
} | ||
|
||
@override | ||
bool shouldRepaint(CustomPainter oldDelegate) => false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import 'package:app_ui/app_ui.dart'; | ||
import 'package:dash_ai_search/l10n/l10n.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class Logo extends StatelessWidget { | ||
const Logo({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final l10n = context.l10n; | ||
|
||
return Row( | ||
children: [ | ||
Text( | ||
l10n.vertexAI, | ||
style: const TextStyle( | ||
fontSize: 18, | ||
fontWeight: FontWeight.w400, | ||
color: Colors.black, | ||
), | ||
), | ||
const SizedBox(width: 4), | ||
vertexIcons.asterisk.image(), | ||
const SizedBox(width: 4), | ||
Text( | ||
l10n.flutter, | ||
style: const TextStyle( | ||
fontSize: 18, | ||
fontWeight: FontWeight.w400, | ||
color: Colors.black, | ||
), | ||
), | ||
], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import 'package:app_ui/app_ui.dart'; | ||
import 'package:dash_ai_search/l10n/l10n.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class WelcomeView extends StatelessWidget { | ||
const WelcomeView({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final l10n = context.l10n; | ||
|
||
return Center( | ||
child: SingleChildScrollView( | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
Text( | ||
l10n.initialScreenTitle, | ||
textAlign: TextAlign.center, | ||
style: const TextStyle( | ||
fontSize: 72, | ||
fontWeight: FontWeight.w700, | ||
color: Color(0xFF020F30), | ||
), | ||
), | ||
const SizedBox(height: 40), | ||
CTAButton( | ||
icon: vertexIcons.arrowForward.image(), | ||
label: l10n.startAsking, | ||
), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export 'background.dart'; | ||
export 'logo.dart'; | ||
export 'welcome_view.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,19 @@ | ||
{ | ||
"@@locale": "en", | ||
"counterAppBarTitle": "Counter", | ||
"@counterAppBarTitle": { | ||
"description": "Text shown in the AppBar of the Counter Page" | ||
"vertexAI": "Vertex AI", | ||
"@vertexAI": { | ||
"description": "Vertex AI text on logo" | ||
}, | ||
"flutter": "Flutter", | ||
"@flutter": { | ||
"description": "Flutter text on logo" | ||
}, | ||
"initialScreenTitle": "Ask a question, get \nthe right answer, with \nGoogle Vertex AI", | ||
"@initialScreenTitle": { | ||
"description": "Title shown on Initial screen" | ||
}, | ||
"startAsking": "Start asking", | ||
"@startAsking": { | ||
"description": "Button text for start asking" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
import 'package:app_ui/src/generated/assets.gen.dart'; | ||
|
||
export 'src/widgets/widgets.dart'; | ||
|
||
/// Global reference to actual app_ui icons. | ||
const vertexIcons = Assets.icons; |
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
/// {@template cta_button} | ||
/// A button that displays an image on the left side and a text on the right | ||
/// side. | ||
/// {@endtemplate} | ||
class CTAButton extends StatelessWidget { | ||
/// {@macro cta_button} | ||
const CTAButton({ | ||
required this.label, | ||
this.icon, | ||
this.onPressed, | ||
super.key, | ||
}); | ||
|
||
/// The image that will be displayed on the left side of the button. | ||
final Image? icon; | ||
|
||
/// The text that will be displayed on the right side of the button. | ||
final String label; | ||
|
||
/// The callback that will be called when the button is tapped. | ||
final VoidCallback? onPressed; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return ElevatedButton( | ||
onPressed: onPressed, | ||
style: const ButtonStyle( | ||
backgroundColor: MaterialStatePropertyAll( | ||
Color(0xFF0273E6), | ||
), | ||
padding: MaterialStatePropertyAll( | ||
EdgeInsets.only( | ||
left: 24, | ||
top: 20, | ||
bottom: 20, | ||
right: 32, | ||
), | ||
), | ||
), | ||
child: Row( | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
if (icon != null) icon!, | ||
Text( | ||
label, | ||
textAlign: TextAlign.center, | ||
style: const TextStyle( | ||
fontSize: 18, | ||
fontWeight: FontWeight.w500, | ||
color: Colors.white, | ||
), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export 'animated_sprite.dart'; | ||
export 'app_animated_cross_fade.dart'; | ||
export 'app_circular_progress_indicator.dart'; | ||
export 'cta_button.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
include: package:very_good_analysis/analysis_options.5.1.0.yaml | ||
linter: | ||
rules: | ||
prefer_const_constructors: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export 'pump_app.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
extension PumpApp on WidgetTester { | ||
Future<void> pumpApp(Widget widget) { | ||
return pumpWidget( | ||
MaterialApp( | ||
home: widget, | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import 'package:app_ui/app_ui.dart'; | ||
import 'package:app_ui/src/generated/assets.gen.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
import '../helpers/helpers.dart'; | ||
|
||
void main() { | ||
group('CTAButton', () { | ||
testWidgets('renders correctly', (tester) async { | ||
await tester.pumpApp( | ||
CTAButton( | ||
icon: Assets.icons.arrowForward.image(), | ||
label: 'label', | ||
), | ||
); | ||
|
||
expect(find.text('label'), findsOneWidget); | ||
}); | ||
|
||
testWidgets('calls onPressed when tap', (tester) async { | ||
var called = false; | ||
|
||
await tester.pumpApp( | ||
CTAButton( | ||
icon: Assets.icons.arrowForward.image(), | ||
label: 'label', | ||
onPressed: () { | ||
called = true; | ||
}, | ||
), | ||
); | ||
|
||
await tester.tap(find.byType(CTAButton)); | ||
expect(called, isTrue); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
include: package:very_good_analysis/analysis_options.5.1.0.yaml | ||
linter: | ||
rules: | ||
prefer_const_constructors: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import 'package:dash_ai_search/home/home.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
import '../../helpers/helpers.dart'; | ||
|
||
void main() { | ||
group('HomePage', () { | ||
testWidgets('renders correctly', (tester) async { | ||
await tester.pumpApp( | ||
HomePage(), | ||
); | ||
|
||
expect(find.byType(Background), findsOneWidget); | ||
expect(find.byType(Logo), findsOneWidget); | ||
expect(find.byType(WelcomeView), findsOneWidget); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import 'package:dash_ai_search/home/home.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
import '../../helpers/helpers.dart'; | ||
|
||
void main() { | ||
group('Background', () { | ||
testWidgets('renders correctly', (tester) async { | ||
await tester.pumpApp( | ||
Background(), | ||
); | ||
|
||
expect(find.byType(Circle), findsNWidgets(6)); | ||
}); | ||
|
||
test('verifies should not repaint', () async { | ||
final circlePainter = CirclePainter( | ||
offset: Offset.zero, | ||
radius: 10, | ||
borderColor: Colors.white, | ||
dotted: false, | ||
); | ||
expect(circlePainter.shouldRepaint(circlePainter), false); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import 'package:dash_ai_search/home/home.dart'; | ||
import 'package:dash_ai_search/l10n/l10n.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
import '../../helpers/helpers.dart'; | ||
|
||
void main() { | ||
group('Logo', () { | ||
testWidgets('renders correctly', (tester) async { | ||
await tester.pumpApp( | ||
Logo(), | ||
); | ||
|
||
final l10n = tester.element(find.byType(Logo)).l10n; | ||
|
||
expect(find.text(l10n.vertexAI), findsOneWidget); | ||
expect(find.byType(Image), findsOneWidget); | ||
expect(find.text(l10n.flutter), findsOneWidget); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
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_test/flutter_test.dart'; | ||
|
||
import '../../helpers/helpers.dart'; | ||
|
||
void main() { | ||
group('WelcomeView', () { | ||
testWidgets('renders correctly', (tester) async { | ||
await tester.pumpApp( | ||
WelcomeView(), | ||
); | ||
|
||
final l10n = tester.element(find.byType(WelcomeView)).l10n; | ||
|
||
expect(find.text(l10n.initialScreenTitle), findsOneWidget); | ||
expect(find.byType(CTAButton), findsOneWidget); | ||
}); | ||
}); | ||
} |