| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- import 'package:flutter/cupertino.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:keyboard/utils/grid_util.dart';
- import '../data/bean/widget_location.dart';
- import '../resource/assets.gen.dart';
- /// 步骤卡片工具类
- class StepCardUtil {
- StepCardUtil._();
- /// 一列多少个
- static const int defaultCrossAxisCount = 3;
- /// 获取卡片背景图片
- static ImageProvider getCardBgImageProvider(
- int itemCount, {
- int crossAxisCount = defaultCrossAxisCount,
- }) {
- // 计算出九宫格有多少行
- int rowCount = GridUtil.calculateRowCount(itemCount, crossAxisCount);
- // 根据行数不同,使用不同的步骤卡片背景
- if (rowCount == 1) {
- return Assets.images.bgIntimacyAnalyseUploadCard.provider();
- } else if (rowCount == 2) {
- return Assets.images.bgIntimacyAnalyseUploadCard2.provider();
- } else {
- return Assets.images.bgIntimacyAnalyseUploadCard3.provider();
- }
- }
- /// 计算顶部Icon的位置
- static WidgetLocation calculateTopIconWidgetLocation(
- int itemCount, {
- int crossAxisCount = defaultCrossAxisCount,
- }) {
- // 计算出九宫格有多少行
- int rowCount = GridUtil.calculateRowCount(itemCount, crossAxisCount);
- if (rowCount == 1) {
- return WidgetLocation(null, -8.h, 0, null);
- } else if (rowCount == 2) {
- return WidgetLocation(null, -5.h, 0, null);
- } else {
- return WidgetLocation(null, -11.h, 0, null);
- }
- }
- }
|