Skip to content

Commit

Permalink
change effect
Browse files Browse the repository at this point in the history
  • Loading branch information
MH0386 committed Jul 15, 2024
1 parent cfb050b commit 704cfef
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 16 deletions.
37 changes: 21 additions & 16 deletions lib/Pages/home.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:mh0386/Pages/resume.dart';
import 'package:mh0386/controller.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:google_fonts/google_fonts.dart';
Expand All @@ -10,6 +11,7 @@ class Home extends StatelessWidget {

@override
Widget build(BuildContext context) {
final textController = Get.put(TextController());
return MaterialApp(
title: 'Mohamed Hisham Abdelzaher',
debugShowCheckedModeBanner: false,
Expand Down Expand Up @@ -198,22 +200,25 @@ class Home extends StatelessWidget {
),
),
),
Animate(
effects: const [
FadeEffect(
delay: Duration(seconds: 1),
duration: Duration(seconds: 5),
),
],
child: Text(
'I am an Undergraduate Student',
style: TextStyle(
color: Colors.white,
fontSize: (MediaQuery.of(context).size.width * 0.04 <
MediaQuery.of(context).size.height * 0.04)
? MediaQuery.of(context).size.width * 0.04
: MediaQuery.of(context).size.height * 0.04,
fontFamily: GoogleFonts.jetBrainsMono().fontFamily,
Obx(
() => Animate(
effects: const [
FadeEffect(
delay: Duration(seconds: 1),
duration: Duration(seconds: 3),
),
],
child: Text(
textController.texts[textController.currentIndex.value],
key: ValueKey<int>(textController.currentIndex.value),
style: TextStyle(
color: Colors.white,
fontSize: (MediaQuery.of(context).size.width * 0.04 <
MediaQuery.of(context).size.height * 0.04)
? MediaQuery.of(context).size.width * 0.04
: MediaQuery.of(context).size.height * 0.04,
fontFamily: GoogleFonts.jetBrainsMono().fontFamily,
),
),
),
),
Expand Down
26 changes: 26 additions & 0 deletions lib/controller.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import 'package:get/get.dart';
import 'dart:async';

class TextController extends GetxController {
var currentIndex = 0.obs;
List<String> texts = [
"Welcome to My Portfolio",
"I am an Undergraduate Student",
"I love coding",
];

@override
void onInit() {
super.onInit();
Timer.periodic(
const Duration(seconds: 5),
(timer) {
if (currentIndex.value < texts.length - 1) {
currentIndex.value++;
} else {
currentIndex.value = 0;
}
},
);
}
}

0 comments on commit 704cfef

Please sign in to comment.