Skip to content

Commit

Permalink
feat: 平板布局
Browse files Browse the repository at this point in the history
  • Loading branch information
MiaoMint committed Aug 16, 2023
1 parent dea59c8 commit b79a79b
Show file tree
Hide file tree
Showing 5 changed files with 272 additions and 171 deletions.
106 changes: 60 additions & 46 deletions lib/pages/detail/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'package:miru_app/pages/detail/widgets/detail_extension_tile.dart';
import 'package:miru_app/pages/detail/widgets/detail_favorite_button.dart';
import 'package:miru_app/pages/detail/widgets/detail_overview.dart';
import 'package:miru_app/utils/i18n.dart';
import 'package:miru_app/utils/layout.dart';
import 'package:miru_app/widgets/cache_network_image.dart';
import 'package:miru_app/widgets/card_tile.dart';
import 'package:miru_app/widgets/platform_widget.dart';
Expand Down Expand Up @@ -71,8 +72,14 @@ class _DetailPageState extends State<DetailPage> {
child: Text(c.error.value),
);
}
return DefaultTabController(
length: 3,
final tabs = [
if (!LayoutUtils.isTablet) Tab(text: episodesString),
Tab(text: 'detail.overview'.i18n),
if (c.type == ExtensionType.bangumi) Tab(text: 'detail.cast'.i18n),
];

final content = DefaultTabController(
length: tabs.length,
child: NestedScrollView(
controller: c.scrollController,
headerSliverBuilder:
Expand All @@ -89,12 +96,7 @@ class _DetailPageState extends State<DetailPage> {
),
flexibleSpace: const DetailAppbarflexibleSpace(),
bottom: TabBar(
tabs: [
Tab(text: episodesString),
Tab(text: 'detail.overview'.i18n),
if (c.type == ExtensionType.bangumi)
Tab(text: 'detail.cast'.i18n),
],
tabs: tabs,
),
actions: [
IconButton(
Expand All @@ -117,52 +119,64 @@ class _DetailPageState extends State<DetailPage> {
padding: const EdgeInsets.all(8),
child: TabBarView(
children: [
const DetailEpisodes(),
if (!LayoutUtils.isTablet) const DetailEpisodes(),
const DetailOverView(),
Obx(() {
if (c.tmdbDetail == null || c.tmdbDetail!.casts.isEmpty) {
return const SizedBox();
}
return ListView.builder(
padding: const EdgeInsets.all(0),
itemBuilder: (context, index) {
final cast = c.tmdbDetail!.casts[index];
late String url = '';
if (cast.profilePath != null) {
url = TmdbApi.getImageUrl(cast.profilePath!) ?? '';
}
if (c.type == ExtensionType.bangumi)
Obx(() {
if (c.tmdbDetail == null || c.tmdbDetail!.casts.isEmpty) {
return const SizedBox();
}
return ListView.builder(
padding: const EdgeInsets.all(0),
itemBuilder: (context, index) {
final cast = c.tmdbDetail!.casts[index];
late String url = '';
if (cast.profilePath != null) {
url = TmdbApi.getImageUrl(cast.profilePath!) ?? '';
}

return ListTile(
leading: Container(
decoration: const BoxDecoration(
shape: BoxShape.circle,
),
clipBehavior: Clip.antiAlias,
child: CacheNetWorkImage(
url,
width: 50,
height: 50,
),
),
title: Text(cast.name),
subtitle: Text(cast.character),
onTap: () {
launchUrl(
Uri.parse(
"https://www.themoviedb.org/person/${cast.id}",
return ListTile(
leading: Container(
decoration: const BoxDecoration(
shape: BoxShape.circle,
),
);
},
);
},
itemCount: c.tmdbDetail!.casts.length,
);
}),
clipBehavior: Clip.antiAlias,
child: CacheNetWorkImage(
url,
width: 50,
height: 50,
),
),
title: Text(cast.name),
subtitle: Text(cast.character),
onTap: () {
launchUrl(
Uri.parse(
"https://www.themoviedb.org/person/${cast.id}",
),
);
},
);
},
itemCount: c.tmdbDetail!.casts.length,
);
}),
],
),
),
),
);
if (LayoutUtils.isTablet) {
return Row(
children: [
Expanded(child: content),
const Expanded(
child: SafeArea(child: DetailEpisodes()),
),
],
);
}
return content;
}),
);
}
Expand Down
222 changes: 129 additions & 93 deletions lib/pages/extension_settings/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:miru_app/router/router.dart';
import 'package:miru_app/utils/database.dart';
import 'package:miru_app/utils/extension.dart';
import 'package:miru_app/utils/i18n.dart';
import 'package:miru_app/utils/layout.dart';
import 'package:miru_app/widgets/cache_network_image.dart';
import 'package:miru_app/widgets/card_tile.dart';
import 'package:miru_app/widgets/messenger.dart';
Expand Down Expand Up @@ -138,103 +139,101 @@ class _ExtensionSettingsPageState extends State<ExtensionSettingsPage> {
);
}
final extension = c.runtime.value!.extension;
return Scaffold(
appBar: AppBar(
title: Text('extension-info.title'.i18n),
),
body: SingleChildScrollView(
child: Column(
children: [
const SizedBox(height: 30),
Center(
child: Container(
height: 100,
width: 100,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
),
clipBehavior: Clip.antiAlias,
child: CacheNetWorkImage(
extension.icon ?? '',
fit: BoxFit.contain,
),

final content = SingleChildScrollView(
child: Column(
children: [
const SizedBox(height: 30),
Center(
child: Container(
height: 100,
width: 100,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
),
clipBehavior: Clip.antiAlias,
child: CacheNetWorkImage(
extension.icon ?? '',
fit: BoxFit.contain,
),
),
const SizedBox(height: 16),
Text(
extension.name,
style: Theme.of(context).textTheme.titleLarge,
),
Text(
extension.package,
style: Theme.of(context).textTheme.bodySmall,
),
const SizedBox(height: 30),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: GridView(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: 3,
crossAxisSpacing: 2,
mainAxisSpacing: 8,
),
children: [
InfoCard(
icon: Icons.person,
title: 'extension-info.author'.i18n,
content: extension.author,
),
InfoCard(
icon: Icons.info,
title: 'extension-info.version'.i18n,
content: extension.version,
),
InfoCard(
icon: Icons.language,
title: 'extension-info.language'.i18n,
content: extension.lang,
),
InfoCard(
icon: Icons.description,
title: 'extension-info.license'.i18n,
content: extension.license,
),
InfoCard(
icon: Icons.link,
title: 'extension-info.original-site'.i18n,
content: extension.webSite,
),
],
),
const SizedBox(height: 16),
Text(
extension.name,
style: Theme.of(context).textTheme.titleLarge,
),
Text(
extension.package,
style: Theme.of(context).textTheme.bodySmall,
),
const SizedBox(height: 30),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: GridView(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: 3,
crossAxisSpacing: 2,
mainAxisSpacing: 8,
),
children: [
InfoCard(
icon: Icons.person,
title: 'extension-info.author'.i18n,
content: extension.author,
),
InfoCard(
icon: Icons.info,
title: 'extension-info.version'.i18n,
content: extension.version,
),
InfoCard(
icon: Icons.language,
title: 'extension-info.language'.i18n,
content: extension.lang,
),
InfoCard(
icon: Icons.description,
title: 'extension-info.license'.i18n,
content: extension.license,
),
InfoCard(
icon: Icons.link,
title: 'extension-info.original-site'.i18n,
content: extension.webSite,
),
],
),
Padding(
padding: const EdgeInsets.all(16),
child: Row(
children: [
Expanded(
child: OutlinedButton(
onPressed: () async {
await ExtensionUtils.uninstall(extension.package);
Get.back();
},
child: Text('common.uninstall'.i18n),
),
),
Padding(
padding: const EdgeInsets.all(16),
child: Row(
children: [
Expanded(
child: OutlinedButton(
onPressed: () async {
await ExtensionUtils.uninstall(extension.package);
Get.back();
},
child: Text('common.uninstall'.i18n),
),
const SizedBox(width: 16),
Expanded(
child: FilledButton(
onPressed: () {
Get.to(CodeEditPage(extension: extension));
},
child: Text('extension.edit-code'.i18n),
),
)
],
),
),
const SizedBox(width: 16),
Expanded(
child: FilledButton(
onPressed: () {
Get.to(CodeEditPage(extension: extension));
},
child: Text('extension.edit-code'.i18n),
),
)
],
),
),
if (!LayoutUtils.isTablet) ...[
const Divider(),
SettingsTile(
title: 'cookie-clean.title'.i18n,
Expand All @@ -251,10 +250,47 @@ class _ExtensionSettingsPageState extends State<ExtensionSettingsPage> {
),
),
...settingsContent(),
],
),
]
],
),
);

return Scaffold(
appBar: AppBar(
title: Text('extension-info.title'.i18n),
),
body: LayoutUtils.isTablet
? Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(child: content),
Expanded(
child: SingleChildScrollView(
child: Column(
children: [
SettingsTile(
title: 'cookie-clean.title'.i18n,
buildSubtitle: () => 'cookie-clean.subtitle'.i18n,
trailing: TextButton(
child: Text('cookie-clean.clean'.i18n),
onPressed: () {
c.runtime.value!.cleanCookie();
showPlatformSnackbar(
context: context,
content: 'cookie-clean.success'.i18n,
);
},
),
),
...settingsContent(),
],
),
),
),
],
)
: content,
);
});
}

Expand Down
Loading

0 comments on commit b79a79b

Please sign in to comment.