App: add a selectable app design with a Terminal look
AppDesign builds each design's light and dark ThemeData with an AppDesignTokens extension (corner radius, flat surfaces, frame colour, ANSI accents, prompt glyph). Settings gains a Design picker stored per device; the theme hosts rebuild live. Terminal is monospace (bundled RobotoMono), near-black or paper, flat 1px frames with 3px corners, and draws the chat transcript as prompt lines, tool dot/result lines and bracketed follow-up lines. Default keeps its exact themes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/ui/theme/app_design.dart';
|
||||
import 'package:pipelines_app/ui/theme/app_design_controller.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
void main() {
|
||||
test('restore applies the stored design; unknown ids keep Default', () async {
|
||||
final stored = AppDesignController(store: MemoryAppDesignStore('terminal'));
|
||||
var notified = 0;
|
||||
stored.addListener(() => notified++);
|
||||
await stored.restore();
|
||||
expect(stored.design, AppDesign.terminal);
|
||||
expect(notified, 1);
|
||||
|
||||
final unknown = AppDesignController(store: MemoryAppDesignStore('neon'));
|
||||
await unknown.restore();
|
||||
expect(unknown.design, AppDesign.standard);
|
||||
});
|
||||
|
||||
test('select applies at once and stores the id', () async {
|
||||
final store = MemoryAppDesignStore();
|
||||
final designs = AppDesignController(store: store);
|
||||
final pending = designs.select(AppDesign.terminal);
|
||||
expect(designs.design, AppDesign.terminal);
|
||||
await pending;
|
||||
expect(store.id, 'terminal');
|
||||
expect(designs.saveFailed, isFalse);
|
||||
});
|
||||
|
||||
test('a failed save is reported and the choice still applies', () async {
|
||||
final store = MemoryAppDesignStore()..failSaves = true;
|
||||
final designs = AppDesignController(store: store);
|
||||
await designs.select(AppDesign.terminal);
|
||||
expect(designs.design, AppDesign.terminal);
|
||||
expect(designs.saveFailed, isTrue);
|
||||
store.failSaves = false;
|
||||
await designs.select(AppDesign.standard);
|
||||
expect(designs.saveFailed, isFalse);
|
||||
});
|
||||
|
||||
test('a choice made while restoring wins over the stored one', () async {
|
||||
final designs = AppDesignController(
|
||||
store: MemoryAppDesignStore('terminal'),
|
||||
);
|
||||
final restoring = designs.restore();
|
||||
await designs.select(AppDesign.standard);
|
||||
await restoring;
|
||||
expect(designs.design, AppDesign.standard);
|
||||
});
|
||||
|
||||
test('shared preferences keep the choice per device', () async {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
const store = SharedPreferencesAppDesignStore();
|
||||
expect(await store.load(), isNull);
|
||||
expect(await store.save('terminal'), isTrue);
|
||||
expect(await store.load(), 'terminal');
|
||||
final designs = AppDesignController(store: store);
|
||||
await designs.restore();
|
||||
expect(designs.design, AppDesign.terminal);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user