app-starlock/star_lock/lib/baseWidget.dart
2023-08-29 17:39:35 +08:00

71 lines
2.0 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:star_lock/app_settings/app_colors.dart';
import 'package:star_lock/translations/trans_lib.dart';
import 'tools/refreshHeadFoot.dart';
mixin BaseWidget {
double fs(double value) => value.sp;
double w(double width) => width.w;
double h(double height) => height.h;
initUI(Widget widget) => ScreenUtilInit(
// designSize: const Size(750, 1334),
designSize: const Size(375, 812),
minTextAdapt: true,
splitScreenMode: true,
builder: (context, child) {
return widget;
},
);
///数据为空的视图
Widget emptyView() {
return Container(
width: double.infinity,
height: double.infinity,
color: Colors.white,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Image.asset(
'images/icon_unHaveData.png',
height: 120.w,
width: 120.w,
),
Padding(
padding: const EdgeInsets.only(top: 10),
child: Text(TranslationLoader.lanKeys!.noData!.tr,
style: TextStyle(
fontSize: 22.sp, color: AppColors.darkGrayTextColor)),
)
],
),
);
}
SmartRefresher smartRefresher(RefreshController refreshController,{
Widget? child,
Function()? onRefresh,
Function()? onLoading,
bool enablePullDown = true,
bool enablePullUp = false,
bool enableTwoLevel = false,
}) => SmartRefresher(
controller: refreshController,
onRefresh: onRefresh,
onLoading: onLoading,
enablePullUp: enablePullUp,
enablePullDown: enablePullDown,
enableTwoLevel: enableTwoLevel,
header: const HeaderWidget(),
footer: const FooterWidget(),
child: child,
);
}