diff --git a/README.md b/README.md index 34c772c..105d86c 100644 --- a/README.md +++ b/README.md @@ -24,3 +24,16 @@ Image Picker (图片选择) Geolocator (位置信息) HTTP/Dio (网络请求) + +# !/bin/bash + +echo "开始清理..." +flutter clean + +echo "获取依赖..." +flutter pub get + +echo "构建APK..." +flutter build apk --release --target-platform android-arm64 + +echo "构建完成!APK位置:build/app/outputs/flutter-apk/app-release.apk" diff --git a/lib/data/repositories/problem_repository.dart b/lib/data/repositories/problem_repository.dart index e84b67b..a3db85f 100644 --- a/lib/data/repositories/problem_repository.dart +++ b/lib/data/repositories/problem_repository.dart @@ -54,6 +54,7 @@ class ProblemRepository extends GetxService { await sqliteProvider.deleteProblem(problemId); } + // TODO 添加创建者id,绑定信息显示 // 在ProblemRepository中添加 Future> fetchProblemsFromServer({ DateTime? startTime, diff --git a/lib/modules/problem/controllers/problem_form_controller.dart b/lib/modules/problem/controllers/problem_form_controller.dart index 709c695..2c0d8d7 100644 --- a/lib/modules/problem/controllers/problem_form_controller.dart +++ b/lib/modules/problem/controllers/problem_form_controller.dart @@ -1,3 +1,5 @@ +import 'dart:convert'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:image_picker/image_picker.dart'; @@ -14,6 +16,7 @@ import 'package:uuid/uuid.dart'; class ProblemFormController extends GetxController { final Problem? problem; + late Map bindInfo; final bool isReadOnly; final ProblemRepository problemRepository; @@ -29,6 +32,9 @@ class ProblemFormController extends GetxController { this.isReadOnly = false, }) { if (problem != null) { + if (problem!.bindData != null) { + bindInfo = jsonDecode(problem!.bindData!); + } descriptionController.text = problem!.description; locationController.text = problem!.location; final imagePaths = problem!.imageUrls @@ -42,6 +48,12 @@ class ProblemFormController extends GetxController { } } + // @override + // void onInit() { + // super.onInit(); + + // } + // 改进的 pickImage 方法 Future pickImage(ImageSource source) async { try { diff --git a/lib/modules/problem/views/problem_form_page.dart b/lib/modules/problem/views/problem_form_page.dart index da69250..955569a 100644 --- a/lib/modules/problem/views/problem_form_page.dart +++ b/lib/modules/problem/views/problem_form_page.dart @@ -47,6 +47,47 @@ class ProblemFormPage extends GetView { child: SingleChildScrollView( child: Column( children: [ + if (controller.problem?.bindData != null) + Container( + color: Colors.white, + padding: const EdgeInsets.symmetric( + horizontal: 16.0, + vertical: 8.0, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _buildSection( + '项目名称', + controller.bindInfo['projectName'], + ), + _buildDivider(), + _buildSection( + '企业名称', + controller.bindInfo['companyName'], + ), + _buildDivider(), + _buildSection( + '要素名称', + controller.bindInfo['censorElementName'], + ), + _buildDivider(), + _buildSection( + '评估内容', + controller.bindInfo['pgContent'], + ), + _buildDivider(), + _buildSection( + '建议项', + controller.bindInfo['suggestion'], + ), + _buildDivider(), + _buildSection('问题类型', ''), + _buildDivider(), + _buildSection('工艺设备名称', ''), + ], + ), + ), _buildInputCard( title: '问题描述', textController: controller.descriptionController, @@ -69,6 +110,61 @@ class ProblemFormPage extends GetView { ); } + // The main widget to build a section with a title and content. + Widget _buildSection(String title, dynamic content) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 12.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + title, + style: const TextStyle( + fontWeight: FontWeight.bold, + fontSize: 16.0, + color: Colors.black87, + ), + ), + const SizedBox(height: 8.0), + // This is where the content is dynamically rendered + ..._buildContent(content), + ], + ), + ); + } + + // A helper method to handle different types of content + List _buildContent(dynamic content) { + if (content is String) { + // If the content is a single string, return a single Text widget. + return [ + Text( + content.isEmpty ? "无" : content, + style: const TextStyle(fontSize: 15.0, color: Colors.black54), + ), + ]; + } else if (content is List) { + // If the content is a list (like suggestions), map it to Text widgets. + return content.map((item) { + // Safely access the 'desc' key from each item in the list + final String desc = (item as Map)['desc'] as String; + return Padding( + padding: const EdgeInsets.only(bottom: 4.0), + child: Text( + desc, + style: const TextStyle(fontSize: 15.0, color: Colors.black54), + ), + ); + }).toList(); + } + // Return an empty list if content is of an unsupported type. + return []; + } + + Widget _buildDivider() { + return Divider(height: 1, color: Colors.grey[300]); + } + /// 构建输入框卡片 Widget _buildInputCard({ required String title,