Skip to content

Commit

Permalink
[Riverpod2x][PicoGram] Finish the PicoGram tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
Arti-Sadra committed Feb 2, 2023
1 parent f80c688 commit 87cb3ab
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 49 deletions.
57 changes: 11 additions & 46 deletions Riverpod/Vandad/Riverpod2.x/picogram/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import 'dart:developer' show log;

import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:firebase_core/firebase_core.dart';

import 'firebase_options.dart';
import 'state/auth/providers/providers.dart';
import 'views/components/animations/animations.dart';
import 'views/components/components.dart';
import 'views/login/login.dart';

extension Log on Object {
void log([String? message]) {
debugPrint('$runtimeType: $message - ${toString()}');
}
}
import 'lib.dart'
show
LoadingScreen,
LoginView,
MainView,
isLoadingProvider,
isLoggedInProvider;

Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
Expand All @@ -38,6 +37,7 @@ class MyApp extends StatelessWidget {
home: Consumer(
builder: (BuildContext context, WidgetRef ref, Widget? child) {
ref.listen<bool>(isLoadingProvider, (_, isLoading) {
log(isLoading.toString(), name: 'isLoading');
if (isLoading) {
LoadingScreen.instance().show(context: context);
} else {
Expand All @@ -52,38 +52,3 @@ class MyApp extends StatelessWidget {
);
}
}

class MainView extends ConsumerWidget {
const MainView({
Key? key,
}) : super(key: key);

@override
Widget build(BuildContext context, WidgetRef ref) {
return Scaffold(
appBar: AppBar(
title: const Text('PicoGram'),
actions: [
IconButton(
icon: const Icon(Icons.logout),
onPressed: () {
ref.read(authStateProvider.notifier).logout();
},
),
],
),
body: SingleChildScrollView(
child: Column(
children: const [
DataNotFoundAnimationView(),
EmptyContentsAnimationView(),
EmptyContentsWithTextAnimationView(text: 'text'),
ErrorAnimationView(),
SmallErrorAnimationView(),
LoadingAnimationView(),
],
),
),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ class _MainViewState extends ConsumerState<MainView> {
body: const TabBarView(
children: [
UserPostsView(),
UserPostsView(),
UserPostsView(),
SearchView(),
HomeView(),
],
),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export 'users_posts/users_posts.dart';
export 'search/search.dart';
export 'search/search.dart';
export 'home/home.dart';

0 comments on commit 87cb3ab

Please sign in to comment.