Skip to content

Commit

Permalink
Feat: Implementing the Splash Screen (#41)
Browse files Browse the repository at this point in the history
* implementing the splash screen

* adding the test for the splash screen
  • Loading branch information
superiorsd10 authored Aug 31, 2023
1 parent a8e2c50 commit 4bb9ae3
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 31 deletions.
Binary file added assets/images/ic_launcher-playstore-nobg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions lib/app/modules/splashScreen/bindings/splash_screen_binding.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import 'package:get/get.dart';
import 'package:ultimate_alarm_clock/app/modules/splashScreen/controllers/splash_screen_controller.dart';

class SplashScreenBinding extends Bindings {
@override
void dependencies() {
Get.put<SplashScreenController>(
SplashScreenController()
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import 'package:get/get.dart';

class SplashScreenController extends GetxController {
@override
void onInit() {
Future.delayed(const Duration(seconds: 1), () {
Get.offNamed('/home');
});
super.onInit();
}
}
40 changes: 40 additions & 0 deletions lib/app/modules/splashScreen/views/splash_screen_view.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ultimate_alarm_clock/app/modules/splashScreen/controllers/splash_screen_controller.dart';
import 'package:ultimate_alarm_clock/app/utils/constants.dart';

class SplashScreenView extends GetView<SplashScreenController> {
const SplashScreenView({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
var width = Get.width;
return Scaffold(
body: SafeArea(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.fromLTRB(20, 10, 0, 10),
child: Image.asset(
'assets/images/ic_launcher-playstore-nobg.png',
fit: BoxFit.cover,
width: width / 2,
height: width / 2,
),
),
Text(
'Ultimate Alarm Clock',
style: Theme.of(context)
.textTheme
.displayMedium!
.copyWith(color: kprimaryColor),
),
],
),
),
),
);
}
}
9 changes: 8 additions & 1 deletion lib/app/routes/app_pages.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'package:get/get.dart';
import 'package:ultimate_alarm_clock/app/modules/splashScreen/bindings/splash_screen_binding.dart';
import 'package:ultimate_alarm_clock/app/modules/splashScreen/views/splash_screen_view.dart';

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

static const INITIAL = Routes.HOME;
static const INITIAL = Routes.SPLASH_SCREEN;

static final routes = [
GetPage(
name: _Paths.SPLASH_SCREEN,
page: () => SplashScreenView(),
binding: SplashScreenBinding(),
),
GetPage(
name: _Paths.HOME,
page: () => const HomeView(),
Expand Down
2 changes: 2 additions & 0 deletions lib/app/routes/app_routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ part of 'app_pages.dart';

abstract class Routes {
Routes._();
static const SPLASH_SCREEN = _Paths.SPLASH_SCREEN;
static const HOME = _Paths.HOME;
static const ADD_ALARM = _Paths.ADD_OR_UPDATE_ALARM;
static const ALARM_RING = _Paths.ALARM_RING;
Expand All @@ -13,6 +14,7 @@ abstract class Routes {

abstract class _Paths {
_Paths._();
static const SPLASH_SCREEN = '/splash-screen';
static const HOME = '/home';
static const ADD_OR_UPDATE_ALARM = '/add-update-alarm';
static const ALARM_RING = '/alarm-ring';
Expand Down
26 changes: 26 additions & 0 deletions test/splash_screen_view_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:get/get.dart';
import 'package:ultimate_alarm_clock/app/modules/splashScreen/controllers/splash_screen_controller.dart';
import 'package:ultimate_alarm_clock/app/modules/splashScreen/views/splash_screen_view.dart';

void main() {
setUpAll(() {
Get.put(SplashScreenController());
});

tearDownAll(() {
Get.reset();
});

testWidgets('SplashScreenView Test', (widgetTester) async {
await widgetTester.pumpWidget(
const GetMaterialApp(
home: SplashScreenView(),
),
);

expect(find.byType(Image), findsOneWidget);
expect(find.byType(Text), findsOneWidget);
});
}
30 changes: 0 additions & 30 deletions test/widget_test.dart

This file was deleted.

0 comments on commit 4bb9ae3

Please sign in to comment.