mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
refactor: genre home section
This commit is contained in:
parent
dff8fe2e64
commit
e6408ccc0d
@ -1,5 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
||||||
import 'package:spotube/extensions/context.dart';
|
import 'package:spotube/extensions/context.dart';
|
||||||
import 'package:spotube/pages/settings/settings.dart';
|
import 'package:spotube/pages/settings/settings.dart';
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ class AnonymousFallback extends ConsumerWidget {
|
|||||||
children: [
|
children: [
|
||||||
Text(context.l10n.not_logged_in),
|
Text(context.l10n.not_logged_in),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
FilledButton(
|
Button.primary(
|
||||||
child: Text(context.l10n.login_with_spotify),
|
child: Text(context.l10n.login_with_spotify),
|
||||||
onPressed: () => ServiceUtils.pushNamed(context, SettingsPage.name),
|
onPressed: () => ServiceUtils.pushNamed(context, SettingsPage.name),
|
||||||
)
|
)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
||||||
import 'package:spotube/collections/assets.gen.dart';
|
import 'package:spotube/collections/assets.gen.dart';
|
||||||
import 'package:spotube/extensions/context.dart';
|
import 'package:spotube/extensions/context.dart';
|
||||||
|
|
||||||
@ -8,7 +8,6 @@ class NotFound extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final theme = Theme.of(context);
|
|
||||||
final widgets = [
|
final widgets = [
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 150,
|
height: 150,
|
||||||
@ -19,11 +18,10 @@ class NotFound extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Text(context.l10n.nothing_found, style: theme.textTheme.titleLarge),
|
Text(context.l10n.nothing_found).large().semiBold(),
|
||||||
Text(
|
Text(
|
||||||
context.l10n.the_box_is_empty,
|
context.l10n.the_box_is_empty,
|
||||||
style: theme.textTheme.titleMedium,
|
).semiBold(),
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import 'dart:math';
|
|
||||||
|
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
@ -8,7 +6,6 @@ import 'package:shadcn_flutter/shadcn_flutter_extension.dart';
|
|||||||
import 'package:skeletonizer/skeletonizer.dart';
|
import 'package:skeletonizer/skeletonizer.dart';
|
||||||
import 'package:spotify/spotify.dart';
|
import 'package:spotify/spotify.dart';
|
||||||
import 'package:spotube/collections/fake.dart';
|
import 'package:spotube/collections/fake.dart';
|
||||||
import 'package:spotube/collections/gradients.dart';
|
|
||||||
import 'package:spotube/collections/spotube_icons.dart';
|
import 'package:spotube/collections/spotube_icons.dart';
|
||||||
import 'package:spotube/components/image/universal_image.dart';
|
import 'package:spotube/components/image/universal_image.dart';
|
||||||
import 'package:spotube/extensions/constrains.dart';
|
import 'package:spotube/extensions/constrains.dart';
|
||||||
@ -84,70 +81,33 @@ class HomeGenresSection extends HookConsumerWidget {
|
|||||||
final category =
|
final category =
|
||||||
categories.elementAtOrNull(index) ?? FakeData.category;
|
categories.elementAtOrNull(index) ?? FakeData.category;
|
||||||
|
|
||||||
return HookBuilder(builder: (context) {
|
return Button(
|
||||||
final (:gradient, :textColor) = useMemoized(
|
style: ButtonVariance.secondary.copyWith(
|
||||||
() {
|
padding: (context, states, value) {
|
||||||
final gradient =
|
return EdgeInsets.zero;
|
||||||
gradients[Random().nextInt(gradients.length)];
|
},
|
||||||
final text = gradient.colors
|
),
|
||||||
.take(2)
|
onPressed: () {},
|
||||||
.any((c) => c.computeLuminance() > 0.5)
|
child: CardImage(
|
||||||
? Colors.gray[900]
|
onPressed: () {
|
||||||
: Colors.white;
|
context.pushNamed(
|
||||||
return (
|
GenrePlaylistsPage.name,
|
||||||
gradient: LinearGradient(
|
pathParameters: {
|
||||||
colors: gradient.colors
|
"categoryId": category.id!,
|
||||||
.map((c) => c.withAlpha((0.8 * 255).ceil()))
|
},
|
||||||
.toList(),
|
extra: category,
|
||||||
),
|
|
||||||
textColor: text
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
[],
|
direction: Axis.horizontal,
|
||||||
);
|
image: UniversalImage(
|
||||||
|
path: category.icons!.first.url!,
|
||||||
return MouseRegion(
|
fit: BoxFit.cover,
|
||||||
cursor: SystemMouseCursors.click,
|
height: 50,
|
||||||
child: GestureDetector(
|
width: 50,
|
||||||
onTap: () {
|
|
||||||
context.pushNamed(
|
|
||||||
GenrePlaylistsPage.name,
|
|
||||||
pathParameters: {
|
|
||||||
"categoryId": category.id!,
|
|
||||||
},
|
|
||||||
extra: category,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
image: DecorationImage(
|
|
||||||
image: UniversalImage.imageProvider(
|
|
||||||
category.icons!.first.url!,
|
|
||||||
),
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
borderRadius: BorderRadius.circular(5),
|
|
||||||
color: context.theme.colorScheme.muted,
|
|
||||||
gradient:
|
|
||||||
categoriesQuery.isLoading ? null : gradient,
|
|
||||||
),
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
|
||||||
child: Align(
|
|
||||||
alignment: Alignment.centerLeft,
|
|
||||||
child: Text(
|
|
||||||
category.name!,
|
|
||||||
style: context.theme.typography.large,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
title: Text(category.name!),
|
||||||
});
|
),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -36,14 +36,15 @@ class LastFMLoginPage extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
child: SingleChildScrollView(
|
child: Row(
|
||||||
child: Container(
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
constraints: const BoxConstraints(maxWidth: 400),
|
children: [
|
||||||
alignment: Alignment.center,
|
Container(
|
||||||
padding: const EdgeInsets.all(16),
|
constraints: const BoxConstraints(maxWidth: 400),
|
||||||
child: Card(
|
alignment: Alignment.center,
|
||||||
child: Padding(
|
padding: const EdgeInsets.all(16),
|
||||||
padding: const EdgeInsets.all(16.0).copyWith(top: 8),
|
child: Card(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: Form(
|
child: Form(
|
||||||
onSubmit: (context, values) async {
|
onSubmit: (context, values) async {
|
||||||
try {
|
try {
|
||||||
@ -136,7 +137,7 @@ class LastFMLoginPage extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user