feat: optimize ui

This commit is contained in:
louis 2024-03-22 17:26:57 +08:00
parent f325cce223
commit 9e39aa8c41
38 changed files with 294 additions and 265 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 202 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 347 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 164 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 202 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 410 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 616 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 322 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 208 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 202 KiB

View File

@ -15,7 +15,7 @@ class AppTheme {
static const Color nearlyWhite = Color(0xFFFEFEFE); static const Color nearlyWhite = Color(0xFFFEFEFE);
static const Color black = Color(0xFF000000); static const Color black = Color(0xFF000000);
static const Color nearlyBlack = Color(0xFF213333); static const Color nearlyBlack = Color(0xFF213333);
static const Color grey = Color(0xFF3A5160); static const Color grey = Color.fromARGB(255, 98, 101, 102);
static const Color snackbarErrorBackgroudColor = Colors.red; static const Color snackbarErrorBackgroudColor = Colors.red;
static const Color snackbarSuccessBackgroudColor = Colors.green; static const Color snackbarSuccessBackgroudColor = Colors.green;
static const Color snackbarWarningBackgroudColor = Colors.orange; static const Color snackbarWarningBackgroudColor = Colors.orange;

View File

@ -8,6 +8,6 @@ enum InventoryInOrOutEnum { In, Out }
// InventoryInOrOutEnum // InventoryInOrOutEnum
const Map<InventoryInOrOutEnum, int> InventoryInOrOutEnumValues = { const Map<InventoryInOrOutEnum, int> InventoryInOrOutEnumValues = {
InventoryInOrOutEnum.In: 1, InventoryInOrOutEnum.In: 0,
InventoryInOrOutEnum.Out: 2, InventoryInOrOutEnum.Out: 1,
}; };

View File

@ -50,9 +50,9 @@ class IndexPage extends StatelessWidget {
if (AppInfoService.to.checkIsFirstInstall()) { if (AppInfoService.to.checkIsFirstInstall()) {
// app打开的页面 // app打开的页面
} }
return StorageService.to.getString(CacheKeys.token, isWithUser: false) == final token =
null StorageService.to.getString(CacheKeys.token, isWithUser: false);
? RouteConfig.login bool isLogined = token != null;
: RouteConfig.home; return isLogined ? RouteConfig.home : RouteConfig.login;
} }
} }

View File

@ -18,14 +18,16 @@ class ChangeButtonRow extends StatelessWidget {
children: [ children: [
const TodayButton(), const TodayButton(),
const Spacer(), const Spacer(),
InkWell( ClipOval(
child: InkWell(
onTap: () => controller.onMoveBack(), onTap: () => controller.onMoveBack(),
child: ChangeIconButton( child: ChangeIconButton(
icon: Icon( icon: Icon(
Icons.arrow_back_ios_rounded, Icons.arrow_back_ios_rounded,
color: Colors.white, color: Colors.white,
size: ScreenAdaper.sp(30), size: ScreenAdaper.sp(30),
))), )),
)),
const SizedBox( const SizedBox(
width: defaultPadding, width: defaultPadding,
), ),

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:sk_base_mobile/app_theme.dart';
import 'package:sk_base_mobile/constants/bg_color.dart'; import 'package:sk_base_mobile/constants/bg_color.dart';
import 'package:sk_base_mobile/util/screen_adaper_util.dart'; import 'package:sk_base_mobile/util/screen_adaper_util.dart';
@ -11,8 +12,11 @@ class ChangeIconButton extends StatelessWidget {
height: ScreenAdaper.height(60), height: ScreenAdaper.height(60),
width: ScreenAdaper.height(60), width: ScreenAdaper.height(60),
alignment: Alignment.center, alignment: Alignment.center,
decoration: decoration: BoxDecoration(
BoxDecoration(shape: BoxShape.circle, color: neviBlue, boxShadow: [ shape: BoxShape.circle,
gradient: const LinearGradient(
colors: [AppTheme.primaryColorLight, AppTheme.primaryColor]),
boxShadow: [
BoxShadow( BoxShadow(
color: neviBlue.withOpacity(.3), color: neviBlue.withOpacity(.3),
offset: Offset(0, ScreenAdaper.height(10)), offset: Offset(0, ScreenAdaper.height(10)),

View File

@ -1,14 +1,14 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:sk_base_mobile/app_theme.dart';
import 'package:sk_base_mobile/config.dart'; import 'package:sk_base_mobile/config.dart';
import 'package:sk_base_mobile/constants/bg_color.dart'; import 'package:sk_base_mobile/constants/bg_color.dart';
import 'package:sk_base_mobile/constants/data.dart';
import 'package:sk_base_mobile/constants/enum.dart';
import 'package:sk_base_mobile/screens/inventory_inout/components/inventory_inout_card_content.dart';
import 'package:sk_base_mobile/screens/inventory_inout/inventory_inout_controller.dart'; import 'package:sk_base_mobile/screens/inventory_inout/inventory_inout_controller.dart';
import 'package:sk_base_mobile/util/util.dart'; import 'package:sk_base_mobile/util/util.dart';
import 'package:sk_base_mobile/widgets/fade_in_cache_image.dart'; import 'package:sk_base_mobile/widgets/fade_in_cache_image.dart';
import '../../../constants/enum.dart';
class InventoryInoutCard extends StatelessWidget { class InventoryInoutCard extends StatelessWidget {
InventoryInoutCard({required this.index, required this.ind}); InventoryInoutCard({required this.index, required this.ind});
final int index; final int index;
@ -16,50 +16,28 @@ class InventoryInoutCard extends StatelessWidget {
final controller = Get.find<InventoryInoutController>(); final controller = Get.find<InventoryInoutController>();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Dismissible( return Container(
key: UniqueKey(),
confirmDismiss: (direction) async {
// return await ModalUtil.showWarningDialog(
// 'Remove Task', 'Are you sure to remove this task', 'Confirm', () {
// controller.db.delete(controller.list[ind][index].key, 'Tasks');
// controller.list[ind].remove(controller.list[ind][index]);
// });
},
child: Container(
margin: EdgeInsets.symmetric( margin: EdgeInsets.symmetric(
vertical: ScreenAdaper.height(15), vertical: ScreenAdaper.height(15),
horizontal: ScreenAdaper.width(15)), horizontal: ScreenAdaper.width(15)),
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(
horizontal: ScreenAdaper.width(defaultPadding)), horizontal: ScreenAdaper.width(defaultPadding),
vertical: ScreenAdaper.height(defaultPadding)),
decoration: BoxDecoration( decoration: BoxDecoration(
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: lightAccentBlue.withOpacity(.5), color: AppTheme.barrierColor.withOpacity(0.2),
offset: Offset(0, ScreenAdaper.height(5)), offset: Offset(0, ScreenAdaper.height(5)),
blurRadius: ScreenAdaper.sp(10)), blurRadius: ScreenAdaper.sp(10)),
], ],
color: Colors.white, color: AppTheme.nearlyWhite,
borderRadius: BorderRadius.circular(ScreenAdaper.sp(30))), borderRadius: BorderRadius.circular(ScreenAdaper.sp(30))),
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
// Image.asset( buildImage(),
// Data().images[controller.list[ind][index].image], Expanded(child: buildContent()),
// height: 100,
// width: 100,
// ),
if (controller.list[ind][index].files.isNotEmpty)
ClipRRect(
borderRadius: BorderRadius.circular(ScreenAdaper.sp(15)),
child: FadeInCacheImage(
width: ScreenAdaper.width(100),
height: ScreenAdaper.width(100),
url:
'${GloablConfig.OSS_URL}${controller.list[ind][index].files[0]?.path}'),
),
SizedBox(
width: ScreenAdaper.width(defaultPadding) / 2,
),
InventoryInoutCardContent(index: index, ind: ind),
// const Spacer( // const Spacer(
// flex: 2, // flex: 2,
// ), // ),
@ -171,6 +149,120 @@ class InventoryInoutCard extends StatelessWidget {
// ), // ),
], ],
), ),
);
}
Widget buildContent() {
return Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Text(
controller.list[ind][index].product?.name ?? '-',
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: ScreenAdaper.sp(25)),
)),
buildInOrOut()
],
),
Text(
controller.list[ind][index].product?.company?.name ?? '-',
style: TextStyle(
color: AppTheme.grey,
fontWeight: FontWeight.bold,
fontSize: ScreenAdaper.sp(20)),
),
SizedBox(
height: ScreenAdaper.height(5),
),
Row(
children: [
Expanded(
child: Text(
'项目: ${controller.list[ind][index].project?.name}',
style: TextStyle(
fontWeight: FontWeight.w600, fontSize: ScreenAdaper.sp(20)),
),
),
],
),
SizedBox(
height: ScreenAdaper.height(5),
),
Row(
children: [
Expanded(
child: Text(
'数量: ${controller.list[ind][index].quantity} ${controller.list[ind][index].product?.unit?.label ?? '-'}',
style: TextStyle(
fontWeight: FontWeight.w600, fontSize: ScreenAdaper.sp(20)),
),
),
Text(
controller.list[ind][index].agent ?? '-',
style: TextStyle(
fontWeight: FontWeight.w600, fontSize: ScreenAdaper.sp(20)),
),
],
)
],
);
}
Widget buildImage() {
return Container(
margin: EdgeInsets.only(right: ScreenAdaper.width(defaultPadding) / 2),
child: ClipRRect(
borderRadius: BorderRadius.circular(ScreenAdaper.sp(15)),
child: FadeInCacheImage(
width: ScreenAdaper.width(100),
height: ScreenAdaper.width(100),
url: controller.list[ind][index].product?.files.isNotEmpty ??
false
? '${GloablConfig.OSS_URL}${controller.list[ind][index].product?.files[0].path}'
: ''),
));
}
Widget buildInOrOut() {
final bgColor = controller.list[ind][index].inOrOut ==
InventoryInOrOutEnumValues[InventoryInOrOutEnum.In]
? AppTheme.snackbarSuccessBackgroudColor
: AppTheme.snackbarErrorBackgroudColor;
final textInOut = controller.list[ind][index].inOrOut ==
InventoryInOrOutEnumValues[InventoryInOrOutEnum.In]
? ''
: '';
return Container(
alignment: Alignment.center,
height: ScreenAdaper.height(40),
width: ScreenAdaper.width(40),
decoration: BoxDecoration(
shape: BoxShape.circle,
gradient: LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [
bgColor.withOpacity(0.6),
bgColor,
]),
boxShadow: [
BoxShadow(
color: lightOrange,
offset: Offset(0, ScreenAdaper.height(10)),
blurRadius: ScreenAdaper.sp(10))
]),
child: Text(
textInOut,
style: const TextStyle(
color: AppTheme.nearlyWhite, fontWeight: FontWeight.w600),
), ),
); );
} }

View File

@ -1,72 +0,0 @@
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sk_base_mobile/constants/bg_color.dart';
import 'package:sk_base_mobile/constants/data.dart';
import 'package:sk_base_mobile/screens/inventory_inout/inventory_inout_controller.dart';
import 'package:sk_base_mobile/util/screen_adaper_util.dart';
class InventoryInoutCardContent extends StatelessWidget {
InventoryInoutCardContent(
{super.key, required this.index, required this.ind});
final int index;
final int ind;
final int randomColor1 = Random().nextInt(9);
final int randomColor2 = Random().nextInt(9);
final controller = Get.find<InventoryInoutController>();
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
controller.list[ind][index].product?.name ?? 'Product Name',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: ScreenAdaper.sp(25)),
),
// Text(
// '${controller.list[ind][index].time} - ${controller.list[ind][index].time}',
// style: const TextStyle(
// color: Colors.grey, fontWeight: FontWeight.w300, fontSize: 12),
// ),
SizedBox(
height: ScreenAdaper.width(defaultPadding) / 2,
),
// Row(
// children: [
// Container(
// alignment: Alignment.center,
// padding: const EdgeInsets.symmetric(vertical: 3, horizontal: 10),
// decoration: BoxDecoration(
// color: Data().colors[randomColor1].withOpacity(.5),
// borderRadius: BorderRadius.circular(10),
// ),
// child: Text(
// Data().tags[Random().nextInt(13)],
// style: TextStyle(color: Data().colors[randomColor1]),
// ),
// ),
// const SizedBox(
// width: defaultPadding / 2,
// ),
// Container(
// alignment: Alignment.center,
// padding: const EdgeInsets.symmetric(vertical: 3, horizontal: 10),
// decoration: BoxDecoration(
// color: Data().colors[randomColor2].withOpacity(.5),
// borderRadius: BorderRadius.circular(10)),
// child: Text(
// Data().tags[Random().nextInt(13)],
// style: TextStyle(color: Data().colors[randomColor2]),
// ),
// )
// ],
// ),
],
);
}
}

View File

@ -15,12 +15,12 @@ class TaskList extends StatelessWidget {
return Responsive( return Responsive(
tablet: Grid( tablet: Grid(
crossAsis: 2, crossAsis: 2,
ratio: 3, ratio: 2.2,
ind: index, ind: index,
), ),
largeTablet: Grid( largeTablet: Grid(
crossAsis: 3, crossAsis: 3,
ratio: 3, ratio: 2.3,
ind: index, ind: index,
), ),
mobile: Grid( mobile: Grid(

View File

@ -9,7 +9,8 @@ class TaskPageView extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return PageView( return PageView(
physics: const NeverScrollableScrollPhysics(), physics: const BouncingScrollPhysics(),
reverse: true,
controller: controller.pageController, controller: controller.pageController,
children: List.generate( children: List.generate(
controller.daysNum, controller.daysNum,

View File

@ -59,7 +59,8 @@ class InventoryInoutController extends GetxController {
duration: const Duration(milliseconds: 100), duration: const Duration(milliseconds: 100),
left: value * 80, left: value * 80,
child: ClipRRect( child: ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(30)), borderRadius:
const BorderRadius.all(Radius.circular(30)),
child: Material( child: Material(
child: Ink( child: Ink(
decoration: BoxDecoration( decoration: BoxDecoration(
@ -67,7 +68,7 @@ class InventoryInoutController extends GetxController {
colors: [Colors.green[300]!, Colors.green], colors: [Colors.green[300]!, Colors.green],
), ),
borderRadius: borderRadius:
BorderRadius.all(Radius.circular(30)), const BorderRadius.all(Radius.circular(30)),
), ),
child: ElevatedButton( child: ElevatedButton(
onPressed: () { onPressed: () {
@ -80,7 +81,7 @@ class InventoryInoutController extends GetxController {
shadowColor: MaterialStateProperty.all( shadowColor: MaterialStateProperty.all(
Colors.transparent), Colors.transparent),
shape: MaterialStateProperty.all( shape: MaterialStateProperty.all(
RoundedRectangleBorder( const RoundedRectangleBorder(
borderRadius: borderRadius:
BorderRadius.all(Radius.circular(30)), BorderRadius.all(Radius.circular(30)),
), ),
@ -256,12 +257,12 @@ class InventoryInoutController extends GetxController {
} }
getDateAccordingTabs(int value) { getDateAccordingTabs(int value) {
return '${DateUtil.addPrefix(dateTime.add(Duration(days: value)).year.toString())}-${DateUtil.addPrefix(dateTime.add(Duration(days: value)).month.toString())}-${DateUtil.addPrefix(dateTime.add(Duration(days: value)).day.toString())}'; return DateUtil.format(dateTime.add(Duration(days: -(daysNum - value))));
} }
getSepretLists() { getSepretLists() {
List<RxList<InventoryInOutModel>> tempList = []; List<RxList<InventoryInOutModel>> tempList = [];
for (int i = 0; i < 7; i++) { for (int i = daysNum; i > 0; i--) {
RxList<InventoryInOutModel> tempList1 = <InventoryInOutModel>[].obs; RxList<InventoryInOutModel> tempList1 = <InventoryInOutModel>[].obs;
tempList1.clear(); tempList1.clear();
for (int j = 0; j < model.length; j++) { for (int j = 0; j < model.length; j++) {

View File

@ -115,7 +115,7 @@ class AuthStore extends GetxController {
try { try {
final response = await Api.getUserInfo(); final response = await Api.getUserInfo();
if (response.data != null) { if (response.data != null) {
UserInfoModel userInfo = UserInfoModel.fromJson(response.data['data']); UserInfoModel userInfo = UserInfoModel.fromJson(response.data);
await updateUserInfoState(userInfo); await updateUserInfoState(userInfo);
} }
} catch (e) { } catch (e) {

View File

@ -1,6 +1,8 @@
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:sk_base_mobile/app_theme.dart'; import 'package:sk_base_mobile/app_theme.dart';
import 'package:sk_base_mobile/util/screen_adaper_util.dart';
class FadeInCacheImage extends StatefulWidget { class FadeInCacheImage extends StatefulWidget {
final double? width; final double? width;
@ -40,13 +42,12 @@ class _FadeInCacheImageState extends State<FadeInCacheImage> {
theContext = context; theContext = context;
if ((widget.url == null || widget.url == '' || widget.url == 'null')) { if ((widget.url == null || widget.url == '' || widget.url == 'null')) {
return Image( return Container(
width: widget.width, width: widget.width,
height: widget.height, height: widget.height,
fit: widget.fit, child: Icon(Icons.image_not_supported,
image: AssetImage( size: ScreenAdaper.sp(100), color: AppTheme.grey),
'assets/images/deer_detail_banner1.jpg', );
));
} }
return buildImg(widget.url); return buildImg(widget.url);