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:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';
import 'package:fluwx/fluwx.dart';
import 'package:get/get.dart';
import 'package:provider/provider.dart';
@ -41,23 +42,34 @@ class _MyAppState extends State<MyApp> {
ChangeNotifierProvider(create: (context) => UserProvider()),
ChangeNotifierProvider(create: (context) => SignUpProvider()),
],
child: GetMaterialApp(
title: '智慧社区',
debugShowCheckedModeBanner: false,
theme: ThemeData(primarySwatch: Colors.yellow),
home: SplashPage(),
//
localizationsDelegates: [
PickerLocalizationsDelegate.delegate,
RefreshLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: [const Locale('zh', 'CH')],
locale: Locale('zh'),
builder: BotToastInit(),
navigatorObservers: [BotToastNavigatorObserver()],
child: GestureDetector(
onTap: () {
//
//
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus &&
currentFocus.focusedChild != null) {
FocusManager.instance.primaryFocus.unfocus();
}
},
child: GetMaterialApp(
title: '智慧社区',
debugShowCheckedModeBanner: false,
theme: ThemeData(primarySwatch: Colors.yellow),
home: SplashPage(),
//
localizationsDelegates: [
PickerLocalizationsDelegate.delegate,
RefreshLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: [const Locale('zh', 'CH')],
locale: Locale('zh'),
builder: BotToastInit(),
navigatorObservers: [BotToastNavigatorObserver()],
),
),
);
}

@ -1,7 +1,11 @@
import 'dart:io';
import 'package:akuCommunity/const/resource.dart';
import 'package:akuCommunity/ui/manager/advice/advice_page.dart';
import 'package:akuCommunity/widget/bee_scaffold.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_screenutil/flutter_screenutil.dart';
import 'package:velocity_x/velocity_x.dart';
@ -16,6 +20,7 @@ class NewAdvicePage extends StatefulWidget {
class _NewAdvicePageState extends State<NewAdvicePage> {
int _type = 0;
List<File> _files = [];
String get title {
switch (widget.type) {
case AdviceType.SUGGESTION:
@ -106,12 +111,36 @@ class _NewAdvicePageState extends State<NewAdvicePage> {
24.hb,
TextField(
// controller: ,
minLines: 6,
maxLines: 99,
decoration: InputDecoration(
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/base/base_style.dart';
//TODO CLEAN BOTTOM CODES.
//THIS IS SHIT BUTTON
///TODO CLEAN BOTTOM CODES.
///
///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.")
class BottomButton extends StatefulWidget {
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 'package:akuCommunity/painters/plus_painter.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/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -64,32 +65,38 @@ class _GridImagePickerState extends State<GridImagePicker> {
}
Widget _buildItem(File file) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.w),
image: DecorationImage(
image: FileImage(file),
return Hero(
tag: file.hashCode,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.w),
image: DecorationImage(
image: FileImage(file),
fit: BoxFit.cover,
),
),
child: MaterialButton(
onPressed: () {
Get.to(BeeImagePreview(file: file),opaque: false);
},
onLongPress: () async {
bool result = await Get.dialog(CupertinoAlertDialog(
title: '删除该图片?'.text.isIntrinsic.make(),
actions: [
CupertinoDialogAction(
child: '取消'.text.isIntrinsic.make(),
onPressed: Get.back,
),
CupertinoDialogAction(
child: '确定'.text.red600.isIntrinsic.make(),
onPressed: () => Get.back(result: true),
),
],
));
if (result == true) _files.remove(file);
setState(() {});
},
),
),
child: MaterialButton(
onPressed: () {},
onLongPress: () async {
bool result = await Get.dialog(CupertinoAlertDialog(
title: '删除该图片?'.text.isIntrinsic.make(),
actions: [
CupertinoDialogAction(
child: '取消'.text.isIntrinsic.make(),
onPressed: Get.back,
),
CupertinoDialogAction(
child: '确定'.text.red600.isIntrinsic.make(),
onPressed: () => Get.back(result: true),
),
],
));
if (result == true) _files.remove(file);
setState(() {});
},
),
);
}

Loading…
Cancel
Save