Reformat code with latest Flutter 3 linting

This commit is contained in:
Varakh 2022-06-23 00:44:08 +02:00
parent 7ef179906d
commit 011113d72b
35 changed files with 107 additions and 233 deletions

View file

@ -30,8 +30,7 @@ class _DialogManagerState extends State<DialogManager> {
void _showDialog(DialogRequest request) {
List<Widget> actions = <Widget>[];
if (request.buttonTitleDeny != null &&
request.buttonTitleDeny!.isNotEmpty) {
if (request.buttonTitleDeny != null && request.buttonTitleDeny!.isNotEmpty) {
Widget denyBtn = TextButton(
child: Text(request.buttonTitleDeny!),
onPressed: () {

View file

@ -15,11 +15,7 @@ class ApiKey {
final String? comment;
ApiKey(
{required this.key,
required this.created,
required this.accessLevel,
this.comment});
ApiKey({required this.key, required this.created, required this.accessLevel, this.comment});
// JSON Init
factory ApiKey.fromJson(Map<String, dynamic> json) => _$ApiKeyFromJson(json);

View file

@ -12,8 +12,7 @@ class ApiKeys {
ApiKeys({required this.apikeys});
// JSON Init
factory ApiKeys.fromJson(Map<String, dynamic> json) =>
_$ApiKeysFromJson(json);
factory ApiKeys.fromJson(Map<String, dynamic> json) => _$ApiKeysFromJson(json);
// JSON Export
Map<String, dynamic> toJson() => _$ApiKeysToJson(this);

View file

@ -15,8 +15,7 @@ class ApiKeysResponse {
ApiKeysResponse({required this.status, required this.data});
// JSON Init
factory ApiKeysResponse.fromJson(Map<String, dynamic> json) =>
_$ApiKeysResponseFromJson(json);
factory ApiKeysResponse.fromJson(Map<String, dynamic> json) => _$ApiKeysResponseFromJson(json);
// JSON Export
Map<String, dynamic> toJson() => _$ApiKeysResponseToJson(this);

View file

@ -15,8 +15,7 @@ class ConfigResponse {
ConfigResponse({required this.status, required this.data});
// JSON Init
factory ConfigResponse.fromJson(Map<String, dynamic> json) =>
_$ConfigResponseFromJson(json);
factory ConfigResponse.fromJson(Map<String, dynamic> json) => _$ConfigResponseFromJson(json);
// JSON Export
Map<String, dynamic> toJson() => _$ConfigResponseToJson(this);

View file

@ -13,8 +13,7 @@ class CreateApiKeyResponse {
CreateApiKeyResponse({required this.status, required this.data});
// JSON Init
factory CreateApiKeyResponse.fromJson(Map<String, dynamic> json) =>
_$CreateApiKeyResponseFromJson(json);
factory CreateApiKeyResponse.fromJson(Map<String, dynamic> json) => _$CreateApiKeyResponseFromJson(json);
// JSON Export
Map<String, dynamic> toJson() => _$CreateApiKeyResponseToJson(this);

View file

@ -19,8 +19,7 @@ class History {
History({required this.items, required this.multipasteItems, this.totalSize});
// JSON Init
factory History.fromJson(Map<String, dynamic> json) =>
_$HistoryFromJson(json);
factory History.fromJson(Map<String, dynamic> json) => _$HistoryFromJson(json);
// JSON Export
Map<String, dynamic> toJson() => _$HistoryToJson(this);

View file

@ -23,8 +23,7 @@ class HistoryItem {
this.thumbnail});
// JSON Init
factory HistoryItem.fromJson(Map<String, dynamic> json) =>
_$HistoryItemFromJson(json);
factory HistoryItem.fromJson(Map<String, dynamic> json) => _$HistoryItemFromJson(json);
// JSON Export
Map<String, dynamic> toJson() => _$HistoryItemToJson(this);

View file

@ -15,8 +15,7 @@ class HistoryMultipasteItem {
HistoryMultipasteItem(this.items, {required this.date, required this.urlId});
// JSON Init
factory HistoryMultipasteItem.fromJson(Map<String, dynamic> json) =>
_$HistoryMultipasteItemFromJson(json);
factory HistoryMultipasteItem.fromJson(Map<String, dynamic> json) => _$HistoryMultipasteItemFromJson(json);
// JSON Export
Map<String, dynamic> toJson() => _$HistoryMultipasteItemToJson(this);

View file

@ -9,8 +9,7 @@ class HistoryMultipasteItemEntry {
HistoryMultipasteItemEntry({required this.id});
// JSON Init
factory HistoryMultipasteItemEntry.fromJson(Map<String, dynamic> json) =>
_$HistoryMultipasteItemEntryFromJson(json);
factory HistoryMultipasteItemEntry.fromJson(Map<String, dynamic> json) => _$HistoryMultipasteItemEntryFromJson(json);
// JSON Export
Map<String, dynamic> toJson() => _$HistoryMultipasteItemEntryToJson(this);

View file

@ -15,8 +15,7 @@ class HistoryResponse {
HistoryResponse({required this.status, required this.data});
// JSON Init
factory HistoryResponse.fromJson(Map<String, dynamic> json) =>
_$HistoryResponseFromJson(json);
factory HistoryResponse.fromJson(Map<String, dynamic> json) => _$HistoryResponseFromJson(json);
// JSON Export
Map<String, dynamic> toJson() => _$HistoryResponseToJson(this);

View file

@ -15,8 +15,7 @@ class RestError {
required this.errorId,
}); // JSON Init
factory RestError.fromJson(Map<String, dynamic> json) =>
_$RestErrorFromJson(json);
factory RestError.fromJson(Map<String, dynamic> json) => _$RestErrorFromJson(json);
// JSON Export
Map<String, dynamic> toJson() => _$RestErrorToJson(this);

View file

@ -13,8 +13,7 @@ class Uploaded {
Uploaded({required this.ids, required this.urls});
// JSON Init
factory Uploaded.fromJson(Map<String, dynamic> json) =>
_$UploadedFromJson(json);
factory Uploaded.fromJson(Map<String, dynamic> json) => _$UploadedFromJson(json);
// JSON Export
Map<String, dynamic> toJson() => _$UploadedToJson(this);

View file

@ -13,8 +13,7 @@ class UploadedMulti {
UploadedMulti({required this.url, required this.urlId});
// JSON Init
factory UploadedMulti.fromJson(Map<String, dynamic> json) =>
_$UploadedMultiFromJson(json);
factory UploadedMulti.fromJson(Map<String, dynamic> json) => _$UploadedMultiFromJson(json);
// JSON Export
Map<String, dynamic> toJson() => _$UploadedMultiToJson(this);

View file

@ -15,8 +15,7 @@ class UploadedMultiResponse {
UploadedMultiResponse({required this.status, required this.data});
// JSON Init
factory UploadedMultiResponse.fromJson(Map<String, dynamic> json) =>
_$UploadedMultiResponseFromJson(json);
factory UploadedMultiResponse.fromJson(Map<String, dynamic> json) => _$UploadedMultiResponseFromJson(json);
// JSON Export
Map<String, dynamic> toJson() => _$UploadedMultiResponseToJson(this);

View file

@ -15,8 +15,7 @@ class UploadedResponse {
UploadedResponse({required this.status, required this.data});
// JSON Init
factory UploadedResponse.fromJson(Map<String, dynamic> json) =>
_$UploadedResponseFromJson(json);
factory UploadedResponse.fromJson(Map<String, dynamic> json) => _$UploadedResponseFromJson(json);
// JSON Export
Map<String, dynamic> toJson() => _$UploadedResponseToJson(this);

View file

@ -13,8 +13,7 @@ class Session {
: url = '',
apiKey = '';
factory Session.fromJson(Map<String, dynamic> json) =>
_$SessionFromJson(json);
factory Session.fromJson(Map<String, dynamic> json) => _$SessionFromJson(json);
Map<String, dynamic> toJson() => _$SessionToJson(this);
}

View file

@ -26,8 +26,7 @@ class UploadedPaste {
this.items});
// JSON Init
factory UploadedPaste.fromJson(Map<String, dynamic> json) =>
_$UploadedPasteFromJson(json);
factory UploadedPaste.fromJson(Map<String, dynamic> json) => _$UploadedPasteFromJson(json);
// JSON Export
Map<String, dynamic> toJson() => _$UploadedPasteToJson(this);

View file

@ -33,10 +33,8 @@ class FileRepository {
return response;
}
Future<UploadedResponse> postUpload(
List<File>? files, Map<String, String>? additionalFiles) async {
var response = await _api.post('/file/upload',
files: files, additionalFiles: additionalFiles);
Future<UploadedResponse> postUpload(List<File>? files, Map<String, String>? additionalFiles) async {
var response = await _api.post('/file/upload', files: files, additionalFiles: additionalFiles);
return UploadedResponse.fromJson(json.decode(response.body));
}
@ -44,12 +42,10 @@ class FileRepository {
Map<String, String> multiPasteIds = Map();
ids.forEach((element) {
multiPasteIds.putIfAbsent(
"ids[${ids.indexOf(element) + 1}]", () => element);
multiPasteIds.putIfAbsent("ids[${ids.indexOf(element) + 1}]", () => element);
});
var response =
await _api.post('/file/create_multipaste', fields: multiPasteIds);
var response = await _api.post('/file/create_multipaste', fields: multiPasteIds);
return UploadedMultiResponse.fromJson(json.decode(response.body));
}
}

View file

@ -8,8 +8,8 @@ import '../services/api.dart';
class UserRepository {
Api _api = locator<Api>();
Future<CreateApiKeyResponse> postApiKey(String url, String username,
String password, String accessLevel, String comment) async {
Future<CreateApiKeyResponse> postApiKey(
String url, String username, String password, String accessLevel, String comment) async {
_api.setUrl(url);
var fields = Map.fromEntries([

View file

@ -24,34 +24,25 @@ class Api implements ApiErrorConverter {
String _url = "";
String _apiKey = "";
Map<String, String> _headers = {
"Content-Type": _applicationJson,
"Accept": _applicationJson
};
Map<String, String> _headers = {"Content-Type": _applicationJson, "Accept": _applicationJson};
Duration _timeout = Duration(seconds: Constants.apiRequestTimeoutLimit);
Future<http.Response> fetch<T>(String route) async {
try {
_logger.d(
"Requesting GET API endpoint '${_url + route}' with headers '$_headers' and maximum timeout '$_timeout'");
var response = await http
.get(Uri.parse(_url + route), headers: _headers)
.timeout(_timeout);
_logger
.d("Requesting GET API endpoint '${_url + route}' with headers '$_headers' and maximum timeout '$_timeout'");
var response = await http.get(Uri.parse(_url + route), headers: _headers).timeout(_timeout);
handleRestErrors(response);
return response;
} on TimeoutException {
throw ServiceException(
code: ErrorCode.SOCKET_TIMEOUT, message: _errorTimeout);
throw ServiceException(code: ErrorCode.SOCKET_TIMEOUT, message: _errorTimeout);
} on SocketException {
throw ServiceException(
code: ErrorCode.SOCKET_ERROR, message: _errorNoConnection);
throw ServiceException(code: ErrorCode.SOCKET_ERROR, message: _errorNoConnection);
}
}
Future<http.Response> post<T>(String route,
{Map<String, String?>? fields,
List<File>? files,
Map<String, String>? additionalFiles}) async {
{Map<String, String?>? fields, List<File>? files, Map<String, String>? additionalFiles}) async {
try {
var uri = Uri.parse(_url + route);
var request = http.MultipartRequest('POST', uri)
@ -68,34 +59,27 @@ class Api implements ApiErrorConverter {
if (files != null && files.isNotEmpty) {
files.forEach((element) async {
request.files.add(await http.MultipartFile.fromPath(
'file[${files.indexOf(element) + 1}]', element.path));
request.files.add(await http.MultipartFile.fromPath('file[${files.indexOf(element) + 1}]', element.path));
});
}
if (additionalFiles != null && additionalFiles.length > 0) {
List<String> keys = additionalFiles.keys.toList();
additionalFiles.forEach((key, value) {
var index = files != null
? files.length + keys.indexOf(key) + 1
: keys.indexOf(key) + 1;
request.files.add(http.MultipartFile.fromString('file[$index]', value,
filename: key));
var index = files != null ? files.length + keys.indexOf(key) + 1 : keys.indexOf(key) + 1;
request.files.add(http.MultipartFile.fromString('file[$index]', value, filename: key));
});
}
_logger.d(
"Requesting POST API endpoint '${uri.toString()}' and ${request.files.length} files");
_logger.d("Requesting POST API endpoint '${uri.toString()}' and ${request.files.length} files");
var multiResponse = await request.send();
var response = await http.Response.fromStream(multiResponse);
handleRestErrors(response);
return response;
} on TimeoutException {
throw ServiceException(
code: ErrorCode.SOCKET_TIMEOUT, message: _errorTimeout);
throw ServiceException(code: ErrorCode.SOCKET_TIMEOUT, message: _errorTimeout);
} on SocketException {
throw ServiceException(
code: ErrorCode.SOCKET_ERROR, message: _errorNoConnection);
throw ServiceException(code: ErrorCode.SOCKET_ERROR, message: _errorNoConnection);
}
}
@ -123,17 +107,14 @@ class Api implements ApiErrorConverter {
/// have a json decoded object. Replace this with a custom
/// conversion method by overwriting the interface if needed
void handleRestErrors(http.Response response) {
if (response.statusCode != HttpStatus.ok &&
response.statusCode != HttpStatus.noContent) {
if (response.statusCode != HttpStatus.ok && response.statusCode != HttpStatus.noContent) {
if (response.headers.containsKey(HttpHeaders.contentTypeHeader)) {
ContentType responseContentType =
ContentType.parse(response.headers[HttpHeaders.contentTypeHeader]!);
ContentType responseContentType = ContentType.parse(response.headers[HttpHeaders.contentTypeHeader]!);
if (ContentType.json.primaryType == responseContentType.primaryType &&
ContentType.json.subType == responseContentType.subType) {
var parsedBody = convert(response);
throw new RestServiceException(response.statusCode,
responseBody: parsedBody);
throw new RestServiceException(response.statusCode, responseBody: parsedBody);
}
}

View file

@ -27,28 +27,20 @@ class DialogService {
title: title,
description: description,
buttonTitleAccept:
buttonTitleAccept == null || buttonTitleAccept.isEmpty
? translate('dialog.confirm')
: buttonTitleAccept));
buttonTitleAccept == null || buttonTitleAccept.isEmpty ? translate('dialog.confirm') : buttonTitleAccept));
return _dialogCompleter!.future;
}
Future<DialogResponse> showConfirmationDialog(
{String? title,
String? description,
String? buttonTitleAccept,
String? buttonTitleDeny}) {
{String? title, String? description, String? buttonTitleAccept, String? buttonTitleDeny}) {
_dialogCompleter = Completer<DialogResponse>();
_showDialogListener(DialogRequest(
title: title,
description: description,
buttonTitleAccept:
buttonTitleAccept == null || buttonTitleAccept.isEmpty
? translate('dialog.confirm')
: buttonTitleAccept,
buttonTitleDeny: buttonTitleDeny == null || buttonTitleDeny.isEmpty
? translate('dialog.cancel')
: buttonTitleDeny));
buttonTitleAccept == null || buttonTitleAccept.isEmpty ? translate('dialog.confirm') : buttonTitleAccept,
buttonTitleDeny:
buttonTitleDeny == null || buttonTitleDeny.isEmpty ? translate('dialog.cancel') : buttonTitleDeny));
return _dialogCompleter!.future;
}

View file

@ -23,8 +23,7 @@ class FileService {
return await _fileRepository.postDelete(id);
}
Future<UploadedResponse> uploadPaste(
List<File>? files, Map<String, String>? additionalFiles) async {
Future<UploadedResponse> uploadPaste(List<File>? files, Map<String, String>? additionalFiles) async {
return await _fileRepository.postUpload(files, additionalFiles);
}

View file

@ -57,8 +57,7 @@ class PermissionService extends StoppableService {
return;
}
var ignoredDialog =
await _storageService.hasStoragePermissionDialogIgnored();
var ignoredDialog = await _storageService.hasStoragePermissionDialogIgnored();
if (ignoredDialog) {
_logger.d('Permanently ignored permission request, skipping');
@ -105,9 +104,8 @@ class PermissionService extends StoppableService {
super.start();
await checkEnabledAndPermission();
_serviceCheckTimer = Timer.periodic(
Duration(milliseconds: Constants.mediaPermissionCheckInterval),
(_serviceTimer) async {
_serviceCheckTimer =
Timer.periodic(Duration(milliseconds: Constants.mediaPermissionCheckInterval), (_serviceTimer) async {
if (!super.serviceStopped) {
await checkEnabledAndPermission();
} else {

View file

@ -12,10 +12,9 @@ class UserService {
final FileService _fileService = locator<FileService>();
final UserRepository _userRepository = locator<UserRepository>();
Future<CreateApiKeyResponse> createApiKey(String url, String username,
String password, String accessLevel, String comment) async {
return await _userRepository.postApiKey(
url, username, password, accessLevel, comment);
Future<CreateApiKeyResponse> createApiKey(
String url, String username, String password, String accessLevel, String comment) async {
return await _userRepository.postApiKey(url, username, password, accessLevel, comment);
}
Future<ApiKeysResponse> getApiKeys() async {
@ -27,8 +26,7 @@ class UserService {
try {
await _fileService.getHistory();
} on ServiceException catch (e) {
throw new ServiceException(
code: ErrorCode.INVALID_API_KEY, message: e.message);
throw new ServiceException(code: ErrorCode.INVALID_API_KEY, message: e.message);
}
}
}

View file

@ -34,8 +34,7 @@ class HistoryModel extends BaseModel {
String? errorMessage;
void init() {
_refreshTriggerSubscription =
_refreshService.refreshEventController.stream.listen((event) {
_refreshTriggerSubscription = _refreshService.refreshEventController.stream.listen((event) {
if (event == RefreshEvent.RefreshHistory) {
_logger.d('History needs a refresh');
getHistory();
@ -55,8 +54,7 @@ class HistoryModel extends BaseModel {
pastes.add(
UploadedPaste(
id: key,
date:
DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch),
date: DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch),
filename: value.filename,
filesize: int.parse(value.filesize),
hash: value.hash,
@ -92,11 +90,9 @@ class HistoryModel extends BaseModel {
e.responseBody is RestError &&
e.responseBody.message != null) {
if (e.statusCode == HttpStatus.badRequest) {
errorMessage = translate('api.bad_request',
args: {'reason': e.responseBody.message});
errorMessage = translate('api.bad_request', args: {'reason': e.responseBody.message});
} else {
errorMessage = translate('api.general_rest_error_payload',
args: {'message': e.responseBody.message});
errorMessage = translate('api.general_rest_error_payload', args: {'message': e.responseBody.message});
}
} else {
errorMessage = translate('api.general_rest_error');
@ -119,8 +115,7 @@ class HistoryModel extends BaseModel {
Future deletePaste(String id) async {
DialogResponse res = await _dialogService.showConfirmationDialog(
title: translate('history.delete_dialog.title'),
description:
translate('history.delete_dialog.description', args: {'id': id}),
description: translate('history.delete_dialog.description', args: {'id': id}),
buttonTitleAccept: translate('history.delete_dialog.accept'),
buttonTitleDeny: translate('history.delete_dialog.deny'));
@ -144,8 +139,7 @@ class HistoryModel extends BaseModel {
e.statusCode != HttpStatus.forbidden &&
e.responseBody is RestError &&
e.responseBody.message != null) {
errorMessage = translate('api.general_rest_error_payload',
args: {'message': e.responseBody.message});
errorMessage = translate('api.general_rest_error_payload', args: {'message': e.responseBody.message});
} else {
errorMessage = translate('api.general_rest_error');
}

View file

@ -117,19 +117,14 @@ class LoginModel extends BaseModel {
try {
if (useCredentialsLogin) {
CreateApiKeyResponse apiKeyResponse = await _userService.createApiKey(
url,
username,
password,
'apikey',
'fbmobile-${new DateTime.now().millisecondsSinceEpoch}');
url, username, password, 'apikey', 'fbmobile-${new DateTime.now().millisecondsSinceEpoch}');
var newKey = apiKeyResponse.data['new_key'];
if (newKey != null) {
success = await _sessionService.login(url, newKey);
} else {
throw new ServiceException(
code: ErrorCode.INVALID_API_KEY,
message: translate('login.errors.invalid_api_key'));
code: ErrorCode.INVALID_API_KEY, message: translate('login.errors.invalid_api_key'));
}
} else {
_sessionService.setApiConfig(url, apiKey);
@ -141,15 +136,13 @@ class LoginModel extends BaseModel {
if (e is RestServiceException) {
if (e.statusCode == HttpStatus.unauthorized) {
errorMessage = translate('login.errors.wrong_credentials');
} else if (e.statusCode != HttpStatus.unauthorized &&
e.statusCode == HttpStatus.forbidden) {
} else if (e.statusCode != HttpStatus.unauthorized && e.statusCode == HttpStatus.forbidden) {
errorMessage = translate('login.errors.forbidden');
} else if (e.statusCode == HttpStatus.notFound) {
errorMessage = translate('api.incompatible_error_not_found');
}
if (e.statusCode == HttpStatus.badRequest) {
errorMessage = translate('api.bad_request',
args: {'reason': e.responseBody.message});
errorMessage = translate('api.bad_request', args: {'reason': e.responseBody.message});
} else {
errorMessage = translate('api.general_rest_error');
}

View file

@ -27,8 +27,7 @@ class AppRouter {
return MaterialPageRoute(
builder: (_) => Scaffold(
body: Center(
child: Text(translate('dev.no_route',
args: {'route': settings.name})),
child: Text(translate('dev.no_route', args: {'route': settings.name})),
),
));
}

View file

@ -31,9 +31,7 @@ class _BaseViewState<T extends BaseModel> extends State<BaseView<T>> {
@override
Widget build(BuildContext context) {
return ChangeNotifierProvider<T?>(
create: (context) => model,
child: Consumer<T>(builder: widget.builder!));
return ChangeNotifierProvider<T?>(create: (context) => model, child: Consumer<T>(builder: widget.builder!));
}
@override

View file

@ -42,8 +42,7 @@ class HistoryView extends StatelessWidget {
? Container(
padding: EdgeInsets.all(0),
child: RefreshIndicator(
onRefresh: () async => await model.getHistory(),
child: _renderItems(model, url, context)))
onRefresh: () async => await model.getHistory(), child: _renderItems(model, url, context)))
: Container(
padding: EdgeInsets.all(25),
child: CenteredErrorRow(
@ -63,8 +62,7 @@ class HistoryView extends StatelessWidget {
var openInBrowserButton = _renderOpenInBrowser(model, fullPasteUrl);
var dateWidget = ListTile(
title: Text(
FormatterUtil.formatEpoch(paste.date!.millisecondsSinceEpoch)),
title: Text(FormatterUtil.formatEpoch(paste.date!.millisecondsSinceEpoch)),
subtitle: Text(translate('history.date')),
);
@ -76,8 +74,7 @@ class HistoryView extends StatelessWidget {
var copyWidget = ListTile(
title: Text(translate('history.copy_link.description')),
trailing: IconButton(
icon: Icon(Icons.copy,
color: blueColor, textDirection: TextDirection.ltr),
icon: Icon(Icons.copy, color: blueColor, textDirection: TextDirection.ltr),
onPressed: () {
FlutterClipboard.copy(fullPasteUrl).then((value) {
final snackBar = SnackBar(
@ -168,14 +165,12 @@ class HistoryView extends StatelessWidget {
trailing: Wrap(children: [
openInBrowserButton,
IconButton(
icon: Icon(Icons.share,
color: blueColor, textDirection: TextDirection.ltr),
icon: Icon(Icons.share, color: blueColor, textDirection: TextDirection.ltr),
onPressed: () async {
await Share.share(fullPasteUrl);
})
]),
subtitle: Text(!paste.isMulti! ? paste.filename! : '',
style: TextStyle(fontStyle: FontStyle.italic)),
subtitle: Text(!paste.isMulti! ? paste.filename! : '', style: TextStyle(fontStyle: FontStyle.italic)),
),
));
});
@ -196,8 +191,7 @@ class HistoryView extends StatelessWidget {
Widget _renderOpenInBrowser(HistoryModel model, String url) {
return IconButton(
icon: Icon(Icons.open_in_new,
color: blueColor, textDirection: TextDirection.ltr),
icon: Icon(Icons.open_in_new, color: blueColor, textDirection: TextDirection.ltr),
onPressed: () {
return model.openLink(url);
});

View file

@ -59,18 +59,13 @@ class LoginView extends StatelessWidget {
child: Icon(Icons.help, color: buttonBackgroundColor),
onTap: () {
_dialogService.showDialog(
title: translate(
'login.compatibility_dialog.title'),
description: translate(
'login.compatibility_dialog.body'));
title: translate('login.compatibility_dialog.title'),
description: translate('login.compatibility_dialog.body'));
},
),
InkWell(
child: Icon(
model.useCredentialsLogin
? Icons.person_outline
: Icons.vpn_key,
color: blueColor),
child:
Icon(model.useCredentialsLogin ? Icons.person_outline : Icons.vpn_key, color: blueColor),
onTap: () {
model.toggleLoginMethod();
},
@ -90,13 +85,11 @@ class LoginView extends StatelessWidget {
apiKeyController: model.apiKeyController),
UIHelper.verticalSpaceMedium(),
ElevatedButton(
child: Text(translate('login.button'),
style: TextStyle(color: buttonForegroundColor)),
child: Text(translate('login.button'), style: TextStyle(color: buttonForegroundColor)),
onPressed: () async {
var loginSuccess = await model.login();
if (loginSuccess) {
_navigationService
.navigateAndReplaceTo(HomeView.routeName);
_navigationService.navigateAndReplaceTo(HomeView.routeName);
}
},
)

View file

@ -9,8 +9,7 @@ class AnonymousTabBarView extends StatefulWidget {
AnonymousTabBarState createState() => AnonymousTabBarState();
}
class AnonymousTabBarState extends State<AnonymousTabBarView>
with SingleTickerProviderStateMixin {
class AnonymousTabBarState extends State<AnonymousTabBarView> with SingleTickerProviderStateMixin {
TabController? _tabController;
int _currentTabIndex = 0;

View file

@ -9,8 +9,7 @@ class TabBarContainerView extends StatelessWidget {
@override
Widget build(BuildContext context) {
Session? currentSession = Provider.of<Session?>(context);
bool isAuthenticated =
currentSession != null ? currentSession.apiKey.isNotEmpty : false;
bool isAuthenticated = currentSession != null ? currentSession.apiKey.isNotEmpty : false;
if (isAuthenticated) {
return AuthenticatedTabBarView();

View file

@ -26,8 +26,7 @@ class UploadView extends StatelessWidget {
}
bool _isUploadButtonEnabled(UploadModel model) {
return model.pasteTextTouched ||
(model.paths != null && model.paths!.length > 0);
return model.pasteTextTouched || (model.paths != null && model.paths!.length > 0);
}
Widget _render(UploadModel model, BuildContext context) {
@ -40,9 +39,7 @@ class UploadView extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
CircularProgressIndicator(),
(model.stateMessage != null && model.stateMessage!.isNotEmpty
? Text(model.stateMessage!)
: Container())
(model.stateMessage != null && model.stateMessage!.isNotEmpty ? Text(model.stateMessage!) : Container())
]))
: ListView(children: <Widget>[
Padding(
@ -61,15 +58,12 @@ class UploadView extends StatelessWidget {
color: buttonBackgroundColor,
),
suffixIcon: IconButton(
onPressed: () =>
model.pasteTextController.clear(),
onPressed: () => model.pasteTextController.clear(),
icon: Icon(Icons.clear),
),
hintText: translate('upload.text_to_be_pasted'),
contentPadding:
EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(32.0)),
contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
border: OutlineInputBorder(borderRadius: BorderRadius.circular(32.0)),
),
controller: model.pasteTextController)),
Padding(
@ -85,24 +79,20 @@ class UploadView extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.end,
children: [
ElevatedButton.icon(
icon: Icon(Icons.file_copy_sharp,
color: blueColor),
icon: Icon(Icons.file_copy_sharp, color: blueColor),
onPressed: () => model.openFileExplorer(),
label: Text(
translate('upload.open_file_explorer'),
style:
TextStyle(color: buttonForegroundColor),
style: TextStyle(color: buttonForegroundColor),
)),
ElevatedButton.icon(
icon: Icon(Icons.cancel, color: orangeColor),
onPressed: model.paths != null &&
model.paths!.length > 0
onPressed: model.paths != null && model.paths!.length > 0
? () => model.clearCachedFiles()
: null,
label: Text(
translate('upload.clear_temporary_files'),
style:
TextStyle(color: buttonForegroundColor),
style: TextStyle(color: buttonForegroundColor),
)),
],
)),
@ -128,48 +118,35 @@ class UploadView extends StatelessWidget {
onPressed: !_isUploadButtonEnabled(model)
? null
: () async {
Map<String, bool>? items =
await model.upload();
String? clipboardContent = model
.generatePasteLinks(items, url);
Map<String, bool>? items = await model.upload();
String? clipboardContent = model.generatePasteLinks(items, url);
if (clipboardContent != null &&
clipboardContent.isNotEmpty) {
FlutterClipboard.copy(
clipboardContent)
.then((value) {
if (clipboardContent != null && clipboardContent.isNotEmpty) {
FlutterClipboard.copy(clipboardContent).then((value) {
final snackBar = SnackBar(
action: SnackBarAction(
label: translate(
'upload.dismiss'),
label: translate('upload.dismiss'),
textColor: blueColor,
onPressed: () {
ScaffoldMessenger.of(
context)
.hideCurrentSnackBar();
ScaffoldMessenger.of(context).hideCurrentSnackBar();
},
),
content: Text(translate(
'upload.uploaded')),
content: Text(translate('upload.uploaded')),
duration: Duration(seconds: 10),
);
ScaffoldMessenger.of(context)
.showSnackBar(snackBar);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
});
}
},
icon: Icon(Icons.upload_rounded,
color: greenColor),
icon: Icon(Icons.upload_rounded, color: greenColor),
label: Text(
translate('upload.upload'),
style:
TextStyle(color: buttonForegroundColor),
style: TextStyle(color: buttonForegroundColor),
)),
])),
model.errorMessage != null && model.errorMessage!.isNotEmpty
? (Padding(
padding:
const EdgeInsets.only(top: 10.0, bottom: 10.0),
padding: const EdgeInsets.only(top: 10.0, bottom: 10.0),
child: CenteredErrorRow(model.errorMessage)))
: Container(),
Builder(
@ -181,28 +158,16 @@ class UploadView extends StatelessWidget {
: model.paths != null
? Container(
padding: const EdgeInsets.only(bottom: 30.0),
height:
MediaQuery.of(context).size.height * 0.50,
height: MediaQuery.of(context).size.height * 0.50,
child: ListView.separated(
itemCount: model.paths != null &&
model.paths!.isNotEmpty
? model.paths!.length
: 1,
itemBuilder:
(BuildContext context, int index) {
final bool isMultiPath =
model.paths != null &&
model.paths!.isNotEmpty;
itemCount: model.paths != null && model.paths!.isNotEmpty ? model.paths!.length : 1,
itemBuilder: (BuildContext context, int index) {
final bool isMultiPath = model.paths != null && model.paths!.isNotEmpty;
final String name = (isMultiPath
? model.paths!
.map((e) => e.name)
.toList()[index]
? model.paths!.map((e) => e.name).toList()[index]
: model.fileName ?? '...');
final path = model.paths!.length > 0
? model.paths!
.map((e) => e.path)
.toList()[index]
.toString()
? model.paths!.map((e) => e.path).toList()[index].toString()
: '';
return Card(
@ -213,9 +178,7 @@ class UploadView extends StatelessWidget {
subtitle: Text(path),
));
},
separatorBuilder:
(BuildContext context, int index) =>
const Divider(),
separatorBuilder: (BuildContext context, int index) => const Divider(),
),
)
: Container(),

View file

@ -32,7 +32,6 @@ class _SwipeNavigationState extends State<SwipeNavigation> {
@override
Widget build(BuildContext context) {
return SimpleGestureDetector(
onHorizontalSwipe: _onHorizontalSwipe, child: widget.child!);
return SimpleGestureDetector(onHorizontalSwipe: _onHorizontalSwipe, child: widget.child!);
}
}