Merge branch 'master' of github.com:open-trade/flutter_hbb into service
This commit is contained in:
commit
0ae338524c
@ -43,7 +43,28 @@ final ButtonStyle flatButtonStyle = TextButton.styleFrom(
|
|||||||
void showLoading(String text) {
|
void showLoading(String text) {
|
||||||
DialogManager.reset();
|
DialogManager.reset();
|
||||||
EasyLoading.dismiss();
|
EasyLoading.dismiss();
|
||||||
EasyLoading.show(status: text, maskType: EasyLoadingMaskType.black);
|
EasyLoading.show(
|
||||||
|
indicator: Container(
|
||||||
|
constraints: BoxConstraints(maxWidth: 240),
|
||||||
|
child:
|
||||||
|
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||||
|
Center(child: CircularProgressIndicator()),
|
||||||
|
SizedBox(height: 20),
|
||||||
|
Center(
|
||||||
|
child: Text(Translator.call(text),
|
||||||
|
style: TextStyle(fontSize: 15))),
|
||||||
|
SizedBox(height: 20),
|
||||||
|
Center(
|
||||||
|
child: TextButton(
|
||||||
|
style: flatButtonStyle,
|
||||||
|
onPressed: () {
|
||||||
|
EasyLoading.dismiss();
|
||||||
|
backToHome();
|
||||||
|
},
|
||||||
|
child: Text(Translator.call('Cancel'),
|
||||||
|
style: TextStyle(color: MyTheme.accent))))
|
||||||
|
])),
|
||||||
|
maskType: EasyLoadingMaskType.black);
|
||||||
}
|
}
|
||||||
|
|
||||||
backToHome() {
|
backToHome() {
|
||||||
|
@ -8,6 +8,7 @@ import 'common.dart';
|
|||||||
import 'models/model.dart';
|
import 'models/model.dart';
|
||||||
import 'pages/home_page.dart';
|
import 'pages/home_page.dart';
|
||||||
import 'pages/server_page.dart';
|
import 'pages/server_page.dart';
|
||||||
|
import 'pages/settings_page.dart';
|
||||||
|
|
||||||
Future<Null> main() async {
|
Future<Null> main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
@ -21,6 +22,7 @@ class App extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final analytics = FirebaseAnalytics();
|
final analytics = FirebaseAnalytics();
|
||||||
|
refreshCurrentUser();
|
||||||
return MultiProvider(
|
return MultiProvider(
|
||||||
providers: [
|
providers: [
|
||||||
ChangeNotifierProvider.value(value: FFI.ffiModel),
|
ChangeNotifierProvider.value(value: FFI.ffiModel),
|
||||||
|
@ -65,6 +65,10 @@ class FfiModel with ChangeNotifier {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateUser() {
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
bool keyboard() => _permissions['keyboard'] != false;
|
bool keyboard() => _permissions['keyboard'] != false;
|
||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
@ -103,7 +107,7 @@ class FfiModel with ChangeNotifier {
|
|||||||
_permissions.clear();
|
_permissions.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void update(String peerId,HandleMsgBox handleMsgBox) {
|
void update(String peerId, HandleMsgBox handleMsgBox) {
|
||||||
var pos;
|
var pos;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
var evt = FFI.popEvent();
|
var evt = FFI.popEvent();
|
||||||
@ -130,9 +134,10 @@ class FfiModel with ChangeNotifier {
|
|||||||
} else if (name == 'permission') {
|
} else if (name == 'permission') {
|
||||||
FFI.ffiModel.updatePermission(evt);
|
FFI.ffiModel.updatePermission(evt);
|
||||||
} else if (name == 'chat_client_mode') {
|
} else if (name == 'chat_client_mode') {
|
||||||
FFI.chatModel.receive(ChatModel.clientModeID,evt['text'] ?? "");
|
FFI.chatModel.receive(ChatModel.clientModeID, evt['text'] ?? "");
|
||||||
} else if (name == 'chat_server_mode') {
|
} else if (name == 'chat_server_mode') {
|
||||||
FFI.chatModel.receive(int.parse(evt['id'] as String),evt['text'] ?? "");
|
FFI.chatModel
|
||||||
|
.receive(int.parse(evt['id'] as String), evt['text'] ?? "");
|
||||||
} else if (name == 'file_dir') {
|
} else if (name == 'file_dir') {
|
||||||
FFI.fileModel.receiveFileDir(evt);
|
FFI.fileModel.receiveFileDir(evt);
|
||||||
} else if (name == 'job_progress') {
|
} else if (name == 'job_progress') {
|
||||||
|
@ -15,7 +15,7 @@ bool mouseIn = false;
|
|||||||
class PlatformFFI {
|
class PlatformFFI {
|
||||||
static void clearRgbaFrame() {}
|
static void clearRgbaFrame() {}
|
||||||
|
|
||||||
static Uint8List getRgba() {
|
static Uint8List? getRgba() {
|
||||||
return js.context.callMethod('getRgba');
|
return js.context.callMethod('getRgba');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,29 +19,7 @@ class ConnectionPage extends StatefulWidget implements PageShape {
|
|||||||
final title = translate("Connection");
|
final title = translate("Connection");
|
||||||
|
|
||||||
@override
|
@override
|
||||||
final appBarActions = isWeb
|
final appBarActions = isWeb ? <Widget>[WebMenu()] : <Widget>[];
|
||||||
? <Widget>[
|
|
||||||
PopupMenuButton<String>(itemBuilder: (context) {
|
|
||||||
return [
|
|
||||||
PopupMenuItem(
|
|
||||||
child: Text(translate('ID/Relay Server')),
|
|
||||||
value: "server",
|
|
||||||
),
|
|
||||||
PopupMenuItem(
|
|
||||||
child: Text(translate('About') + ' RustDesk'),
|
|
||||||
value: "about",
|
|
||||||
)
|
|
||||||
];
|
|
||||||
}, onSelected: (value) {
|
|
||||||
if (value == 'server') {
|
|
||||||
showServer();
|
|
||||||
}
|
|
||||||
if (value == 'about') {
|
|
||||||
showAbout();
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
]
|
|
||||||
: [];
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_ConnectionPageState createState() => _ConnectionPageState();
|
_ConnectionPageState createState() => _ConnectionPageState();
|
||||||
@ -276,11 +254,15 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
|||||||
context: context,
|
context: context,
|
||||||
position: this._menuPos,
|
position: this._menuPos,
|
||||||
items: [
|
items: [
|
||||||
PopupMenuItem<String>(
|
PopupMenuItem<String>(
|
||||||
child: Text(translate('Remove')), value: 'remove'),
|
child: Text(translate('Remove')), value: 'remove')
|
||||||
PopupMenuItem<String>(
|
] +
|
||||||
child: Text(translate('File transfer')), value: 'file'),
|
(isWeb
|
||||||
],
|
? []
|
||||||
|
: [
|
||||||
|
PopupMenuItem<String>(
|
||||||
|
child: Text(translate('File transfer')), value: 'file')
|
||||||
|
]),
|
||||||
elevation: 8,
|
elevation: 8,
|
||||||
);
|
);
|
||||||
if (value == 'remove') {
|
if (value == 'remove') {
|
||||||
@ -293,3 +275,48 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class WebMenu extends StatefulWidget {
|
||||||
|
@override
|
||||||
|
_WebMenuState createState() => _WebMenuState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _WebMenuState extends State<WebMenu> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
Provider.of<FfiModel>(context);
|
||||||
|
final username = getUsername();
|
||||||
|
return PopupMenuButton<String>(itemBuilder: (context) {
|
||||||
|
return [
|
||||||
|
PopupMenuItem(
|
||||||
|
child: Text(translate('ID/Relay Server')),
|
||||||
|
value: "server",
|
||||||
|
),
|
||||||
|
PopupMenuItem(
|
||||||
|
child: Text(username == null
|
||||||
|
? translate("Login")
|
||||||
|
: translate("Logout") + ' ($username)'),
|
||||||
|
value: "login",
|
||||||
|
),
|
||||||
|
PopupMenuItem(
|
||||||
|
child: Text(translate('About') + ' RustDesk'),
|
||||||
|
value: "about",
|
||||||
|
)
|
||||||
|
];
|
||||||
|
}, onSelected: (value) {
|
||||||
|
if (value == 'server') {
|
||||||
|
showServer();
|
||||||
|
}
|
||||||
|
if (value == 'about') {
|
||||||
|
showAbout();
|
||||||
|
}
|
||||||
|
if (value == 'login') {
|
||||||
|
if (username == null) {
|
||||||
|
showLogin();
|
||||||
|
} else {
|
||||||
|
logout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -306,12 +306,16 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
onPressed: changeTouchMode,
|
onPressed: changeTouchMode,
|
||||||
)
|
)
|
||||||
]) +
|
]) +
|
||||||
<Widget>[
|
(isWeb
|
||||||
IconButton(
|
? []
|
||||||
color: Colors.white,
|
: <Widget>[
|
||||||
icon: Icon(Icons.message),
|
IconButton(
|
||||||
onPressed: toggleChatOverlay,
|
color: Colors.white,
|
||||||
),
|
icon: Icon(Icons.message),
|
||||||
|
onPressed: toggleChatOverlay,
|
||||||
|
)
|
||||||
|
]) +
|
||||||
|
[
|
||||||
IconButton(
|
IconButton(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
icon: Icon(Icons.more_vert),
|
icon: Icon(Icons.more_vert),
|
||||||
|
@ -1,11 +1,16 @@
|
|||||||
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||||
import 'package:settings_ui/settings_ui.dart';
|
import 'package:settings_ui/settings_ui.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
import '../common.dart';
|
import '../common.dart';
|
||||||
|
import '../widgets/dialog.dart';
|
||||||
import '../models/model.dart';
|
import '../models/model.dart';
|
||||||
import 'home_page.dart';
|
import 'home_page.dart';
|
||||||
|
|
||||||
class SettingsPage extends StatelessWidget implements PageShape {
|
class SettingsPage extends StatefulWidget implements PageShape {
|
||||||
@override
|
@override
|
||||||
final title = translate("Settings");
|
final title = translate("Settings");
|
||||||
|
|
||||||
@ -15,14 +20,39 @@ class SettingsPage extends StatelessWidget implements PageShape {
|
|||||||
@override
|
@override
|
||||||
final appBarActions = [];
|
final appBarActions = [];
|
||||||
|
|
||||||
|
@override
|
||||||
|
_SettingsState createState() => _SettingsState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SettingsState extends State<SettingsPage> {
|
||||||
static const url = 'https://rustdesk.com/';
|
static const url = 'https://rustdesk.com/';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
Provider.of<FfiModel>(context);
|
||||||
|
final username = getUsername();
|
||||||
return SettingsList(
|
return SettingsList(
|
||||||
sections: [
|
sections: [
|
||||||
SettingsSection(
|
SettingsSection(
|
||||||
title: Text("Common"),
|
title: Text(""),
|
||||||
|
tiles: [
|
||||||
|
SettingsTile.navigation(
|
||||||
|
title: Text(username == null
|
||||||
|
? translate("Login")
|
||||||
|
: translate("Logout") + ' ($username)'),
|
||||||
|
leading: Icon(Icons.person),
|
||||||
|
onPressed: (context) {
|
||||||
|
if (username == null) {
|
||||||
|
showLogin();
|
||||||
|
} else {
|
||||||
|
logout();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SettingsSection(
|
||||||
|
title: Text(translate("Settings")),
|
||||||
tiles: [
|
tiles: [
|
||||||
SettingsTile.navigation(
|
SettingsTile.navigation(
|
||||||
title: Text(translate('ID/Relay Server')),
|
title: Text(translate('ID/Relay Server')),
|
||||||
@ -34,20 +64,19 @@ class SettingsPage extends StatelessWidget implements PageShape {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
SettingsSection(
|
SettingsSection(
|
||||||
title: Text("About"),
|
title: Text(translate("About")),
|
||||||
tiles: [
|
tiles: [
|
||||||
SettingsTile.navigation(
|
SettingsTile.navigation(
|
||||||
title: Text("Version: " + version),
|
title: Text(translate("Version: ") + version),
|
||||||
value: InkWell(
|
value: InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
const url = 'https://rustdesk.com/';
|
|
||||||
if (await canLaunch(url)) {
|
if (await canLaunch(url)) {
|
||||||
await launch(url);
|
await launch(url);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.symmetric(vertical: 8),
|
padding: EdgeInsets.symmetric(vertical: 8),
|
||||||
child: Text('Support',
|
child: Text('rustdesk.com',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
decoration: TextDecoration.underline,
|
decoration: TextDecoration.underline,
|
||||||
)),
|
)),
|
||||||
@ -65,10 +94,12 @@ void showServer() {
|
|||||||
final formKey = GlobalKey<FormState>();
|
final formKey = GlobalKey<FormState>();
|
||||||
final id0 = FFI.getByName('option', 'custom-rendezvous-server');
|
final id0 = FFI.getByName('option', 'custom-rendezvous-server');
|
||||||
final relay0 = FFI.getByName('option', 'relay-server');
|
final relay0 = FFI.getByName('option', 'relay-server');
|
||||||
|
final api0 = FFI.getByName('option', 'api-server');
|
||||||
final key0 = FFI.getByName('option', 'key');
|
final key0 = FFI.getByName('option', 'key');
|
||||||
var id = '';
|
var id = '';
|
||||||
var relay = '';
|
var relay = '';
|
||||||
var key = '';
|
var key = '';
|
||||||
|
var api = '';
|
||||||
DialogManager.show((setState, close) {
|
DialogManager.show((setState, close) {
|
||||||
return CustomAlertDialog(
|
return CustomAlertDialog(
|
||||||
title: Text(translate('ID/Relay Server')),
|
title: Text(translate('ID/Relay Server')),
|
||||||
@ -103,6 +134,16 @@ void showServer() {
|
|||||||
]
|
]
|
||||||
: []) +
|
: []) +
|
||||||
[
|
[
|
||||||
|
TextFormField(
|
||||||
|
initialValue: api0,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: translate('API Server'),
|
||||||
|
),
|
||||||
|
validator: validate,
|
||||||
|
onSaved: (String? value) {
|
||||||
|
if (value != null) api = value.trim();
|
||||||
|
},
|
||||||
|
),
|
||||||
TextFormField(
|
TextFormField(
|
||||||
initialValue: key0,
|
initialValue: key0,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
@ -136,6 +177,9 @@ void showServer() {
|
|||||||
'option', '{"name": "relay-server", "value": "$relay"}');
|
'option', '{"name": "relay-server", "value": "$relay"}');
|
||||||
if (key != key0)
|
if (key != key0)
|
||||||
FFI.setByName('option', '{"name": "key", "value": "$key"}');
|
FFI.setByName('option', '{"name": "key", "value": "$key"}');
|
||||||
|
if (api != api0)
|
||||||
|
FFI.setByName(
|
||||||
|
'option', '{"name": "api-server", "value": "$api"}');
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -173,7 +217,7 @@ void showAbout() {
|
|||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.symmetric(vertical: 8),
|
padding: EdgeInsets.symmetric(vertical: 8),
|
||||||
child: Text('Support',
|
child: Text('rustdesk.com',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
decoration: TextDecoration.underline,
|
decoration: TextDecoration.underline,
|
||||||
)),
|
)),
|
||||||
@ -186,3 +230,221 @@ void showAbout() {
|
|||||||
);
|
);
|
||||||
}, barrierDismissible: true);
|
}, barrierDismissible: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<String> login(String name, String pass) async {
|
||||||
|
/* js test CORS
|
||||||
|
const data = { username: 'example', password: 'xx' };
|
||||||
|
|
||||||
|
fetch('http://localhost:21114/api/login', {
|
||||||
|
method: 'POST', // or 'PUT'
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
body: JSON.stringify(data),
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
console.log('Success:', data);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error('Error:', error);
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
final url = getUrl();
|
||||||
|
final body = {
|
||||||
|
'username': name,
|
||||||
|
'password': pass,
|
||||||
|
'id': FFI.getByName('server_id'),
|
||||||
|
'uuid': FFI.getByName('uuid')
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
final response = await http.post(Uri.parse('${url}/api/login'),
|
||||||
|
headers: {"Content-Type": "application/json"}, body: json.encode(body));
|
||||||
|
return parseResp(response.body);
|
||||||
|
} catch (e) {
|
||||||
|
print(e);
|
||||||
|
return 'Failed to access $url';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String parseResp(String body) {
|
||||||
|
final data = json.decode(body);
|
||||||
|
final error = data['error'];
|
||||||
|
if (error != null) {
|
||||||
|
return error!;
|
||||||
|
}
|
||||||
|
final token = data['access_token'];
|
||||||
|
if (token != null) {
|
||||||
|
FFI.setByName('option', '{"name": "access_token", "value": "$token"}');
|
||||||
|
}
|
||||||
|
final info = data['user'];
|
||||||
|
if (info != null) {
|
||||||
|
final value = json.encode(info);
|
||||||
|
FFI.setByName('option', json.encode({"name": "user_info", "value": value}));
|
||||||
|
FFI.ffiModel.updateUser();
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
void refreshCurrentUser() async {
|
||||||
|
final token = FFI.getByName("option", "access_token");
|
||||||
|
if (token == '') return;
|
||||||
|
final url = getUrl();
|
||||||
|
final body = {
|
||||||
|
'id': FFI.getByName('server_id'),
|
||||||
|
'uuid': FFI.getByName('uuid')
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
final response = await http.post(Uri.parse('${url}/api/currentUser'),
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"Authorization": "Bearer $token"
|
||||||
|
},
|
||||||
|
body: json.encode(body));
|
||||||
|
final status = response.statusCode;
|
||||||
|
if (status == 401 || status == 400) {
|
||||||
|
resetToken();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
parseResp(response.body);
|
||||||
|
} catch (e) {
|
||||||
|
print('$e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void logout() async {
|
||||||
|
final token = FFI.getByName("option", "access_token");
|
||||||
|
if (token == '') return;
|
||||||
|
final url = getUrl();
|
||||||
|
final body = {
|
||||||
|
'id': FFI.getByName('server_id'),
|
||||||
|
'uuid': FFI.getByName('uuid')
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
await http.post(Uri.parse('${url}/api/logout'),
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"Authorization": "Bearer $token"
|
||||||
|
},
|
||||||
|
body: json.encode(body));
|
||||||
|
} catch (e) {
|
||||||
|
EasyLoading.showToast('Failed to access $url',
|
||||||
|
maskType: EasyLoadingMaskType.black);
|
||||||
|
}
|
||||||
|
resetToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
void resetToken() {
|
||||||
|
FFI.setByName('option', '{"name": "access_token", "value": ""}');
|
||||||
|
FFI.setByName('option', '{"name": "user_info", "value": ""}');
|
||||||
|
FFI.ffiModel.updateUser();
|
||||||
|
}
|
||||||
|
|
||||||
|
String getUrl() {
|
||||||
|
var url = FFI.getByName('option', 'api-server');
|
||||||
|
if (url == '') {
|
||||||
|
url = FFI.getByName('option', 'custom-rendezvous-server');
|
||||||
|
if (url != '') {
|
||||||
|
if (url.contains(':')) {
|
||||||
|
final tmp = url.split(':');
|
||||||
|
if (tmp.length == 2) {
|
||||||
|
var port = int.parse(tmp[1]) - 2;
|
||||||
|
url = 'http://${tmp[0]}:$port';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
url = 'http://${url}:21114';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (url == '') {
|
||||||
|
url = 'https://admin.rustdesk.com';
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
void showLogin() {
|
||||||
|
final passwordController = TextEditingController();
|
||||||
|
final nameController = TextEditingController();
|
||||||
|
var loading = false;
|
||||||
|
var error = '';
|
||||||
|
DialogManager.show((setState, close) {
|
||||||
|
return CustomAlertDialog(
|
||||||
|
title: Text(translate('Login')),
|
||||||
|
content: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||||
|
TextField(
|
||||||
|
autofocus: true,
|
||||||
|
autocorrect: false,
|
||||||
|
enableSuggestions: false,
|
||||||
|
keyboardType: TextInputType.visiblePassword,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: translate('Username'),
|
||||||
|
),
|
||||||
|
controller: nameController,
|
||||||
|
),
|
||||||
|
PasswordWidget(controller: passwordController),
|
||||||
|
]),
|
||||||
|
actions: (loading
|
||||||
|
? <Widget>[CircularProgressIndicator()]
|
||||||
|
: (error != ""
|
||||||
|
? <Widget>[
|
||||||
|
Text(translate(error),
|
||||||
|
style: TextStyle(color: Colors.red))
|
||||||
|
]
|
||||||
|
: <Widget>[])) +
|
||||||
|
<Widget>[
|
||||||
|
TextButton(
|
||||||
|
style: flatButtonStyle,
|
||||||
|
onPressed: loading
|
||||||
|
? null
|
||||||
|
: () {
|
||||||
|
close();
|
||||||
|
setState(() {
|
||||||
|
loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: Text(translate('Cancel')),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
style: flatButtonStyle,
|
||||||
|
onPressed: loading
|
||||||
|
? null
|
||||||
|
: () async {
|
||||||
|
final name = nameController.text.trim();
|
||||||
|
final pass = passwordController.text.trim();
|
||||||
|
if (name != "" && pass != "") {
|
||||||
|
setState(() {
|
||||||
|
loading = true;
|
||||||
|
});
|
||||||
|
final e = await login(name, pass);
|
||||||
|
setState(() {
|
||||||
|
loading = false;
|
||||||
|
error = e;
|
||||||
|
});
|
||||||
|
if (e == "") {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Text(translate('OK')),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
String? getUsername() {
|
||||||
|
final token = FFI.getByName("option", "access_token");
|
||||||
|
String? username;
|
||||||
|
if (token != "") {
|
||||||
|
final info = FFI.getByName("option", "user_info");
|
||||||
|
if (info != "") {
|
||||||
|
try {
|
||||||
|
Map<String, dynamic> tmp = json.decode(info);
|
||||||
|
username = tmp["name"];
|
||||||
|
} catch (e) {
|
||||||
|
print('$e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
21
web/assets/index.d2272adc.js
Normal file
21
web/assets/index.d2272adc.js
Normal file
File diff suppressed because one or more lines are too long
@ -33,7 +33,7 @@
|
|||||||
<link rel="manifest" href="manifest.json">
|
<link rel="manifest" href="manifest.json">
|
||||||
<script src="ogvjs-1.8.6/ogv.js"></script>
|
<script src="ogvjs-1.8.6/ogv.js"></script>
|
||||||
<script src="yuv.js"></script>
|
<script src="yuv.js"></script>
|
||||||
<script type="module" crossorigin src="assets/index.b043e392.js"></script>
|
<script type="module" crossorigin src="assets/index.d2272adc.js"></script>
|
||||||
<link rel="modulepreload" href="assets/vendor.b7bb6fa2.js">
|
<link rel="modulepreload" href="assets/vendor.b7bb6fa2.js">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user