feat:增加Minio工具类
This commit is contained in:
@@ -79,7 +79,6 @@ Widget _buildCancelButton(BuildContext context) {
|
||||
backgroundColor: Colors.white,
|
||||
foregroundColor: const Color(0xFF4E5969),
|
||||
side: const BorderSide(color: Color(0xFFDCDFE6)),
|
||||
padding: const EdgeInsets.symmetric(vertical: 15),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||
elevation: 0,
|
||||
),
|
||||
@@ -90,10 +89,9 @@ Widget _buildCancelButton(BuildContext context) {
|
||||
/// 提交按钮
|
||||
Widget _buildSubmitButton(BuildContext context, VoidCallback onConfirm) {
|
||||
return ElevatedButton(
|
||||
onPressed: onConfirm,
|
||||
onPressed: () => onConfirm(),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).primaryColor, // 使用传入的context获取主题
|
||||
padding: const EdgeInsets.symmetric(vertical: 15),
|
||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||
elevation: 0,
|
||||
),
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:photo_view/photo_view.dart';
|
||||
import 'package:photo_view/photo_view_gallery.dart';
|
||||
@@ -88,19 +90,35 @@ class _ImagePreviewPageState extends State<ImagePreviewPage> {
|
||||
}
|
||||
}
|
||||
|
||||
Widget buildFileImage(BuildContext context, File imageFile) {
|
||||
return GestureDetector(
|
||||
onTap: () => showFullScreenImage(context, FileImage(imageFile)),
|
||||
child: Image(
|
||||
image: FileImage(imageFile),
|
||||
width: 120,
|
||||
height: 120,
|
||||
fit: BoxFit.cover,
|
||||
loadingBuilder: (context, child, loadingProgress) {
|
||||
if (loadingProgress == null) return child;
|
||||
return buildImageLoadingIndicator(loadingProgress);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildNetworkImage(BuildContext context, String url) {
|
||||
return ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
_showFullScreenImage(context, url);
|
||||
showFullScreenImage(context, NetworkImage(url));
|
||||
},
|
||||
child: Image.network(
|
||||
url,
|
||||
fit: BoxFit.cover,
|
||||
loadingBuilder: (context, child, loadingProgress) {
|
||||
if (loadingProgress == null) return child;
|
||||
return _buildLoadingIndicator(loadingProgress);
|
||||
return buildImageLoadingIndicator(loadingProgress);
|
||||
},
|
||||
errorBuilder: (context, error, stackTrace) => _buildErrorImage(),
|
||||
),
|
||||
@@ -108,7 +126,7 @@ Widget buildNetworkImage(BuildContext context, String url) {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLoadingIndicator(ImageChunkEvent? loadingProgress) {
|
||||
Widget buildImageLoadingIndicator(ImageChunkEvent? loadingProgress) {
|
||||
return Center(
|
||||
child: SizedBox(
|
||||
width: 30,
|
||||
@@ -131,15 +149,14 @@ Widget _buildErrorImage() {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPhotoView(String url) {
|
||||
Widget _buildPhotoView(ImageProvider imageProvider) {
|
||||
return PhotoView(
|
||||
imageProvider: NetworkImage(url),
|
||||
imageProvider: imageProvider,
|
||||
backgroundDecoration: const BoxDecoration(color: Colors.transparent),
|
||||
minScale: PhotoViewComputedScale.contained,
|
||||
maxScale: PhotoViewComputedScale.covered * 2,
|
||||
initialScale: PhotoViewComputedScale.contained,
|
||||
heroAttributes: PhotoViewHeroAttributes(tag: url),
|
||||
loadingBuilder: (context, event) => _buildLoadingIndicator(event),
|
||||
loadingBuilder: (context, event) => buildImageLoadingIndicator(event),
|
||||
errorBuilder: (context, error, stackTrace) => _buildErrorImage(),
|
||||
);
|
||||
}
|
||||
@@ -155,7 +172,7 @@ Widget _buildCloseImage(BuildContext context) {
|
||||
);
|
||||
}
|
||||
|
||||
void _showFullScreenImage(BuildContext context, String url) {
|
||||
void showFullScreenImage(BuildContext context, ImageProvider imageProvider) {
|
||||
Navigator.of(context).push(
|
||||
PageRouteBuilder(
|
||||
opaque: false,
|
||||
@@ -169,7 +186,7 @@ void _showFullScreenImage(BuildContext context, String url) {
|
||||
body: Stack(
|
||||
children: [
|
||||
// 可缩放图片
|
||||
Positioned.fill(child: _buildPhotoView(url)),
|
||||
Positioned.fill(child: _buildPhotoView(imageProvider)),
|
||||
// 关闭按钮
|
||||
_buildCloseImage(context),
|
||||
],
|
||||
@@ -179,3 +196,46 @@ void _showFullScreenImage(BuildContext context, String url) {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildImageUploadButton({required VoidCallback onPickImage}) {
|
||||
return InkWell(
|
||||
onTap: onPickImage,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Container(
|
||||
width: 96,
|
||||
height: 96,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: Colors.black),
|
||||
),
|
||||
child: const Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.add, color: Color(0xFF86909C)),
|
||||
SizedBox(height: 6),
|
||||
Text('添加图片', style: TextStyle(color: Color(0xFF86909C))),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildDeleteImage({required VoidCallback onRemoveImage}) {
|
||||
return Positioned(
|
||||
top: 0,
|
||||
right: 0,
|
||||
child: GestureDetector(
|
||||
onTap: onRemoveImage,
|
||||
child: Container(
|
||||
width: 24,
|
||||
height: 24,
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.red,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: const Icon(Icons.close, color: Colors.white, size: 16),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ class _RecipeCalendarState extends State<RecipeCalendar> {
|
||||
DateTime _selectedDay = DateTime.now();
|
||||
DateTime _focusedDay = DateTime.now();
|
||||
|
||||
List<Record> recordList = [];
|
||||
List<Record> selectRecordList = [];
|
||||
List<FoodRecord> recordList = [];
|
||||
List<FoodRecord> selectRecordList = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -109,7 +109,7 @@ class _RecipeCalendarState extends State<RecipeCalendar> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget recipeRecordItem(BuildContext context, Record record) {
|
||||
Widget recipeRecordItem(BuildContext context, FoodRecord record) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
|
||||
return Card(
|
||||
|
||||
@@ -15,7 +15,7 @@ class RecipeTimeline extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _RecipeTimeline extends State<RecipeTimeline> {
|
||||
List<Record> recordList = [];
|
||||
List<FoodRecord> recordList = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -30,7 +30,7 @@ class _RecipeTimeline extends State<RecipeTimeline> {
|
||||
});
|
||||
}
|
||||
|
||||
Widget buildTimelineCard(BuildContext context, Record record) {
|
||||
Widget buildTimelineCard(BuildContext context, FoodRecord record) {
|
||||
final imageUrls = ['${AppConfig.baseApiUrl}/${record.imageUrl}'];
|
||||
|
||||
void imageTapClick() {
|
||||
@@ -79,7 +79,7 @@ class _RecipeTimeline extends State<RecipeTimeline> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildTimeline(BuildContext context, List<Record> recordList) {
|
||||
Widget buildTimeline(BuildContext context, List<FoodRecord> recordList) {
|
||||
if (recordList.isEmpty) {
|
||||
return buildEmptyData();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user