Accept review comments
This commit is contained in:
parent
e55b440ac8
commit
e30f038395
4 changed files with 44 additions and 45 deletions
|
@ -52,24 +52,33 @@ class Session {
|
|||
final String token;
|
||||
final int creationTime;
|
||||
final String ip;
|
||||
final String userAgent;
|
||||
final String ua;
|
||||
final String prettyUA;
|
||||
final int lastUsedTime;
|
||||
|
||||
Session(this.token, this.creationTime, this.ip, this.userAgent,
|
||||
this.lastUsedTime);
|
||||
Session(
|
||||
this.token,
|
||||
this.creationTime,
|
||||
this.ip,
|
||||
this.ua,
|
||||
this.prettyUA,
|
||||
this.lastUsedTime,
|
||||
);
|
||||
|
||||
Session copyWith({
|
||||
String token,
|
||||
int creationTime,
|
||||
String ip,
|
||||
String userAgent,
|
||||
String ua,
|
||||
String prettyUA,
|
||||
int lastUsedTime,
|
||||
}) {
|
||||
return Session(
|
||||
token ?? this.token,
|
||||
creationTime ?? this.creationTime,
|
||||
ip ?? this.ip,
|
||||
userAgent ?? this.userAgent,
|
||||
ua ?? this.ua,
|
||||
prettyUA ?? this.prettyUA,
|
||||
lastUsedTime ?? this.lastUsedTime,
|
||||
);
|
||||
}
|
||||
|
@ -79,7 +88,8 @@ class Session {
|
|||
'token': token,
|
||||
'creationTime': creationTime,
|
||||
'ip': ip,
|
||||
'userAgent': userAgent,
|
||||
'ua': ua,
|
||||
'prettyUA': prettyUA,
|
||||
'lastUsedTime': lastUsedTime,
|
||||
};
|
||||
}
|
||||
|
@ -89,7 +99,8 @@ class Session {
|
|||
map['token'],
|
||||
map['creationTime'],
|
||||
map['ip'],
|
||||
map['userAgent'],
|
||||
map['ua'],
|
||||
map['prettyUA'],
|
||||
map['lastUsedTime'],
|
||||
);
|
||||
}
|
||||
|
@ -101,7 +112,7 @@ class Session {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Session(token: $token, creationTime: $creationTime, ip: $ip, userAgent: $userAgent, lastUsedTime: $lastUsedTime)';
|
||||
return 'Session(token: $token, creationTime: $creationTime, ip: $ip, ua: $ua, prettyUA: $prettyUA, lastUsedTime: $lastUsedTime)';
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -112,7 +123,8 @@ class Session {
|
|||
other.token == token &&
|
||||
other.creationTime == creationTime &&
|
||||
other.ip == ip &&
|
||||
other.userAgent == userAgent &&
|
||||
other.ua == ua &&
|
||||
other.prettyUA == prettyUA &&
|
||||
other.lastUsedTime == lastUsedTime;
|
||||
}
|
||||
|
||||
|
@ -121,7 +133,8 @@ class Session {
|
|||
return token.hashCode ^
|
||||
creationTime.hashCode ^
|
||||
ip.hashCode ^
|
||||
userAgent.hashCode ^
|
||||
ua.hashCode ^
|
||||
prettyUA.hashCode ^
|
||||
lastUsedTime.hashCode;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:photos/core/configuration.dart';
|
||||
import 'package:photos/models/sessions.dart';
|
||||
import 'package:photos/services/user_service.dart';
|
||||
import 'package:photos/ui/loading_widget.dart';
|
||||
import 'package:photos/utils/date_time_util.dart';
|
||||
import 'package:photos/utils/dialog_util.dart';
|
||||
import 'package:user_agent_parser/user_agent_parser.dart';
|
||||
|
||||
class SessionsPage extends StatefulWidget {
|
||||
SessionsPage({Key key}) : super(key: key);
|
||||
|
@ -17,7 +15,6 @@ class SessionsPage extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _SessionsPageState extends State<SessionsPage> {
|
||||
final _userAgentParser = UserAgentParser();
|
||||
Sessions _sessions;
|
||||
|
||||
@override
|
||||
|
@ -44,7 +41,11 @@ class _SessionsPageState extends State<SessionsPage> {
|
|||
for (final session in _sessions.sessions) {
|
||||
rows.add(_getSessionWidget(session));
|
||||
}
|
||||
return Column(children: rows);
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
children: rows,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _getSessionWidget(Session session) {
|
||||
|
@ -58,23 +59,30 @@ class _SessionsPageState extends State<SessionsPage> {
|
|||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
_getUAWidget(session),
|
||||
Padding(padding: EdgeInsets.all(4)),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
_getUAWidget(session),
|
||||
Padding(padding: EdgeInsets.all(4)),
|
||||
Text(
|
||||
session.ip,
|
||||
style: TextStyle(
|
||||
color: Colors.white.withOpacity(0.8),
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
getFormattedTime(lastUsedTime),
|
||||
style: TextStyle(
|
||||
color: Colors.white.withOpacity(0.8),
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Text(getFormattedTime(lastUsedTime)),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -117,7 +125,7 @@ class _SessionsPageState extends State<SessionsPage> {
|
|||
),
|
||||
Padding(padding: EdgeInsets.all(8)),
|
||||
Text(
|
||||
session.userAgent,
|
||||
session.ua,
|
||||
style: TextStyle(
|
||||
color: Colors.white.withOpacity(0.7),
|
||||
fontSize: 14,
|
||||
|
@ -181,20 +189,6 @@ class _SessionsPageState extends State<SessionsPage> {
|
|||
),
|
||||
);
|
||||
}
|
||||
if (session.userAgent.contains("ente")) {
|
||||
return Text("Desktop");
|
||||
}
|
||||
final parsedUA = _userAgentParser.parseResult(session.userAgent);
|
||||
if (parsedUA.browser == null) {
|
||||
if (session.userAgent.contains("Android")) {
|
||||
return Text("Android");
|
||||
}
|
||||
if (session.userAgent.contains("iPhone")) {
|
||||
return Text("iPhone");
|
||||
}
|
||||
return Text("Mobile");
|
||||
} else {
|
||||
return Text("Browser (" + parsedUA.browser.name + ")");
|
||||
}
|
||||
return Text(session.prettyUA);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1189,13 +1189,6 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
user_agent_parser:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: user_agent_parser
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.0.1+2"
|
||||
uuid:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
|
@ -97,7 +97,6 @@ dependencies:
|
|||
syncfusion_flutter_sliders: ^19.2.49
|
||||
uni_links: ^0.5.1
|
||||
url_launcher: ^6.0.3
|
||||
user_agent_parser: ^0.0.1+2
|
||||
uuid: ^3.0.4
|
||||
video_player:
|
||||
path: thirdparty/plugins/packages/video_player/video_player
|
||||
|
|
Loading…
Add table
Reference in a new issue