Skip to content

Commit 4bb9ae3

Browse files
authored
Feat: Implementing the Splash Screen (CCExtractor#41)
* implementing the splash screen * adding the test for the splash screen
1 parent a8e2c50 commit 4bb9ae3

9 files changed

+98
-31
lines changed
98.8 KB
Loading
72.9 KB
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import 'package:get/get.dart';
2+
import 'package:ultimate_alarm_clock/app/modules/splashScreen/controllers/splash_screen_controller.dart';
3+
4+
class SplashScreenBinding extends Bindings {
5+
@override
6+
void dependencies() {
7+
Get.put<SplashScreenController>(
8+
SplashScreenController()
9+
);
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import 'package:get/get.dart';
2+
3+
class SplashScreenController extends GetxController {
4+
@override
5+
void onInit() {
6+
Future.delayed(const Duration(seconds: 1), () {
7+
Get.offNamed('/home');
8+
});
9+
super.onInit();
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:get/get.dart';
3+
import 'package:ultimate_alarm_clock/app/modules/splashScreen/controllers/splash_screen_controller.dart';
4+
import 'package:ultimate_alarm_clock/app/utils/constants.dart';
5+
6+
class SplashScreenView extends GetView<SplashScreenController> {
7+
const SplashScreenView({Key? key}) : super(key: key);
8+
9+
@override
10+
Widget build(BuildContext context) {
11+
var width = Get.width;
12+
return Scaffold(
13+
body: SafeArea(
14+
child: Center(
15+
child: Column(
16+
mainAxisAlignment: MainAxisAlignment.center,
17+
children: [
18+
Padding(
19+
padding: const EdgeInsets.fromLTRB(20, 10, 0, 10),
20+
child: Image.asset(
21+
'assets/images/ic_launcher-playstore-nobg.png',
22+
fit: BoxFit.cover,
23+
width: width / 2,
24+
height: width / 2,
25+
),
26+
),
27+
Text(
28+
'Ultimate Alarm Clock',
29+
style: Theme.of(context)
30+
.textTheme
31+
.displayMedium!
32+
.copyWith(color: kprimaryColor),
33+
),
34+
],
35+
),
36+
),
37+
),
38+
);
39+
}
40+
}

lib/app/routes/app_pages.dart

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import 'package:get/get.dart';
2+
import 'package:ultimate_alarm_clock/app/modules/splashScreen/bindings/splash_screen_binding.dart';
3+
import 'package:ultimate_alarm_clock/app/modules/splashScreen/views/splash_screen_view.dart';
24

35
import '../modules/addOrUpdateAlarm/bindings/add_or_update_alarm_binding.dart';
46
import '../modules/addOrUpdateAlarm/views/add_or_update_alarm_view.dart';
@@ -18,9 +20,14 @@ part 'app_routes.dart';
1820
class AppPages {
1921
AppPages._();
2022

21-
static const INITIAL = Routes.HOME;
23+
static const INITIAL = Routes.SPLASH_SCREEN;
2224

2325
static final routes = [
26+
GetPage(
27+
name: _Paths.SPLASH_SCREEN,
28+
page: () => SplashScreenView(),
29+
binding: SplashScreenBinding(),
30+
),
2431
GetPage(
2532
name: _Paths.HOME,
2633
page: () => const HomeView(),

lib/app/routes/app_routes.dart

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ part of 'app_pages.dart';
33

44
abstract class Routes {
55
Routes._();
6+
static const SPLASH_SCREEN = _Paths.SPLASH_SCREEN;
67
static const HOME = _Paths.HOME;
78
static const ADD_ALARM = _Paths.ADD_OR_UPDATE_ALARM;
89
static const ALARM_RING = _Paths.ALARM_RING;
@@ -13,6 +14,7 @@ abstract class Routes {
1314

1415
abstract class _Paths {
1516
_Paths._();
17+
static const SPLASH_SCREEN = '/splash-screen';
1618
static const HOME = '/home';
1719
static const ADD_OR_UPDATE_ALARM = '/add-update-alarm';
1820
static const ALARM_RING = '/alarm-ring';

test/splash_screen_view_test.dart

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_test/flutter_test.dart';
3+
import 'package:get/get.dart';
4+
import 'package:ultimate_alarm_clock/app/modules/splashScreen/controllers/splash_screen_controller.dart';
5+
import 'package:ultimate_alarm_clock/app/modules/splashScreen/views/splash_screen_view.dart';
6+
7+
void main() {
8+
setUpAll(() {
9+
Get.put(SplashScreenController());
10+
});
11+
12+
tearDownAll(() {
13+
Get.reset();
14+
});
15+
16+
testWidgets('SplashScreenView Test', (widgetTester) async {
17+
await widgetTester.pumpWidget(
18+
const GetMaterialApp(
19+
home: SplashScreenView(),
20+
),
21+
);
22+
23+
expect(find.byType(Image), findsOneWidget);
24+
expect(find.byType(Text), findsOneWidget);
25+
});
26+
}

test/widget_test.dart

-30
This file was deleted.

0 commit comments

Comments
 (0)