Skip to content

Commit

Permalink
Add new default design, remove yaru theme
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Mar 19, 2023
1 parent 2ea5502 commit 43617b2
Show file tree
Hide file tree
Showing 18 changed files with 227 additions and 319 deletions.
36 changes: 28 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: 🏭 Build nightly
if: ${{ github.ref != 'refs/tags/stable' }}
run: |
flutter build apk -v --release --flavor development
flutter build apk -v --release --flavor development --dart-define=flavor=development
cp build/app/outputs/flutter-apk/app-development-release.apk linwood-butterfly-android.apk
- name: 🏭 Build production
if: ${{ github.ref == 'refs/tags/stable' }}
Expand Down Expand Up @@ -78,10 +78,16 @@ jobs:
flutter clean
flutter pub get
flutter doctor -v
- name: 🏭 Build
shell: pwsh
- name: 🏭 Build nightly
if: ${{ github.ref != 'refs/tags/stable' }}
run: |
flutter build windows -v --release
flutter doctor -v
flutter build windows -v --release --dart-define=flavor=development
- name: 🏭 Build production
if: ${{ github.ref == 'refs/tags/stable' }}
run: |
flutter doctor -v
flutter build windows -v --release --dart-define=flavor=production
- name: Build setup
shell: pwsh
run: |
Expand Down Expand Up @@ -149,9 +155,16 @@ jobs:
flutter clean
flutter pub get
flutter doctor -v
- name: 🏭 Build
- name: 🏭 Build nightly
if: ${{ github.ref != 'refs/tags/stable' }}
run: |
flutter doctor -v
flutter build linux -v --release --dart-define=flavor=development
- name: 🏭 Build production
if: ${{ github.ref == 'refs/tags/stable' }}
run: |
flutter build linux -v --release
flutter doctor -v
flutter build linux -v --release --dart-define=flavor=production
- name: Build .deb executable
run: |
cp -fr build/linux/x64/release/bundle linux/debian/usr/bin
Expand Down Expand Up @@ -251,9 +264,16 @@ jobs:
flutter clean
flutter pub get
flutter doctor -v
- name: 🏭 Build
- name: 🏭 Build nightly
if: ${{ github.ref != 'refs/tags/stable' }}
run: |
flutter build linux -v --release
flutter doctor -v
flutter build linux -v --release --dart-define=flavor=development
- name: 🏭 Build production
if: ${{ github.ref == 'refs/tags/stable' }}
run: |
flutter doctor -v
flutter build linux -v --release --dart-define=flavor=production
- name: Copy nessessary files
run: |
cp images/logo.svg build/linux/x64/release/bundle/dev.linwood.butterfly.svg
Expand Down
4 changes: 4 additions & 0 deletions app/lib/cubits/current_index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import '../embed/embedding.dart';
import '../handlers/handler.dart';
import '../models/viewport.dart';
import '../selections/selection.dart';
import '../theme.dart';
import '../view_painter.dart';

part 'current_index.freezed.dart';
Expand Down Expand Up @@ -57,6 +58,9 @@ class CurrentIndexCubit extends Cubit<CurrentIndex> {
: super(CurrentIndex(null, MoveHandler(), settingsCubit, transformCubit,
embedding: embedding));

ThemeData getTheme(bool dark, [ColorScheme? overridden]) =>
getThemeData(state.settingsCubit.state.design, dark, overridden);

Handler getHandler({bool disableTemporary = false}) {
if (disableTemporary) {
return state.handler;
Expand Down
3 changes: 3 additions & 0 deletions app/lib/cubits/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,17 @@ class SettingsCubit extends Cubit<ButterflySettings> {

Future<void> changeTheme(ThemeMode theme) async {
emit(state.copyWith(theme: theme));
return save();
}

Future<void> changeDesign(String design) async {
emit(state.copyWith(design: design));
return save();
}

Future<void> resetDesign() async {
emit(state.copyWith(design: ''));
return save();
}

Future<void> changeLocale(Locale? locale) {
Expand Down
4 changes: 1 addition & 3 deletions app/lib/handlers/hand.dart
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,6 @@ class HandHandler extends Handler<HandPainter> {
CurrentIndexCubit currentIndexCubit, AppDocument document,
[Area? currentArea]) {
final foregrounds = <Renderer>[];
final scheme = ThemeManager.getThemeByName(
currentIndexCubit.state.settingsCubit.state.design)
.colorScheme;
if (_movingElements.isNotEmpty && _currentMovePosition != null) {
final renderers = _movingElements.map((e) {
final position = currentIndexCubit.getGridPosition(
Expand All @@ -202,6 +199,7 @@ class HandHandler extends Handler<HandPainter> {
foregrounds.addAll(renderers);
}
final selectionRect = getSelectionRect();
final scheme = currentIndexCubit.getTheme(false).colorScheme;
if (selectionRect != null) {
foregrounds.add(HandSelectionRenderer(
selectionRect, scheme, _transformMode, _transformCorner));
Expand Down
1 change: 0 additions & 1 deletion app/lib/handlers/handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import 'package:butterfly/helpers/rect_helper.dart';
import 'package:butterfly/models/cursor.dart';
import 'package:butterfly/renderers/foregrounds/area.dart';
import 'package:butterfly/renderers/foregrounds/waypoint.dart';
import 'package:butterfly/theme/manager.dart';
import 'package:butterfly_api/butterfly_api.dart';
import 'package:butterfly_api/butterfly_text.dart' as text;
import 'package:collection/collection.dart';
Expand Down
69 changes: 35 additions & 34 deletions app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:butterfly/api/intent.dart';
import 'package:butterfly/services/sync.dart';
import 'package:butterfly/settings/behaviors/mouse.dart';
import 'package:butterfly_api/butterfly_api.dart';
import 'package:dynamic_color/dynamic_color.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
Expand All @@ -30,7 +31,7 @@ import 'settings/personalization.dart';
import 'settings/connection.dart';
import 'settings/connections.dart';
import 'setup.dart' if (dart.library.html) 'setup_web.dart';
import 'theme/manager.dart';
import 'theme.dart';
import 'views/error.dart';
import 'views/main.dart';
import 'views/window.dart';
Expand Down Expand Up @@ -251,42 +252,44 @@ class ButterflyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (_) => SettingsCubit.fromPrefs(prefs),
child: BlocBuilder<SettingsCubit, ButterflySettings>(
buildWhen: (previous, current) =>
previous.nativeWindowTitleBar != current.nativeWindowTitleBar,
builder: (context, settings) {
if (!kIsWeb && isWindow()) {
windowManager.waitUntilReadyToShow().then((_) async {
windowManager.setTitleBarStyle(settings.nativeWindowTitleBar
? TitleBarStyle.normal
: TitleBarStyle.hidden);
windowManager.setFullScreen(settings.startInFullScreen);
});
} else {
setFullScreen(settings.startInFullScreen);
}
return RepositoryProvider(
create: (context) =>
SyncService(context, context.read<SettingsCubit>()),
lazy: false,
child: _buildApp(),
);
},
return DynamicColorBuilder(
builder: (lightDynamic, darkDynamic) => BlocProvider(
create: (_) => SettingsCubit.fromPrefs(prefs),
child: BlocBuilder<SettingsCubit, ButterflySettings>(
buildWhen: (previous, current) =>
previous.nativeWindowTitleBar != current.nativeWindowTitleBar,
builder: (context, settings) {
if (!kIsWeb && isWindow()) {
windowManager.waitUntilReadyToShow().then((_) async {
windowManager.setTitleBarStyle(settings.nativeWindowTitleBar
? TitleBarStyle.normal
: TitleBarStyle.hidden);
windowManager.setFullScreen(settings.startInFullScreen);
});
} else {
setFullScreen(settings.startInFullScreen);
}
return RepositoryProvider(
create: (context) =>
SyncService(context, context.read<SettingsCubit>()),
lazy: false,
child: _buildApp(lightDynamic, darkDynamic),
);
},
),
),
);
}

Widget _buildApp() {
Widget _buildApp(ColorScheme? lightDynamic, ColorScheme? darkDynamic) {
return BlocBuilder<SettingsCubit, ButterflySettings>(
buildWhen: (previous, current) =>
previous.theme != current.theme ||
previous.localeTag != current.localeTag ||
previous.design != current.design,
builder: (context, state) => MaterialApp.router(
locale: state.locale,
title: 'Butterfly',
title: isNightly ? 'Butterfly Nightly' : 'Butterfly',
routeInformationProvider: _router.routeInformationProvider,
routeInformationParser: _router.routeInformationParser,
routerDelegate: _router.routerDelegate,
Expand All @@ -295,17 +298,15 @@ class ButterflyApp extends StatelessWidget {
LocaleNamesLocalizationsDelegate(),
],
supportedLocales: getLocales(),
theme: ThemeManager.getThemeByName(state.design),
themeMode: state.theme,
builder: (context, child) {
if (child == null) {
return const Center(child: CircularProgressIndicator());
}
return child;
},
darkTheme: ThemeManager.getThemeByName(state.design, dark: true),
theme: getThemeData(state.design, false, lightDynamic),
darkTheme: getThemeData(state.design, true, darkDynamic),
));
}

final GoRouter _router;
}

const flavor = String.fromEnvironment('flavor');
const isNightly =
flavor == 'nightly' || flavor == 'dev' || flavor == 'development';
Loading

0 comments on commit 43617b2

Please sign in to comment.