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

阅读界面笔记讨论目录

上级 c9044f19
......@@ -39,7 +39,6 @@ class CoinRechargeController extends GetxController {
@override
void onInit() {
initPlatformState();
_getProduct();
_getPendingPurchase();
super.onInit();
}
......@@ -78,6 +77,7 @@ class CoinRechargeController extends GetxController {
}
rechargeModel = coinModel;
_buyIndex = data.indexOf(coinModel);
update();
}
......@@ -100,20 +100,13 @@ class CoinRechargeController extends GetxController {
Future<void> initPlatformState() async{
var result = await FlutterInappPurchase.instance.initialize();
print('--------------initPlatformState-------------------------$result');
try {
String msg = await FlutterInappPurchase.instance.consumeAll();
print('consumeAllItems: $msg');
} catch (err) {
print('consumeAllItems error: $err');
}
_connectionSubscription =
FlutterInappPurchase.connectionUpdated.listen((connected) {
_connectionSubscription = FlutterInappPurchase.connectionUpdated.listen((connected) {
print('connected: $connected');
});
_purchaseUpdatedSubscription =
FlutterInappPurchase.purchaseUpdated.listen((productItem) {
_purchaseUpdatedSubscription = FlutterInappPurchase.purchaseUpdated.listen((productItem) {
CustomToast.dismiss();
if(productItem != null){
_resultItem = productItem;
......@@ -121,8 +114,7 @@ class CoinRechargeController extends GetxController {
}
});
_purchaseErrorSubscription =
FlutterInappPurchase.purchaseError.listen((purchaseError) {
_purchaseErrorSubscription = FlutterInappPurchase.purchaseError.listen((purchaseError) {
CustomToast.dismiss();
Toast.show(purchaseError!.message.toString());
});
......@@ -136,19 +128,24 @@ class CoinRechargeController extends GetxController {
.map((coinModel) => coinModel.identifying!)
.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) {
_items.add(item);
}
print('-------------_items-------------------$items');
_items = items;
_purchases = [];
update();
}
/// 创建订单
void _createRechargeOrder() async {
void createRechargeOrder() async {
final result = await MineAPI.createRechargeOrder(identifying: rechargeModel.identifying??'', type: payModel.type.toString());
print('-----------------------------------${result.ordersnum}--------------------------------${result.msg}');
payOrderModel = result;
// 创建订单成功开启支付流程
if (payOrderModel.ordersnum !=null){
......
......@@ -63,7 +63,7 @@ class _CoinRechargePageState extends State<CoinRechargePage> {
text: '立即充值${controller.rechargeModel.priceName??''}',
isEnabled: true,
onPressed: () {
// context.goNamed(Routes.login);
controller.createRechargeOrder();
},
),
),
......
......@@ -4,6 +4,13 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
// 目录
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;
//
......@@ -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;
......@@ -89,3 +112,12 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
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;
import 'package:easy_refresh/easy_refresh.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_book/theme.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:flutter_book/utils/index.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
......
......@@ -69,7 +69,7 @@ class _ReadPageState extends State<ReadPage> {
right: 0,
top: 0,
bottom: 49 + MediaQuery.of(context).viewInsets.bottom,
child: _showContent(readController,currentIndex)
child: _showContent(readController,readController.toolModel)
),
AnimatedPositioned(
duration: readController.controller.duration!,
......@@ -81,98 +81,102 @@ class _ReadPageState extends State<ReadPage> {
child: Container(
color: Colors.limeAccent,
alignment: Alignment.center,
child: BottomNavigationBar(
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',
child: _createToolBar(readController)
),
activeIcon: Image.asset(
'assets/images/discuss_select.png',
)
),
],
)
),
),
),
);
}
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,int index) {
print('++++++++++++++++++++++++$index');
Widget _showContent(ReadController controller,ToolModel model) {
print('++++++++++++++++++++++++${model.tag}');
if (controller.show){
if (index == 0){
return Container(
if (model.tag == 0){
return model.selected? Container(
color: Color(0xFF000000).withOpacity(0.5),
padding: EdgeInsets.only(top: MediaQuery.of(context).size.height * 0.2),
child: ClipRRect(
borderRadius: BorderRadius.only(topRight: Radius.circular(8.w),topLeft: Radius.circular(8.w)),
child: Container(
color: Colors.white,
child: ReadCategoryPage(controller: controller,),
child: ReadCategoryPage(controller: controller,onTap: (){
controller.chooseTool(model);
},),
),
),
// child: ReadCategoryPage(),
);
):const SizedBox();
}
else if (index == 1){
return Container(
else if (model.tag == 1){
return model.selected? Container(
color: Color(0xFF000000).withOpacity(0.5),
padding: EdgeInsets.only(top: MediaQuery.of(context).size.height * 0.2),
child: ClipRRect(
borderRadius: BorderRadius.only(topRight: Radius.circular(8.w),topLeft: Radius.circular(8.w)),
child: Container(
color: Colors.white,
child: ReadNotePage(),
child: ReadNotePage(onTap: (){
controller.chooseTool(model);
},),
),
),
// child: ReadCategoryPage(),
);
):const SizedBox();
}
else if (index == 2){
return Container(
else if (model.tag == 2){
return model.selected? Container(
color: Color(0xFF000000).withOpacity(0.5),
padding: EdgeInsets.only(top: MediaQuery.of(context).size.height * 0.2),
child: ClipRRect(
borderRadius: BorderRadius.only(topRight: Radius.circular(8.w),topLeft: Radius.circular(8.w)),
child: Container(
color: Colors.white,
child: ReadNotePage(),
child: ReadDiscussPage(onTap: (){
controller.chooseTool(model);
},),
),
),
// child: ReadCategoryPage(),
);
):const SizedBox();
}
}
return const SizedBox();
......
......@@ -2,9 +2,11 @@ part of web;
class ReadCategoryPage extends StatefulWidget {
final ReadController controller;
final void Function()? onTap;
const ReadCategoryPage({
Key? key,
required this.controller,
required this.onTap,
}) : super(key: key);
@override
......@@ -24,7 +26,10 @@ class _ReadCategoryPageState extends State<ReadCategoryPage> {
children: [
Container(
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(
margin: EdgeInsets.only(left: 15.w,right: 15.w,),
......@@ -45,7 +50,7 @@ class _ReadCategoryPageState extends State<ReadCategoryPage> {
child: CustomInputSearch(
controller: searchController,
readOnly: false,
hintText: '请输入书籍名称',
hintText: '请输入书籍名称分类',
onTap: () {
// context.pushNamed(Routes.msgs);
},
......
part of web;
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
State<ReadDiscussPage> createState() => _ReadDiscussPageState();
......@@ -20,7 +24,10 @@ class _ReadDiscussPageState extends State<ReadDiscussPage> {
children: [
Container(
margin: EdgeInsets.only(left: 15.w,right: 15.w,top: 15.w,bottom: 15.w),
child: GestureDetector(
onTap: widget.onTap,
child: Image.asset('assets/images/close.png')
)
),
Container(
margin: EdgeInsets.only(left: 15.w,right: 15.w,),
......@@ -41,7 +48,7 @@ class _ReadDiscussPageState extends State<ReadDiscussPage> {
child: CustomInputSearch(
controller: searchController,
readOnly: false,
hintText: '请输入书籍名称',
hintText: '请输入书籍名称讨论',
onTap: () {
// context.pushNamed(Routes.msgs);
},
......@@ -52,12 +59,14 @@ class _ReadDiscussPageState extends State<ReadDiscussPage> {
),
),
BuildBook(),
ListView.builder(
Expanded(
child: ListView.builder(
itemBuilder: (BuildContext context,int index){
DiscussModel model = controller.discuss[index];
return BuildDiscuss(model: model,);
},
itemCount: controller.discuss.length,
),
)
],
......
part of web;
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
State<ReadNotePage> createState() => _ReadNotePageState();
......@@ -18,7 +22,10 @@ class _ReadNotePageState extends State<ReadNotePage> {
children: [
Container(
margin: EdgeInsets.only(left: 15.w,right: 15.w,top: 15.w,bottom: 15.w),
child: GestureDetector(
onTap: widget.onTap,
child: Image.asset('assets/images/close.png')
)
),
Container(
margin: EdgeInsets.only(left: 15.w,right: 15.w,),
......@@ -39,7 +46,7 @@ class _ReadNotePageState extends State<ReadNotePage> {
child: CustomInputSearch(
controller: searchController,
readOnly: false,
hintText: '请输入书籍名称',
hintText: '请输入书籍名称笔记',
onTap: () {
// context.pushNamed(Routes.msgs);
},
......
......@@ -65,6 +65,7 @@ class Gaps {
class Fonts {
static const medium = FontWeight.w500;
static const regular = FontWeight.w400;
static const bold = FontWeight.bold;
static const boldSemi = FontWeight.w600;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论