84 lines
2.2 KiB
Dart
84 lines
2.2 KiB
Dart
// Author: fruit.com.cn
|
|
|
|
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.onProfile,
|
|
});
|
|
|
|
final TextEditingController controller;
|
|
final FocusNode focusNode;
|
|
final ValueChanged<String> onChanged;
|
|
final bool loading;
|
|
final VoidCallback onProfile;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final l10n = AppLocalizations.of(context)!;
|
|
return SizedBox(
|
|
height: AppDimens.contentHeaderHeight,
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: AppDimens.pageHorizontal,
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: DiscoverSearchField(
|
|
controller: controller,
|
|
focusNode: focusNode,
|
|
onChanged: onChanged,
|
|
loading: loading,
|
|
horizontalPadding: 0,
|
|
),
|
|
),
|
|
const SizedBox(width: AppDimens.spaceSm),
|
|
_profile(l10n),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _profile(AppLocalizations l10n) {
|
|
return Semantics(
|
|
button: true,
|
|
label: l10n.myTab,
|
|
child: InkWell(
|
|
key: const Key('discover-profile'),
|
|
customBorder: const CircleBorder(),
|
|
onTap: onProfile,
|
|
child: Container(
|
|
width: 36,
|
|
height: 36,
|
|
decoration: const BoxDecoration(
|
|
shape: BoxShape.circle,
|
|
gradient: LinearGradient(
|
|
begin: Alignment.topLeft,
|
|
end: Alignment.bottomRight,
|
|
colors: [Color(0xFF6A5CFF), AppColors.blue],
|
|
),
|
|
),
|
|
child: const Icon(
|
|
Icons.person_rounded,
|
|
color: AppColors.onSurface,
|
|
size: 18,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|