82 lines
2.2 KiB
Dart
Executable File
82 lines
2.2 KiB
Dart
Executable File
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:star_lock/app_settings/app_colors.dart';
|
|
import 'package:star_lock/login/selectCountryRegion/common/countryRegionEntity.dart';
|
|
|
|
class Utils {
|
|
static String getImgPath(String name, {String format = 'png'}) {
|
|
return 'assets/images/$name.$format';
|
|
}
|
|
|
|
static void showSnackBar(BuildContext context, String msg) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(
|
|
content: Text(msg),
|
|
duration: const Duration(seconds: 2),
|
|
),
|
|
);
|
|
}
|
|
|
|
static Widget getSusItem(BuildContext context, String tag,
|
|
{double susHeight = 40}) {
|
|
if (tag == '★') {
|
|
tag = '★ 热门城市';
|
|
}
|
|
return Container(
|
|
height: susHeight,
|
|
width: MediaQuery.of(context).size.width,
|
|
padding: const EdgeInsets.only(left: 16.0),
|
|
color: const Color(0xFFF3F4F5),
|
|
alignment: Alignment.centerLeft,
|
|
child: Text(
|
|
tag,
|
|
softWrap: false,
|
|
style: const TextStyle(
|
|
fontSize: 14.0,
|
|
color: Color(0xFF666666),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
static Widget getListItem(
|
|
BuildContext context, CountryRegionModel model, Function() onClick,
|
|
{double susHeight = 40}) {
|
|
return GestureDetector(
|
|
child: Container(
|
|
color: Colors.white,
|
|
height: 80.h,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: <Widget>[
|
|
SizedBox(
|
|
width: 20.w,
|
|
),
|
|
Text(
|
|
model.name!,
|
|
style: TextStyle(
|
|
color: AppColors.darkGrayTextColor, fontSize: 24.sp),
|
|
),
|
|
Expanded(
|
|
child: SizedBox(
|
|
width: 30.w,
|
|
)),
|
|
// Text(
|
|
// '+${model.code}',
|
|
// style: TextStyle(color: AppColors.blackColor, fontSize: 22.sp),
|
|
// ),
|
|
// SizedBox(
|
|
// width: 60.w,
|
|
// )
|
|
],
|
|
),
|
|
),
|
|
onTap: () {
|
|
onClick();
|
|
// LogUtil.e("onItemClick : $model");
|
|
// Utils.showSnackBar(context, 'onItemClick : ${model.name}');
|
|
},
|
|
);
|
|
}
|
|
}
|