Commit b99145b8 authored by netyouli's avatar netyouli

添加创作增删改查功能

parent 2ed6da52
......@@ -501,7 +501,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/RunnerDebug.entitlements;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = "";
......@@ -518,7 +518,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.wudi.app;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "iOS Team Store Provisioning Profile: com.wudi.app";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "dev-profile";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
......@@ -550,7 +550,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.wudi.app;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "iOS Team Store Provisioning Profile: com.wudi.app";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "dis-profile";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
......
......@@ -19,6 +19,7 @@ class AppRoutes {
static const HOME_PAGE = '/home';
static const CREATION_PAGE = '/creation';
static const CREATION_HISTORY_PAGE = '/creation-history';
static const CREATION_HISTORY_DETAIL_PAGE = '/creation-history-detail';
static const CREATION_PAGE_DETAIL = '/creation-detail';
static const ASSISTANT_PAGE = '/assistant';
static const MY_PAGE = '/my';
......
......@@ -2,6 +2,7 @@ import 'package:chart/pages/assistant-item/index.dart';
import 'package:chart/pages/assistant/index.dart';
import 'package:chart/pages/chat/view.dart';
import 'package:chart/pages/creation-detail/index.dart';
import 'package:chart/pages/creation/history/detail/index.dart';
import 'package:chart/pages/creation/history/index.dart';
import 'package:chart/pages/creation/index.dart';
import 'package:chart/pages/eula/bindings.dart';
......@@ -182,6 +183,11 @@ class AppPages {
page: () => CreateHistoryPage(),
binding: CreateHistoryBinding(),
),
GetPage(
name: AppRoutes.CREATION_HISTORY_DETAIL_PAGE,
page: () => const CreateHistoryDetailPage(),
binding: CreateHistoryDetailBinding(),
),
GetPage(
name: AppRoutes.ASSISTANT_PAGE,
page: () => AssistantPage(),
......
......@@ -120,6 +120,7 @@ class CreationDetailController extends GetxController {
model.object = inputControllerMap["input1"]?.text ?? "";
model.subject = inputControllerMap["input2"]?.text ?? "";
model.content = state.genText;
model.title = model.content.length > 5 ? model.content.substring(0, 5) : model.content;
model.date = "${date.year}-${date.month < 10 ? "0${date.month}" : date.month}-${date.day < 10 ? "0${date.day}" : date.day} ${date.hour < 10 ? "0${date.hour}" : date.hour}:${date.minute < 10 ? "0${date.minute}" : date.minute}:${date.second < 10 ? "0${date.second}" : date.second}";
DBTool.insert(model);
return;
......
......@@ -2,21 +2,21 @@
import '../../../common/db/db_tool.dart';
class DetailModel implements DBModel {
static const TableName = "DetailModel";
var type = "";
var title = "";
var object = "";
var subject = "";
var content = "";
var date = "";
@override
String get tableName => TableName;
String get tableName => "DetailModel";
@override
String get createTableSql => "CREATE TABLE $tableName (id INTEGER PRIMARY KEY AUTOINCREMENT, type TEXT, object TEXT, subject TEXT, content TEXT, date TEXT)";
String get createTableSql => "CREATE TABLE $tableName (id INTEGER PRIMARY KEY AUTOINCREMENT, type TEXT, object TEXT, subject TEXT, content TEXT, date TEXT, title TEXT)";
@override
Map<String, Object> get mapValues => {"type": type, "object": object, "subject": subject, "content": content, "date": date};
Map<String, Object> get mapValues => {"type": type, "object": object, "subject": subject, "content": content, "date": date, "title": title};
static DetailModel fromJson(Map<String, Object?> jsonData) {
final model = DetailModel();
......@@ -25,6 +25,7 @@ class DetailModel implements DBModel {
model.object = jsonData["object"] as String? ?? "";
model.subject = jsonData["subject"] as String? ?? "";
model.date = jsonData["date"] as String? ?? "";
model.title = jsonData["title"] as String? ?? "";
return model;
}
......
......@@ -7,7 +7,6 @@ import '../../../common/db/db_tool.dart';
class CreateHistoryController extends GetxController {
CreateHistoryController();
static CreateHistoryController get to => Get.put(CreateHistoryController());
final state = CreateHistoryState();
getHistoryMoels() {
......@@ -17,4 +16,16 @@ class CreateHistoryController extends GetxController {
});
}
searchHistory(String value) {
final where = value.isNotEmpty ? "title LIKE '%$value%'" : null;
DBTool.query(DetailModel(), where: where).then((value) {
final list = value.map((e) => DetailModel.fromJson(e)).toList();
state.models.value = list;
});
}
deleteHistory(DetailModel model) {
DBTool.delete(model, where: "date = '${model.date}'");//.then((value) => getHistoryMoels());
}
}
\ No newline at end of file
import './controller.dart';
import 'package:get/get.dart';
class CreateHistoryDetailBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut<CreateHistoryDetailController>(() => CreateHistoryDetailController());
}
}
\ No newline at end of file
import 'package:chart/pages/creation/history/detail/state.dart';
import 'package:get/get.dart';
class CreateHistoryDetailController extends GetxController {
CreateHistoryDetailController();
static CreateHistoryDetailController get to => Get.put(CreateHistoryDetailController());
final state = CreateHistoryDetailState();
}
\ No newline at end of file
library creation_history_detail;
export './controller.dart';
export './view.dart';
export './bindings.dart';
\ No newline at end of file
import 'package:get/get.dart';
import '../../../creation-detail/models/detail_model.dart';
class CreateHistoryDetailState {
var model = DetailModel().obs;
}
\ No newline at end of file
import './controller.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class CreateHistoryDetailPage extends GetView<CreateHistoryDetailController> {
const CreateHistoryDetailPage({Key? key}) : super(key: key);
Widget _mainView() {
return Obx(() => Container(
padding: const EdgeInsets.all(15),
width: double.infinity,
child: Column(crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text("类型:${controller.state.model.value.type} \n时间:${controller.state.model.value.date}", textAlign: TextAlign.start,),
const SizedBox(height: 15,),
Container(
padding: const EdgeInsets.all(20),
width: Get.width,
constraints: const BoxConstraints(minHeight: 300),
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(4),
gradient: const LinearGradient(colors: [
Color.fromARGB(
255, 40, 40, 57),
Color.fromARGB(
255, 40, 40, 57),
],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
),
child: Text(controller.state.model.value.content))
])
));
}
@override
Widget build(BuildContext context) {
return GetBuilder<CreateHistoryDetailController>(id: "history_detail", init: CreateHistoryDetailController(),
builder: (_) {
return Container(
decoration: BoxDecoration(
image: DecorationImage(
image: Image.asset("assets/images/background.png").image,
fit: BoxFit.cover),
),
child: Scaffold(
backgroundColor: Color.fromARGB(0, 29, 33, 60),
appBar: AppBar(
backgroundColor: Color.fromARGB(255, 29, 33, 60),
title: Obx(() => Text(
controller.state.model.value.title,
)),
elevation: 0),
body: SafeArea(child: _mainView()),
)
);
});
}
}
\ No newline at end of file
import './detail/controller.dart';
import 'package:chart/common/routers/routes.dart';
import 'package:chart/pages/creation/history/controller.dart';
import 'package:chart/pages/creation/history/detail/view.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class CreateHistoryPage extends GetView<CreateHistoryController> {
const CreateHistoryPage({Key? key}) : super(key: key);
class SearchSliverAppBar extends SliverPersistentHeaderDelegate {
final double expandedHeight;
final Widget searchBar;
SearchSliverAppBar({required this.expandedHeight, required this.searchBar});
Widget _mainView() {
return Obx(() => ListView(
children: controller.state.models.map((e) {
@override
Widget build(
BuildContext context, double shrinkOffset, bool overlapsContent) {
return Container(
padding: const EdgeInsets.all(15),
color: const Color.fromARGB(255, 29, 33, 60),
child: Column(
children: [
searchBar,
],
),
);
}
@override
double get maxExtent => expandedHeight;
@override
double get minExtent => expandedHeight;
@override
bool shouldRebuild(covariant SearchSliverAppBar oldDelegate) {
return expandedHeight != oldDelegate.expandedHeight ||
searchBar != oldDelegate.searchBar;
}
}
class CreateHistoryPage extends GetView<CreateHistoryController> {
CreateHistoryPage({Key? key}) : super(key: key);
Widget _makeCell(int index) {
final model = controller.state.models[index];
return GestureDetector(
onTap: () {
CreateHistoryDetailController.to.state.model.value = model;
Get.toNamed(AppRoutes.CREATION_HISTORY_DETAIL_PAGE);
},
child: Container(
padding: const EdgeInsets.all(15),
width: double.infinity,
child: Column(crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text("类型:${e.type} \n时间:${e.date}", textAlign: TextAlign.start,),
Text("类型:${model.type}\n标题:${model.title}\n时间:${model.date}"),
const SizedBox(height: 15,),
Container(
padding: const EdgeInsets.all(20),
width: Get.width,
constraints: const BoxConstraints(minHeight: 300),
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(4),
......@@ -33,10 +72,70 @@ class CreateHistoryPage extends GetView<CreateHistoryController> {
end: Alignment.bottomCenter,
),
),
child: Text(e.content))
child: Text(model.content, overflow: TextOverflow.ellipsis, maxLines: 3,))
]),
)
);
}
Widget _makeTableView() {
final border = OutlineInputBorder(
borderRadius: BorderRadius.circular(22.0),
borderSide: const BorderSide(color:Color(0xFFb05ddd))
);
return Obx(() => CustomScrollView(
slivers: [
SliverPersistentHeader(pinned: true,
delegate: SearchSliverAppBar(
expandedHeight: 78.0,
searchBar: TextField(
onChanged: (value) {
controller.searchHistory(value);
},
style: const TextStyle(
fontWeight: FontWeight.w400,
fontSize: 14,
),
maxLines: 1,
decoration: InputDecoration(
hintText: '搜索标题',
border: border,
enabledBorder: border,
focusedBorder: border,
disabledBorder: border,
contentPadding: const EdgeInsets.symmetric(horizontal: 15),
hintStyle: TextStyle(color: Colors.grey[400]),
),
)
)
),
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
final model = controller.state.models[index];
return Dismissible(
key: Key(model.date),
direction: DismissDirection.endToStart,
onDismissed: (direction) {
controller.state.models.removeAt(index);
controller.deleteHistory(model);
},
background: Container(
color: Colors.red,
alignment: Alignment.centerRight,
child: const Padding(
padding: EdgeInsets.only(right: 16.0),
child: Icon(Icons.delete, color: Colors.white),
),
),
child: _makeCell(index)
);
}).toList()
},
childCount: controller.state.models.length,
),
),
],
));
}
......@@ -51,14 +150,14 @@ class CreateHistoryPage extends GetView<CreateHistoryController> {
fit: BoxFit.cover),
),
child: Scaffold(
backgroundColor: Color.fromARGB(0, 29, 33, 60),
backgroundColor: const Color.fromARGB(0, 29, 33, 60),
appBar: AppBar(
backgroundColor: Color.fromARGB(255, 29, 33, 60),
backgroundColor: const Color.fromARGB(255, 29, 33, 60),
title: const Text(
"创作记录",
),
elevation: 0),
body: SafeArea(child: _mainView()),
body: SafeArea(child: _makeTableView()),
)
);
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment