feat(flutter): 完成 K28-A1 四 Tab 首页
This commit is contained in:
1 parent
f981f88e0d
commit
49f3e63ed0
25 files changed
+606
-689
No files matched your search
@@ -28,8 +28,6 @@ class DiscoverLogic extends ChangeNotifier {
|
||||
String _lastRequestedQuery = '';
|
||||
int _searchRequest = 0;
|
||||
bool _disposed = false;
|
||||
TheaterLanguage language = TheaterLanguage.all;
|
||||
String? selectedCategoryId;
|
||||
|
||||
bool get hasSearchQuery => search.text.trim().isNotEmpty;
|
||||
|
||||
@@ -50,20 +48,6 @@ class DiscoverLogic extends ChangeNotifier {
|
||||
|
||||
void openSearch() => searchFocus.requestFocus();
|
||||
|
||||
/// Selects a language for the visual filter state.
|
||||
void selectLanguage(TheaterLanguage value) {
|
||||
if (language == value) return;
|
||||
language = value;
|
||||
notify();
|
||||
}
|
||||
|
||||
/// Selects one category chip; null represents all categories.
|
||||
void selectCategory(String? categoryId) {
|
||||
if (selectedCategoryId == categoryId) return;
|
||||
selectedCategoryId = categoryId;
|
||||
notify();
|
||||
}
|
||||
|
||||
void retrySearch() {
|
||||
final query = search.text.trim();
|
||||
if (query.isNotEmpty) unawaited(_runSearch(query));
|
||||
|
||||
@@ -7,9 +7,6 @@ import '../../core/data/models/drama.dart';
|
||||
/// 剧场页与根导航之间的动作。
|
||||
enum DiscoverPageAction { home, create, my }
|
||||
|
||||
/// Language choices shown by the theater filter UI.
|
||||
enum TheaterLanguage { all, zh, id, ms, en }
|
||||
|
||||
/// 剧场页导航回调;没有 `onAction` 时按独立页面处理。
|
||||
class DiscoverPageCallbacks {
|
||||
const DiscoverPageCallbacks({
|
||||
|
||||
@@ -4,8 +4,12 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../core/data/models/content_category.dart';
|
||||
import '../../core/data/models/drama.dart';
|
||||
import '../../core/data/models/home_feed.dart';
|
||||
import '../../core/data/repositories/catalog_repository.dart';
|
||||
import '../../core/data/repositories/search_repository.dart';
|
||||
import '../../core/data/services/catalog_controller.dart';
|
||||
import '../../core/data/services/category_controller.dart';
|
||||
import '../../core/formatting/error_text.dart';
|
||||
import '../../core/theme/app_colors.dart';
|
||||
@@ -15,14 +19,19 @@ import '../../core/widgets/app_bottom_nav.dart';
|
||||
import '../../core/widgets/empty_state.dart';
|
||||
import '../../l10n/app_localizations.dart';
|
||||
import '../drama_detail/drama_detail_view.dart';
|
||||
import 'category_dramas_page.dart';
|
||||
import 'discover_binding.dart';
|
||||
import 'discover_logic.dart';
|
||||
import 'discover_types.dart';
|
||||
import 'widgets/category_grid.dart';
|
||||
import 'widgets/discover_header.dart';
|
||||
import 'widgets/discover_search_field.dart';
|
||||
import 'widgets/discover_search_results.dart';
|
||||
import 'widgets/drama_grid.dart';
|
||||
import 'widgets/feed_banner_carousel.dart';
|
||||
import 'widgets/ranking_section.dart';
|
||||
|
||||
/// Theater page with fixed search, category chips, and a two-column catalogue.
|
||||
/// 剧场页:搜索 + 分类九宫格 + 榜单 + 全部剧目。
|
||||
class DiscoverPage extends StatefulWidget {
|
||||
const DiscoverPage({
|
||||
super.key,
|
||||
@@ -87,18 +96,13 @@ class _DiscoverPageState extends State<DiscoverPage> {
|
||||
Widget _page(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
final categories = context.watch<CategoryController>();
|
||||
final banners = context.watch<CatalogController>().banners;
|
||||
final content = SafeArea(
|
||||
bottom: !embedded,
|
||||
child: Column(
|
||||
children: [
|
||||
DiscoverHeader(
|
||||
controller: logic.search,
|
||||
focusNode: logic.searchFocus,
|
||||
onChanged: (_) => logic.onSearchChanged(),
|
||||
loading: logic.searchLoading,
|
||||
onProfile: _openProfile,
|
||||
),
|
||||
Expanded(child: _feed(l10n, categories)),
|
||||
DiscoverHeader(onSearch: logic.openSearch, onProfile: _openProfile),
|
||||
Expanded(child: _feed(l10n, categories, banners)),
|
||||
if (!embedded) _bottomNav(l10n),
|
||||
],
|
||||
),
|
||||
@@ -114,28 +118,43 @@ class _DiscoverPageState extends State<DiscoverPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _feed(AppLocalizations l10n, CategoryController categories) {
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: logic.searchFocus.unfocus,
|
||||
child: RefreshIndicator(
|
||||
key: const Key('discover-refresh'),
|
||||
color: AppColors.blue,
|
||||
backgroundColor: AppColors.card,
|
||||
onRefresh: categories.load,
|
||||
child: ListView(
|
||||
controller: logic.scroll,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
padding: const EdgeInsets.only(bottom: 24),
|
||||
children: _content(l10n, categories),
|
||||
),
|
||||
Widget _feed(
|
||||
AppLocalizations l10n,
|
||||
CategoryController categories,
|
||||
List<FeedBanner> banners,
|
||||
) {
|
||||
return RefreshIndicator(
|
||||
key: const Key('discover-refresh'),
|
||||
color: AppColors.blue,
|
||||
backgroundColor: AppColors.card,
|
||||
onRefresh: categories.load,
|
||||
child: ListView(
|
||||
controller: logic.scroll,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
padding: const EdgeInsets.only(bottom: 24),
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: DiscoverSearchField(
|
||||
controller: logic.search,
|
||||
focusNode: logic.searchFocus,
|
||||
onChanged: (_) => logic.onSearchChanged(),
|
||||
loading: logic.searchLoading,
|
||||
),
|
||||
),
|
||||
..._content(l10n, categories, banners),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> _content(AppLocalizations l10n, CategoryController categories) {
|
||||
List<Widget> _content(
|
||||
AppLocalizations l10n,
|
||||
CategoryController categories,
|
||||
List<FeedBanner> banners,
|
||||
) {
|
||||
if (logic.hasSearchQuery) return [_searchContent(l10n)];
|
||||
return _theaterContent(l10n, categories);
|
||||
return _theaterContent(l10n, categories, banners);
|
||||
}
|
||||
|
||||
Widget _searchContent(AppLocalizations l10n) => DiscoverSearchResults(
|
||||
@@ -149,6 +168,7 @@ class _DiscoverPageState extends State<DiscoverPage> {
|
||||
List<Widget> _theaterContent(
|
||||
AppLocalizations l10n,
|
||||
CategoryController categories,
|
||||
List<FeedBanner> banners,
|
||||
) {
|
||||
if (categories.loading && categories.feed.sections.isEmpty) {
|
||||
return [_block(const CircularProgressIndicator(strokeWidth: 2))];
|
||||
@@ -168,19 +188,38 @@ class _DiscoverPageState extends State<DiscoverPage> {
|
||||
),
|
||||
];
|
||||
}
|
||||
return _theaterBlocks(l10n, categories);
|
||||
return _theaterBlocks(l10n, categories, banners);
|
||||
}
|
||||
|
||||
List<Widget> _theaterBlocks(
|
||||
AppLocalizations l10n,
|
||||
CategoryController categories,
|
||||
List<FeedBanner> banners,
|
||||
) {
|
||||
final dramas = logic.selectedCategoryId == null
|
||||
? categories.feed.dramas
|
||||
: categories.dramasOf(logic.selectedCategoryId!);
|
||||
final dramas = categories.feed.dramas;
|
||||
return [
|
||||
_categoryChips(l10n, categories),
|
||||
_languageChips(l10n),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 12),
|
||||
child: CategoryGrid(
|
||||
categories: categories.categories,
|
||||
onTap: (category) => _openCategory(category, categories),
|
||||
),
|
||||
),
|
||||
if (banners.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 12),
|
||||
child: FeedBannerCarousel(
|
||||
banners: banners,
|
||||
active: widget.active,
|
||||
onOpen: _openBanner,
|
||||
),
|
||||
),
|
||||
if (categories.feed.sections.isNotEmpty || dramas.isNotEmpty)
|
||||
RankingSection(
|
||||
sections: categories.feed.sections,
|
||||
fallback: dramas,
|
||||
onOpen: _openDrama,
|
||||
),
|
||||
_sectionTitle(l10n.allDramas),
|
||||
if (dramas.isEmpty) _emptyCatalog(l10n) else _dramaGrid(l10n, dramas),
|
||||
];
|
||||
@@ -203,93 +242,6 @@ class _DiscoverPageState extends State<DiscoverPage> {
|
||||
return DramaGrid(l10n: l10n, dramas: dramas, onOpen: _openDrama);
|
||||
}
|
||||
|
||||
Widget _categoryChips(AppLocalizations l10n, CategoryController categories) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(
|
||||
AppDimens.pageHorizontal,
|
||||
AppDimens.spaceMd,
|
||||
AppDimens.pageHorizontal,
|
||||
0,
|
||||
),
|
||||
child: Wrap(
|
||||
key: const Key('theater-category-chips'),
|
||||
spacing: AppDimens.spaceSm,
|
||||
runSpacing: AppDimens.spaceSm,
|
||||
children: [
|
||||
_filterChip(
|
||||
key: const Key('theater-category-all'),
|
||||
label: l10n.all,
|
||||
selected: logic.selectedCategoryId == null,
|
||||
onSelected: () => logic.selectCategory(null),
|
||||
),
|
||||
for (final category in categories.categories)
|
||||
_filterChip(
|
||||
key: Key('theater-category-${category.id}'),
|
||||
label: category.name,
|
||||
selected: logic.selectedCategoryId == category.id,
|
||||
onSelected: () => logic.selectCategory(category.id),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _languageChips(AppLocalizations l10n) {
|
||||
final entries = [
|
||||
(TheaterLanguage.all, l10n.allLanguages),
|
||||
(TheaterLanguage.zh, l10n.simplifiedChinese),
|
||||
(TheaterLanguage.id, l10n.bahasaIndonesia),
|
||||
(TheaterLanguage.ms, l10n.bahasaMelayu),
|
||||
(TheaterLanguage.en, l10n.english),
|
||||
];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(
|
||||
AppDimens.pageHorizontal,
|
||||
AppDimens.spaceSm,
|
||||
AppDimens.pageHorizontal,
|
||||
0,
|
||||
),
|
||||
child: Wrap(
|
||||
key: const Key('theater-language-chips'),
|
||||
spacing: AppDimens.spaceSm,
|
||||
runSpacing: AppDimens.spaceSm,
|
||||
children: [
|
||||
for (final entry in entries)
|
||||
_filterChip(
|
||||
key: Key('theater-language-${entry.$1.name}'),
|
||||
label: entry.$2,
|
||||
selected: logic.language == entry.$1,
|
||||
onSelected: () => logic.selectLanguage(entry.$1),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _filterChip({
|
||||
required Key key,
|
||||
required String label,
|
||||
required bool selected,
|
||||
required VoidCallback onSelected,
|
||||
}) {
|
||||
return ChoiceChip(
|
||||
key: key,
|
||||
label: Text(label),
|
||||
selected: selected,
|
||||
showCheckmark: false,
|
||||
onSelected: (_) => onSelected(),
|
||||
backgroundColor: AppColors.card,
|
||||
selectedColor: AppColors.blue,
|
||||
side: BorderSide(color: selected ? AppColors.blue : AppColors.border),
|
||||
labelStyle: TextStyle(
|
||||
color: selected ? AppColors.onPrimary : AppColors.muted,
|
||||
fontSize: AppDimens.chipFont,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
shape: const StadiumBorder(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _sectionTitle(String title) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(14, 18, 14, 10),
|
||||
@@ -339,6 +291,18 @@ class _DiscoverPageState extends State<DiscoverPage> {
|
||||
);
|
||||
}
|
||||
|
||||
void _openCategory(ContentCategory category, CategoryController categories) {
|
||||
Navigator.of(context).push<void>(
|
||||
MaterialPageRoute(
|
||||
builder: (_) => CategoryDramasPage(
|
||||
title: category.name,
|
||||
dramas: categories.dramasOf(category.id),
|
||||
onOpen: widget.callbacks.onDramaSelected == null ? null : _openDrama,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _openDrama(Drama drama) {
|
||||
final callback = widget.callbacks.onDramaSelected;
|
||||
if (callback != null) {
|
||||
@@ -354,6 +318,27 @@ class _DiscoverPageState extends State<DiscoverPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _openBanner(FeedBanner banner) async {
|
||||
final dramaId = banner.dramaId;
|
||||
if (dramaId == null) return;
|
||||
for (final drama in context.read<CatalogController>().dramas) {
|
||||
if (drama.id == dramaId) {
|
||||
_pushDetail(drama);
|
||||
return;
|
||||
}
|
||||
}
|
||||
try {
|
||||
final drama = await context.read<CatalogRepository>().fetchDrama(dramaId);
|
||||
if (mounted) _pushDetail(drama);
|
||||
} catch (_) {
|
||||
if (!mounted) return;
|
||||
final message = AppLocalizations.of(context)!.detailLoadFailed;
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text(message)));
|
||||
}
|
||||
}
|
||||
|
||||
Widget _bottomNav(AppLocalizations l10n) => AppBottomNav(
|
||||
items: [
|
||||
AppBottomNavItem(
|
||||
@@ -367,7 +352,7 @@ class _DiscoverPageState extends State<DiscoverPage> {
|
||||
tabKey: const Key('discover-nav-current'),
|
||||
icon: Icons.explore_outlined,
|
||||
selectedIcon: Icons.explore_rounded,
|
||||
label: l10n.theaterTab,
|
||||
label: l10n.discoverTab,
|
||||
selected: true,
|
||||
onTap: () {},
|
||||
),
|
||||
|
||||
@@ -3,48 +3,37 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/theme/app_colors.dart';
|
||||
import '../../../core/theme/app_dimens.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
import 'discover_search_field.dart';
|
||||
|
||||
/// Theater header with a persistent search field and profile entry.
|
||||
/// 剧场页页头:品牌、搜索与个人页入口。
|
||||
class DiscoverHeader extends StatelessWidget {
|
||||
const DiscoverHeader({
|
||||
super.key,
|
||||
required this.controller,
|
||||
required this.focusNode,
|
||||
required this.onChanged,
|
||||
required this.loading,
|
||||
required this.onSearch,
|
||||
required this.onProfile,
|
||||
});
|
||||
|
||||
final TextEditingController controller;
|
||||
final FocusNode focusNode;
|
||||
final ValueChanged<String> onChanged;
|
||||
final bool loading;
|
||||
final VoidCallback onSearch;
|
||||
final VoidCallback onProfile;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
return SizedBox(
|
||||
height: AppDimens.contentHeaderHeight,
|
||||
height: 46,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: AppDimens.pageHorizontal,
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: DiscoverSearchField(
|
||||
controller: controller,
|
||||
focusNode: focusNode,
|
||||
onChanged: onChanged,
|
||||
loading: loading,
|
||||
horizontalPadding: 0,
|
||||
),
|
||||
_brand(l10n),
|
||||
const Spacer(),
|
||||
_HeaderIcon(
|
||||
key: const Key('discover-search-button'),
|
||||
icon: Icons.search_rounded,
|
||||
tooltip: l10n.search,
|
||||
onTap: onSearch,
|
||||
),
|
||||
const SizedBox(width: AppDimens.spaceSm),
|
||||
const SizedBox(width: 8),
|
||||
_profile(l10n),
|
||||
],
|
||||
),
|
||||
@@ -52,6 +41,37 @@ class DiscoverHeader extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _brand(AppLocalizations l10n) {
|
||||
return Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 24,
|
||||
height: 24,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.blue,
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.play_arrow_rounded,
|
||||
color: AppColors.onPrimary,
|
||||
size: 16,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
l10n.discoverTab,
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Outfit',
|
||||
color: AppColors.onSurface,
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w800,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _profile(AppLocalizations l10n) {
|
||||
return Semantics(
|
||||
button: true,
|
||||
@@ -81,3 +101,34 @@ class DiscoverHeader extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _HeaderIcon extends StatelessWidget {
|
||||
const _HeaderIcon({
|
||||
super.key,
|
||||
required this.icon,
|
||||
required this.tooltip,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
final IconData icon;
|
||||
final String tooltip;
|
||||
final VoidCallback onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: 36,
|
||||
height: 36,
|
||||
child: IconButton(
|
||||
tooltip: tooltip,
|
||||
onPressed: onTap,
|
||||
padding: EdgeInsets.zero,
|
||||
style: IconButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF2C2D33),
|
||||
foregroundColor: AppColors.onSurface,
|
||||
),
|
||||
icon: Icon(icon, size: 18),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -13,19 +13,17 @@ class DiscoverSearchField extends StatelessWidget {
|
||||
required this.focusNode,
|
||||
required this.onChanged,
|
||||
required this.loading,
|
||||
this.horizontalPadding = 14,
|
||||
});
|
||||
|
||||
final TextEditingController controller;
|
||||
final FocusNode focusNode;
|
||||
final ValueChanged<String> onChanged;
|
||||
final bool loading;
|
||||
final double horizontalPadding;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: horizontalPadding),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14),
|
||||
child: SizedBox(
|
||||
height: 36,
|
||||
child: TextField(
|
||||
|
||||
@@ -2,10 +2,9 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/config/app_config.dart';
|
||||
import '../../../core/data/models/drama.dart';
|
||||
import '../../../core/theme/app_colors.dart';
|
||||
import '../../../core/theme/app_dimens.dart';
|
||||
import '../../../core/widgets/remote_image.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
|
||||
const int _columns = 2;
|
||||
@@ -84,8 +83,6 @@ class DramaGridCard extends StatelessWidget {
|
||||
_title(),
|
||||
const SizedBox(height: 2),
|
||||
_genre(),
|
||||
const SizedBox(height: AppDimens.spaceXs),
|
||||
_metadata(),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -118,7 +115,7 @@ class DramaGridCard extends StatelessWidget {
|
||||
l10n.free,
|
||||
style: const TextStyle(
|
||||
color: AppColors.onPrimary,
|
||||
fontSize: AppDimens.cardMeta,
|
||||
fontSize: 8,
|
||||
fontWeight: FontWeight.w800,
|
||||
),
|
||||
),
|
||||
@@ -133,7 +130,7 @@ class DramaGridCard extends StatelessWidget {
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
color: AppColors.onSurface,
|
||||
fontSize: AppDimens.previewSectionTitle,
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w800,
|
||||
),
|
||||
);
|
||||
@@ -146,39 +143,7 @@ class DramaGridCard extends StatelessWidget {
|
||||
key: Key('home-drama-genre-${drama.id}'),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
color: AppColors.muted,
|
||||
fontSize: AppDimens.cardMeta,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _metadata() {
|
||||
return Wrap(
|
||||
spacing: AppDimens.spaceSm,
|
||||
runSpacing: AppDimens.spaceXs,
|
||||
children: [
|
||||
Text(
|
||||
l10n.episodeCount(drama.episodeCount),
|
||||
key: Key('home-drama-episode-count-${drama.id}'),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
color: AppColors.subtle,
|
||||
fontSize: AppDimens.cardViews,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
l10n.viewCountLabel(drama.viewCount),
|
||||
key: Key('home-drama-views-${drama.id}'),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
color: AppColors.subtle,
|
||||
fontSize: AppDimens.cardViews,
|
||||
),
|
||||
),
|
||||
],
|
||||
style: const TextStyle(color: Color(0xFFBBBBBB), fontSize: 9),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -190,12 +155,33 @@ class _DiscoverCoverImage extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return RemoteImage(
|
||||
path,
|
||||
final url = AppConfig.mediaUrl(path);
|
||||
if (url.isEmpty) return _placeholder();
|
||||
return Image.network(
|
||||
url,
|
||||
width: double.infinity,
|
||||
fit: BoxFit.fitWidth,
|
||||
showFallbackIcon: true,
|
||||
fallbackAspectRatio: 3 / 4,
|
||||
loadingBuilder: (context, child, progress) {
|
||||
if (progress == null) return child;
|
||||
return _placeholder();
|
||||
},
|
||||
errorBuilder: (_, _, _) => _placeholder(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _placeholder() {
|
||||
return AspectRatio(
|
||||
aspectRatio: 3 / 4,
|
||||
child: ColoredBox(
|
||||
color: AppColors.card,
|
||||
child: const Center(
|
||||
child: Icon(
|
||||
Icons.image_not_supported_outlined,
|
||||
color: AppColors.muted,
|
||||
size: 32,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -4,13 +4,14 @@ import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/data/models/home_feed.dart';
|
||||
import '../../../core/data/models/drama.dart';
|
||||
import '../../../core/data/models/home_feed.dart';
|
||||
import '../../../core/theme/app_colors.dart';
|
||||
import '../../../core/theme/app_dimens.dart';
|
||||
import '../../../core/widgets/remote_image.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
|
||||
const double _carouselHeight = 154;
|
||||
const double _indicatorHeight = 24;
|
||||
const double _dotSize = 6;
|
||||
const double _activeDotWidth = 18;
|
||||
@@ -115,6 +116,9 @@ class _FeedBannerCarouselState extends State<FeedBannerCarousel> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.banners.isEmpty) return const SizedBox.shrink();
|
||||
final height = widget.dramaFor == null
|
||||
? _carouselHeight
|
||||
: AppDimens.heroBannerHeight;
|
||||
return Listener(
|
||||
key: const Key('feed-banner-carousel'),
|
||||
onPointerDown: (_) => _pause(),
|
||||
@@ -123,7 +127,7 @@ class _FeedBannerCarouselState extends State<FeedBannerCarousel> {
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: AppDimens.heroBannerHeight,
|
||||
height: height,
|
||||
child: PageView.builder(
|
||||
controller: _controller,
|
||||
itemCount: widget.banners.length,
|
||||
@@ -147,20 +151,22 @@ class _FeedBannerCarouselState extends State<FeedBannerCarousel> {
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
RemoteImage(banner.imageUrl, showFallbackIcon: true),
|
||||
const DecoratedBox(
|
||||
DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [Color(0x120B0C10), Color(0xE60B0C10)],
|
||||
colors: drama == null
|
||||
? const [Color(0x00000000), Color(0x8A0B0C10)]
|
||||
: const [Color(0x120B0C10), Color(0xE60B0C10)],
|
||||
),
|
||||
),
|
||||
),
|
||||
if (drama != null)
|
||||
Positioned(
|
||||
left: 16,
|
||||
right: 64,
|
||||
bottom: 14,
|
||||
left: AppDimens.pageHorizontal,
|
||||
right: _copyRightGap,
|
||||
bottom: AppDimens.cardPadding,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -244,6 +250,8 @@ class _FeedBannerCarouselState extends State<FeedBannerCarousel> {
|
||||
}
|
||||
}
|
||||
|
||||
const double _copyRightGap = 64;
|
||||
|
||||
class _PlayMark extends StatelessWidget {
|
||||
const _PlayMark();
|
||||
|
||||
|
||||
Reference in new issue
Block a user