This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
import 'dart:developer'; | |
import 'dart:io'; | |
import 'package:flutter/cupertino.dart'; | |
import 'package:gp_flutter_core/config/service/gql_config.dart'; | |
import 'package:graphql_flutter/graphql_flutter.dart'; | |
/// The service responsible for networking requests | |
class GpGQLClient { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Define top level functions at any suitable location "I did in a separate dart file" | |
Timer sessionTimer; | |
/// intialize a timer to trigger a function after a period of inactiveness | |
void initializeTimer() { | |
sessionTimer = | |
Timer.periodic(const Duration(minutes: 5), (_) => UserUtil.logOut()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TextPage extends StatelessWidget { | |
final String endpoint; | |
final String selectedSubject; | |
final String searchQuery; | |
TextPage( | |
{Key key, | |
@required this.endpoint, | |
@required this.selectedSubject, | |
@required this.searchQuery}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'dart:ui' as UI; | |
class MovieDetail extends StatelessWidget{ | |
final movie; | |
var image_url = 'https://image.tmdb.org/t/p/w500/'; | |
MovieDetail(this.movie); | |
Color mainColor = const Color(0xff3C3261); | |
@override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Advised to set the root tag of your layout to the coordinate layout and give it a id | |
// So i will just comment the layout file code | |
/* | |
<?xml version="1.0" encoding="utf-8"?> | |
<android.support.design.widget.CoordinatorLayout | |
android:id="@+id/cl_forSnackBar" | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// since I can connect from multiple devices, we store each connection instance separately | |
// any time that connectionsRef's value is null (i.e. has no children) I am offline | |
final FirebaseDatabase database = FirebaseDatabase.getInstance(); | |
final DatabaseReference myConnectionsRef = database.getReference("users/joe/connections"); | |
// stores the timestamp of my last disconnect (the last time I was seen online) | |
final DatabaseReference lastOnlineRef = database.getReference("/users/joe/lastOnline"); | |
final DatabaseReference connectedRef = database.getReference(".info/connected"); | |
connectedRef.addValueEventListener(new ValueEventListener() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DatabaseReferene connectRef = FirebaseDatabase.getInstance().getReference(".info/connected"); | |
connectRef.addValueEventListener(new ValueEventListener() { | |
@override | |
public void onDataCHanged(DataSnapshot dataSnapshot){ | |
boolean isConnected = dataSnapshot.getValue(Boolean.class); | |
if(connected){ | |
System.out.println("Your are now connected"); | |
}else{ | |
System.out.println("Your are disconnected"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Please feel free to check the firbase real time databse documentation */ | |
public class NewPost(String userId, String username, String title, String body){ | |
// Get[key] used to store the post at the node ["posts"] | |
// [push] create the post at node["posts"] | |
String key = mDatabase.child("posts").push.getKey(); | |
Post post = new Post(userId, username, title, body); | |
//[Map] is a key value object in java | |
// follow the link here: [https://goo.gl/e2XHLa] you should see the code where the method[toMap] is declared. | |
Map<String, Object> postValues = post.toMap(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class User(){ | |
public String username; | |
public String email; | |
public void User(){ | |
} | |
public void User(String username, String email){ | |
this.username = username; | |
this.email = email; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FirebaseAuth authUser = FirebaseAuth.getInstance(); | |
authUser.signInWithEmailAndPassword(userEmail, userPassword).addOnCompleteListener(new OnCompleteListener() { | |
@Override | |
public void onComplete(Task task) { | |
if (task.isSuccessful()) { | |
FirebaseUser user = task.getResult().getUser(); | |
String userEmail = user.getEmail(); | |
} | |
} | |
}); |
NewerOlder