snapshot of https://github.com/flutter/samples.git (main, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Main Branch CI / Test Flutter beta on ubuntu-latest (push) Has been skipped
Main Branch CI / Test Flutter stable on ubuntu-latest (push) Has been skipped
Main Branch CI / Test Flutter beta on macos-latest (push) Has been cancelled
Main Branch CI / Test Flutter stable on macos-latest (push) Has been cancelled
Some checks failed
Main Branch CI / Test Flutter beta on ubuntu-latest (push) Has been skipped
Main Branch CI / Test Flutter stable on ubuntu-latest (push) Has been skipped
Main Branch CI / Test Flutter beta on macos-latest (push) Has been cancelled
Main Branch CI / Test Flutter stable on macos-latest (push) Has been cancelled
This commit is contained in:
112
platform_design/lib/song_detail_tab.dart
Normal file
112
platform_design/lib/song_detail_tab.dart
Normal file
@@ -0,0 +1,112 @@
|
||||
// Copyright 2020 The Flutter team. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'widgets.dart';
|
||||
|
||||
/// Page shown when a card in the songs tab is tapped.
|
||||
///
|
||||
/// On Android, this page sits at the top of your app. On iOS, this page is on
|
||||
/// top of the songs tab's content but is below the tab bar itself.
|
||||
class SongDetailTab extends StatelessWidget {
|
||||
const SongDetailTab({
|
||||
required this.id,
|
||||
required this.song,
|
||||
required this.color,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final int id;
|
||||
final String song;
|
||||
final Color color;
|
||||
|
||||
Widget _buildBody() {
|
||||
return SafeArea(
|
||||
bottom: false,
|
||||
left: false,
|
||||
right: false,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Hero(
|
||||
tag: id,
|
||||
child: HeroAnimatingSongCard(
|
||||
song: song,
|
||||
color: color,
|
||||
heroAnimation: const AlwaysStoppedAnimation(1),
|
||||
),
|
||||
// This app uses a flightShuttleBuilder to specify the exact widget
|
||||
// to build while the hero transition is mid-flight.
|
||||
//
|
||||
// It could either be specified here or in SongsTab.
|
||||
flightShuttleBuilder:
|
||||
(
|
||||
context,
|
||||
animation,
|
||||
flightDirection,
|
||||
fromHeroContext,
|
||||
toHeroContext,
|
||||
) {
|
||||
return HeroAnimatingSongCard(
|
||||
song: song,
|
||||
color: color,
|
||||
heroAnimation: animation,
|
||||
);
|
||||
},
|
||||
),
|
||||
const Divider(height: 0, color: Colors.grey),
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: 10,
|
||||
itemBuilder: (context, index) => switch (index) {
|
||||
0 => const Padding(
|
||||
padding: EdgeInsets.only(left: 15, top: 16, bottom: 8),
|
||||
child: Text(
|
||||
'You might also like:',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
_ => const SongPlaceholderTile(),
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
// Non-shared code below because we're using different scaffolds.
|
||||
// ===========================================================================
|
||||
|
||||
Widget _buildAndroid(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text(song)),
|
||||
body: _buildBody(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildIos(BuildContext context) {
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
middle: Text(song),
|
||||
previousPageTitle: 'Songs',
|
||||
),
|
||||
child: _buildBody(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(context) {
|
||||
return PlatformWidget(
|
||||
androidBuilder: _buildAndroid,
|
||||
iosBuilder: _buildIos,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user