Skip to content

Commit

Permalink
(version/ehlogin) Update version
Browse files Browse the repository at this point in the history
  • Loading branch information
violet-dev committed Jul 18, 2020
1 parent 8165c97 commit d0c6950
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 5 deletions.
Empty file added lib/network/cookies.dart
Empty file.
Empty file.
75 changes: 75 additions & 0 deletions lib/pages/settings/login/ehentai_login.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Source code from
// https://github.com/tommy351/eh-redux/blob/master/lib/screens/login/screen.dart
// https://github.com/tommy351/eh-redux/blob/master/lib/utils/cookie.dart

import 'dart:async';
import 'dart:convert';
import 'dart:collection';
import 'dart:developer' as developer;

import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';

Map<String, String> parseCookies(String cookies) {
final result = HashMap<String, String>();

for (final cookie in cookies.split(';')) {
final index = cookie.indexOf('=');

if (index > -1) {
final key = cookie.substring(0, index).trim();
final value = cookie.substring(index + 1).trim();
result[key] = value;
}
}

return result;
}

// Input id-pwd login?
// Or cookie?

class LoginScreen extends StatefulWidget {
@override
_LoginScreenState createState() => _LoginScreenState();
}

class _LoginScreenState extends State<LoginScreen> {
static const _loginUrl = 'https://e-hentai.org/bounce_login.php';

final _webViewController = Completer<WebViewController>();

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Login"),
),
body: WebView(
initialUrl: _loginUrl,
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (controller) {
_webViewController.complete(controller);
},
onPageFinished: (url) {
_checkCookie();
},
),
);
}

Future<void> _checkCookie() async {
final controller = await _webViewController.future;
final cookieString =
jsonDecode(await controller.evaluateJavascript('document.cookie'))
as String;
final cookies = parseCookies(cookieString);
developer.log('Get cookies: $cookies');

if (cookies.containsKey('ipb_member_id')) {
// await sessionStore.setSession(cookieString);
// await _cookieManager.clearCookies();
Navigator.pop(context);
}
}
}
2 changes: 1 addition & 1 deletion lib/pages/settings/version_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class VersionViewPage extends StatelessWidget {
style: TextStyle(fontSize: 30),
),
Text(
'0.7.5',
'0.7.6',
style: TextStyle(fontSize: 20),
),
Text(''),
Expand Down
7 changes: 5 additions & 2 deletions lib/pages/viewer/vertical_viewer_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class ViewerWidget extends StatelessWidget {

@override
Widget build(BuildContext context) {
final height = MediaQuery.of(context).size.height;
if (once == false) {
once = true;
User.getInstance().then((value) => value.getUserLog().then((value) async {
Expand All @@ -125,7 +126,8 @@ class ViewerWidget extends StatelessWidget {
}
}));
}
return Container(
return PhotoView.customChild(
child: Container(
color: const Color(0xff444444),
// child: Scrollbar(
// controller: scroll,
Expand Down Expand Up @@ -169,6 +171,7 @@ class ViewerWidget extends StatelessWidget {
child: ListView.builder(
itemCount: urls.length,
controller: scroll,
cacheExtent: height * 4,
itemBuilder: (context, index) {
return Container(
padding: EdgeInsets.all(2),
Expand Down Expand Up @@ -211,7 +214,7 @@ class ViewerWidget extends StatelessWidget {
]);
},
),
);
));
}

String latestLabel = '';
Expand Down
2 changes: 1 addition & 1 deletion lib/update_sync.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class UpdateSyncManager {
// Current version
static const int majorVersion = 0;
static const int minorVersion = 7;
static const int patchVersion = 5;
static const int patchVersion = 6;

static bool updateRequire = false;
static String version = "";
Expand Down
7 changes: 7 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
webview_flutter:
dependency: "direct main"
description:
name: webview_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.22+1"
xml:
dependency: transitive
description:
Expand Down
3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ description: A new Flutter project.
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 0.7.5+0
version: 0.7.6+0

environment:
sdk: ">=2.2.0 <3.0.0"
Expand Down Expand Up @@ -79,6 +79,7 @@ dependencies:
url_launcher:
uuid:
vibration: ^1.4.0
webview_flutter:
# archive:
# english_words:
# extended_image:
Expand Down

0 comments on commit d0c6950

Please sign in to comment.