Skip to content

Commit

Permalink
Merge branch 'main' into maintenance/docs-and-testing
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamKarolDiCioccio committed Aug 22, 2024
2 parents f6e88b5 + 3b1ffd7 commit 635915c
Show file tree
Hide file tree
Showing 27 changed files with 152 additions and 59 deletions.
3 changes: 3 additions & 0 deletions app/assets/graphics/logos/open_local_ui.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions app/assets/l10n/intl_en.arb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"@@locale": "en",
"deviceUnpluggedSnackBar": "Device unplugged. Power delivery reduced.",
"devicePluggedInSnackBar": "Device plugged in. Power delivery increased.",
"abortModelRemovalSnackBar": "Abort model removal",
"abortSessionRemovalSnackBar": "Abort session removal",
"aboutPageContributorsTitle": "Contributors",
Expand Down
2 changes: 1 addition & 1 deletion app/lib/backend/providers/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import 'package:open_local_ui/backend/providers/model_settings.dart';
import 'package:open_local_ui/constants/flutter.dart';
import 'package:open_local_ui/core/http.dart';
import 'package:open_local_ui/core/logger.dart';
import 'package:open_local_ui/frontend/helpers/snackbar.dart';
import 'package:open_local_ui/core/snackbar.dart';
import 'package:windows_taskbar/windows_taskbar.dart';

enum ModelProviderStatus {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion app/lib/core/update.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:open_local_ui/core/github.dart';
import 'package:open_local_ui/core/logger.dart';
import 'package:open_local_ui/core/process.dart';
import 'package:open_local_ui/env.dart';
import 'package:open_local_ui/frontend/helpers/snackbar.dart';
import 'package:open_local_ui/core/snackbar.dart';
import 'package:path_provider/path_provider.dart';
import 'package:shared_preferences/shared_preferences.dart';

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'package:adaptive_theme/adaptive_theme.dart';
import 'package:flutter/material.dart';

import 'package:bitsdojo_window/bitsdojo_window.dart';
import 'package:system_theme/system_theme.dart';

class WindowManagementBar extends StatelessWidget {
const WindowManagementBar({super.key});
class WindowManagementBarComponent extends StatelessWidget {
const WindowManagementBarComponent({super.key});

@override
Widget build(BuildContext context) {
Expand All @@ -18,19 +18,22 @@ class WindowManagementBar extends StatelessWidget {
children: [
MinimizeWindowButton(
colors: WindowButtonColors(
iconNormal: SystemTheme.accentColor.accent,
iconNormal:
AdaptiveTheme.of(context).theme.colorScheme.secondary,
iconMouseOver: Colors.green,
),
),
MaximizeWindowButton(
colors: WindowButtonColors(
iconNormal: SystemTheme.accentColor.accent,
iconNormal:
AdaptiveTheme.of(context).theme.colorScheme.secondary,
iconMouseOver: Colors.orange,
),
),
CloseWindowButton(
colors: WindowButtonColors(
iconNormal: SystemTheme.accentColor.accent,
iconNormal:
AdaptiveTheme.of(context).theme.colorScheme.secondary,
iconMouseOver: Colors.red,
),
),
Expand Down
2 changes: 1 addition & 1 deletion app/lib/frontend/pages/dashboard/models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import 'package:open_local_ui/frontend/dialogs/model_details.dart';
import 'package:open_local_ui/frontend/dialogs/model_settings.dart';
import 'package:open_local_ui/frontend/dialogs/pull_model.dart';
import 'package:open_local_ui/frontend/dialogs/push_model.dart';
import 'package:open_local_ui/frontend/helpers/snackbar.dart';
import 'package:open_local_ui/core/snackbar.dart';
import 'package:open_local_ui/frontend/screens/dashboard.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
Expand Down
2 changes: 1 addition & 1 deletion app/lib/frontend/pages/dashboard/sessions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'package:open_local_ui/backend/models/chat_session.dart';
import 'package:open_local_ui/backend/providers/chat.dart';
import 'package:open_local_ui/core/format.dart';
import 'package:open_local_ui/frontend/dialogs/confirmation.dart';
import 'package:open_local_ui/frontend/helpers/snackbar.dart';
import 'package:open_local_ui/core/snackbar.dart';
import 'package:open_local_ui/frontend/screens/dashboard.dart';
import 'package:path_provider/path_provider.dart';
import 'package:provider/provider.dart';
Expand Down
2 changes: 1 addition & 1 deletion app/lib/frontend/pages/dashboard/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'package:open_local_ui/backend/providers/chat.dart';
import 'package:open_local_ui/backend/providers/locale.dart';
import 'package:open_local_ui/core/color.dart';
import 'package:open_local_ui/frontend/dialogs/color_picker.dart';
import 'package:open_local_ui/frontend/helpers/snackbar.dart';
import 'package:open_local_ui/core/snackbar.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:system_theme/system_theme.dart';
Expand Down
36 changes: 33 additions & 3 deletions app/lib/frontend/screens/dashboard.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:io';

import 'package:battery_plus/battery_plus.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

Expand All @@ -14,13 +15,13 @@ import 'package:open_local_ui/core/github.dart';
import 'package:open_local_ui/core/logger.dart';
import 'package:open_local_ui/core/update.dart';
import 'package:open_local_ui/frontend/dialogs/update.dart';
import 'package:open_local_ui/frontend/helpers/snackbar.dart';
import 'package:open_local_ui/core/snackbar.dart';
import 'package:open_local_ui/frontend/pages/dashboard/about.dart';
import 'package:open_local_ui/frontend/pages/dashboard/chat.dart';
import 'package:open_local_ui/frontend/pages/dashboard/models.dart';
import 'package:open_local_ui/frontend/pages/dashboard/sessions.dart';
import 'package:open_local_ui/frontend/pages/dashboard/settings.dart';
import 'package:open_local_ui/frontend/widgets/window_management_bar.dart';
import 'package:open_local_ui/frontend/components/window_management_bar.dart';
import 'package:path_provider/path_provider.dart';
import 'package:supabase_flutter/supabase_flutter.dart';
import 'package:system_info2/system_info2.dart';
Expand All @@ -47,6 +48,7 @@ class _DashboardScreenState extends State<DashboardScreen> {

WidgetsBinding.instance.addPostFrameCallback((_) async {
_checkForUpdates();
_registerBatteryCallback();
});
}

Expand All @@ -57,6 +59,34 @@ class _DashboardScreenState extends State<DashboardScreen> {
super.dispose();
}

void _registerBatteryCallback() {
final battery = Battery();

battery.onBatteryStateChanged.listen((BatteryState state) {
switch (state) {
case BatteryState.discharging:
SnackBarHelpers.showSnackBar(
AppLocalizations.of(context).snackBarWarningTitle,
AppLocalizations.of(context).deviceUnpluggedSnackBar,
SnackbarContentType.warning,
);
logger.i('Battery charging');
break;
case BatteryState.charging:
SnackBarHelpers.showSnackBar(
AppLocalizations.of(context).snackBarSuccessTitle,
AppLocalizations.of(context).devicePluggedInSnackBar,
SnackbarContentType.success,
);
logger.i('Battery discharging');
break;
default:
logger.i('Battery state: $state');
break;
}
});
}

void _checkForUpdates() {
UpdateHelper.isAppUpdateAvailable().then(
(updateAvailable) {
Expand Down Expand Up @@ -107,7 +137,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
right: 0.0,
width: MediaQuery.of(context).size.width,
height: 32.0,
child: const WindowManagementBar(),
child: const WindowManagementBarComponent(),
),
],
);
Expand Down
12 changes: 6 additions & 6 deletions app/lib/frontend/screens/onboarding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import 'package:flutter_svg/flutter_svg.dart';
import 'package:gap/gap.dart';
import 'package:gpu_info/gpu_info.dart';
import 'package:introduction_screen/introduction_screen.dart';
import 'package:open_local_ui/components/rive_animation.dart';
import 'package:open_local_ui/components/typewriter_text.dart';
import 'package:open_local_ui/frontend/components/rive_animation.dart';
import 'package:open_local_ui/frontend/components/typewriter_text.dart';
import 'package:open_local_ui/core/color.dart';
import 'package:open_local_ui/core/process.dart';
import 'package:open_local_ui/frontend/dialogs/color_picker.dart';
import 'package:open_local_ui/frontend/helpers/snackbar.dart';
import 'package:open_local_ui/core/snackbar.dart';
import 'package:open_local_ui/frontend/screens/dashboard.dart';
import 'package:open_local_ui/frontend/widgets/preference_selector.dart';
import 'package:open_local_ui/frontend/widgets/window_management_bar.dart';
import 'package:open_local_ui/frontend/components/window_management_bar.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:system_info2/system_info2.dart';
import 'package:system_theme/system_theme.dart';
Expand Down Expand Up @@ -54,7 +54,7 @@ class _OnboardingScreenState extends State<OnboardingScreen> {
title: AppLocalizations.of(context).setupPageWelcomeSlideTitle,
bodyWidget: TypewriterTextComponent(
text: AppLocalizations.of(context).setupPageWelcomeSlideText,
duration: 1500.ms,
duration: 3000.ms,
),
decoration: const PageDecoration(
titleTextStyle: TextStyle(
Expand Down Expand Up @@ -265,7 +265,7 @@ class _OnboardingScreenState extends State<OnboardingScreen> {
right: 0.0,
width: MediaQuery.of(context).size.width,
height: 32.0,
child: const WindowManagementBar(),
child: const WindowManagementBarComponent(),
),
],
);
Expand Down
33 changes: 33 additions & 0 deletions app/lib/frontend/screens/splash.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import 'package:adaptive_theme/adaptive_theme.dart';
import 'package:flutter/material.dart';

import 'package:animated_splash_screen/animated_splash_screen.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:open_local_ui/frontend/screens/dashboard.dart';
import 'package:open_local_ui/frontend/screens/onboarding.dart';
import 'package:page_transition/page_transition.dart';

class SplashScreen extends StatelessWidget {
final bool userOnboarded;

const SplashScreen({Key? key, required this.userOnboarded}) : super(key: key);

@override
Widget build(BuildContext context) {
return AnimatedSplashScreen(
splash: SvgPicture.asset(
'assets/graphics/logos/open_local_ui.svg',
width: 512,
// ignore: deprecated_member_use
color:
AdaptiveTheme.of(context).mode.isDark ? Colors.white : Colors.black,
),
nextScreen:
userOnboarded ? const DashboardScreen() : const OnboardingScreen(),
backgroundColor: AdaptiveTheme.of(context).theme.primaryColor,
splashTransition: SplashTransition.fadeTransition,
pageTransitionType: PageTransitionType.theme,
duration: 1500,
);
}
}
4 changes: 2 additions & 2 deletions app/lib/frontend/screens/update_in_progress.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:gap/gap.dart';
import 'package:open_local_ui/core/update.dart';
import 'package:open_local_ui/frontend/widgets/window_management_bar.dart';
import 'package:open_local_ui/frontend/components/window_management_bar.dart';

class UpdateInProgressScreen extends StatefulWidget {
const UpdateInProgressScreen({super.key});
Expand Down Expand Up @@ -57,7 +57,7 @@ class _UpdateInProgressScreenState extends State<UpdateInProgressScreen> {
right: 0.0,
width: MediaQuery.of(context).size.width,
height: 32.0,
child: const WindowManagementBar(),
child: const WindowManagementBarComponent(),
),
],
);
Expand Down
3 changes: 1 addition & 2 deletions app/lib/frontend/widgets/chat_example_questions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ import 'dart:math';

import 'package:flutter/material.dart';


import 'package:adaptive_theme/adaptive_theme.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:gap/gap.dart';
import 'package:open_local_ui/backend/providers/chat.dart';
import 'package:open_local_ui/backend/providers/model.dart';
import 'package:open_local_ui/frontend/helpers/snackbar.dart';
import 'package:open_local_ui/core/snackbar.dart';
import 'package:provider/provider.dart';
import 'package:unicons/unicons.dart';

Expand Down
2 changes: 1 addition & 1 deletion app/lib/frontend/widgets/chat_input_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:open_local_ui/backend/providers/chat.dart';
import 'package:open_local_ui/backend/providers/model.dart';
import 'package:open_local_ui/core/image.dart';
import 'package:open_local_ui/frontend/dialogs/attachments_dropzone.dart';
import 'package:open_local_ui/frontend/helpers/snackbar.dart';
import 'package:open_local_ui/core/snackbar.dart';
import 'package:provider/provider.dart';
import 'package:unicons/unicons.dart';

Expand Down
2 changes: 1 addition & 1 deletion app/lib/frontend/widgets/chat_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import 'package:gap/gap.dart';
import 'package:open_local_ui/backend/models/chat_message.dart';
import 'package:open_local_ui/backend/providers/chat.dart';
import 'package:open_local_ui/core/format.dart';
import 'package:open_local_ui/frontend/helpers/snackbar.dart';
import 'package:open_local_ui/core/snackbar.dart';
import 'package:open_local_ui/frontend/widgets/markdown_body.dart';
import 'package:open_local_ui/frontend/widgets/tts_player.dart';
import 'package:provider/provider.dart';
Expand Down
3 changes: 1 addition & 2 deletions app/lib/frontend/widgets/chat_toolbar.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import 'package:flutter/material.dart';


import 'package:adaptive_theme/adaptive_theme.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:gap/gap.dart';
import 'package:open_local_ui/backend/providers/chat.dart';
import 'package:open_local_ui/backend/providers/model.dart';
import 'package:open_local_ui/frontend/helpers/snackbar.dart';
import 'package:open_local_ui/core/snackbar.dart';
import 'package:provider/provider.dart';
import 'package:unicons/unicons.dart';

Expand Down
3 changes: 1 addition & 2 deletions app/lib/frontend/widgets/markdown_body.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:flutter/material.dart';


import 'package:adaptive_theme/adaptive_theme.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
// ignore: depend_on_referenced_packages
Expand All @@ -9,7 +8,7 @@ import 'package:flutter_highlight/themes/atom-one-dark.dart';
import 'package:flutter_highlight/themes/atom-one-light.dart';
import 'package:markdown_widget/markdown_widget.dart';
import 'package:open_local_ui/constants/style.dart';
import 'package:open_local_ui/frontend/helpers/snackbar.dart';
import 'package:open_local_ui/core/snackbar.dart';
import 'package:open_local_ui/frontend/widgets/markdown_code_wrapper.dart';
import 'package:url_launcher/url_launcher.dart';

Expand Down
2 changes: 1 addition & 1 deletion app/lib/frontend/widgets/markdown_code_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:gap/gap.dart';
import 'package:open_local_ui/core/asset.dart';
import 'package:open_local_ui/frontend/helpers/snackbar.dart';
import 'package:open_local_ui/core/snackbar.dart';
import 'package:unicons/unicons.dart';

Map<String, String> languageToAsset = {
Expand Down
13 changes: 3 additions & 10 deletions app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import 'package:feedback/feedback.dart';
import 'package:flex_color_picker/flex_color_picker.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_native_splash/flutter_native_splash.dart';
import 'package:open_local_ui/backend/databases/chat_sessions.dart';
import 'package:open_local_ui/backend/providers/chat.dart';
import 'package:open_local_ui/backend/providers/locale.dart';
Expand All @@ -19,8 +18,7 @@ import 'package:open_local_ui/core/asset.dart';
import 'package:open_local_ui/core/color.dart';
import 'package:open_local_ui/core/logger.dart';
import 'package:open_local_ui/env.dart';
import 'package:open_local_ui/frontend/screens/dashboard.dart';
import 'package:open_local_ui/frontend/screens/onboarding.dart';
import 'package:open_local_ui/frontend/screens/splash.dart';
import 'package:provider/provider.dart';
import 'package:rive/rive.dart';
import 'package:shared_preferences/shared_preferences.dart';
Expand Down Expand Up @@ -145,8 +143,7 @@ void _preloadAssets() async {
}

void main() async {
WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized();
FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);
WidgetsFlutterBinding.ensureInitialized();

// Internal services

Expand Down Expand Up @@ -198,8 +195,6 @@ void main() async {
prefs.setBool('userOnboarded', true);
}

FlutterNativeSplash.remove();

// Run app

runApp(
Expand Down Expand Up @@ -297,9 +292,7 @@ class _MyAppState extends State<MyApp> {
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
home: widget.userOnboarded
? const DashboardScreen()
: const OnboardingScreen(),
home: SplashScreen(userOnboarded: widget.userOnboarded),
debugShowCheckedModeBanner: kDebugMode,
),
);
Expand Down
2 changes: 2 additions & 0 deletions app/macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Foundation

import app_links
import audioplayers_darwin
import battery_plus
import bitsdojo_window_macos
import device_info_plus
import irondash_engine_context
Expand All @@ -23,6 +24,7 @@ import url_launcher_macos
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AppLinksMacosPlugin.register(with: registry.registrar(forPlugin: "AppLinksMacosPlugin"))
AudioplayersDarwinPlugin.register(with: registry.registrar(forPlugin: "AudioplayersDarwinPlugin"))
BatteryPlusMacosPlugin.register(with: registry.registrar(forPlugin: "BatteryPlusMacosPlugin"))
BitsdojoWindowPlugin.register(with: registry.registrar(forPlugin: "BitsdojoWindowPlugin"))
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
IrondashEngineContextPlugin.register(with: registry.registrar(forPlugin: "IrondashEngineContextPlugin"))
Expand Down
Loading

0 comments on commit 635915c

Please sign in to comment.