add global auto unfocus

finish advice page
add image preview page
hmxc
小赖 4 years ago
parent e2966ca68a
commit 92f82b1349

@ -5,6 +5,7 @@ import 'package:akuCommunity/utils/developer_util.dart';
import 'package:bot_toast/bot_toast.dart'; import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';
import 'package:fluwx/fluwx.dart'; import 'package:fluwx/fluwx.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@ -41,6 +42,16 @@ class _MyAppState extends State<MyApp> {
ChangeNotifierProvider(create: (context) => UserProvider()), ChangeNotifierProvider(create: (context) => UserProvider()),
ChangeNotifierProvider(create: (context) => SignUpProvider()), ChangeNotifierProvider(create: (context) => SignUpProvider()),
], ],
child: GestureDetector(
onTap: () {
//
//
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus &&
currentFocus.focusedChild != null) {
FocusManager.instance.primaryFocus.unfocus();
}
},
child: GetMaterialApp( child: GetMaterialApp(
title: '智慧社区', title: '智慧社区',
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,
@ -59,6 +70,7 @@ class _MyAppState extends State<MyApp> {
builder: BotToastInit(), builder: BotToastInit(),
navigatorObservers: [BotToastNavigatorObserver()], navigatorObservers: [BotToastNavigatorObserver()],
), ),
),
); );
} }
} }

@ -1,7 +1,11 @@
import 'dart:io';
import 'package:akuCommunity/const/resource.dart'; import 'package:akuCommunity/const/resource.dart';
import 'package:akuCommunity/ui/manager/advice/advice_page.dart'; import 'package:akuCommunity/ui/manager/advice/advice_page.dart';
import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart';
import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/utils/headers.dart';
import 'package:akuCommunity/widget/buttons/bottom_button.dart';
import 'package:akuCommunity/widget/picker/grid_image_picker.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:velocity_x/velocity_x.dart'; import 'package:velocity_x/velocity_x.dart';
@ -16,6 +20,7 @@ class NewAdvicePage extends StatefulWidget {
class _NewAdvicePageState extends State<NewAdvicePage> { class _NewAdvicePageState extends State<NewAdvicePage> {
int _type = 0; int _type = 0;
List<File> _files = [];
String get title { String get title {
switch (widget.type) { switch (widget.type) {
case AdviceType.SUGGESTION: case AdviceType.SUGGESTION:
@ -106,12 +111,36 @@ class _NewAdvicePageState extends State<NewAdvicePage> {
24.hb, 24.hb,
TextField( TextField(
// controller: , // controller: ,
minLines: 6,
maxLines: 99,
decoration: InputDecoration( decoration: InputDecoration(
border: OutlineInputBorder(), border: OutlineInputBorder(),
isDense: true,
contentPadding: EdgeInsets.symmetric(
horizontal: 22.w,
vertical: 32.w,
),
hintText: '您对我们的工作有什么建议吗?欢迎您提给我们宝贵的建议,谢谢',
hintStyle: TextStyle(
fontSize: 28.sp,
color: Color(0xFF999999),
),
),
), ),
32.hb,
'添加图片信息(${_files.length}/9)'.text.size(28.sp).make(),
24.hb,
GridImagePicker(
onChange: (files) {
_files = files;
},
), ),
], ],
), ),
bottomNavi: BottomButton(
onPressed: () {},
child: '确认提交'.text.make(),
),
); );
} }
} }

@ -3,8 +3,13 @@ import 'package:flutter/cupertino.dart';
import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/utils/headers.dart';
import 'package:akuCommunity/base/base_style.dart'; import 'package:akuCommunity/base/base_style.dart';
//TODO CLEAN BOTTOM CODES. ///TODO CLEAN BOTTOM CODES.
//THIS IS SHIT BUTTON ///
///THIS IS SHIT BUTTON
///
///use `widget/buttons/bottom_button` instead of this widget.
///
///try import `'package:akuCommunity/widget/buttons/bottom_button.dart'`
@Deprecated("sh*t bottom_button need to be cleaned.") @Deprecated("sh*t bottom_button need to be cleaned.")
class BottomButton extends StatefulWidget { class BottomButton extends StatefulWidget {
final String title; final String title;

@ -0,0 +1,33 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class BeeImagePreview extends StatefulWidget {
final File file;
BeeImagePreview({Key key, @required this.file}) : super(key: key);
@override
_BeeImagePreviewState createState() => _BeeImagePreviewState();
}
class _BeeImagePreviewState extends State<BeeImagePreview> {
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: Get.back,
child: Scaffold(
backgroundColor: Colors.black54,
body: Center(
child: InteractiveViewer(
minScale: 0.2,
child: Hero(
tag: widget.file.hashCode,
child: Image.file(widget.file),
),
),
),
),
);
}
}

@ -1,6 +1,7 @@
import 'dart:io'; import 'dart:io';
import 'package:akuCommunity/painters/plus_painter.dart'; import 'package:akuCommunity/painters/plus_painter.dart';
import 'package:akuCommunity/widget/picker/bee_image_picker.dart'; import 'package:akuCommunity/widget/picker/bee_image_picker.dart';
import 'package:akuCommunity/widget/picker/bee_image_preview.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -64,15 +65,20 @@ class _GridImagePickerState extends State<GridImagePicker> {
} }
Widget _buildItem(File file) { Widget _buildItem(File file) {
return Container( return Hero(
tag: file.hashCode,
child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.w), borderRadius: BorderRadius.circular(8.w),
image: DecorationImage( image: DecorationImage(
image: FileImage(file), image: FileImage(file),
fit: BoxFit.cover,
), ),
), ),
child: MaterialButton( child: MaterialButton(
onPressed: () {}, onPressed: () {
Get.to(BeeImagePreview(file: file),opaque: false);
},
onLongPress: () async { onLongPress: () async {
bool result = await Get.dialog(CupertinoAlertDialog( bool result = await Get.dialog(CupertinoAlertDialog(
title: '删除该图片?'.text.isIntrinsic.make(), title: '删除该图片?'.text.isIntrinsic.make(),
@ -91,6 +97,7 @@ class _GridImagePickerState extends State<GridImagePicker> {
setState(() {}); setState(() {});
}, },
), ),
),
); );
} }

Loading…
Cancel
Save