Skip to content

Commit

Permalink
feat: Add welcome card ui
Browse files Browse the repository at this point in the history
  • Loading branch information
shihabkandil committed Sep 6, 2024
1 parent 09a43e6 commit 74131a1
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 3 deletions.
Binary file added assets/images/welcome_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions lib/common/constants/theme/app_colors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ class AppColors {
];

static const Color black = Colors.black;
static const Color grayishBlue = Color(0xFFA0AEC0);
}
2 changes: 1 addition & 1 deletion lib/common/core/router/app_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ class AppRouter extends RootStackRouter {
@override
List<AutoRoute> get routes => [
AutoRoute(page: AuthRoute.page, initial: true),
AutoRoute(page: DashboardRoute.page),
AutoRoute(page: DashboardRoute.page, path: '/dashboard'),
];
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:ui';

import 'package:admin_dashboard/features/dashboard/presentation/widgets/welcome_card.dart';
import 'package:auto_route/annotations.dart';
import 'package:flutter/material.dart';

Expand Down Expand Up @@ -32,6 +33,8 @@ class DashboardScreen extends StatelessWidget {
children: [
20.verticalSpace,
const HeaderCardsList(),
20.verticalSpace,
const WelcomeCard(name: 'Anonymous')
],
),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:admin_dashboard/common/extensions/widgets_extensions.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import '../../../../common/extensions/context_extensions.dart';
import '../../../../common/extensions/widgets_extensions.dart';
import 'header_analytics_card.dart';

class HeaderCardsList extends StatelessWidget {
Expand Down
58 changes: 58 additions & 0 deletions lib/features/dashboard/presentation/widgets/welcome_card.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import 'package:admin_dashboard/common/extensions/widgets_extensions.dart';
import 'package:flutter/material.dart';

import '../../../../common/constants/theme/app_colors.dart';
import '../../../../common/constants/theme/app_theme_data.dart';
import '../../../../common/extensions/context_extensions.dart';
import '../../../../gen/assets.gen.dart';

class WelcomeCard extends StatelessWidget {
const WelcomeCard({super.key, required this.name});

final String name;

@override
Widget build(BuildContext context) {
return SizedBox(
width: 650,
height: 340,
child: DecoratedBox(
decoration: BoxDecoration(borderRadius: BorderRadius.circular(20)),
child: Stack(
children: [
Assets.images.welcomeBackground.image(fit: BoxFit.fill),
Padding(
padding: const EdgeInsets.all(32),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
context.localizer.welcomeBack,
style: context.textTheme.labelLarge!.copyWith(
color: AppColors.grayishBlue,
),
),
6.verticalSpace,
Text(
name,
style: context.textTheme.headlineMedium!.copyWith(
fontWeight: FontWeight.bold,
),
),
16.verticalSpace,
Text(
context.localizer.gladToSeeYou,
textAlign: TextAlign.start,
style: context.textTheme.bodyLarge!.copyWith(
color: AppColors.grayishBlue,
),
),
],
),
),
],
),
),
);
}
}
3 changes: 2 additions & 1 deletion lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
"welcomeBack": "Welcome back!",
"yourEmailAddress": "Your email address",
"yourFullName": "Your full name",
"yourPassword": "Your password"
"yourPassword": "Your password",
"gladToSeeYou": "Glad to see you again!\nAsk me anything."
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:admin_dashboard/features/dashboard/presentation/screens/dashboard_screen.dart';
import 'package:admin_dashboard/features/dashboard/presentation/widgets/header_cards_list.dart';
import 'package:admin_dashboard/features/dashboard/presentation/widgets/welcome_card.dart';
import 'package:flutter_test/flutter_test.dart';

import '../../../../app_pumper.dart';
Expand All @@ -9,5 +10,6 @@ void main() {
await widgetTester.pumpWidget(const AppPumper(child: DashboardScreen()));

expect(find.byType(HeaderCardsList), findsOneWidget);
expect(find.byType(WelcomeCard), findsOneWidget);
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import 'package:admin_dashboard/features/dashboard/presentation/widgets/welcome_card.dart';
import 'package:admin_dashboard/gen/assets.gen.dart';
import 'package:admin_dashboard/l10n/generated/app_localizations_en.dart';
import 'package:flutter_test/flutter_test.dart';

import '../../../../app_pumper.dart';

void main() {
group("Welcome card", () {
testWidgets(
"should show Welcome card with user name",
(widgetTester) async {
// Arrange
String name = 'example';

await widgetTester.pumpWidget(
AppPumper(
child: WelcomeCard(name: name),
),
);

expect(find.text(name), findsOneWidget);
},
);

testWidgets(
"should show greeting assets",
(widgetTester) async {
// Arrange
String welcomeBack = AppLocalizationsEn().welcomeBack;
String gladToSeeYou = AppLocalizationsEn().gladToSeeYou;
final image = Assets.images.welcomeBackground.provider();

await widgetTester.pumpWidget(
const AppPumper(
child: WelcomeCard(name: 'example'),
),
);

expect(find.text(welcomeBack), findsOneWidget);
expect(find.text(gladToSeeYou), findsOneWidget);
expect(find.image(image), findsOneWidget);
},
);
});
}

0 comments on commit 74131a1

Please sign in to comment.