Skip to content

Commit

Permalink
Merge pull request #39 from Merrit/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Merrit authored Jul 20, 2021
2 parents d052564 + 77b7b3f commit 1f5ee3a
Show file tree
Hide file tree
Showing 21 changed files with 484 additions and 468 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/build-linux-appimage.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
name: Build AppImage on new release
on: [push, pull_request, release, workflow_dispatch]
name: Build Linux AppImage
on:
workflow_dispatch:
pull_request:
release:
types:
- created
jobs:
build-appimage:
runs-on: Ubuntu-20.04
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/build-linux-portable.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
name: Build Linux portable version on release
on: [push, pull_request, release, workflow_dispatch]
name: Build Linux portable
on:
workflow_dispatch:
pull_request:
release:
types:
- created
jobs:
build_and_preview:
runs-on: ubuntu-latest
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/build-win32.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
name: Build Win32 versions on release
on: [push, pull_request, release, workflow_dispatch]
name: Build Win32
on:
workflow_dispatch:
pull_request:
release:
types:
- created
jobs:
build_and_preview:
runs-on: windows-latest
Expand Down
40 changes: 0 additions & 40 deletions .github/workflows/generate-changelog.yml

This file was deleted.

144 changes: 0 additions & 144 deletions CHANGELOG.md

This file was deleted.

20 changes: 20 additions & 0 deletions lib/application/theme/cubit/theme_cubit.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
import 'package:nyrna/application/theme/enums/app_theme.dart';
import 'package:nyrna/settings/settings.dart';

part 'theme_state.dart';

late ThemeCubit themeCubit;

class ThemeCubit extends Cubit<ThemeState> {
ThemeCubit() : super(ThemeState(appTheme: Settings.instance.appTheme)) {
themeCubit = this;
}

void changeTheme(AppTheme appTheme) {
Settings.instance.appTheme = appTheme;
emit(state.copyWith(appTheme: appTheme));
}
}
49 changes: 49 additions & 0 deletions lib/application/theme/cubit/theme_state.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
part of 'theme_cubit.dart';

@immutable
class ThemeState extends Equatable {
final AppTheme appTheme;

ThemeState({
required this.appTheme,
});

final Color pitchBlack = Colors.black;

ThemeData get themeData {
final brightness =
(appTheme == AppTheme.light) ? Brightness.light : Brightness.dark;
final isPitchBlack = (appTheme == AppTheme.pitchBlack);
final appBarTheme = AppBarTheme(
centerTitle: true,
backgroundColor: isPitchBlack ? pitchBlack : null,
);
final cardColor = isPitchBlack ? pitchBlack : null;
final colorScheme = ThemeData().colorScheme.copyWith(
brightness: brightness,
secondary: Colors.lightBlueAccent,
);
final scaffoldBackgroundColor = isPitchBlack ? pitchBlack : null;

final toggleableActiveColor =
isPitchBlack ? Colors.blue[900] : Colors.lightBlueAccent;
return ThemeData(
appBarTheme: appBarTheme,
cardColor: cardColor,
colorScheme: colorScheme,
scaffoldBackgroundColor: scaffoldBackgroundColor,
toggleableActiveColor: toggleableActiveColor,
);
}

ThemeState copyWith({
AppTheme? appTheme,
}) {
return ThemeState(
appTheme: appTheme ?? this.appTheme,
);
}

@override
List<Object> get props => [appTheme];
}
5 changes: 5 additions & 0 deletions lib/application/theme/enums/app_theme.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
enum AppTheme {
light,
dark,
pitchBlack,
}
2 changes: 2 additions & 0 deletions lib/application/theme/theme.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export 'enums/app_theme.dart';
export 'cubit/theme_cubit.dart';
40 changes: 27 additions & 13 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:logging/logging.dart';
import 'package:nyrna/config.dart';
import 'package:nyrna/logger/log_file.dart';
Expand All @@ -11,10 +12,11 @@ import 'package:nyrna/screens/apps_screen.dart';
import 'package:nyrna/screens/loading_screen.dart';
import 'package:nyrna/settings/screens/settings_screen.dart';
import 'package:nyrna/settings/settings.dart';
import 'package:nyrna/theme.dart';
import 'package:nyrna/window/active_window.dart';
import 'package:provider/provider.dart';

import 'application/theme/cubit/theme_cubit.dart';

Future<void> main(List<String> args) async {
await parseArgs(args);
await initSettings();
Expand All @@ -24,8 +26,16 @@ Future<void> main(List<String> args) async {
// `-t` or `--toggle` flag detected.
if (Config.toggle) await toggleActiveWindow();

// Run main GUI interface.
runApp(MyApp());
runApp(
MultiBlocProvider(
providers: [
BlocProvider(
create: (context) => ThemeCubit(),
),
],
child: MyApp(),
),
);
}

/// Parse command-line arguments.
Expand Down Expand Up @@ -86,17 +96,21 @@ class MyApp extends StatelessWidget {
providers: [
ChangeNotifierProvider<Nyrna>(create: (_) => Nyrna()),
],
child: MaterialApp(
title: 'Nyrna',
theme: NyrnaTheme.dark,
routes: {
LoadingScreen.id: (context) => LoadingScreen(),
LogScreen.id: (context) => LogScreen(),
RunningAppsScreen.id: (context) => RunningAppsScreen(),
SettingsScreen.id: (conext) => SettingsScreen(),
child: BlocBuilder<ThemeCubit, ThemeState>(
builder: (context, state) {
return MaterialApp(
title: 'Nyrna',
theme: state.themeData,
routes: {
LoadingScreen.id: (context) => LoadingScreen(),
LogScreen.id: (context) => LogScreen(),
RunningAppsScreen.id: (context) => RunningAppsScreen(),
SettingsScreen.id: (conext) => SettingsScreen(),
},
home: LoadingScreen(),
debugShowCheckedModeBanner: false,
);
},
home: LoadingScreen(),
debugShowCheckedModeBanner: false,
),
);
}
Expand Down
Loading

0 comments on commit 1f5ee3a

Please sign in to comment.