mirror of
https://github.com/haorendashu/nowser.git
synced 2025-12-17 18:04:18 +01:00
url input page
This commit is contained in:
@@ -5,6 +5,7 @@ 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';
|
||||||
|
import 'package:nowser/router/web_url_input/web_url_input_router.dart';
|
||||||
|
|
||||||
import '../../const/router_path.dart';
|
import '../../const/router_path.dart';
|
||||||
import '../../util/router_util.dart';
|
import '../../util/router_util.dart';
|
||||||
@@ -27,7 +28,7 @@ class _WebHomeComponent extends State<WebHomeComponent> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
textEditingController.text = "https://nostr.build/login/";
|
// textEditingController.text = "https://nostr.build/login/";
|
||||||
// textEditingController.text = "https://web.nostrmo.com/";
|
// textEditingController.text = "https://web.nostrmo.com/";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,12 +40,20 @@ class _WebHomeComponent extends State<WebHomeComponent> {
|
|||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Center(
|
child: Center(
|
||||||
|
child: Hero(
|
||||||
|
tag: "urlInput",
|
||||||
|
child: Material(
|
||||||
child: TextField(
|
child: TextField(
|
||||||
controller: textEditingController,
|
controller: textEditingController,
|
||||||
decoration: InputDecoration(border: OutlineInputBorder()),
|
decoration:
|
||||||
onSubmitted: (value) {
|
const InputDecoration(border: OutlineInputBorder()),
|
||||||
print("onSubmitted $value");
|
readOnly: true,
|
||||||
if (value.startsWith("http")) {
|
onTap: () async {
|
||||||
|
var value = await RouterUtil.router(
|
||||||
|
context, RouterPath.WEB_URL_INPUT);
|
||||||
|
if (value != null &&
|
||||||
|
value is String &&
|
||||||
|
value.startsWith("http")) {
|
||||||
widget.webInfo.url = value;
|
widget.webInfo.url = value;
|
||||||
widget.webInfo.title = null;
|
widget.webInfo.title = null;
|
||||||
|
|
||||||
@@ -54,6 +63,8 @@ class _WebHomeComponent extends State<WebHomeComponent> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
Container(
|
Container(
|
||||||
height: 60,
|
height: 60,
|
||||||
child: Row(
|
child: Row(
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
class RouterPath {
|
class RouterPath {
|
||||||
static const String INDEX = "/";
|
static const String INDEX = "/";
|
||||||
static const String WEB_TABS = "/webTabs";
|
static const String WEB_TABS = "/webTabs";
|
||||||
|
static const String WEB_URL_INPUT = "/webUrlInput";
|
||||||
static const String ME = "/me";
|
static const String ME = "/me";
|
||||||
static const String KEYS = "/keys";
|
static const String KEYS = "/keys";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import 'package:nowser/router/index/index_router.dart';
|
|||||||
import 'package:nowser/router/keys/keys_router.dart';
|
import 'package:nowser/router/keys/keys_router.dart';
|
||||||
import 'package:nowser/router/me/me_router.dart';
|
import 'package:nowser/router/me/me_router.dart';
|
||||||
import 'package:nowser/router/web_tabs_select/web_tabs_select_router.dart';
|
import 'package:nowser/router/web_tabs_select/web_tabs_select_router.dart';
|
||||||
|
import 'package:nowser/router/web_url_input/web_url_input_router.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:receive_intent/receive_intent.dart' as receiveIntent;
|
import 'package:receive_intent/receive_intent.dart' as receiveIntent;
|
||||||
|
|
||||||
@@ -88,6 +89,7 @@ class _MyApp extends State<MyApp> {
|
|||||||
routes = {
|
routes = {
|
||||||
RouterPath.INDEX: (context) => IndexRouter(),
|
RouterPath.INDEX: (context) => IndexRouter(),
|
||||||
RouterPath.WEB_TABS: (context) => WebTabsSelectRouter(),
|
RouterPath.WEB_TABS: (context) => WebTabsSelectRouter(),
|
||||||
|
RouterPath.WEB_URL_INPUT: (context) => WebUrlInputRouter(),
|
||||||
RouterPath.ME: (context) => MeRouter(),
|
RouterPath.ME: (context) => MeRouter(),
|
||||||
RouterPath.KEYS: (context) => KeysRouter(),
|
RouterPath.KEYS: (context) => KeysRouter(),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
||||||
import 'package:nostr_sdk/utils/string_util.dart';
|
import 'package:nostr_sdk/utils/string_util.dart';
|
||||||
import 'package:nowser/component/webview/web_info.dart';
|
import 'package:nowser/component/webview/web_info.dart';
|
||||||
import 'package:nowser/component/webview/webview_component.dart';
|
import 'package:nowser/component/webview/webview_component.dart';
|
||||||
@@ -80,6 +81,33 @@ class _IndexWebComponent extends State<IndexWebComponent> {
|
|||||||
RouterUtil.router(context, RouterPath.WEB_TABS);
|
RouterUtil.router(context, RouterPath.WEB_TABS);
|
||||||
}),
|
}),
|
||||||
Expanded(
|
Expanded(
|
||||||
|
child: Hero(
|
||||||
|
tag: "urlInput",
|
||||||
|
child: Material(
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: () async {
|
||||||
|
if (webInfo.controller == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var url = await webInfo.controller!.getUrl();
|
||||||
|
var value = await RouterUtil.router(context,
|
||||||
|
RouterPath.WEB_URL_INPUT, url.toString());
|
||||||
|
if (value != null &&
|
||||||
|
value is String &&
|
||||||
|
value.startsWith("http")) {
|
||||||
|
webInfo.url = value;
|
||||||
|
webInfo.title = null;
|
||||||
|
|
||||||
|
if (webInfo.controller != null) {
|
||||||
|
webInfo.controller!.loadUrl(
|
||||||
|
urlRequest: URLRequest(
|
||||||
|
url: WebUri(value),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
behavior: HitTestBehavior.translucent,
|
||||||
child: Container(
|
child: Container(
|
||||||
margin: const EdgeInsets.only(
|
margin: const EdgeInsets.only(
|
||||||
left: 8,
|
left: 8,
|
||||||
@@ -87,8 +115,8 @@ class _IndexWebComponent extends State<IndexWebComponent> {
|
|||||||
),
|
),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border.all(),
|
border: Border.all(),
|
||||||
borderRadius:
|
borderRadius: BorderRadius.circular(
|
||||||
BorderRadius.circular(Base.BASE_PADDING_HALF),
|
Base.BASE_PADDING_HALF),
|
||||||
),
|
),
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
left: Base.BASE_PADDING,
|
left: Base.BASE_PADDING,
|
||||||
@@ -102,7 +130,11 @@ class _IndexWebComponent extends State<IndexWebComponent> {
|
|||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
)),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
wrapBottomBtn(const Icon(Icons.space_dashboard),
|
wrapBottomBtn(const Icon(Icons.space_dashboard),
|
||||||
left: 8, right: 8),
|
left: 8, right: 8),
|
||||||
wrapBottomBtn(const Icon(Icons.segment), left: 8, right: 13,
|
wrapBottomBtn(const Icon(Icons.segment), left: 8, right: 13,
|
||||||
|
|||||||
58
lib/router/web_url_input/web_url_input_router.dart
Normal file
58
lib/router/web_url_input/web_url_input_router.dart
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:nowser/util/router_util.dart';
|
||||||
|
|
||||||
|
import '../../const/base.dart';
|
||||||
|
|
||||||
|
class WebUrlInputRouter extends StatefulWidget {
|
||||||
|
@override
|
||||||
|
State<StatefulWidget> createState() {
|
||||||
|
return _WebUrlInputRouter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _WebUrlInputRouter extends State<WebUrlInputRouter> {
|
||||||
|
TextEditingController textEditingController = TextEditingController();
|
||||||
|
|
||||||
|
String? url;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
if (url == null) {
|
||||||
|
var arg = RouterUtil.routerArgs(context);
|
||||||
|
if (arg != null && arg is String) {
|
||||||
|
url = arg;
|
||||||
|
textEditingController.text = arg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Widget> list = [];
|
||||||
|
|
||||||
|
var inputWidget = Hero(
|
||||||
|
tag: "urlInput",
|
||||||
|
child: Material(
|
||||||
|
child: TextField(
|
||||||
|
controller: textEditingController,
|
||||||
|
decoration: const InputDecoration(border: OutlineInputBorder()),
|
||||||
|
autofocus: true,
|
||||||
|
onSubmitted: (value) {
|
||||||
|
RouterUtil.back(context, value);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
list.add(Expanded(child: Container()));
|
||||||
|
list.add(Container(
|
||||||
|
padding: const EdgeInsets.all(Base.BASE_PADDING),
|
||||||
|
child: inputWidget,
|
||||||
|
));
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
body: Container(
|
||||||
|
child: Column(
|
||||||
|
children: list,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user