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 black = Color(0xFF000000);
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 snackbarSuccessBackgroudColor = Colors.green;
static const Color snackbarWarningBackgroudColor = Colors.orange;

View File

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

View File

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

View File

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

View File

@ -1,4 +1,5 @@
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/util/screen_adaper_util.dart';
@ -11,8 +12,11 @@ class ChangeIconButton extends StatelessWidget {
height: ScreenAdaper.height(60),
width: ScreenAdaper.height(60),
alignment: Alignment.center,
decoration:
BoxDecoration(shape: BoxShape.circle, color: neviBlue, boxShadow: [
decoration: BoxDecoration(
shape: BoxShape.circle,
gradient: const LinearGradient(
colors: [AppTheme.primaryColorLight, AppTheme.primaryColor]),
boxShadow: [
BoxShadow(
color: neviBlue.withOpacity(.3),
offset: Offset(0, ScreenAdaper.height(10)),

View File

@ -1,14 +1,14 @@
import 'package:flutter/material.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/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/util/util.dart';
import 'package:sk_base_mobile/widgets/fade_in_cache_image.dart';
import '../../../constants/enum.dart';
class InventoryInoutCard extends StatelessWidget {
InventoryInoutCard({required this.index, required this.ind});
final int index;
@ -16,50 +16,28 @@ class InventoryInoutCard extends StatelessWidget {
final controller = Get.find<InventoryInoutController>();
@override
Widget build(BuildContext context) {
return Dismissible(
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(
return Container(
margin: EdgeInsets.symmetric(
vertical: ScreenAdaper.height(15),
horizontal: ScreenAdaper.width(15)),
padding: EdgeInsets.symmetric(
horizontal: ScreenAdaper.width(defaultPadding)),
horizontal: ScreenAdaper.width(defaultPadding),
vertical: ScreenAdaper.height(defaultPadding)),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: lightAccentBlue.withOpacity(.5),
color: AppTheme.barrierColor.withOpacity(0.2),
offset: Offset(0, ScreenAdaper.height(5)),
blurRadius: ScreenAdaper.sp(10)),
],
color: Colors.white,
color: AppTheme.nearlyWhite,
borderRadius: BorderRadius.circular(ScreenAdaper.sp(30))),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
// Image.asset(
// Data().images[controller.list[ind][index].image],
// 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),
buildImage(),
Expanded(child: buildContent()),
// const Spacer(
// 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(
tablet: Grid(
crossAsis: 2,
ratio: 3,
ratio: 2.2,
ind: index,
),
largeTablet: Grid(
crossAsis: 3,
ratio: 3,
ratio: 2.3,
ind: index,
),
mobile: Grid(

View File

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

View File

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

View File

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

View File

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