TF-265 Remove prefix https:// in url login form
This commit is contained in:
@@ -13,4 +13,16 @@ extension URLExtension on String {
|
||||
return '$prefixUrlHttps${this}';
|
||||
}
|
||||
}
|
||||
|
||||
String removePrefix() {
|
||||
if (startsWith(prefixUrlHttps)) {
|
||||
return replaceAll(prefixUrlHttps, '');
|
||||
} else if (startsWith(prefixUrlHttp)) {
|
||||
return replaceAll(prefixUrlHttp, '');
|
||||
} else {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
bool isValid() => startsWith(prefixUrlHttps) || startsWith(prefixUrlHttp);
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:core/core.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:model/model.dart';
|
||||
@@ -16,6 +17,8 @@ class LoginController extends GetxController {
|
||||
final DynamicUrlInterceptors _dynamicUrlInterceptors;
|
||||
final AuthorizationInterceptors _authorizationInterceptors;
|
||||
|
||||
final TextEditingController urlInputController = TextEditingController();
|
||||
|
||||
LoginController(
|
||||
this._authenticationInteractor,
|
||||
this._dynamicUrlInterceptors,
|
||||
@@ -69,4 +72,17 @@ class LoginController extends GetxController {
|
||||
void _loginFailureAction(AuthenticationUserFailure failure) {
|
||||
loginState.value = LoginState(Left(failure));
|
||||
}
|
||||
|
||||
void formatUrl(String url) {
|
||||
if (url.isValid()) {
|
||||
urlInputController.text = url.removePrefix();
|
||||
}
|
||||
setUrlText(urlInputController.text);
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
urlInputController.dispose();
|
||||
super.onClose();
|
||||
}
|
||||
}
|
||||
@@ -93,8 +93,9 @@ class LoginView extends GetWidget<LoginController> {
|
||||
width: responsiveUtils.getWidthLoginTextField(context),
|
||||
child: (TextFieldBuilder()
|
||||
..key(Key('login_url_input'))
|
||||
..onChange((value) => loginController.setUrlText(value))
|
||||
..onChange((value) => loginController.formatUrl(value))
|
||||
..textInputAction(TextInputAction.next)
|
||||
..addController(loginController.urlInputController)
|
||||
..keyboardType(TextInputType.url)
|
||||
..textDecoration((LoginInputDecorationBuilder()
|
||||
..setLabelText(AppLocalizations.of(context).prefix_https)
|
||||
|
||||
Reference in New Issue
Block a user