提交 e6854922 authored 作者: yueweilu's avatar yueweilu

阅读界面笔记讨论目录

上级 c9044f19
...@@ -39,7 +39,6 @@ class CoinRechargeController extends GetxController { ...@@ -39,7 +39,6 @@ class CoinRechargeController extends GetxController {
@override @override
void onInit() { void onInit() {
initPlatformState(); initPlatformState();
_getProduct();
_getPendingPurchase(); _getPendingPurchase();
super.onInit(); super.onInit();
} }
...@@ -78,6 +77,7 @@ class CoinRechargeController extends GetxController { ...@@ -78,6 +77,7 @@ class CoinRechargeController extends GetxController {
} }
rechargeModel = coinModel; rechargeModel = coinModel;
_buyIndex = data.indexOf(coinModel); _buyIndex = data.indexOf(coinModel);
update(); update();
} }
...@@ -100,32 +100,24 @@ class CoinRechargeController extends GetxController { ...@@ -100,32 +100,24 @@ class CoinRechargeController extends GetxController {
Future<void> initPlatformState() async{ Future<void> initPlatformState() async{
var result = await FlutterInappPurchase.instance.initialize(); var result = await FlutterInappPurchase.instance.initialize();
print('--------------initPlatformState-------------------------$result');
try { _connectionSubscription = FlutterInappPurchase.connectionUpdated.listen((connected) {
String msg = await FlutterInappPurchase.instance.consumeAll();
print('consumeAllItems: $msg');
} catch (err) {
print('consumeAllItems error: $err');
}
_connectionSubscription =
FlutterInappPurchase.connectionUpdated.listen((connected) {
print('connected: $connected'); print('connected: $connected');
}); });
_purchaseUpdatedSubscription = _purchaseUpdatedSubscription = FlutterInappPurchase.purchaseUpdated.listen((productItem) {
FlutterInappPurchase.purchaseUpdated.listen((productItem) { CustomToast.dismiss();
CustomToast.dismiss(); if(productItem != null){
if(productItem != null){ _resultItem = productItem;
_resultItem = productItem; _requestOrderStatus();
_requestOrderStatus(); }
} });
});
_purchaseErrorSubscription = _purchaseErrorSubscription = FlutterInappPurchase.purchaseError.listen((purchaseError) {
FlutterInappPurchase.purchaseError.listen((purchaseError) { CustomToast.dismiss();
CustomToast.dismiss(); Toast.show(purchaseError!.message.toString());
Toast.show(purchaseError!.message.toString()); });
});
} }
/// 获取商品列表 /// 获取商品列表
...@@ -136,19 +128,24 @@ class CoinRechargeController extends GetxController { ...@@ -136,19 +128,24 @@ class CoinRechargeController extends GetxController {
.map((coinModel) => coinModel.identifying!) .map((coinModel) => coinModel.identifying!)
.toList(); .toList();
List<IAPItem> items = await FlutterInappPurchase.instance.getProducts(productList); print('-------------productList-------------------$productList');
List<IAPItem> items = await FlutterInappPurchase.instance.getProducts(['com.zijing.book.flutterBook']);
for (var item in items) { for (var item in items) {
_items.add(item); _items.add(item);
} }
print('-------------_items-------------------$items');
_items = items; _items = items;
_purchases = []; _purchases = [];
update(); update();
} }
/// 创建订单 /// 创建订单
void _createRechargeOrder() async { void createRechargeOrder() async {
final result = await MineAPI.createRechargeOrder(identifying: rechargeModel.identifying??'', type: payModel.type.toString()); final result = await MineAPI.createRechargeOrder(identifying: rechargeModel.identifying??'', type: payModel.type.toString());
print('-----------------------------------${result.ordersnum}--------------------------------${result.msg}');
payOrderModel = result; payOrderModel = result;
// 创建订单成功开启支付流程 // 创建订单成功开启支付流程
if (payOrderModel.ordersnum !=null){ if (payOrderModel.ordersnum !=null){
......
...@@ -63,7 +63,7 @@ class _CoinRechargePageState extends State<CoinRechargePage> { ...@@ -63,7 +63,7 @@ class _CoinRechargePageState extends State<CoinRechargePage> {
text: '立即充值${controller.rechargeModel.priceName??''}', text: '立即充值${controller.rechargeModel.priceName??''}',
isEnabled: true, isEnabled: true,
onPressed: () { onPressed: () {
// context.goNamed(Routes.login); controller.createRechargeOrder();
}, },
), ),
), ),
......
...@@ -4,6 +4,13 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide ...@@ -4,6 +4,13 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
// 目录 // 目录
List <ChapterModel> chapters = []; List <ChapterModel> chapters = [];
List <ToolModel> tools = [
ToolModel(tag: 0,name: '目录',selected: false,icon: 'assets/images/category_unselect.png',activeIcon: 'assets/images/category_select.png'),
ToolModel(tag: 1,name: '笔记',selected: false,icon: 'assets/images/note_unselect.png',activeIcon:'assets/images/note_select.png'),
ToolModel(tag: 2,name: '讨论',selected: false,icon: 'assets/images/discuss_unselect.png',activeIcon:'assets/images/discuss_select.png'),
];
late ToolModel toolModel = tools.first;
// late final PageController pageController; // late final PageController pageController;
// //
...@@ -33,6 +40,22 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide ...@@ -33,6 +40,22 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
} }
void chooseTool(ToolModel selectedModel){
for (var model in tools) {
// 如果当前遍历到的工具是选中的,并且不是点击的工具,则取消选中
if (model.selected && model != selectedModel) {
model.selected = false;
}
// 如果当前遍历到的工具是点击的工具,切换选中状态
else if (model == selectedModel) {
model.selected = !model.selected;
}
}
toolModel = selectedModel;
update();
}
AnimationController get controller => _controller; AnimationController get controller => _controller;
...@@ -88,4 +111,13 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide ...@@ -88,4 +111,13 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
chapters = await LibraryAPI.chapters(bookId: '110'); chapters = await LibraryAPI.chapters(bookId: '110');
update(); update();
} }
}
class ToolModel {
ToolModel({required this.tag, required this.selected, required this.name,required this.icon,required this.activeIcon});
int tag;
String name;
bool selected;
String icon;
String activeIcon;
} }
\ No newline at end of file
...@@ -4,6 +4,7 @@ library web; ...@@ -4,6 +4,7 @@ library web;
import 'package:easy_refresh/easy_refresh.dart'; import 'package:easy_refresh/easy_refresh.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_book/theme.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:flutter_book/utils/index.dart'; import 'package:flutter_book/utils/index.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
......
...@@ -69,7 +69,7 @@ class _ReadPageState extends State<ReadPage> { ...@@ -69,7 +69,7 @@ class _ReadPageState extends State<ReadPage> {
right: 0, right: 0,
top: 0, top: 0,
bottom: 49 + MediaQuery.of(context).viewInsets.bottom, bottom: 49 + MediaQuery.of(context).viewInsets.bottom,
child: _showContent(readController,currentIndex) child: _showContent(readController,readController.toolModel)
), ),
AnimatedPositioned( AnimatedPositioned(
duration: readController.controller.duration!, duration: readController.controller.duration!,
...@@ -81,44 +81,7 @@ class _ReadPageState extends State<ReadPage> { ...@@ -81,44 +81,7 @@ class _ReadPageState extends State<ReadPage> {
child: Container( child: Container(
color: Colors.limeAccent, color: Colors.limeAccent,
alignment: Alignment.center, alignment: Alignment.center,
child: BottomNavigationBar( child: _createToolBar(readController)
currentIndex: currentIndex,
onTap: (index){
setState(() {
currentIndex = index;
});
// _showBottomSheet(context, index);
},
items: [
BottomNavigationBarItem(
label: '目录',
icon: Image.asset(
'assets/images/category_unselect.png',
),
activeIcon: Image.asset(
'assets/images/category_select.png',
),
),
BottomNavigationBarItem(
label: '笔记',
icon: Image.asset(
'assets/images/note_unselect.png',
),
activeIcon: Image.asset(
'assets/images/note_select.png',
)
),
BottomNavigationBarItem(
label: '讨论',
icon: Image.asset(
'assets/images/discuss_unselect.png',
),
activeIcon: Image.asset(
'assets/images/discuss_select.png',
)
),
],
)
), ),
), ),
...@@ -129,50 +92,91 @@ class _ReadPageState extends State<ReadPage> { ...@@ -129,50 +92,91 @@ class _ReadPageState extends State<ReadPage> {
); );
} }
Widget _showContent(ReadController controller,int index) {
print('++++++++++++++++++++++++$index'); Widget _createToolBar(ReadController controller){
return Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: controller.tools.map((model){
return Expanded(
child: GestureDetector(
onTap: (){
controller.chooseTool(model);
},
child: Container(
color: Colors.white,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: [
SizedBox(
width: 17,
height: 17,
child: Image.asset(model.selected?model.activeIcon:model.icon)
),
// SizedBox(height: 2.5.w,),
model.selected?Text(model.name,style: TextStyle(fontSize: 10.w,height: 1.4,fontWeight: Fonts.medium,color: AppTheme.primary),)
:Text(model.name,style: TextStyle(fontSize: 10.w,height: 1.4,fontWeight: Fonts.medium,color: Colours.c6))
],
),
),
),
);
}).toList()
),
);
}
Widget _showContent(ReadController controller,ToolModel model) {
print('++++++++++++++++++++++++${model.tag}');
if (controller.show){ if (controller.show){
if (index == 0){ if (model.tag == 0){
return Container( return model.selected? Container(
color: Color(0xFF000000).withOpacity(0.5), color: Color(0xFF000000).withOpacity(0.5),
padding: EdgeInsets.only(top: MediaQuery.of(context).size.height * 0.2), padding: EdgeInsets.only(top: MediaQuery.of(context).size.height * 0.2),
child: ClipRRect( child: ClipRRect(
borderRadius: BorderRadius.only(topRight: Radius.circular(8.w),topLeft: Radius.circular(8.w)), borderRadius: BorderRadius.only(topRight: Radius.circular(8.w),topLeft: Radius.circular(8.w)),
child: Container( child: Container(
color: Colors.white, color: Colors.white,
child: ReadCategoryPage(controller: controller,), child: ReadCategoryPage(controller: controller,onTap: (){
controller.chooseTool(model);
},),
), ),
), ),
// child: ReadCategoryPage(), // child: ReadCategoryPage(),
); ):const SizedBox();
} }
else if (index == 1){ else if (model.tag == 1){
return Container( return model.selected? Container(
color: Color(0xFF000000).withOpacity(0.5), color: Color(0xFF000000).withOpacity(0.5),
padding: EdgeInsets.only(top: MediaQuery.of(context).size.height * 0.2), padding: EdgeInsets.only(top: MediaQuery.of(context).size.height * 0.2),
child: ClipRRect( child: ClipRRect(
borderRadius: BorderRadius.only(topRight: Radius.circular(8.w),topLeft: Radius.circular(8.w)), borderRadius: BorderRadius.only(topRight: Radius.circular(8.w),topLeft: Radius.circular(8.w)),
child: Container( child: Container(
color: Colors.white, color: Colors.white,
child: ReadNotePage(), child: ReadNotePage(onTap: (){
controller.chooseTool(model);
},),
), ),
), ),
// child: ReadCategoryPage(), // child: ReadCategoryPage(),
); ):const SizedBox();
} }
else if (index == 2){ else if (model.tag == 2){
return Container( return model.selected? Container(
color: Color(0xFF000000).withOpacity(0.5), color: Color(0xFF000000).withOpacity(0.5),
padding: EdgeInsets.only(top: MediaQuery.of(context).size.height * 0.2), padding: EdgeInsets.only(top: MediaQuery.of(context).size.height * 0.2),
child: ClipRRect( child: ClipRRect(
borderRadius: BorderRadius.only(topRight: Radius.circular(8.w),topLeft: Radius.circular(8.w)), borderRadius: BorderRadius.only(topRight: Radius.circular(8.w),topLeft: Radius.circular(8.w)),
child: Container( child: Container(
color: Colors.white, color: Colors.white,
child: ReadNotePage(), child: ReadDiscussPage(onTap: (){
controller.chooseTool(model);
},),
), ),
), ),
// child: ReadCategoryPage(), // child: ReadCategoryPage(),
); ):const SizedBox();
} }
} }
return const SizedBox(); return const SizedBox();
......
...@@ -2,9 +2,11 @@ part of web; ...@@ -2,9 +2,11 @@ part of web;
class ReadCategoryPage extends StatefulWidget { class ReadCategoryPage extends StatefulWidget {
final ReadController controller; final ReadController controller;
final void Function()? onTap;
const ReadCategoryPage({ const ReadCategoryPage({
Key? key, Key? key,
required this.controller, required this.controller,
required this.onTap,
}) : super(key: key); }) : super(key: key);
@override @override
...@@ -24,7 +26,10 @@ class _ReadCategoryPageState extends State<ReadCategoryPage> { ...@@ -24,7 +26,10 @@ class _ReadCategoryPageState extends State<ReadCategoryPage> {
children: [ children: [
Container( Container(
margin: EdgeInsets.only(left: 15.w,right: 15.w,top: 15.w,bottom: 15.w), margin: EdgeInsets.only(left: 15.w,right: 15.w,top: 15.w,bottom: 15.w),
child: Image.asset('assets/images/close.png') child: GestureDetector(
onTap:widget.onTap,
child: Image.asset('assets/images/close.png'),
)
), ),
Container( Container(
margin: EdgeInsets.only(left: 15.w,right: 15.w,), margin: EdgeInsets.only(left: 15.w,right: 15.w,),
...@@ -45,7 +50,7 @@ class _ReadCategoryPageState extends State<ReadCategoryPage> { ...@@ -45,7 +50,7 @@ class _ReadCategoryPageState extends State<ReadCategoryPage> {
child: CustomInputSearch( child: CustomInputSearch(
controller: searchController, controller: searchController,
readOnly: false, readOnly: false,
hintText: '请输入书籍名称', hintText: '请输入书籍名称分类',
onTap: () { onTap: () {
// context.pushNamed(Routes.msgs); // context.pushNamed(Routes.msgs);
}, },
......
part of web; part of web;
class ReadDiscussPage extends StatefulWidget { class ReadDiscussPage extends StatefulWidget {
const ReadDiscussPage({Key? key}) : super(key: key); final void Function()? onTap;
const ReadDiscussPage({
Key? key,
required this.onTap,
}) : super(key: key);
@override @override
State<ReadDiscussPage> createState() => _ReadDiscussPageState(); State<ReadDiscussPage> createState() => _ReadDiscussPageState();
...@@ -20,7 +24,10 @@ class _ReadDiscussPageState extends State<ReadDiscussPage> { ...@@ -20,7 +24,10 @@ class _ReadDiscussPageState extends State<ReadDiscussPage> {
children: [ children: [
Container( Container(
margin: EdgeInsets.only(left: 15.w,right: 15.w,top: 15.w,bottom: 15.w), margin: EdgeInsets.only(left: 15.w,right: 15.w,top: 15.w,bottom: 15.w),
child: Image.asset('assets/images/close.png') child: GestureDetector(
onTap: widget.onTap,
child: Image.asset('assets/images/close.png')
)
), ),
Container( Container(
margin: EdgeInsets.only(left: 15.w,right: 15.w,), margin: EdgeInsets.only(left: 15.w,right: 15.w,),
...@@ -41,7 +48,7 @@ class _ReadDiscussPageState extends State<ReadDiscussPage> { ...@@ -41,7 +48,7 @@ class _ReadDiscussPageState extends State<ReadDiscussPage> {
child: CustomInputSearch( child: CustomInputSearch(
controller: searchController, controller: searchController,
readOnly: false, readOnly: false,
hintText: '请输入书籍名称', hintText: '请输入书籍名称讨论',
onTap: () { onTap: () {
// context.pushNamed(Routes.msgs); // context.pushNamed(Routes.msgs);
}, },
...@@ -52,12 +59,14 @@ class _ReadDiscussPageState extends State<ReadDiscussPage> { ...@@ -52,12 +59,14 @@ class _ReadDiscussPageState extends State<ReadDiscussPage> {
), ),
), ),
BuildBook(), BuildBook(),
ListView.builder( Expanded(
itemBuilder: (BuildContext context,int index){ child: ListView.builder(
DiscussModel model = controller.discuss[index]; itemBuilder: (BuildContext context,int index){
return BuildDiscuss(model: model,); DiscussModel model = controller.discuss[index];
}, return BuildDiscuss(model: model,);
itemCount: controller.discuss.length, },
itemCount: controller.discuss.length,
),
) )
], ],
......
part of web; part of web;
class ReadNotePage extends StatefulWidget { class ReadNotePage extends StatefulWidget {
const ReadNotePage({Key? key}) : super(key: key); final void Function()? onTap;
const ReadNotePage({
Key? key,
required this.onTap,
}) : super(key: key);
@override @override
State<ReadNotePage> createState() => _ReadNotePageState(); State<ReadNotePage> createState() => _ReadNotePageState();
...@@ -18,7 +22,10 @@ class _ReadNotePageState extends State<ReadNotePage> { ...@@ -18,7 +22,10 @@ class _ReadNotePageState extends State<ReadNotePage> {
children: [ children: [
Container( Container(
margin: EdgeInsets.only(left: 15.w,right: 15.w,top: 15.w,bottom: 15.w), margin: EdgeInsets.only(left: 15.w,right: 15.w,top: 15.w,bottom: 15.w),
child: Image.asset('assets/images/close.png') child: GestureDetector(
onTap: widget.onTap,
child: Image.asset('assets/images/close.png')
)
), ),
Container( Container(
margin: EdgeInsets.only(left: 15.w,right: 15.w,), margin: EdgeInsets.only(left: 15.w,right: 15.w,),
...@@ -39,7 +46,7 @@ class _ReadNotePageState extends State<ReadNotePage> { ...@@ -39,7 +46,7 @@ class _ReadNotePageState extends State<ReadNotePage> {
child: CustomInputSearch( child: CustomInputSearch(
controller: searchController, controller: searchController,
readOnly: false, readOnly: false,
hintText: '请输入书籍名称', hintText: '请输入书籍名称笔记',
onTap: () { onTap: () {
// context.pushNamed(Routes.msgs); // context.pushNamed(Routes.msgs);
}, },
......
...@@ -65,6 +65,7 @@ class Gaps { ...@@ -65,6 +65,7 @@ class Gaps {
class Fonts { class Fonts {
static const medium = FontWeight.w500; static const medium = FontWeight.w500;
static const regular = FontWeight.w400;
static const bold = FontWeight.bold; static const bold = FontWeight.bold;
static const boldSemi = FontWeight.w600; static const boldSemi = FontWeight.w600;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论