Skip to content

Commit b047f45

Browse files
committed
fix(macos): launch with the full reader composition
1 parent ffa83a0 commit b047f45

8 files changed

Lines changed: 234 additions & 103 deletions

File tree

‎docs/05-api/02-shell.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ document, `_EmptyLibrary` offers another folder instead
9999
(`lib/api/screens/reader_screen.dart:531-537`,
100100
`lib/api/screens/reader_screen.dart:708-739`).
101101

102+
The welcome composition centres itself inside the available height at normal
103+
desktop sizes. Below its preferred height it scrolls instead of overflowing,
104+
so deliberately compact windows remain usable
105+
(`lib/api/widgets/welcome_view.dart:21-40`, `:137-154`).
106+
102107
## Events
103108

104109
None today. The shell is where future UI slots would be presented: top-bar

‎docs/06-platforms/02-macos.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ bar that doubles as a drag handle with double-click-to-zoom
7878
`lib/infrastructure/platform/platform_io.dart:106-117`). See
7979
[Window Chrome](../03-infrastructure/desktop/03-window-chrome.md).
8080

81+
The initial content frame is 1280 × 800, wide enough to enter the reader's
82+
full desktop composition instead of its compact mode. The window remains
83+
resizable down to the smaller minimum above
84+
(`macos/Runner/Base.lproj/MainMenu.xib:333-340`).
85+
8186
The application File menu is native AppKit chrome, inserted beside the app
8287
menu after AppKit has installed the menu bar. Its Command-O Open panel accepts
8388
folders and Markdown files in one multi-selection operation; Command-Shift-O

‎docs/09-contributing/02-testing-and-validation.md‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,14 @@ Widget tests protect what a reader can observe:
8989
`test/presentation/inline_composer_test.dart:49-338`,
9090
`test/presentation/paragraph_setting_test.dart:61-335`,
9191
`test/presentation/code_block_test.dart:55-88`).
92-
- Chrome tests cover distinct Open shortcuts, search, panel motion and resizing,
93-
error notices, compact-window behavior, and reduced-motion behavior
94-
(`test/presentation/reader_chrome_test.dart:248-562`).
92+
- Chrome tests cover distinct Open shortcuts, the full launch composition,
93+
search, panel motion and resizing, error notices, compact-window behavior,
94+
and reduced-motion behavior
95+
(`test/presentation/reader_chrome_test.dart:248-579`).
96+
- Welcome tests hold both launch-size centring and short-window scrolling, while
97+
the native configuration test protects the 1280 × 800 macOS launch frame
98+
(`test/presentation/welcome_view_test.dart:28-55`,
99+
`test/infrastructure/macos_window_configuration_test.dart:5-16`).
95100
- Shelf tests hold the root-reorder state machine, expansion preservation,
96101
standalone adaptation, hover removal, and accessible arrange actions
97102
(`test/presentation/shelf_panel_test.dart:49-391`).

‎lib/api/widgets/welcome_view.dart‎

Lines changed: 124 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -21,112 +21,138 @@ class WelcomeView extends StatelessWidget {
2121
@override
2222
Widget build(BuildContext context) {
2323
final p = context.palette;
24-
return Center(
25-
child: ConstrainedBox(
26-
constraints: const BoxConstraints(maxWidth: 520),
27-
child: Column(
28-
mainAxisSize: MainAxisSize.min,
29-
children: [
30-
const BrandMark(size: 64),
31-
const SizedBox(height: 22),
32-
Text(
33-
'Visual MD',
34-
style: context.type.serif(
35-
color: p.ink,
36-
size: 40,
37-
weight: FontWeight.w700,
38-
height: 1.1,
39-
),
40-
),
41-
const SizedBox(height: 10),
42-
Text(
43-
'The last markdown reader you need.',
44-
textAlign: TextAlign.center,
45-
style: context.type.serif(
46-
color: p.muted,
47-
size: 19,
48-
style: FontStyle.italic,
49-
),
50-
),
51-
const SizedBox(height: 40),
52-
Container(
53-
width: double.infinity,
54-
padding: const EdgeInsets.symmetric(vertical: 44, horizontal: 24),
55-
decoration: BoxDecoration(
56-
color: p.panel.withValues(alpha: 0.6),
57-
borderRadius: BorderRadius.circular(14),
58-
border: Border.all(color: p.border, width: 1.5),
59-
),
60-
child: Column(
61-
children: [
62-
Icon(
63-
Icons.drive_folder_upload_outlined,
64-
size: 30,
65-
color: p.muted,
66-
),
67-
const SizedBox(height: 14),
68-
Text(
69-
opening
70-
? 'Shelving your documents…'
71-
: 'Drop a folder or markdown anywhere',
72-
style: context.type.sans(
73-
color: p.ink,
74-
size: 15,
75-
weight: FontWeight.w500,
24+
return LayoutBuilder(
25+
builder: (context, constraints) {
26+
const verticalInset = 24.0;
27+
final minimumHeight = constraints.hasBoundedHeight
28+
? (constraints.maxHeight - verticalInset * 2).clamp(
29+
0.0,
30+
double.infinity,
31+
)
32+
: 0.0;
33+
return SingleChildScrollView(
34+
padding: const EdgeInsets.symmetric(vertical: verticalInset),
35+
child: ConstrainedBox(
36+
constraints: BoxConstraints(minHeight: minimumHeight),
37+
child: Center(
38+
child: ConstrainedBox(
39+
constraints: const BoxConstraints(maxWidth: 520),
40+
child: Column(
41+
mainAxisSize: MainAxisSize.min,
42+
children: [
43+
const BrandMark(size: 64),
44+
const SizedBox(height: 22),
45+
Text(
46+
'Visual MD',
47+
style: context.type.serif(
48+
color: p.ink,
49+
size: 40,
50+
weight: FontWeight.w700,
51+
height: 1.1,
52+
),
53+
),
54+
const SizedBox(height: 10),
55+
Text(
56+
'The last markdown reader you need.',
57+
textAlign: TextAlign.center,
58+
style: context.type.serif(
59+
color: p.muted,
60+
size: 19,
61+
style: FontStyle.italic,
62+
),
7663
),
77-
),
78-
const SizedBox(height: 6),
79-
Text(
80-
'Open one file, or every markdown nested in a folder.',
81-
textAlign: TextAlign.center,
82-
style: context.type.sans(color: p.muted, size: 13),
83-
),
84-
const SizedBox(height: 22),
85-
FilledButton.icon(
86-
onPressed: opening ? null : onOpenFolder,
87-
style: FilledButton.styleFrom(
88-
backgroundColor: p.accent,
89-
foregroundColor: p.paper,
64+
const SizedBox(height: 40),
65+
Container(
66+
width: double.infinity,
9067
padding: const EdgeInsets.symmetric(
91-
horizontal: 20,
92-
vertical: 14,
68+
vertical: 44,
69+
horizontal: 24,
9370
),
94-
textStyle: context.type.sans(
95-
color: p.paper,
96-
size: 14,
97-
weight: FontWeight.w600,
71+
decoration: BoxDecoration(
72+
color: p.panel.withValues(alpha: 0.6),
73+
borderRadius: BorderRadius.circular(14),
74+
border: Border.all(color: p.border, width: 1.5),
75+
),
76+
child: Column(
77+
children: [
78+
Icon(
79+
Icons.drive_folder_upload_outlined,
80+
size: 30,
81+
color: p.muted,
82+
),
83+
const SizedBox(height: 14),
84+
Text(
85+
opening
86+
? 'Shelving your documents…'
87+
: 'Drop a folder or markdown anywhere',
88+
style: context.type.sans(
89+
color: p.ink,
90+
size: 15,
91+
weight: FontWeight.w500,
92+
),
93+
),
94+
const SizedBox(height: 6),
95+
Text(
96+
'Open one file, or every markdown nested in a folder.',
97+
textAlign: TextAlign.center,
98+
style: context.type.sans(color: p.muted, size: 13),
99+
),
100+
const SizedBox(height: 22),
101+
FilledButton.icon(
102+
onPressed: opening ? null : onOpenFolder,
103+
style: FilledButton.styleFrom(
104+
backgroundColor: p.accent,
105+
foregroundColor: p.paper,
106+
padding: const EdgeInsets.symmetric(
107+
horizontal: 20,
108+
vertical: 14,
109+
),
110+
textStyle: context.type.sans(
111+
color: p.paper,
112+
size: 14,
113+
weight: FontWeight.w600,
114+
),
115+
),
116+
icon: const Icon(
117+
Icons.folder_open_outlined,
118+
size: 18,
119+
),
120+
label: const Text('Open a folder'),
121+
),
122+
],
98123
),
99124
),
100-
icon: const Icon(Icons.folder_open_outlined, size: 18),
101-
label: const Text('Open a folder'),
102-
),
103-
],
104-
),
105-
),
106-
const SizedBox(height: 18),
107-
TextButton(
108-
onPressed: opening ? null : onOpenSample,
109-
child: Text(
110-
'or browse the sample library',
111-
style: context.type.sans(
112-
color: p.accent,
113-
size: 13.5,
114-
weight: FontWeight.w500,
125+
const SizedBox(height: 18),
126+
TextButton(
127+
onPressed: opening ? null : onOpenSample,
128+
child: Text(
129+
'or browse the sample library',
130+
style: context.type.sans(
131+
color: p.accent,
132+
size: 13.5,
133+
weight: FontWeight.w500,
134+
),
135+
),
136+
),
137+
if (error != null) ...[
138+
const SizedBox(height: 8),
139+
Text(
140+
error!,
141+
style: context.type.sans(color: p.accent, size: 13),
142+
),
143+
],
144+
const SizedBox(height: 28),
145+
Text(
146+
'Nothing leaves your machine.',
147+
style: context.type.sans(color: p.muted, size: 12),
148+
),
149+
],
115150
),
116151
),
117152
),
118-
if (error != null) ...[
119-
const SizedBox(height: 8),
120-
Text(error!, style: context.type.sans(color: p.accent, size: 13)),
121-
],
122-
const SizedBox(height: 28),
123-
Text(
124-
'Nothing leaves your machine.',
125-
style: context.type.sans(color: p.muted, size: 12),
126-
),
127-
],
128-
),
129-
),
153+
),
154+
);
155+
},
130156
);
131157
}
132158
}

‎macos/Runner/Base.lproj/MainMenu.xib‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,10 @@
332332
</menu>
333333
<window title="APP_NAME" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g" customClass="MainFlutterWindow" customModule="Runner" customModuleProvider="target">
334334
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
335-
<rect key="contentRect" x="335" y="390" width="800" height="600"/>
335+
<rect key="contentRect" x="335" y="390" width="1280" height="800"/>
336336
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1577"/>
337337
<view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ">
338-
<rect key="frame" x="0.0" y="0.0" width="800" height="600"/>
338+
<rect key="frame" x="0.0" y="0.0" width="1280" height="800"/>
339339
<autoresizingMask key="autoresizingMask"/>
340340
</view>
341341
</window>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import 'dart:io';
2+
3+
import 'package:flutter_test/flutter_test.dart';
4+
5+
void main() {
6+
test('macOS launches in the full desktop composition', () {
7+
final source = File('macos/Runner/Base.lproj/MainMenu.xib')
8+
.readAsStringSync();
9+
10+
expect(
11+
source,
12+
contains(
13+
'<rect key="contentRect" x="335" y="390" width="1280" height="800"/>',
14+
),
15+
);
16+
});
17+
}

‎test/presentation/reader_chrome_test.dart‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,23 @@ void main() {
305305
},
306306
);
307307

308+
testWidgets('the desktop launch width preserves both default side panels', (
309+
tester,
310+
) async {
311+
await pumpReader(tester, size: const Size(1280, 800));
312+
313+
expect(find.byType(ShelfPanel), findsOneWidget);
314+
expect(find.byType(OutlinePanel), findsOneWidget);
315+
expect(
316+
panelWidth(tester, ShelfPanel),
317+
closeTo(PanelWidths.defaultShelf, 0.001),
318+
);
319+
expect(
320+
panelWidth(tester, OutlinePanel),
321+
closeTo(PanelWidths.defaultOutline, 0.001),
322+
);
323+
});
324+
308325
testWidgets('the shelf toggles on the press, not the release', (
309326
tester,
310327
) async {
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_test/flutter_test.dart';
3+
import 'package:visualmd/api/theme/library_theme.dart';
4+
import 'package:visualmd/api/widgets/welcome_view.dart';
5+
import 'package:visualmd/presentation/theme/built_in_themes.dart';
6+
7+
void main() {
8+
Future<void> pumpWelcome(WidgetTester tester, Size size) async {
9+
tester.view.physicalSize = size;
10+
tester.view.devicePixelRatio = 1;
11+
addTearDown(tester.view.reset);
12+
await tester.pumpWidget(
13+
MaterialApp(
14+
theme: libraryTheme(BuiltInThemes.paper),
15+
home: Scaffold(
16+
body: WelcomeView(
17+
opening: false,
18+
error: null,
19+
onOpenFolder: () {},
20+
onOpenSample: () {},
21+
),
22+
),
23+
),
24+
);
25+
await tester.pumpAndSettle();
26+
}
27+
28+
testWidgets('the welcome composition fits the desktop launch viewport', (
29+
tester,
30+
) async {
31+
await pumpWelcome(tester, const Size(1280, 716));
32+
33+
expect(tester.takeException(), isNull);
34+
expect(find.text('Nothing leaves your machine.'), findsOneWidget);
35+
expect(
36+
tester.getBottomRight(find.text('Nothing leaves your machine.')).dy,
37+
lessThanOrEqualTo(716),
38+
);
39+
});
40+
41+
testWidgets('a deliberately short window scrolls instead of overflowing', (
42+
tester,
43+
) async {
44+
await pumpWelcome(tester, const Size(800, 480));
45+
46+
expect(tester.takeException(), isNull);
47+
expect(find.byType(SingleChildScrollView), findsOneWidget);
48+
await tester.drag(
49+
find.byType(SingleChildScrollView),
50+
const Offset(0, -160),
51+
);
52+
await tester.pumpAndSettle();
53+
expect(find.text('Nothing leaves your machine.'), findsOneWidget);
54+
expect(tester.takeException(), isNull);
55+
});
56+
}

0 commit comments

Comments
 (0)