mirror of
https://github.com/haorendashu/nowser.git
synced 2025-12-18 02:04:18 +01:00
add some config to project and change come simple ui
This commit is contained in:
@@ -3,6 +3,10 @@ import 'package:nowser/component/webview/web_info.dart';
|
||||
import 'package:nowser/const/base.dart';
|
||||
import 'package:nowser/main.dart';
|
||||
|
||||
import '../../const/router_path.dart';
|
||||
import '../../util/router_util.dart';
|
||||
import 'webview_number_component.dart';
|
||||
|
||||
class WebHomeComponent extends StatefulWidget {
|
||||
WebInfo webInfo;
|
||||
|
||||
@@ -26,19 +30,56 @@ class _WebHomeComponent extends State<WebHomeComponent> {
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(Base.BASE_PADDING),
|
||||
child: Center(
|
||||
child: TextField(
|
||||
controller: textEditingController,
|
||||
decoration: InputDecoration(border: OutlineInputBorder()),
|
||||
onSubmitted: (value) {
|
||||
print("onSubmitted $value");
|
||||
if (value.startsWith("http")) {
|
||||
widget.webInfo.url = value;
|
||||
widget.webInfo.title = null;
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: TextField(
|
||||
controller: textEditingController,
|
||||
decoration: InputDecoration(border: OutlineInputBorder()),
|
||||
onSubmitted: (value) {
|
||||
print("onSubmitted $value");
|
||||
if (value.startsWith("http")) {
|
||||
widget.webInfo.url = value;
|
||||
widget.webInfo.title = null;
|
||||
|
||||
webProvider.updateWebInfo(widget.webInfo);
|
||||
}
|
||||
},
|
||||
webProvider.updateWebInfo(widget.webInfo);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
height: 60,
|
||||
child: Row(
|
||||
children: [
|
||||
wrapBottomBtn(
|
||||
Container(
|
||||
alignment: Alignment.center,
|
||||
child: WebViewNumberComponent(),
|
||||
), onTap: () {
|
||||
RouterUtil.router(context, RouterPath.WEB_TABS);
|
||||
}),
|
||||
wrapBottomBtn(const Icon(Icons.space_dashboard)),
|
||||
wrapBottomBtn(const Icon(Icons.segment)),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget wrapBottomBtn(Widget btn, {Function? onTap}) {
|
||||
return Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
if (onTap != null) {
|
||||
onTap();
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
child: btn,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
27
lib/component/webview/webview_number_component.dart
Normal file
27
lib/component/webview/webview_number_component.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../provider/web_provider.dart';
|
||||
|
||||
class WebViewNumberComponent extends StatefulWidget {
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return _WebViewNumberComponent();
|
||||
}
|
||||
}
|
||||
|
||||
class _WebViewNumberComponent extends State<WebViewNumberComponent> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector<WebProvider, int>(builder: (context, length, child) {
|
||||
return Badge(
|
||||
label: Text("$length"),
|
||||
backgroundColor:
|
||||
Colors.blueAccent, // TODO here should use background color
|
||||
child: Icon(Icons.crop_din),
|
||||
);
|
||||
}, selector: (context, provider) {
|
||||
return provider.webInfos.length;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user