mirror of
https://github.com/haorendashu/nowser.git
synced 2025-12-17 09:54:19 +01:00
change auth dialog to support different type auth task
This commit is contained in:
78
lib/component/auth_dialog/auth_app_connect_dialog.dart
Normal file
78
lib/component/auth_dialog/auth_app_connect_dialog.dart
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:nowser/component/auth_dialog/auth_dialog_base_componnet.dart';
|
||||||
|
import 'package:nowser/const/connect_type.dart';
|
||||||
|
|
||||||
|
import '../../const/base.dart';
|
||||||
|
|
||||||
|
class AuthAppConnectDialog extends StatefulWidget {
|
||||||
|
static void show(BuildContext context) {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return AuthAppConnectDialog();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<StatefulWidget> createState() {
|
||||||
|
return _AuthAppConnectDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AuthAppConnectDialog extends State<AuthAppConnectDialog> {
|
||||||
|
int connectType = ConnectType.REASONABLE;
|
||||||
|
|
||||||
|
bool showDetail = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
var themeData = Theme.of(context);
|
||||||
|
var baseMargin = EdgeInsets.only(
|
||||||
|
top: Base.BASE_PADDING_HALF,
|
||||||
|
bottom: Base.BASE_PADDING_HALF,
|
||||||
|
);
|
||||||
|
var hintColor = themeData.hintColor;
|
||||||
|
|
||||||
|
List<Widget> list = [];
|
||||||
|
|
||||||
|
list.add(RadioListTile(
|
||||||
|
value: ConnectType.FULLY_TRUST,
|
||||||
|
groupValue: connectType,
|
||||||
|
onChanged: onConnectTypeChange,
|
||||||
|
title: Text("I fully trust it"),
|
||||||
|
subtitle: Text("Auto-sign all requests (except payments)"),
|
||||||
|
));
|
||||||
|
|
||||||
|
list.add(RadioListTile(
|
||||||
|
value: ConnectType.REASONABLE,
|
||||||
|
groupValue: connectType,
|
||||||
|
onChanged: onConnectTypeChange,
|
||||||
|
title: Text("Let's be reasonable"),
|
||||||
|
subtitle: Text("Auto-approve most common requests"),
|
||||||
|
));
|
||||||
|
|
||||||
|
list.add(RadioListTile(
|
||||||
|
value: ConnectType.ALWAY_REJECT,
|
||||||
|
groupValue: connectType,
|
||||||
|
onChanged: onConnectTypeChange,
|
||||||
|
title: Text("I'm a bit paranoid"),
|
||||||
|
subtitle: Text("Do not sign anything without asking me!"),
|
||||||
|
));
|
||||||
|
|
||||||
|
var child = Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: list,
|
||||||
|
);
|
||||||
|
|
||||||
|
return AuthDialogBaseComponnet(title: "App Connect", child: child);
|
||||||
|
}
|
||||||
|
|
||||||
|
void onConnectTypeChange(int? value) {
|
||||||
|
if (value != null) {
|
||||||
|
setState(() {
|
||||||
|
connectType = value;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:nowser/const/base.dart';
|
import 'package:nowser/component/auth_dialog/auth_dialog_base_componnet.dart';
|
||||||
|
|
||||||
import '../logo_component.dart';
|
import '../../const/base.dart';
|
||||||
import 'auth_app_info_component.dart';
|
|
||||||
|
|
||||||
class AuthDialog extends StatefulWidget {
|
class AuthDialog extends StatefulWidget {
|
||||||
static void show(BuildContext context) {
|
static void show(BuildContext context) {
|
||||||
@@ -33,56 +32,6 @@ class _AuthDialog extends State<AuthDialog> {
|
|||||||
var hintColor = themeData.hintColor;
|
var hintColor = themeData.hintColor;
|
||||||
|
|
||||||
List<Widget> list = [];
|
List<Widget> list = [];
|
||||||
|
|
||||||
var topWidget = Container(
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
margin: EdgeInsets.only(
|
|
||||||
left: Base.BASE_PADDING,
|
|
||||||
right: Base.BASE_PADDING,
|
|
||||||
top: Base.BASE_PADDING_HALF,
|
|
||||||
bottom: Base.BASE_PADDING_HALF,
|
|
||||||
),
|
|
||||||
child: LogoComponent(),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: Container(
|
|
||||||
margin: EdgeInsets.only(right: Base.BASE_PADDING_HALF),
|
|
||||||
alignment: Alignment.centerRight,
|
|
||||||
child: DropdownButton<String>(
|
|
||||||
items: [
|
|
||||||
DropdownMenuItem(
|
|
||||||
child: Text("npubxxxxxx"),
|
|
||||||
value: "npubxxxxxx",
|
|
||||||
)
|
|
||||||
],
|
|
||||||
onChanged: (Object? value) {},
|
|
||||||
value: "npubxxxxxx",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
list.add(Container(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
margin: baseMargin,
|
|
||||||
child: Text(
|
|
||||||
"Action Title",
|
|
||||||
style: TextStyle(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: themeData.textTheme.bodyLarge!.fontSize,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
));
|
|
||||||
|
|
||||||
list.add(Container(
|
|
||||||
margin: baseMargin,
|
|
||||||
child: AuthAppInfoComponent(),
|
|
||||||
));
|
|
||||||
|
|
||||||
list.add(Container(
|
list.add(Container(
|
||||||
margin: baseMargin,
|
margin: baseMargin,
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -136,58 +85,11 @@ class _AuthDialog extends State<AuthDialog> {
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
list.add(Container(
|
var child = Column(
|
||||||
child: Row(
|
mainAxisSize: MainAxisSize.min,
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
children: list,
|
||||||
children: [
|
|
||||||
// FilledButton(onPressed: () {}, child: Text("Cancel")),
|
|
||||||
// OutlinedButton(
|
|
||||||
// onPressed: () {},
|
|
||||||
// child: Text(
|
|
||||||
// "Cancel",
|
|
||||||
// style: TextStyle(
|
|
||||||
// color: Colors.red,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// style: ,
|
|
||||||
// ),
|
|
||||||
FilledButton(
|
|
||||||
onPressed: () {},
|
|
||||||
child: Text("Cancel"),
|
|
||||||
style: ButtonStyle(
|
|
||||||
backgroundColor: WidgetStateProperty.all(Colors.red),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
margin: EdgeInsets.only(
|
|
||||||
left: Base.BASE_PADDING_HALF,
|
|
||||||
),
|
|
||||||
child: FilledButton(onPressed: () {}, child: Text("Confirm")),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
));
|
|
||||||
|
|
||||||
return Dialog(
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.all(Base.BASE_PADDING),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
border: Border(
|
|
||||||
bottom: BorderSide(color: hintColor.withOpacity(0.3)))),
|
|
||||||
child: topWidget,
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
padding: EdgeInsets.all(Base.BASE_PADDING),
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: list,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return AuthDialogBaseComponnet(title: "Sign Event", child: child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
143
lib/component/auth_dialog/auth_dialog_base_componnet.dart
Normal file
143
lib/component/auth_dialog/auth_dialog_base_componnet.dart
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:nowser/const/base.dart';
|
||||||
|
import 'package:nowser/util/router_util.dart';
|
||||||
|
|
||||||
|
import '../logo_component.dart';
|
||||||
|
import 'auth_app_info_component.dart';
|
||||||
|
|
||||||
|
class AuthDialogBaseComponnet extends StatefulWidget {
|
||||||
|
String title;
|
||||||
|
|
||||||
|
Widget child;
|
||||||
|
|
||||||
|
AuthDialogBaseComponnet({required this.title, required this.child});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<StatefulWidget> createState() {
|
||||||
|
return _AuthDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AuthDialog extends State<AuthDialogBaseComponnet> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
var themeData = Theme.of(context);
|
||||||
|
var baseMargin = EdgeInsets.only(
|
||||||
|
top: Base.BASE_PADDING_HALF,
|
||||||
|
bottom: Base.BASE_PADDING_HALF,
|
||||||
|
);
|
||||||
|
var hintColor = themeData.hintColor;
|
||||||
|
|
||||||
|
List<Widget> list = [];
|
||||||
|
|
||||||
|
var topWidget = Container(
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
margin: EdgeInsets.only(
|
||||||
|
left: Base.BASE_PADDING,
|
||||||
|
right: Base.BASE_PADDING,
|
||||||
|
top: Base.BASE_PADDING_HALF,
|
||||||
|
bottom: Base.BASE_PADDING_HALF,
|
||||||
|
),
|
||||||
|
child: LogoComponent(),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Container(
|
||||||
|
margin: EdgeInsets.only(right: Base.BASE_PADDING_HALF),
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
child: DropdownButton<String>(
|
||||||
|
items: [
|
||||||
|
DropdownMenuItem(
|
||||||
|
child: Text("npubxxxxxx"),
|
||||||
|
value: "npubxxxxxx",
|
||||||
|
)
|
||||||
|
],
|
||||||
|
onChanged: (Object? value) {},
|
||||||
|
value: "npubxxxxxx",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
list.add(Container(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
margin: baseMargin,
|
||||||
|
child: Text(
|
||||||
|
widget.title,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: themeData.textTheme.bodyLarge!.fontSize,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
|
list.add(Container(
|
||||||
|
margin: baseMargin,
|
||||||
|
child: AuthAppInfoComponent(),
|
||||||
|
));
|
||||||
|
|
||||||
|
list.add(Container(
|
||||||
|
margin: baseMargin,
|
||||||
|
child: widget.child,
|
||||||
|
));
|
||||||
|
|
||||||
|
list.add(Container(
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
// FilledButton(onPressed: () {}, child: Text("Cancel")),
|
||||||
|
// OutlinedButton(
|
||||||
|
// onPressed: () {},
|
||||||
|
// child: Text(
|
||||||
|
// "Cancel",
|
||||||
|
// style: TextStyle(
|
||||||
|
// color: Colors.red,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// style: ,
|
||||||
|
// ),
|
||||||
|
FilledButton(
|
||||||
|
onPressed: () {
|
||||||
|
RouterUtil.back(context);
|
||||||
|
},
|
||||||
|
child: Text("Cancel"),
|
||||||
|
style: ButtonStyle(
|
||||||
|
backgroundColor: WidgetStateProperty.all(Colors.red),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
margin: EdgeInsets.only(
|
||||||
|
left: Base.BASE_PADDING_HALF,
|
||||||
|
),
|
||||||
|
child: FilledButton(onPressed: () {}, child: Text("Confirm")),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
|
return Dialog(
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.all(Base.BASE_PADDING),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border(
|
||||||
|
bottom: BorderSide(color: hintColor.withOpacity(0.3)))),
|
||||||
|
child: topWidget,
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.all(Base.BASE_PADDING),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: list,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:nowser/component/auth_dialog/auth_app_connect_dialog.dart';
|
||||||
import 'package:nowser/component/auth_dialog/auth_dialog.dart';
|
import 'package:nowser/component/auth_dialog/auth_dialog.dart';
|
||||||
|
import 'package:nowser/component/auth_dialog/auth_dialog_base_componnet.dart';
|
||||||
import 'package:nowser/component/webview/web_info.dart';
|
import 'package:nowser/component/webview/web_info.dart';
|
||||||
import 'package:nowser/const/base.dart';
|
import 'package:nowser/const/base.dart';
|
||||||
import 'package:nowser/main.dart';
|
import 'package:nowser/main.dart';
|
||||||
@@ -63,6 +65,7 @@ class _WebHomeComponent extends State<WebHomeComponent> {
|
|||||||
}),
|
}),
|
||||||
wrapBottomBtn(const Icon(Icons.space_dashboard), onTap: () {
|
wrapBottomBtn(const Icon(Icons.space_dashboard), onTap: () {
|
||||||
AuthDialog.show(context);
|
AuthDialog.show(context);
|
||||||
|
// AuthAppConnectDialog.show(context);
|
||||||
}),
|
}),
|
||||||
wrapBottomBtn(const Icon(Icons.segment), onTap: () {
|
wrapBottomBtn(const Icon(Icons.segment), onTap: () {
|
||||||
// AuthDialog.show(context);
|
// AuthDialog.show(context);
|
||||||
|
|||||||
7
lib/const/connect_type.dart
Normal file
7
lib/const/connect_type.dart
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
class ConnectType {
|
||||||
|
static const int FULLY_TRUST = 1;
|
||||||
|
|
||||||
|
static const int REASONABLE = 2;
|
||||||
|
|
||||||
|
static const int ALWAY_REJECT = 3;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user