Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnab771 committed Apr 24, 2020
2 parents 20603be + 15dde06 commit 73a28cd
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 45 deletions.
Binary file modified assets/appdrawer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/loginscreen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions lib/auth/login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@ class AuthProvider {
final uid = user.uid;
return uid;
}

Future getCurrentUser() async {
return await _auth.currentUser();
}
}
1 change: 0 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class Jiyu extends StatelessWidget {
title: "Jiyu",
theme: ThemeData(
primarySwatch: Colors.blue,
backgroundColor: this.backgroundColor,
brightness: Brightness.dark,
canvasColor: this.backgroundColor,
textSelectionColor: Colors.blueAccent,
Expand Down
102 changes: 67 additions & 35 deletions lib/ui/AppDrawer.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import 'package:flutter/material.dart';
import 'package:jiyu/auth/login.dart';
import 'package:jiyu/backup/download.dart';
import 'package:jiyu/sqlite-database/completed.dart';
import 'package:jiyu/sqlite-database/dropped.dart';
import 'package:jiyu/sqlite-database/watching.dart';
import 'package:jiyu/ui/CompletedPage.dart';
import 'package:jiyu/ui/DroppedPage.dart';
import 'package:jiyu/ui/PlantoWatchPage.dart';
Expand All @@ -14,48 +17,77 @@ class AppDrawer extends StatelessWidget {
AppDrawer(this._routeToWatching, this._routeToCompleted, this._routeToDropped,
this._routeToPlanned);

Future<String> totalWatchTime() async {
String _totalWatchTimeHour;
int _totalWatchTimeMin = 0;
List<Watching> watching = await getWatching();
for (Watching item in watching) {
_totalWatchTimeMin += item.watched_episodes * 24;
}

List<Completed> completed = await getCompleted();
for (Completed item in completed) {
_totalWatchTimeMin += item.total_episodes * 24;
}

List<Dropped> dropped = await getDropped();
for (Dropped item in dropped) {
_totalWatchTimeMin += item.watched_episodes * 24;
}
_totalWatchTimeHour = ((_totalWatchTimeMin / 60) / 24).toStringAsFixed(2);

return _totalWatchTimeHour;
}

Widget watchTimeDisplay() {
return FutureBuilder(
future: totalWatchTime(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
return Text(
"Watch time: ${snapshot.data} days",
style: TextStyle(fontWeight: FontWeight.bold),
);
}
},
);
}

@override
Widget build(BuildContext context) {
return Drawer(
child: ListView(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(15.0),
child: Column(
children: <Widget>[
Image.asset(
"assets/icon.png",
width: 150.0,
),
Text(
"Jiyu",
style: TextStyle(
fontSize: 30.0,
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.center,
),
Text(
"Made by Arnab",
style: TextStyle(
fontSize: 15.0,
fontStyle: FontStyle.italic,
),
textAlign: TextAlign.center,
),
SelectableText(
"(https://github.com/Arnab771)",
style: TextStyle(
fontSize: 15.0,
fontStyle: FontStyle.italic,
),
textAlign: TextAlign.center,
)
],
),
Column(
children: <Widget>[
FutureBuilder(
future: AuthProvider().getCurrentUser(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
return UserAccountsDrawerHeader(
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(14.0),
bottomRight: Radius.circular(14.0),
),
gradient: LinearGradient(
colors: [Colors.blueAccent, Colors.blue[700]])),
accountName: Text(snapshot.data.displayName),
accountEmail: watchTimeDisplay(),
currentAccountPicture: ClipRRect(
borderRadius: BorderRadius.circular(20.0),
child: Image.network(snapshot.data.photoUrl),
),
);
}
if (snapshot.connectionState == ConnectionState.waiting) {
return CircularProgressIndicator();
}
}),
],
),
Container(
color: this._routeToWatching == false ? Colors.black38 : null,
color: this._routeToWatching == false ? Colors.black12 : null,
child: ListTile(
leading: Icon(Icons.arrow_upward),
title: Text("Watching"),
Expand Down
5 changes: 3 additions & 2 deletions lib/ui/CompletedPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ class _CompletedPageState extends State<CompletedPage> {
data[index].name,
style: TextStyle(fontWeight: FontWeight.bold),
),
subtitle:
Text(data[index].total_episodes.toString()),
subtitle: (data[index].total_episodes == 0)
? Text("?")
: Text(data[index].total_episodes.toString()),
isThreeLine: false,
onLongPress: () {
showDialog(
Expand Down
6 changes: 4 additions & 2 deletions lib/ui/DroppedPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ class _DroppedPageState extends State<DroppedPage> {
data[index].name,
style: TextStyle(fontWeight: FontWeight.bold),
),
subtitle: Text(
data[index].watched_episodes.toString() +
subtitle: (data[index].total_episodes == 0)
? Text(data[index].watched_episodes.toString() +
"/?")
: Text(data[index].watched_episodes.toString() +
"/" +
data[index].total_episodes.toString()),
isThreeLine: false,
Expand Down
19 changes: 19 additions & 0 deletions lib/ui/LoginPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,25 @@ class _LoginPageState extends State<LoginPage> {
),
textAlign: TextAlign.center,
),
Text(
"Made by Arnab",
style: TextStyle(
fontSize: 15.0,
fontStyle: FontStyle.italic,
),
textAlign: TextAlign.center,
),
Padding(
padding: const EdgeInsets.only(bottom: 10.0),
child: SelectableText(
"(https://github.com/Arnab771)",
style: TextStyle(
fontSize: 15.0,
fontStyle: FontStyle.italic,
),
textAlign: TextAlign.center,
),
),
MaterialButton(
onPressed: () async {
bool res = await AuthProvider().signInWithGoogle();
Expand Down
5 changes: 3 additions & 2 deletions lib/ui/PlantoWatchPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ class _PlantoWatchPageState extends State<PlantoWatchPage> {
data[index].name,
style: TextStyle(fontWeight: FontWeight.bold),
),
subtitle:
Text(data[index].total_episodes.toString()),
subtitle: (data[index].total_episodes == 0)
? Text("?")
: Text(data[index].total_episodes.toString()),
isThreeLine: false,
onLongPress: () {
showDialog(
Expand Down
9 changes: 7 additions & 2 deletions lib/ui/WatchingPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,13 @@ class _WatchingPageState extends State<WatchingPage> {
),
),
),
subtitle: Text(
data[index].watched_episodes.toString() +
subtitle: (data[index].total_episodes == 0)
? Text(
data[index].watched_episodes.toString() +
"/?")
: Text(data[index]
.watched_episodes
.toString() +
"/" +
data[index].total_episodes.toString()),
isThreeLine: false,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: jiyu
description: An anime tracker for anime fans to manage the anime they watch.

version: 1.4.2+12
version: 1.4.3+1
environment:
sdk: ">=2.1.0 <3.0.0"

Expand Down

0 comments on commit 73a28cd

Please sign in to comment.