Skip to content

Commit

Permalink
add: dialog and devtools_options
Browse files Browse the repository at this point in the history
  • Loading branch information
harljo committed Apr 10, 2024
1 parent fc24d40 commit 9172d6f
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 127 deletions.
1 change: 1 addition & 0 deletions devtools_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extensions:
221 changes: 94 additions & 127 deletions lib/settings/_account.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:quacker/client/client.dart';
import 'package:quacker/constants.dart';
Expand All @@ -13,141 +15,106 @@ class SettingsAccountFragment extends StatefulWidget {
}

class _SettingsAccountFragment extends State<SettingsAccountFragment> {
var multiFactorController = TextEditingController();
bool hidePassword = true;

@override
Widget build(BuildContext context) {
var model = context.read<WebFlowAuthModel>();
return Scaffold(
appBar: AppBar(title: Text(L10n.current.account)),
body: Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
child: ListView(children: [
Row(
children: [
Flexible(
child: PrefLabel(
title: Text(L10n.of(context).loginNameTwitterAcc),
),
),
Flexible(
child: PrefText(
label: '',
pref: optionLoginNameTwitterAcc,
//style: const TextStyle(fontSize: 16,height:1),
decoration: InputDecoration(
contentPadding: EdgeInsets.fromLTRB(3, 0, 16, 3),
isDense: true,
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(width: 1, color: Theme.of(context).colorScheme.primary),
),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(width: 1, color: Theme.of(context).colorScheme.primary),
),
),
),
),
],
),
Row(
children: [
Flexible(
child: PrefLabel(
title: Text(L10n.of(context).passwordTwitterAcc),
),
),
Flexible(
child: PrefText(
obscureText: hidePassword,
label: '',
pref: optionPasswordTwitterAcc,
//style: const TextStyle(fontSize: 16,height:1),
decoration: InputDecoration(
contentPadding: EdgeInsets.fromLTRB(3, 0, 16, 3),
isDense: true,
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(width: 1, color: Theme.of(context).colorScheme.primary),
),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(width: 1, color: Theme.of(context).colorScheme.primary),
),
suffix: InkWell(
onTap: () => setState(() => hidePassword = !hidePassword),
child: Icon(
hidePassword ? Icons.visibility : Icons.visibility_off,
),
),
),
),
),
],
appBar: AppBar(
title: Text(L10n.current.account),
actions: [
IconButton(
onPressed: () => showDialog(context: context, builder: (_) => addDialog(model)),
icon: const Icon(Icons.add))
],
),
);
}
}

class addDialog extends StatefulWidget {
final WebFlowAuthModel model;

const addDialog(this.model, {super.key});

@override
State<addDialog> createState() => _addDialog();
}

class _addDialog extends State<addDialog> {
bool hidePassword = true;
var multiFactorController = TextEditingController();

Widget build(BuildContext context) {
return AlertDialog(
title: Text(L10n.of(context).account),
content: Column(mainAxisSize: MainAxisSize.min, children: [
Flexible(
child: PrefText(
pref: optionLoginNameTwitterAcc,
decoration:
InputDecoration(label: Text(L10n.of(context).loginNameTwitterAcc), border: const OutlineInputBorder()),
),
Row(
children: [
Flexible(
child: PrefLabel(
title: Text(L10n.of(context).emailTwitterAcc),
),
),
Flexible(
child: PrefText(
label: '',
pref: optionEmailTwitterAcc,
//style: const TextStyle(fontSize: 16,height:1),
decoration: InputDecoration(
contentPadding: EdgeInsets.fromLTRB(3, 0, 16, 3),
isDense: true,
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(width: 1, color: Theme.of(context).colorScheme.primary),
),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(width: 1, color: Theme.of(context).colorScheme.primary),
),
),
),
),
Flexible(
child: PrefText(
obscureText: hidePassword,
pref: optionPasswordTwitterAcc,
decoration: InputDecoration(
label: Text(L10n.of(context).passwordTwitterAcc),
border: const OutlineInputBorder(),
suffix: IconButton(
icon: Icon(hidePassword ? Icons.visibility : Icons.visibility_off),
onPressed: () => setState(() => hidePassword = !hidePassword),
),
],
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
FilledButton(
onPressed: () async {
try {
final _authHeader = await model.GetAuthHeader(userAgentHeader);

if (context.mounted) {
showSnackBar(context, icon: '✅', message: L10n.of(context).login_success);
}
} catch (e) {
if (context.mounted) {
showSnackBar(context, icon: '🙅', message: e.toString().substring(22).replaceAll('\n', ''));
}
}
},
child: Text(L10n.of(context).login)),
SizedBox(
width: 10,
),
OutlinedButton(
onPressed: () async {
await model.DeleteAllCookies();
if (context.mounted) {
showSnackBar(context, icon: '🍪', message: L10n.current.twitterCookiesDeleted);
}
},
child: Text(L10n.of(context).DeleteTwitterCookies))
],
),
Flexible(
child: PrefText(
keyboardType: TextInputType.emailAddress,
pref: optionEmailTwitterAcc,
decoration:
InputDecoration(label: Text(L10n.of(context).emailTwitterAcc), border: const OutlineInputBorder()),
),
Padding(
padding: EdgeInsets.all(8.0),
child: Text(
"⚠️ 2FA is currently not supported ⚠️",
textAlign: TextAlign.center,
)),
]),
),
),
const Padding(
padding: EdgeInsets.all(8.0),
child: Text(
"⚠️ 2FA is currently not supported ⚠️",
textAlign: TextAlign.center,
)),
]),
actionsAlignment: MainAxisAlignment.center,
actions: [
FilledButton(
onPressed: () async {
try {
await widget.model.GetAuthHeader(userAgentHeader);
Navigator.pop(context);
sleep(Durations.medium1);
if (context.mounted) {
showSnackBar(context, icon: '✅', message: L10n.of(context).login_success);
}
} catch (e) {
Navigator.pop(context);
sleep(Durations.medium1);
if (context.mounted) {
showSnackBar(context, icon: '🙅', message: e.toString().substring(22).replaceAll('\n', ''));
}
}
},
child: Text(L10n.of(context).login)),
OutlinedButton(
onPressed: () async {
await widget.model.DeleteAllCookies();
Navigator.pop(context);
sleep(Durations.medium1);
if (context.mounted) {
showSnackBar(context, icon: '🍪', message: L10n.current.twitterCookiesDeleted);
}
},
child: Text(L10n.of(context).DeleteTwitterCookies))
],
);
}
}

0 comments on commit 9172d6f

Please sign in to comment.