218 lines
7.9 KiB
Dart
218 lines
7.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
// import 'package:flutter_svg/flutter_svg.dart';
|
|
|
|
class ConstImg {
|
|
ConstImg._();
|
|
|
|
static const String bottomBar = "assets/common/bottom_bar.png";
|
|
static const String tabHomeSelected = "assets/common/tab_home_selected.png";
|
|
static const String tabHomeUnselect = "assets/common/tab_home_unselect.png";
|
|
static const String tabSearchSelected =
|
|
"assets/common/tab_search_selected.png";
|
|
static const String tabSearchUnselect =
|
|
"assets/common/tab_search_unselect.png";
|
|
static const String tabLikeSelected = "assets/common/tab_like_selected.png";
|
|
static const String tabLikeUnselect = "assets/common/tab_like_unselect.png";
|
|
static const String tabMineSelected = "assets/common/tab_mine_selected.png";
|
|
static const String tabMineUnselect = "assets/common/tab_mine_unselect.png";
|
|
// loading
|
|
static const String loading = "assets/common/loading.gif";
|
|
static const String btnBg = "assets/common/btn_bg.png";
|
|
static const String noData = "assets/common/no_data.png";
|
|
static const String nodataImg = "assets/common/nodata_img.png";
|
|
static const String noworkImg = "assets/common/nowork_img.png";
|
|
// applogo
|
|
static const String appLogo = "assets/common/applogo.png";
|
|
// space_img_h
|
|
static const String spaceImgH = "assets/common/space_img_h.png";
|
|
static const String spaceImgW = "assets/common/space_img_w.png";
|
|
|
|
|
|
static const String homeBg = "assets/imgs/home_bg.png";
|
|
|
|
// home_card_bg
|
|
static const String homeCardBg = "assets/imgs/home_card_bg.png";
|
|
// home_top_bg
|
|
static const String homeTopBg = "assets/imgs/home_top_bg.png";
|
|
// home_title_daily/hot/hot_cate/mystery/weekly
|
|
static const String homeTitleDaily = "assets/imgs/home_title_daily.png";
|
|
static const String homeTitleHot = "assets/imgs/home_title_hot.png";
|
|
static const String homeTitleHotCate = "assets/imgs/home_title_hot_cate.png";
|
|
static const String homeTitleMystery = "assets/imgs/home_title_mystery.png";
|
|
static const String homeTitleWeekly = "assets/imgs/home_title_weekly.png";
|
|
static const String homeOpenNowBox = "assets/imgs/home_opennow_box.png";
|
|
// splash_page
|
|
static const String splashPage = "assets/imgs/splash_page.png";
|
|
// heart
|
|
static const String heart = "assets/imgs/heart.png";
|
|
// hot_bg1
|
|
static const String hotBg1 = "assets/imgs/hot_bg1.png";
|
|
static const String hotBg2 = "assets/imgs/hot_bg2.png";
|
|
// home_rank_bg
|
|
static const String homeRankBg = "assets/imgs/home_rank_bg.png";
|
|
// yellow_bg purple red
|
|
static const String yellowBg = "assets/imgs/yellow_bg.png";
|
|
static const String purpleBg = "assets/imgs/purple_bg.png";
|
|
static const String redBg = "assets/imgs/red_bg.png";
|
|
// box cl gift opened
|
|
static const String boxBtn = "assets/imgs/box_button.png";
|
|
static const String boxClose = "assets/imgs/box_close.png";
|
|
static const String boxOpened = "assets/imgs/box_opened.png";
|
|
static const String boxGift = "assets/imgs/box_gift.png";
|
|
|
|
/// pics
|
|
static const String delete = "assets/pics/delete.png";
|
|
static const String back = "assets/pics/back.png";
|
|
static const String search = "assets/pics/search_icon.png";
|
|
static const String hot = "assets/pics/hot.png";
|
|
static const String star = "assets/pics/star.png";
|
|
static const String look = "assets/pics/look.png";
|
|
// bgs
|
|
static const String likeBg = "assets/pics/like_bg.png";
|
|
static const String collectionBg = "assets/pics/collection_bg.png";
|
|
static const String playlogBg = "assets/pics/playlog_bg.png";
|
|
// like_selected_bg
|
|
static const String likeSelectedBg = "assets/pics/like_selected_bg.png";
|
|
static const String likeUnselectBg = "assets/pics/like_unselect_bg.png";
|
|
static const String continueWatch = "assets/pics/continue_watch.png";
|
|
static const String playLt = "assets/pics/player_lt.png";
|
|
static const String liked = "assets/pics/liked.png";
|
|
static const String unlike = "assets/pics/unlike.png";
|
|
static const String espBg = "assets/pics/esp_bg.png";
|
|
static const String cateSelLeft = "assets/pics/cate_sel_left.png";
|
|
static const String cateSelRight = "assets/pics/cate_sel_right.png";
|
|
|
|
static const String playTag = "assets/pics/play_tag.png";
|
|
static const String rank1 = "assets/pics/rank1.png";
|
|
static const String rank2 = "assets/pics/rank2.png";
|
|
static const String rank3 = "assets/pics/rank3.png";
|
|
|
|
/// mine
|
|
static const String copy = "assets/mine/copy.png";
|
|
static const String littleLeft = "assets/mine/little_left.png";
|
|
static const String littleRight = "assets/mine/little_right.png";
|
|
static const String mineTop = "assets/mine/mine_top.png";
|
|
static const String sectionTopBg = "assets/mine/section_top_bg.png";
|
|
static const String sectionBg1 = "assets/mine/section_bg1.png";
|
|
static const String sectionBg2 = "assets/mine/section_bg2.png";
|
|
static const String sectionBg3 = "assets/mine/section_bg3.png";
|
|
static const String defAvatar = "assets/mine/def_avatar.png";
|
|
// mine_btn_bg
|
|
static const String mineBtnBg = "assets/mine/mine_btn_bg.png";
|
|
static const String mineAb = "assets/mine/mine_ab.png";
|
|
static const String minePp = "assets/mine/mine_pp.png";
|
|
static const String mineUa = "assets/mine/mine_ua.png";
|
|
static const String collection = "assets/mine/collection.png";
|
|
|
|
|
|
|
|
static const String loadingJson = "assets/bagua.json";
|
|
// static get appLoading => Lottie.asset(loadingJson, width: 60, height: 60);
|
|
}
|
|
|
|
class HelpImg {
|
|
/// load local
|
|
static Widget asset(
|
|
String path, {
|
|
BoxFit? fit,
|
|
double? width,
|
|
double? height,
|
|
Color? color,
|
|
bool isDartData = false,
|
|
String? dartPath,
|
|
}) {
|
|
String assets = path;
|
|
|
|
return Image.asset(
|
|
assets,
|
|
fit: fit,
|
|
width: width,
|
|
height: height,
|
|
color: color,
|
|
);
|
|
}
|
|
|
|
static Widget networkRadius(
|
|
String path, {
|
|
BoxFit? fit,
|
|
double? width,
|
|
double? height,
|
|
BoxShape? shape,
|
|
BorderRadius? borderRadius,
|
|
Widget? errorWidget,
|
|
bool isWidth = false,
|
|
}) {
|
|
return ClipRRect(
|
|
borderRadius: borderRadius ?? BorderRadius.circular(3),
|
|
child: network(
|
|
path,
|
|
fit: fit,
|
|
width: width,
|
|
height: height,
|
|
shape: shape,
|
|
errorWidget: errorWidget,
|
|
isWidth: isWidth
|
|
),
|
|
);
|
|
}
|
|
|
|
/// load network
|
|
static Widget network(
|
|
String path, {
|
|
BoxFit? fit,
|
|
double? width,
|
|
double? height,
|
|
Color? color,
|
|
BoxShape? shape,
|
|
BorderRadius? borderRadius,
|
|
Widget? errorWidget,
|
|
bool isWidth = false,
|
|
}) {
|
|
// bool isSvg = path.toLowerCase().endsWith('.svg');
|
|
// if (isSvg) {
|
|
// return SvgPicture.network(
|
|
// path,
|
|
// width: width,
|
|
// height: height,
|
|
// // fit: fit ?? BoxFit.fill,
|
|
// colorFilter: color != null
|
|
// ? ColorFilter.mode(color, BlendMode.srcIn)
|
|
// : null,
|
|
// placeholderBuilder: (context) => Container(
|
|
// width: width,
|
|
// height: height,
|
|
// color: Colors.grey[200],
|
|
// child: Center(child: CircularProgressIndicator()),
|
|
// ),
|
|
// );
|
|
// }
|
|
return FadeInImage.assetNetwork(
|
|
placeholder: isWidth==true ? ConstImg.spaceImgW : ConstImg.spaceImgH, image: path,
|
|
width: width, height: height, fit: BoxFit.cover
|
|
);
|
|
|
|
return Image.network(
|
|
path,
|
|
width: width,
|
|
height: height,
|
|
fit: fit,
|
|
loadingBuilder: (context, child, loadingProgress) {
|
|
if (loadingProgress == null) return child;
|
|
return HelpImg.asset(isWidth==true ? ConstImg.spaceImgW : ConstImg.spaceImgH, fit: BoxFit.fill,
|
|
width: width, height: height
|
|
);
|
|
},
|
|
errorBuilder: (context, error, stackTrace) {
|
|
// ✅ 关键:处理加载失败的情况
|
|
return errorWidget ??
|
|
SizedBox(
|
|
width: width, height: height,
|
|
child: HelpImg.asset(isWidth==true ? ConstImg.spaceImgW : ConstImg.spaceImgH, fit: BoxFit.fill,
|
|
width: width, height: height
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|