feat: fav note page

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-03-28 21:25:39 +08:00
parent da3f64feab
commit cc774015f9
15 changed files with 487 additions and 91 deletions

View File

@@ -725,5 +725,13 @@ class Api {
static const String pgcIndexResult = '/pgc/season/index/result'; static const String pgcIndexResult = '/pgc/season/index/result';
static const String noteList = '/x/note/publish/list/archive'; static const String archiveNoteList = '/x/note/publish/list/archive';
static const String noteList = '/x/note/list';
static const String userNoteList = '/x/note/publish/list/user';
static const String addNote = '/x/note/add';
static const String archiveNote = '/x/note/list/archive';
} }

View File

@@ -272,9 +272,11 @@ class Request {
static String headerUa({type = 'mob'}) { static String headerUa({type = 'mob'}) {
return type == 'mob' return type == 'mob'
? Platform.isIOS ? Platform.isIOS
? 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1 Mobile/15E148 Safari/604.1' ? 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1 Mobile/15E148 BiliApp/62000200'
: 'Mozilla/5.0 (Linux; Android 10; SM-G975F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.101 Mobile Safari/537.36' : 'Mozilla/5.0 (Linux; Android 10; SM-G975F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.101 Mobile Safari/537.36'
: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15'; : type == 'ios'
? 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1 Mobile/15E148 BiliApp/62000200'
: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15';
} }
static String responseDecoder(List<int> responseBytes, RequestOptions options, static String responseDecoder(List<int> responseBytes, RequestOptions options,

View File

@@ -1074,7 +1074,7 @@ class VideoHttp {
required int page, required int page,
}) async { }) async {
var res = await Request().get( var res = await Request().get(
Api.noteList, Api.archiveNoteList,
queryParameters: { queryParameters: {
'csrf': Accounts.main.csrf, 'csrf': Accounts.main.csrf,
'oid': oid, 'oid': oid,
@@ -1090,4 +1090,88 @@ class VideoHttp {
return LoadingState.error(res.data['message']); return LoadingState.error(res.data['message']);
} }
} }
static Future<LoadingState> noteList({
required int page,
}) async {
var res = await Request().get(
Api.noteList,
queryParameters: {
'pn': page,
'ps': 10,
'csrf': Accounts.main.csrf,
},
);
if (res.data['code'] == 0) {
return LoadingState.success(res.data['data']?['list']);
} else {
return LoadingState.error(res.data['message']);
}
}
static Future<LoadingState> userNoteList({
required int page,
}) async {
var res = await Request().get(
Api.userNoteList,
queryParameters: {
'pn': page,
'ps': 10,
'csrf': Accounts.main.csrf,
},
);
if (res.data['code'] == 0) {
return LoadingState.success(res.data['data']?['list']);
} else {
return LoadingState.error(res.data['message']);
}
}
static Future<LoadingState> addNote({
required oid,
required String title,
required String summary,
}) async {
String noteId = '';
try {
final res = await Request().get(Api.archiveNote, queryParameters: {
'oid': oid,
'oid_type': 0,
'csrf': Accounts.main.csrf,
});
if (res.data['code'] == 0) {
if (res.data['data']['noteIds'] != null) {
noteId = res.data['data']['noteIds'].first;
}
}
} catch (_) {}
var res = await Request().post(
Api.addNote,
data: {
'cont_len': summary.length,
'note_id': noteId,
'oid': oid,
'oid_type': 0,
'platform': 'web',
'title': title,
'summary': summary,
'content': jsonEncode([
{"insert": summary},
]),
'from': 'close',
'hash': DateTime.now().millisecondsSinceEpoch,
'tags': '',
'csrf': Accounts.main.csrf,
},
options: Options(
contentType: Headers.formUrlEncodedContentType,
),
);
if (res.data['code'] == 0) {
return LoadingState.success(res.data['data']?['list']);
} else {
return LoadingState.error(res.data['message']);
}
}
} }

View File

@@ -59,18 +59,19 @@ abstract class CommonController extends GetxController
LoadingState response = await customGetData(); LoadingState response = await customGetData();
if (response is Success) { if (response is Success) {
if (!customHandleResponse(response)) { if (!customHandleResponse(response)) {
if ((response.response as List?).isNullOrEmpty) { List dataList = (response.response as List?) ?? [];
if (dataList.isEmpty) {
isEnd = true; isEnd = true;
} }
List currentList = loadingState.value is Success List currentList = loadingState.value is Success
? (loadingState.value as Success).response ? (loadingState.value as Success).response
: []; : [];
List? handleList = handleListResponse(currentList, response.response); List? handleList = handleListResponse(currentList, dataList);
loadingState.value = isRefresh loadingState.value = isRefresh
? handleList != null ? handleList != null
? LoadingState.success(handleList) ? LoadingState.success(handleList)
: response : response
: LoadingState.success(currentList + response.response); : LoadingState.success(currentList + dataList);
// handleSuccess(currentList, response.response); // handleSuccess(currentList, response.response);
} }
currentPage++; currentPage++;

View File

@@ -0,0 +1,85 @@
import 'package:PiliPlus/common/constants.dart';
import 'package:PiliPlus/common/skeleton/video_card_h.dart';
import 'package:PiliPlus/common/widgets/http_error.dart';
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/pages/fav/note/controller.dart';
import 'package:PiliPlus/pages/fav/note/widget/item.dart';
import 'package:PiliPlus/utils/grid.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class FavNoteChildPage extends StatefulWidget {
const FavNoteChildPage({super.key, required this.isPublish});
final bool isPublish;
@override
State<FavNoteChildPage> createState() => _FavNoteChildPageState();
}
class _FavNoteChildPageState extends State<FavNoteChildPage>
with AutomaticKeepAliveClientMixin {
late final FavNoteController _favNoteController =
Get.put(FavNoteController(widget.isPublish), tag: '${widget.isPublish}');
@override
Widget build(BuildContext context) {
super.build(context);
return refreshIndicator(
onRefresh: () async {
await _favNoteController.onRefresh();
},
child: CustomScrollView(
slivers: [
Obx(() => _buildBody(_favNoteController.loadingState.value)),
],
),
);
}
Widget _buildBody(LoadingState loadingState) {
return switch (loadingState) {
Loading() => SliverGrid(
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
mainAxisSpacing: 2,
maxCrossAxisExtent: Grid.mediumCardWidth * 2,
childAspectRatio: StyleString.aspectRatio * 2.2,
),
delegate: SliverChildBuilderDelegate(
(context, index) {
return const VideoCardHSkeleton();
},
childCount: 10,
),
),
Success() => (loadingState.response as List?)?.isNotEmpty == true
? SliverPadding(
padding: EdgeInsets.only(
bottom: MediaQuery.paddingOf(context).bottom + 80),
sliver: SliverGrid(
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
mainAxisSpacing: 2,
maxCrossAxisExtent: Grid.mediumCardWidth * 2,
childAspectRatio: StyleString.aspectRatio * 2.7,
),
delegate: SliverChildBuilderDelegate(
(context, index) {
return FavNoteItem(item: loadingState.response[index]);
},
childCount: loadingState.response.length,
),
),
)
: HttpError(callback: _favNoteController.onReload),
Error() => HttpError(
errMsg: loadingState.errMsg,
callback: _favNoteController.onReload,
),
LoadingState() => throw UnimplementedError(),
};
}
@override
bool get wantKeepAlive => true;
}

View File

@@ -0,0 +1,22 @@
import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/http/video.dart';
import 'package:PiliPlus/pages/common/multi_select_controller.dart';
class FavNoteController extends MultiSelectController {
FavNoteController(this.isPublish);
final bool isPublish;
@override
void onInit() {
super.onInit();
queryData();
}
@override
Future<LoadingState> customGetData() {
return isPublish
? VideoHttp.userNoteList(page: currentPage)
: VideoHttp.noteList(page: currentPage);
}
}

View File

@@ -0,0 +1,87 @@
import 'package:PiliPlus/pages/fav/note/child_view.dart';
import 'package:flutter/material.dart';
class FavNotePage extends StatefulWidget {
const FavNotePage({super.key});
@override
State<FavNotePage> createState() => _FavNotePageState();
}
class _FavNotePageState extends State<FavNotePage>
with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin {
late final TabController _tabController =
TabController(length: 2, vsync: this);
@override
bool get wantKeepAlive => true;
@override
void dispose() {
_tabController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
super.build(context);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: TabBar(
overlayColor: WidgetStateProperty.all(Colors.transparent),
splashFactory: NoSplash.splashFactory,
isScrollable: true,
tabAlignment: TabAlignment.start,
controller: _tabController,
padding: const EdgeInsets.symmetric(horizontal: 8),
dividerHeight: 0,
indicatorWeight: 0,
indicatorPadding:
const EdgeInsets.symmetric(horizontal: 3, vertical: 8),
indicator: BoxDecoration(
color: Theme.of(context).colorScheme.secondaryContainer,
borderRadius: BorderRadius.circular(20),
),
indicatorSize: TabBarIndicatorSize.tab,
labelStyle: TabBarTheme.of(context)
.labelStyle
?.copyWith(fontSize: 14) ??
const TextStyle(fontSize: 14),
labelColor: Theme.of(context).colorScheme.onSecondaryContainer,
unselectedLabelColor: Theme.of(context).colorScheme.outline,
tabs: [
Tab(text: '未发布笔记'),
Tab(text: '公开笔记'),
],
),
),
TextButton(
style: TextButton.styleFrom(
foregroundColor: Theme.of(context).colorScheme.onSurfaceVariant,
visualDensity: VisualDensity(horizontal: -2, vertical: -2),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
onPressed: () {},
child: const Text('管理'),
),
const SizedBox(width: 12),
],
),
Expanded(
child: TabBarView(
controller: _tabController,
physics: const NeverScrollableScrollPhysics(),
children: [
FavNoteChildPage(isPublish: false),
FavNoteChildPage(isPublish: true),
],
),
),
],
);
}
}

View File

@@ -0,0 +1,84 @@
import 'package:PiliPlus/common/constants.dart';
import 'package:PiliPlus/common/widgets/network_img_layer.dart';
import 'package:PiliPlus/utils/utils.dart';
import 'package:flutter/material.dart';
class FavNoteItem extends StatelessWidget {
const FavNoteItem({super.key, required this.item});
final dynamic item;
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
Utils.handleWebview(item['web_url'], inApp: true);
},
onLongPress: () {},
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: StyleString.safeSpace,
vertical: 5,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Text(
item['title'],
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
height: 1.4,
fontSize: 14,
fontWeight: FontWeight.bold,
),
),
),
const SizedBox(height: 1),
Text(
item['summary'],
maxLines: 1,
style: TextStyle(
color: Theme.of(context).colorScheme.outline,
),
),
const SizedBox(height: 1),
Text(
item['message'],
maxLines: 1,
style: TextStyle(
color: Theme.of(context).colorScheme.outline,
),
),
],
),
),
if (item['arc']?['pic'] != null) ...[
const SizedBox(width: 10),
AspectRatio(
aspectRatio: StyleString.aspectRatio,
child: LayoutBuilder(
builder:
(BuildContext context, BoxConstraints boxConstraints) {
return NetworkImgLayer(
src: item['arc']?['pic'],
width: boxConstraints.maxWidth,
height: boxConstraints.maxHeight,
);
},
),
),
],
],
),
),
);
}
}

View File

@@ -18,11 +18,16 @@ class FavVideoPage extends StatefulWidget {
State<FavVideoPage> createState() => _FavVideoPageState(); State<FavVideoPage> createState() => _FavVideoPageState();
} }
class _FavVideoPageState extends State<FavVideoPage> { class _FavVideoPageState extends State<FavVideoPage>
with AutomaticKeepAliveClientMixin {
final FavController _favController = Get.find<FavController>(); final FavController _favController = Get.find<FavController>();
@override
bool get wantKeepAlive => true;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
super.build(context);
return refreshIndicator( return refreshIndicator(
onRefresh: () async { onRefresh: () async {
await _favController.onRefresh(); await _favController.onRefresh();

View File

@@ -1,4 +1,5 @@
import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/pages/fav/note/view.dart';
import 'package:PiliPlus/pages/fav/video/index.dart'; import 'package:PiliPlus/pages/fav/video/index.dart';
import 'package:PiliPlus/pages/fav_search/view.dart'; import 'package:PiliPlus/pages/fav_search/view.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -95,7 +96,7 @@ class _FavPageState extends State<FavPage> with SingleTickerProviderStateMixin {
_FavType.bangumi => Center(child: Text(item.title)), _FavType.bangumi => Center(child: Text(item.title)),
_FavType.cinema => Center(child: Text(item.title)), _FavType.cinema => Center(child: Text(item.title)),
_FavType.article => Center(child: Text(item.title)), _FavType.article => Center(child: Text(item.title)),
_FavType.note => Center(child: Text(item.title)), _FavType.note => const FavNotePage(),
}, },
) )
.toList(), .toList(),

View File

@@ -43,38 +43,29 @@ class _MemberContributeState extends State<MemberContribute>
return _controller.tabs != null return _controller.tabs != null
? Column( ? Column(
children: [ children: [
Container( TabBar(
width: double.infinity, overlayColor: WidgetStateProperty.all(Colors.transparent),
color: Theme.of(context).colorScheme.surface, splashFactory: NoSplash.splashFactory,
child: Theme( padding: const EdgeInsets.symmetric(horizontal: 8),
data: ThemeData( isScrollable: true,
splashColor: Colors.transparent, tabs: _controller.tabs!,
highlightColor: Colors.transparent, tabAlignment: TabAlignment.start,
), controller: _controller.tabController,
child: TabBar( dividerHeight: 0,
padding: const EdgeInsets.symmetric(horizontal: 8), indicatorWeight: 0,
isScrollable: true, indicatorPadding:
tabs: _controller.tabs!, const EdgeInsets.symmetric(horizontal: 3, vertical: 8),
tabAlignment: TabAlignment.start, indicator: BoxDecoration(
controller: _controller.tabController, color: Theme.of(context).colorScheme.secondaryContainer,
dividerHeight: 0, borderRadius: BorderRadius.circular(20),
indicatorWeight: 0,
indicatorPadding:
const EdgeInsets.symmetric(horizontal: 3, vertical: 8),
indicator: BoxDecoration(
color: Theme.of(context).colorScheme.secondaryContainer,
borderRadius: BorderRadius.circular(20),
),
indicatorSize: TabBarIndicatorSize.tab,
labelStyle: TabBarTheme.of(context)
.labelStyle
?.copyWith(fontSize: 14) ??
const TextStyle(fontSize: 14),
labelColor:
Theme.of(context).colorScheme.onSecondaryContainer,
unselectedLabelColor: Theme.of(context).colorScheme.outline,
),
), ),
indicatorSize: TabBarIndicatorSize.tab,
labelStyle: TabBarTheme.of(context)
.labelStyle
?.copyWith(fontSize: 14) ??
const TextStyle(fontSize: 14),
labelColor: Theme.of(context).colorScheme.onSecondaryContainer,
unselectedLabelColor: Theme.of(context).colorScheme.outline,
), ),
Expanded( Expanded(
child: TabBarView( child: TabBarView(

View File

@@ -86,56 +86,49 @@ class _SearchResultPageState extends State<SearchResultPage>
), ),
body: Column( body: Column(
children: [ children: [
Container( SizedBox(
width: double.infinity, width: double.infinity,
padding: const EdgeInsets.only(top: 4), child: TabBar(
color: Theme.of(context).colorScheme.surface, overlayColor: WidgetStateProperty.all(Colors.transparent),
child: Theme( splashFactory: NoSplash.splashFactory,
data: ThemeData( padding: const EdgeInsets.only(top: 4, left: 8, right: 8),
splashColor: Colors.transparent, // 点击时的水波纹颜色设置为透明 controller: _tabController,
highlightColor: Colors.transparent, // 点击时的背景高亮颜色设置为透明 tabs: SearchType.values
), .map(
child: TabBar( (item) => Obx(
padding: const EdgeInsets.symmetric(horizontal: 8), () {
controller: _tabController, int count = _searchResultController.count[item.index];
tabs: SearchType.values return Tab(
.map( text:
(item) => Obx( '${item.label}${count != -1 ? ' ${count > 99 ? '99+' : count}' : ''}');
() { },
int count = _searchResultController.count[item.index]; ),
return Tab( )
text: .toList(),
'${item.label}${count != -1 ? ' ${count > 99 ? '99+' : count}' : ''}'); isScrollable: true,
}, indicatorWeight: 0,
), indicatorPadding:
) const EdgeInsets.symmetric(horizontal: 3, vertical: 8),
.toList(), indicator: BoxDecoration(
isScrollable: true, color: Theme.of(context).colorScheme.secondaryContainer,
indicatorWeight: 0, borderRadius: const BorderRadius.all(Radius.circular(20)),
indicatorPadding:
const EdgeInsets.symmetric(horizontal: 3, vertical: 8),
indicator: BoxDecoration(
color: Theme.of(context).colorScheme.secondaryContainer,
borderRadius: const BorderRadius.all(Radius.circular(20)),
),
indicatorSize: TabBarIndicatorSize.tab,
labelColor: Theme.of(context).colorScheme.onSecondaryContainer,
labelStyle: TabBarTheme.of(context)
.labelStyle
?.copyWith(fontSize: 13) ??
const TextStyle(fontSize: 13),
dividerColor: Colors.transparent,
dividerHeight: 0,
unselectedLabelColor: Theme.of(context).colorScheme.outline,
tabAlignment: TabAlignment.start,
onTap: (index) {
if (_tabController.indexIsChanging.not) {
Get.find<SearchPanelController>(
tag: SearchType.values[index].name + _tag)
.animateToTop();
}
},
), ),
indicatorSize: TabBarIndicatorSize.tab,
labelColor: Theme.of(context).colorScheme.onSecondaryContainer,
labelStyle:
TabBarTheme.of(context).labelStyle?.copyWith(fontSize: 13) ??
const TextStyle(fontSize: 13),
dividerColor: Colors.transparent,
dividerHeight: 0,
unselectedLabelColor: Theme.of(context).colorScheme.outline,
tabAlignment: TabAlignment.start,
onTap: (index) {
if (_tabController.indexIsChanging.not) {
Get.find<SearchPanelController>(
tag: SearchType.values[index].name + _tag)
.animateToTop();
}
},
), ),
), ),
Expanded( Expanded(

View File

@@ -1622,6 +1622,11 @@ class VideoDetailController extends GetxController
} }
void showNoteList(BuildContext context) async { void showNoteList(BuildContext context) async {
String? title;
try {
title =
Get.find<VideoIntroController>(tag: heroTag).videoDetail.value.title;
} catch (_) {}
if (plPlayerController.isFullScreen.value) { if (plPlayerController.isFullScreen.value) {
Utils.showFSSheet( Utils.showFSSheet(
context, context,
@@ -1633,6 +1638,7 @@ class VideoDetailController extends GetxController
enableSlide: false, enableSlide: false,
heroTag: heroTag, heroTag: heroTag,
isStein: graphVersion != null, isStein: graphVersion != null,
title: title,
), ),
) )
: NoteListPage( : NoteListPage(
@@ -1640,6 +1646,7 @@ class VideoDetailController extends GetxController
enableSlide: false, enableSlide: false,
heroTag: heroTag, heroTag: heroTag,
isStein: graphVersion != null, isStein: graphVersion != null,
title: title,
), ),
isFullScreen: () => plPlayerController.isFullScreen.value, isFullScreen: () => plPlayerController.isFullScreen.value,
); );
@@ -1650,6 +1657,7 @@ class VideoDetailController extends GetxController
oid: oid.value, oid: oid.value,
heroTag: heroTag, heroTag: heroTag,
isStein: graphVersion != null, isStein: graphVersion != null,
title: title,
), ),
); );
} }

View File

@@ -20,12 +20,14 @@ class NoteListPage extends CommonSlidePage {
this.oid, this.oid,
this.upperMid, this.upperMid,
required this.isStein, required this.isStein,
required this.title,
}); });
final dynamic heroTag; final dynamic heroTag;
final dynamic oid; final dynamic oid;
final dynamic upperMid; final dynamic upperMid;
final bool isStein; final bool isStein;
final dynamic title;
@override @override
State<NoteListPage> createState() => _NoteListPageState(); State<NoteListPage> createState() => _NoteListPageState();
@@ -109,6 +111,8 @@ class _NoteListPageState extends CommonSlidePageState<NoteListPage> {
onPressed: () { onPressed: () {
_key.currentState?.showBottomSheet( _key.currentState?.showBottomSheet(
(context) => WebviewPageNew( (context) => WebviewPageNew(
oid: widget.oid,
title: widget.title,
url: url:
'https://www.bilibili.com/h5/note-app?oid=${widget.oid}&pagefrom=ugcvideo&is_stein_gate=${widget.isStein ? 1 : 0}', 'https://www.bilibili.com/h5/note-app?oid=${widget.oid}&pagefrom=ugcvideo&is_stein_gate=${widget.isStein ? 1 : 0}',
), ),

View File

@@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'package:PiliPlus/http/init.dart'; import 'package:PiliPlus/http/init.dart';
import 'package:PiliPlus/http/video.dart';
import 'package:PiliPlus/utils/accounts/account.dart'; import 'package:PiliPlus/utils/accounts/account.dart';
import 'package:PiliPlus/utils/app_scheme.dart'; import 'package:PiliPlus/utils/app_scheme.dart';
import 'package:PiliPlus/utils/cache_manage.dart'; import 'package:PiliPlus/utils/cache_manage.dart';
@@ -33,17 +34,23 @@ extension _WebviewMenuItemExt on _WebviewMenuItem {
} }
class WebviewPageNew extends StatefulWidget { class WebviewPageNew extends StatefulWidget {
const WebviewPageNew({super.key, this.url}); const WebviewPageNew(
{super.key, this.url, this.oid, this.title, this.uaType});
final String? url; final String? url;
// note
final int? oid;
final String? title;
final String? uaType;
@override @override
State<WebviewPageNew> createState() => _WebviewPageNewState(); State<WebviewPageNew> createState() => _WebviewPageNewState();
} }
class _WebviewPageNewState extends State<WebviewPageNew> { class _WebviewPageNewState extends State<WebviewPageNew> {
late final String _url = widget.url ?? Get.parameters['url'] ?? ''; late final String _url = widget.url ?? Get.parameters['url'] ?? '';
final uaType = Get.parameters['uaType'] ?? 'mob'; late final uaType = widget.uaType ?? Get.parameters['uaType'] ?? 'mob';
final _titleStream = StreamController<String?>(); final _titleStream = StreamController<String?>();
final _progressStream = StreamController<double>(); final _progressStream = StreamController<double>();
bool? _inApp; bool? _inApp;
@@ -183,7 +190,21 @@ class _WebviewPageNewState extends State<WebviewPageNew> {
_webViewController?.addJavaScriptHandler( _webViewController?.addJavaScriptHandler(
handlerName: 'finishButtonClicked', handlerName: 'finishButtonClicked',
callback: (args) { callback: (args) {
Get.back(); _webViewController?.evaluateJavascript(source: """
Array.from(document.querySelectorAll('.ql-editor > p')).map(p => p.textContent).join('\\n');
""").then((value) {
try {
String? summary = (value as String?);
if (summary?.isNotEmpty == true) {
VideoHttp.addNote(
oid: widget.oid!,
title: widget.title!,
summary: summary!,
);
}
} catch (_) {}
Get.back();
});
}, },
); );
}, },