diff --git a/.github/workflows/flutter.yml b/.github/workflows/flutter.yml index bdc327c..c76683a 100644 --- a/.github/workflows/flutter.yml +++ b/.github/workflows/flutter.yml @@ -3,7 +3,7 @@ name: Flutter on: push: - branches: [main, feature/mlt-player-project-launch] + branches: [main, feature/mlt-player-project-launch, feat-unified-launcher-bar] pull_request: jobs: diff --git a/README.md b/README.md index f1768e2..a19a8d7 100644 --- a/README.md +++ b/README.md @@ -109,10 +109,12 @@ necessary. The cryptography implementation is compiled into the Flutter apps. ## 🎬 MLT Player launch and onboarding When Redleaf Hub shows the green **Online** status for an active project, the -Project Library reveals both **Launch Node Leaf** and **Launch MLT Player**. -If the MLT Player executable is not configured, the second bar provides a -shortcut to **Settings & Paths** instead. Hub opens the app as a detached -desktop process. +Project Library displays **one shared 82-pixel launcher bar** with the selected +Redleaf project, **Launch Node Leaf**, and **Launch MLT Player** side by side. +This replaces the two stacked online banners without changing either launch +action. If the MLT Player executable is not configured, its button opens +**Settings & Paths** instead. Hub launches each app as a detached desktop +process. On narrow windows the same actions use compact labels. The handoff arguments are: diff --git a/lib/ui/home_screen.dart b/lib/ui/home_screen.dart index 9764ee2..ff19968 100644 --- a/lib/ui/home_screen.dart +++ b/lib/ui/home_screen.dart @@ -186,6 +186,45 @@ class _HomeScreenState extends State } } + Widget _buildStudioLaunchButton({ + required String label, + required IconData icon, + required bool compact, + required VoidCallback onPressed, + }) { + return DecoratedBox( + decoration: BoxDecoration( + gradient: const LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [Color(0xFFAB2A32), Color(0xFF831C26)], + ), + borderRadius: BorderRadius.circular(8), + ), + child: ElevatedButton.icon( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.transparent, + shadowColor: Colors.transparent, + foregroundColor: Colors.white, + elevation: 0, + padding: EdgeInsets.symmetric( + horizontal: compact ? 10 : 22, + vertical: 14, + ), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), + icon: Icon(icon, size: 19), + label: Text( + label, + style: const TextStyle(fontWeight: FontWeight.w600), + ), + onPressed: onPressed, + ), + ); + } + // --- UI: THE BIG ROUNDED RECTANGLE BUTTONS --- Widget _buildMenu() { final hubState = context.watch(); @@ -557,120 +596,10 @@ class _HomeScreenState extends State ), ), - // --- NODE LEAF STATUS / STUDIO LAUNCHER --- - AnimatedContainer( - duration: const Duration(milliseconds: 300), - height: hubState.isServerRunning ? 82 : 0, - width: double.infinity, - decoration: const BoxDecoration( - gradient: LinearGradient( - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - colors: [Color(0xFF25252D), Color(0xFF1E1E24)], - ), - border: Border( - top: BorderSide(color: Color(0xFF383842)), - ), - ), - child: ClipRect( - child: SingleChildScrollView( - physics: const NeverScrollableScrollPhysics(), - child: LayoutBuilder( - builder: (context, constraints) { - final compact = constraints.maxWidth < 750; - return Padding( - padding: const EdgeInsets.symmetric( - horizontal: 24, - vertical: 13, - ), - child: Row( - children: [ - Container( - width: 13, - height: 13, - decoration: const BoxDecoration( - color: Color(0xFF73D52C), - shape: BoxShape.circle, - ), - ), - const SizedBox(width: 12), - const Text( - 'Node Leaf', - style: TextStyle( - color: Colors.white, - fontSize: 16, - fontWeight: FontWeight.w600, - ), - ), - if (!compact) ...[ - const SizedBox(width: 22), - const SizedBox( - height: 28, - child: VerticalDivider( - color: Color(0xFF383842), - ), - ), - const SizedBox(width: 22), - const Text( - 'Server: ', - style: TextStyle(color: Color(0xFFE8E8EA)), - ), - const Text( - 'Online', - style: TextStyle( - color: Color(0xFF73D52C), - fontWeight: FontWeight.w600, - ), - ), - const Text( - ' (localhost:5000)', - style: TextStyle(color: Color(0xFF828290)), - ), - ], - const Spacer(), - DecoratedBox( - decoration: BoxDecoration( - gradient: const LinearGradient( - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - colors: [Color(0xFFAB2A32), Color(0xFF831C26)], - ), - borderRadius: BorderRadius.circular(8), - ), - child: ElevatedButton.icon( - style: ElevatedButton.styleFrom( - backgroundColor: Colors.transparent, - shadowColor: Colors.transparent, - foregroundColor: Colors.white, - elevation: 0, - padding: EdgeInsets.symmetric( - horizontal: compact ? 12 : 24, - vertical: 14, - ), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8), - ), - ), - icon: const Icon(Icons.play_arrow_rounded), - label: const Text( - 'Launch Node Leaf', - style: TextStyle(fontWeight: FontWeight.w600), - ), - onPressed: () => hubState.launchNodeLeaf(), - ), - ), - ], - ), - ); - }, - ), - ), - ), - ), - // MLT Player uses the same server-online slide-up pattern as - // Node Leaf. Hub only launches the app; MLT Player checks its own - // project registry and prompts for credentials when onboarding. + // One shared launcher. The Redleaf server supplies the online state + // for both Node Leaf and MLT Player, not two stacked banners. AnimatedContainer( + key: const ValueKey('redleaf-studio-launcher'), duration: const Duration(milliseconds: 300), height: hubState.isServerRunning ? 82 : 0, width: double.infinity, @@ -689,44 +618,43 @@ class _HomeScreenState extends State builder: (context, constraints) { final compact = constraints.maxWidth < 750; final configured = hubState.mltPlayerPath?.isNotEmpty ?? false; + final activeName = + hubState.activeProject?.name ?? 'Redleaf'; return Padding( - padding: const EdgeInsets.symmetric( - horizontal: 24, + padding: EdgeInsets.symmetric( + horizontal: compact ? 12 : 24, vertical: 13, ), child: Row( children: [ - Container( - width: 13, - height: 13, - decoration: const BoxDecoration( - color: Color(0xFF73D52C), - shape: BoxShape.circle, - ), - ), - const SizedBox(width: 12), - const Text( - 'MLT Player', - style: TextStyle( - color: Colors.white, - fontSize: 16, - fontWeight: FontWeight.w600, - ), + const Icon( + Icons.circle, + color: Color(0xFF73D52C), + size: 13, ), + const SizedBox(width: 10), if (!compact) ...[ - const SizedBox(width: 22), - const SizedBox( - height: 28, - child: VerticalDivider( - color: Color(0xFF383842), + const Text( + 'REDLEAF', + style: TextStyle( + color: Colors.white, + fontSize: 14, + fontWeight: FontWeight.w600, + ), + ), + const SizedBox(width: 12), + const Text( + 'ONLINE · localhost:5000', + style: TextStyle( + color: Color(0xFF73D52C), + fontSize: 11, ), ), - const SizedBox(width: 22), - Expanded( + const SizedBox(width: 14), + Flexible( child: Text( - configured - ? 'Open ${hubState.activeProject?.name ?? 'Redleaf'} in MLT Player' - : 'Configure the MLT Player executable in Settings', + activeName, + maxLines: 1, overflow: TextOverflow.ellipsis, style: const TextStyle( color: Color(0xFF828290), @@ -735,53 +663,39 @@ class _HomeScreenState extends State ), ), ] else - const Spacer(), - if (!compact) const SizedBox(width: 12), - DecoratedBox( - decoration: BoxDecoration( - gradient: const LinearGradient( - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - colors: [Color(0xFFAB2A32), Color(0xFF831C26)], + const Text( + 'ONLINE', + style: TextStyle( + color: Color(0xFF73D52C), + fontSize: 11, + fontWeight: FontWeight.w600, ), - borderRadius: BorderRadius.circular(8), ), - child: ElevatedButton.icon( - style: ElevatedButton.styleFrom( - backgroundColor: Colors.transparent, - shadowColor: Colors.transparent, - foregroundColor: Colors.white, - elevation: 0, - padding: EdgeInsets.symmetric( - horizontal: compact ? 12 : 24, - vertical: 14, - ), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8), - ), - ), - icon: Icon( - configured - ? Icons.play_arrow_rounded - : Icons.settings_outlined, - ), - label: Text( - configured - ? 'Launch MLT Player' - : 'Set MLT Player Path', - style: const TextStyle( - fontWeight: FontWeight.w600, - ), - ), - onPressed: configured - ? () => _launchMltPlayer(hubState) - : () => Navigator.push( - context, - MaterialPageRoute( - builder: (context) => const SetupScreen(), - ), + const Spacer(), + _buildStudioLaunchButton( + label: compact ? 'Node Leaf' : 'Launch Node Leaf', + icon: Icons.play_arrow_rounded, + compact: compact, + onPressed: hubState.launchNodeLeaf, + ), + const SizedBox(width: 10), + _buildStudioLaunchButton( + label: configured + ? (compact ? 'MLT Player' : 'Launch MLT Player') + : (compact ? 'Set Path' : 'Set MLT Player Path'), + icon: configured + ? Icons.play_arrow_rounded + : Icons.settings_outlined, + compact: compact, + onPressed: configured + ? () => _launchMltPlayer(hubState) + : () => Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + const SetupScreen(), ), - ), + ), ), ], ), diff --git a/test/widget_test.dart b/test/widget_test.dart index 2accb64..4f170cb 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -34,7 +34,9 @@ class _OnlineMltHubState extends _InMemoryHubState { Future<_InMemoryHubState> _makeHubState({ _InMemoryHubState? existing, }) async { - SharedPreferences.setMockInitialValues({}); + if (existing == null) { + SharedPreferences.setMockInitialValues({}); + } final state = existing ?? _InMemoryHubState(); if (state.isLoading) { @@ -210,6 +212,7 @@ void main() { addTearDown(tester.view.resetPhysicalSize); addTearDown(tester.view.resetDevicePixelRatio); + SharedPreferences.setMockInitialValues({}); final online = _OnlineMltHubState(); final loaded = await tester.runAsync( () => _makeHubState(existing: online), @@ -233,10 +236,56 @@ void main() { expect(find.text('Launch Node Leaf'), findsOneWidget); expect(find.text('Launch MLT Player'), findsOneWidget); + expect( + find.byKey(const ValueKey('redleaf-studio-launcher')), + findsOneWidget, + ); + final launcher = tester.widget( + find.byKey(const ValueKey('redleaf-studio-launcher')), + ); + expect(launcher.constraints?.maxHeight, 82.0); + expect(launcher.decoration, isNotNull); + expect(launcher.duration, const Duration(milliseconds: 300)); + expect(find.text('REDLEAF'), findsOneWidget); + expect(find.text('ONLINE · localhost:5000'), findsOneWidget); await tester.tap(find.text('Launch MLT Player')); await tester.pump(); expect(online.launches, 1); }, timeout: const Timeout(Duration(seconds: 20))); + testWidgets('compact studio launcher retains both actions without overflow', + (tester) async { + tester.view.physicalSize = const Size(680, 800); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + + SharedPreferences.setMockInitialValues({}); + final online = _OnlineMltHubState(); + await tester.runAsync( + () => _makeHubState(existing: online), + ); + addTearDown(online.dispose); + online + ..mltPlayerPath = '/virtual/mlt-player' + ..activeProject = online.projects.first; + + await tester.pumpWidget( + ChangeNotifierProvider.value( + value: online, + child: const RedleafHubApp(), + ), + ); + await tester.pump(); + await tester.tap(find.text('Open Project\nLibrary')); + await tester.pump(const Duration(milliseconds: 350)); + + expect(find.text('Node Leaf'), findsOneWidget); + expect(find.text('MLT Player'), findsOneWidget); + expect(find.byKey(const ValueKey('redleaf-studio-launcher')), + findsOneWidget); + expect(tester.takeException(), isNull); + }, timeout: const Timeout(Duration(seconds: 20))); + }