mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00

* feat: add connect server support * feat: add ability discover and connect to same network Spotube(s) and sync queue * feat(connect): add player controls, shuffle, loop, progress bar and queue support * feat: make control page adaptive * feat: add volume control support * cd: upgrade macos runner version * chore: upgrade inappwebview version to 6 * feat: customized devices button * feat: add user icon next to devices button * feat: add play in remote device support * feat: show alert when new client connects * fix: ignore the device itself from broadcast list * fix: volume control not working * feat: add ability to select current device's output speaker
61 lines
2.0 KiB
Dart
61 lines
2.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
import 'package:gap/gap.dart';
|
|
import 'package:spotube/collections/spotube_icons.dart';
|
|
import 'package:spotube/extensions/context.dart';
|
|
import 'package:spotube/services/audio_player/audio_player.dart';
|
|
|
|
class ConnectPageLocalDevices extends HookWidget {
|
|
const ConnectPageLocalDevices({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final ThemeData(:textTheme) = Theme.of(context);
|
|
final devicesFuture = useFuture(audioPlayer.devices);
|
|
final devicesStream = useStream(audioPlayer.devicesStream);
|
|
final selectedDeviceFuture = useFuture(audioPlayer.selectedDevice);
|
|
final selectedDeviceStream = useStream(audioPlayer.selectedDeviceStream);
|
|
|
|
final devices = devicesStream.data ?? devicesFuture.data;
|
|
final selectedDevice =
|
|
selectedDeviceStream.data ?? selectedDeviceFuture.data;
|
|
|
|
if (devices == null) {
|
|
return const SliverToBoxAdapter(child: SizedBox.shrink());
|
|
}
|
|
|
|
return SliverMainAxisGroup(
|
|
slivers: [
|
|
const SliverGap(10),
|
|
SliverPadding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
|
sliver: SliverToBoxAdapter(
|
|
child: Text(
|
|
context.l10n.this_device,
|
|
style: textTheme.titleMedium,
|
|
),
|
|
),
|
|
),
|
|
const SliverGap(10),
|
|
SliverList.separated(
|
|
itemCount: devices.length,
|
|
separatorBuilder: (context, index) => const Gap(10),
|
|
itemBuilder: (context, index) {
|
|
final device = devices[index];
|
|
|
|
return Card(
|
|
child: ListTile(
|
|
leading: const Icon(SpotubeIcons.speaker),
|
|
title: Text(device.description),
|
|
subtitle: Text(device.name),
|
|
selected: selectedDevice == device,
|
|
onTap: () => audioPlayer.setAudioDevice(device),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|