mirror of
https://github.com/foss42/apidash.git
synced 2025-12-06 04:56:16 +08:00
Update basic_auth_fields.dart
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import 'package:apidash/widgets/auth_textfield.dart';
|
import 'package:apidash/widgets/auth_textfield.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:apidash_core/apidash_core.dart';
|
import 'package:apidash_core/apidash_core.dart';
|
||||||
|
import 'consts.dart';
|
||||||
|
|
||||||
class BasicAuthFields extends StatelessWidget {
|
class BasicAuthFields extends StatelessWidget {
|
||||||
final AuthModel? authData;
|
final AuthModel? authData;
|
||||||
@@ -28,7 +29,7 @@ class BasicAuthFields extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
AuthTextField(
|
AuthTextField(
|
||||||
readOnly: readOnly,
|
readOnly: readOnly,
|
||||||
hintText: "Username",
|
hintText: kHintUsername,
|
||||||
controller: usernameController,
|
controller: usernameController,
|
||||||
onChanged: (_) => _updateBasicAuth(
|
onChanged: (_) => _updateBasicAuth(
|
||||||
usernameController,
|
usernameController,
|
||||||
@@ -38,7 +39,7 @@ class BasicAuthFields extends StatelessWidget {
|
|||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
AuthTextField(
|
AuthTextField(
|
||||||
readOnly: readOnly,
|
readOnly: readOnly,
|
||||||
hintText: "Password",
|
hintText: kHintPassword,
|
||||||
isObscureText: true,
|
isObscureText: true,
|
||||||
controller: passwordController,
|
controller: passwordController,
|
||||||
onChanged: (_) => _updateBasicAuth(
|
onChanged: (_) => _updateBasicAuth(
|
||||||
@@ -54,20 +55,17 @@ class BasicAuthFields extends StatelessWidget {
|
|||||||
TextEditingController usernameController,
|
TextEditingController usernameController,
|
||||||
TextEditingController passwordController,
|
TextEditingController passwordController,
|
||||||
) {
|
) {
|
||||||
updateAuth(
|
final basicAuth = AuthBasicAuthModel(
|
||||||
authData?.copyWith(
|
username: usernameController.text.trim(),
|
||||||
type: APIAuthType.basic,
|
password: passwordController.text.trim(),
|
||||||
basic: AuthBasicAuthModel(
|
|
||||||
username: usernameController.text.trim(),
|
|
||||||
password: passwordController.text.trim(),
|
|
||||||
),
|
|
||||||
) ?? AuthModel(
|
|
||||||
type: APIAuthType.basic,
|
|
||||||
basic: AuthBasicAuthModel(
|
|
||||||
username: usernameController.text.trim(),
|
|
||||||
password: passwordController.text.trim(),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
updateAuth(authData?.copyWith(
|
||||||
|
type: APIAuthType.basic,
|
||||||
|
basic: basicAuth,
|
||||||
|
) ??
|
||||||
|
AuthModel(
|
||||||
|
type: APIAuthType.basic,
|
||||||
|
basic: basicAuth,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user