@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
22
33import '../l10n/app_locale.dart' ;
44import '../models/repo_tab.dart' ;
5+ import '../repo/file_explorer.dart' ;
56import '../repo/git_actions.dart' ;
67import '../repo/repo_controller.dart' ;
78import '../shortcuts/app_shortcuts.dart' ;
@@ -20,7 +21,7 @@ const double kRepoToolbarHeight = 46;
2021/// 1. `Branchi [tab] [tab] [+] … ☾ 📌 ⚙` - the open tabs, with the
2122/// app-wide buttons.
2223/// 2. `[branch] [History | Changes N | Files | Report] …
23- /// [● Auto 1:42 ▾] Fetch Pull [Push] ` - the selected tab's
24+ /// 📁 >_ [● Auto 1:42 ▾] Fetch Pull [Push] ` - the selected tab's
2425/// repository toolbar; only when that tab has a repository open
2526/// ([controller] non-null).
2627///
@@ -39,6 +40,8 @@ class AppTopBar extends StatelessWidget {
3940 required this .onToggleTheme,
4041 required this .isPinned,
4142 required this .onTogglePin,
43+ this .repoPath,
44+ this .onOpenTerminal,
4245 });
4346
4447 final List <RepoTab > tabs;
@@ -56,6 +59,13 @@ class AppTopBar extends StatelessWidget {
5659 final bool isPinned;
5760 final VoidCallback onTogglePin;
5861
62+ /// The active tab's repository folder, opened by the file explorer button.
63+ final String ? repoPath;
64+
65+ /// Opens a new terminal in the repository (same as the branch menu's
66+ /// "Open in terminal").
67+ final VoidCallback ? onOpenTerminal;
68+
5969 @override
6070 Widget build (BuildContext context) {
6171 final controller = this .controller;
@@ -130,6 +140,14 @@ class AppTopBar extends StatelessWidget {
130140 );
131141 }
132142
143+ Future <void > _openFileExplorer (BuildContext context, String path) async {
144+ final messenger = ScaffoldMessenger .maybeOf (context);
145+ final error = await openInFileExplorer (path);
146+ if (error != null ) {
147+ messenger? .showSnackBar (SnackBar (content: Text (error)));
148+ }
149+ }
150+
133151 Widget _buildRepoToolbar (BuildContext context, RepoController controller) {
134152 final b = context.branchi;
135153 return Container (
@@ -150,6 +168,31 @@ class AppTopBar extends StatelessWidget {
150168 ],
151169 ),
152170 ),
171+ if (repoPath != null ) ...[
172+ _HoverBox (
173+ tooltip: translate ('bs_open_explorer' ),
174+ onTap: () => _openFileExplorer (context, repoPath! ),
175+ padding: const EdgeInsets .all (6 ),
176+ child: Icon (Icons .folder_open_outlined, size: 16 , color: b.muted),
177+ ),
178+ const SizedBox (width: 4 ),
179+ ],
180+ if (onOpenTerminal != null ) ...[
181+ _HoverBox (
182+ tooltip: translate ('bs_open_terminal' ),
183+ onTap: onOpenTerminal,
184+ padding: const EdgeInsets .all (6 ),
185+ child: Icon (Icons .terminal, size: 16 , color: b.muted),
186+ ),
187+ const SizedBox (width: 4 ),
188+ ],
189+ if (repoPath != null || onOpenTerminal != null )
190+ Container (
191+ width: 1 ,
192+ height: 18 ,
193+ margin: const EdgeInsets .symmetric (horizontal: 8 ),
194+ color: b.line,
195+ ),
153196 AutoPullButton (
154197 watcher: controller.watcher,
155198 isBusy: controller.isPulling,
0 commit comments