Skip to content

Commit

Permalink
Fixed bugs on transitions
Browse files Browse the repository at this point in the history
  • Loading branch information
Vustron committed Nov 18, 2023
1 parent c435a65 commit 43a3dd9
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 157 deletions.
56 changes: 8 additions & 48 deletions lib/auth/signin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ class _SignInState extends State<SignIn> {
children: [
ElevatedButton(
onPressed: () async {
if (_formkey.currentState!.validate()) {
if (_formkey.currentState != null &&
_formkey.currentState!.validate()) {
EasyLoading.show(status: 'Logging in...');
dynamic result = await _auth
.signInWithEmailAndPassword(email, password);
Expand All @@ -130,26 +131,8 @@ class _SignInState extends State<SignIn> {
print('signed in');
EasyLoading.showSuccess('SignIn Success!');
print(result.uid);
await Future.delayed(Duration(seconds: 2));
Navigator.pushReplacement(
context,
PageRouteBuilder(
pageBuilder: (_, __, ___) => Wrapper(
child: Loading(),
),
transitionsBuilder: (context, animation,
secondaryAnimation, child) {
const begin = Offset(0.0, -1.0);
const end = Offset.zero;
const curve = Curves.easeInOutQuart;
var tween = Tween(begin: begin, end: end)
.chain(CurveTween(curve: curve));
var offsetAnimation = animation.drive(tween);
return SlideTransition(
position: offsetAnimation, child: child);
},
),
);
await Future.delayed(Duration(seconds: 1));
Navigator.pushNamed(context, '/getdata');
}
}
},
Expand Down Expand Up @@ -234,35 +217,12 @@ class _SignInState extends State<SignIn> {
onPressed: () async {
try {
final provider = Provider.of<GoogleSignInProvider>(
context,
listen: false,
);
context,
listen: false);
EasyLoading.show(status: 'Loading...');
await provider.googleLogin();
EasyLoading.showSuccess('SignIn Success!');
await Future.delayed(Duration(seconds: 2));
Navigator.pushReplacement(
context,
PageRouteBuilder(
pageBuilder: (_, __, ___) => Wrapper(
child: Loading(),
),
transitionsBuilder: (context, animation,
secondaryAnimation, child) {
const begin = Offset(0.0, -1.0);
const end = Offset.zero;
const curve = Curves.easeInOutQuart;

var tween = Tween(begin: begin, end: end)
.chain(CurveTween(curve: curve));

var offsetAnimation = animation.drive(tween);

return SlideTransition(
position: offsetAnimation, child: child);
},
),
);
Navigator.pushNamed(context, '/getdata');
} catch (error) {
print('Error during Google login: $error');
EasyLoading.showError('Something went wrong');
Expand Down Expand Up @@ -290,7 +250,7 @@ class _SignInState extends State<SignIn> {
TextButton(
onPressed: () => {},
child: Text(
'Ver.2.3.1 \u00A9 Made by Vustron Vustronus 2023',
'Ver.2.3.2 \u00A9 Made by Vustron Vustronus 2023',
style: GoogleFonts.zenDots(
fontSize: 7.0,
fontWeight: FontWeight.bold,
Expand Down
2 changes: 1 addition & 1 deletion lib/auth/signup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class _SignUpState extends State<SignUp> {
TextButton(
onPressed: () => {},
child: Text(
'Ver.2.3.1 \u00A9 Made by Vustron Vustronus 2023',
'Ver.2.3.2 \u00A9 Made by Vustron Vustronus 2023',
style: GoogleFonts.zenDots(
fontSize: 7.0,
fontWeight: FontWeight.bold,
Expand Down
148 changes: 66 additions & 82 deletions lib/components/worldtimeContent.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class _WorldTimeContentState extends State<WorldTimeContent> {
email,
style: GoogleFonts.zenDots(
color: Colors.amberAccent,
letterSpacing: 1.0,
fontSize: 11.0,
fontWeight: FontWeight.bold,
),
Expand Down Expand Up @@ -214,7 +215,7 @@ class _WorldTimeContentState extends State<WorldTimeContent> {
TextButton(
onPressed: () => {},
child: Text(
'Ver.2.3.1 \u00A9 Made by Vustron Vustronus 2023',
'Ver.2.3.2 \u00A9 Made by Vustron Vustronus 2023',
style: GoogleFonts.zenDots(
fontSize: 7.0,
fontWeight: FontWeight.bold,
Expand All @@ -241,94 +242,77 @@ class _WorldTimeContentState extends State<WorldTimeContent> {
child: Column(
children: <Widget>[
Builder(
builder: (context) => Center(
child: InkWell(
onTap: () {
Scaffold.of(context).openDrawer();
},
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
CircleAvatar(
backgroundImage: user != null
? (photoUrl.startsWith('http') ||
photoUrl.startsWith('https'))
? NetworkImage(photoUrl)
: AssetImage(photoUrl)
as ImageProvider<Object>?
: AssetImage(photoUrl),
radius: 20.0,
),
SizedBox(
width: 8.0,
),
Text(
name,
style: GoogleFonts.zenDots(
color: widget.textColor,
fontSize: 12.0,
fontWeight: FontWeight.bold,
),
builder: (context) => InkWell(
onTap: () {
Scaffold.of(context).openDrawer();
},
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
CircleAvatar(
backgroundImage: user != null
? (photoUrl.startsWith('http') ||
photoUrl.startsWith('https'))
? NetworkImage(photoUrl)
: AssetImage(photoUrl)
as ImageProvider<Object>?
: AssetImage(photoUrl),
radius: 20.0,
),
SizedBox(
width: 8.0,
),
Text(
name,
style: GoogleFonts.zenDots(
color: widget.textColor,
fontSize: 12.0,
fontWeight: FontWeight.bold,
),
],
),
],
),
),
],
),
],
),
),
),
SizedBox(height: 10.0),
Center(
child: TextButton.icon(
onPressed: () async {
Future.delayed(Duration(seconds: 0), () async {
Navigator.pop(context);
Navigator.push(
context,
PageRouteBuilder(
pageBuilder:
(context, animation, secondaryAnimation) =>
ChangeLocation(),
transitionsBuilder: (context, animation,
secondaryAnimation, child) {
const begin = Offset(1.0, 0.0);
const end = Offset.zero;
const curve = Curves.easeInOut;

var tween = Tween(begin: begin, end: end)
.chain(CurveTween(curve: curve));

var offsetAnimation = animation.drive(tween);

return SlideTransition(
position: offsetAnimation,
child: child,
);
},
TextButton.icon(
onPressed: () async {
showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return Center(
child: SpinKitPouringHourGlass(
color: Colors.amber,
size: 100.0,
),
).then((result) {
if (result != null) {
setState(() {
widget.data = {
'time': result['time'],
'location': result['location'],
'flag': result['flag'],
'isDayTime': result['isDayTime'],
};
});
}
});
);
},
);
Future.delayed(Duration(seconds: 1), () async {
Navigator.pop(context);
dynamic result = await Navigator.pushReplacementNamed(
context, '/changelocation');
setState(() {
widget.data = {
'time': result['time'],
'location': result['location'],
'flag': result['flag'],
'isDayTime': result['isDayTime'],
};
});
},
icon: Icon(Icons.location_pin, color: widget.textColor),
label: Text('Change Location',
style: GoogleFonts.zenDots(
color: widget.textColor,
)),
),
});
},
icon: Icon(Icons.location_pin, color: widget.textColor),
label: Text('Change Location',
style: GoogleFonts.zenDots(
color: widget.textColor,
)),
),
SizedBox(height: 20.0),
Row(
Expand Down
4 changes: 2 additions & 2 deletions lib/controller/googleAuth.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables, library_private_types_in_public_api, camel_case_types, unused_import, avoid_unnecessary_containers, unused_field, unused_local_variable, avoid_print, empty_catches, file_names, use_build_context_synchronously, unnecessary_null_comparison
// ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables, library_private_types_in_public_api, camel_case_types, unused_import, avoid_unnecessary_containers, unused_field, unused_local_variable, avoid_print, empty_catches, file_names, use_build_context_synchronously, unnecessary_null_comparison, unrelated_type_equality_checks

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
Expand All @@ -11,7 +11,7 @@ class GoogleSignInProvider extends ChangeNotifier {

GoogleSignInAccount? get user => _user;

bool get isGoogleUser => _user != null;
bool get isGoogleUser => _user != false;

Future<void> googleLogin() async {
try {
Expand Down
Loading

0 comments on commit 43a3dd9

Please sign in to comment.