|
|
|
@ -10,21 +10,23 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
|
import 'package:justmusic/screens/add_friend_screen.dart';
|
|
|
|
|
import 'package:justmusic/screens/explanations_screen.dart';
|
|
|
|
|
import 'package:justmusic/screens/feed_screen.dart';
|
|
|
|
|
import 'package:justmusic/screens/loading_screen.dart';
|
|
|
|
|
import 'package:justmusic/screens/login_screen.dart';
|
|
|
|
|
import 'package:justmusic/screens/launching_rocker_screen.dart';
|
|
|
|
|
import 'package:justmusic/screens/post_screen.dart';
|
|
|
|
|
import 'package:justmusic/screens/profile_screen.dart';
|
|
|
|
|
import 'package:justmusic/screens/registration_screen.dart';
|
|
|
|
|
import 'package:justmusic/screens/welcome_screen.dart';
|
|
|
|
|
import 'package:justmusic/values/constants.dart';
|
|
|
|
|
import 'package:justmusic/view_model/CommentViewModel.dart';
|
|
|
|
|
import 'package:justmusic/view_model/MusicViewModel.dart';
|
|
|
|
|
import 'package:justmusic/view_model/PostViewModel.dart';
|
|
|
|
|
import 'package:justmusic/view_model/UserViewModel.dart';
|
|
|
|
|
import 'package:justmusic/model/User.dart' as userJustMusic;
|
|
|
|
|
import 'firebase_options.dart';
|
|
|
|
|
import 'package:timezone/data/latest.dart' as tz;
|
|
|
|
|
|
|
|
|
|
Future<void> main() async {
|
|
|
|
|
tz.initializeTimeZones();
|
|
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
|
await Firebase.initializeApp(
|
|
|
|
|
options: DefaultFirebaseOptions.currentPlatform,
|
|
|
|
@ -99,25 +101,21 @@ class _MyAppState extends State<MyApp> {
|
|
|
|
|
},
|
|
|
|
|
debugShowCheckedModeBanner: false,
|
|
|
|
|
theme: ThemeData(
|
|
|
|
|
// This is the theme of your application.
|
|
|
|
|
//
|
|
|
|
|
// Try running your application with "flutter run". You'll see the
|
|
|
|
|
// application has a blue toolbar. Then, without quitting the app, try
|
|
|
|
|
// changing the primarySwatch below to Colors.green and then invoke
|
|
|
|
|
// "hot reload" (press "r" in the console where you ran "flutter run",
|
|
|
|
|
// or simply save your changes to "hot reload" in a Flutter IDE).
|
|
|
|
|
// Notice that the counter didn't reset back to zero; the application
|
|
|
|
|
// is not restarted.
|
|
|
|
|
primarySwatch: Colors.blue,
|
|
|
|
|
),
|
|
|
|
|
home: FirebaseAuth.instance.currentUser != null
|
|
|
|
|
? StreamBuilder<userJustMusic.User?>(
|
|
|
|
|
stream: userCurrent,
|
|
|
|
|
initialData: null,
|
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
|
if (snapshot.hasData) {
|
|
|
|
|
print("hasdata");
|
|
|
|
|
|
|
|
|
|
home: StreamBuilder<User?>(
|
|
|
|
|
stream: FirebaseAuth.instance.authStateChanges(),
|
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
|
|
|
|
return LoadingScreen();
|
|
|
|
|
} else if (snapshot.hasData) {
|
|
|
|
|
return FutureBuilder<userJustMusic.User?>(
|
|
|
|
|
future: MyApp.userViewModel.getUser(snapshot.data!.uid),
|
|
|
|
|
builder: (context, userSnapshot) {
|
|
|
|
|
if (userSnapshot.connectionState == ConnectionState.waiting) {
|
|
|
|
|
return LoadingScreen();
|
|
|
|
|
} else if (userSnapshot.hasData) {
|
|
|
|
|
MyApp.userViewModel.userCurrent = userSnapshot.data!;
|
|
|
|
|
return AnimatedSwitcher(
|
|
|
|
|
duration: Duration(milliseconds: 1000),
|
|
|
|
|
transitionBuilder: (child, animation) {
|
|
|
|
@ -126,18 +124,15 @@ class _MyAppState extends State<MyApp> {
|
|
|
|
|
child: FeedScreen(),
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
return Scaffold(
|
|
|
|
|
backgroundColor: bgColor,
|
|
|
|
|
body: Center(
|
|
|
|
|
child: Image(
|
|
|
|
|
image: AssetImage("assets/images/logo.png"),
|
|
|
|
|
width: 130,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
return WellcomeScreen();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
: WellcomeScreen());
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
return WellcomeScreen();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
));
|
|
|
|
|
},
|
|
|
|
|
designSize: Size(390, 844),
|
|
|
|
|
);
|
|
|
|
|