Skip to content

Commit

Permalink
Merge pull request #940 from nextcloud/feature/dashboard
Browse files Browse the repository at this point in the history
Add dashboard app
  • Loading branch information
provokateurin authored Oct 19, 2023
2 parents d76e515 + 17b5cc6 commit 279e17f
Show file tree
Hide file tree
Showing 53 changed files with 1,176 additions and 7 deletions.
1 change: 1 addition & 0 deletions .cspell/dart_flutter.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ autofocus
endtemplate
expando
gapless
goldens
lerp
pubspec
sublist
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ See [here](packages/app/README.md) for screenshots.

| App | Status |
|---------------------------------------------------|--------------------|
| [Dashboard](packages/neon/neon_dashboard) | :heavy_check_mark: |
| [Files](packages/neon/neon_files) | :heavy_check_mark: |
| [News](packages/neon/neon_news) | :heavy_check_mark: |
| [Notes](packages/neon/neon_notes) | :heavy_check_mark: |
Expand All @@ -57,7 +58,6 @@ See [here](packages/app/README.md) for screenshots.
| Calendar | :rocket: |
| Contacts | :rocket: |
| Cookbook | :rocket: |
| Dashboard | :rocket: |
| Photos | :rocket: |
| Talk | :rocket: |
| Tasks | :rocket: |
Expand Down
1 change: 1 addition & 0 deletions commitlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ rules:
- dynamite_runtime
- file_icons
- neon
- neon_dashboard
- neon_files
- neon_news
- neon_notes
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 packages/app/lib/apps.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import 'package:neon/models.dart';
import 'package:neon_dashboard/neon_dashboard.dart';
import 'package:neon_files/neon_files.dart';
import 'package:neon_news/neon_news.dart';
import 'package:neon_notes/neon_notes.dart';
import 'package:neon_notifications/neon_notifications.dart';

/// The collection of clients enabled for the Neon app.
final Set<AppImplementation> appImplementations = {
DashboardApp(),
FilesApp(),
NewsApp(),
NotesApp(),
Expand Down
7 changes: 7 additions & 0 deletions packages/app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,13 @@ packages:
relative: true
source: path
version: "1.0.0"
neon_dashboard:
dependency: "direct main"
description:
path: "../neon/neon_dashboard"
relative: true
source: path
version: "1.0.0"
neon_files:
dependency: "direct main"
description:
Expand Down
4 changes: 4 additions & 0 deletions packages/app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ dependencies:
git:
url: https://github.com/nextcloud/neon
path: packages/neon/neon
neon_dashboard:
git:
url: https://github.com/nextcloud/neon
path: packages/neon/neon_dashboard
neon_files:
git:
url: https://github.com/nextcloud/neon
Expand Down
4 changes: 3 additions & 1 deletion packages/app/pubspec_overrides.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# melos_managed_dependency_overrides: dynamite_runtime,file_icons,neon,neon_files,neon_news,neon_notes,neon_notifications,nextcloud,sort_box,neon_lints
# melos_managed_dependency_overrides: dynamite_runtime,file_icons,neon,neon_files,neon_news,neon_notes,neon_notifications,nextcloud,sort_box,neon_lints,neon_dashboard
dependency_overrides:
dynamite_runtime:
path: ../dynamite/dynamite_runtime
file_icons:
path: ../file_icons
neon:
path: ../neon/neon
neon_dashboard:
path: ../neon/neon_dashboard
neon_files:
path: ../neon/neon_files
neon_lints:
Expand Down
2 changes: 1 addition & 1 deletion packages/neon/neon/lib/l10n/en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"@@locale": "en",
"nextcloud": "Nextcloud",
"nextcloudLogo": "Nextcloud logo",
"appImplementationName": "{app, select, nextcloud{Nextcloud} core{Server} files{Files} news{News} notes{Notes} notifications{Notifications} other{}}",
"appImplementationName": "{app, select, nextcloud{Nextcloud} core{Server} dashboard{Dashboard} files{Files} news{News} notes{Notes} notifications{Notifications} other{}}",
"@appImplementationName": {
"placeholders": {
"app": {}
Expand Down
2 changes: 1 addition & 1 deletion packages/neon/neon/lib/l10n/localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ abstract class NeonLocalizations {
/// No description provided for @appImplementationName.
///
/// In en, this message translates to:
/// **'{app, select, nextcloud{Nextcloud} core{Server} files{Files} news{News} notes{Notes} notifications{Notifications} other{}}'**
/// **'{app, select, nextcloud{Nextcloud} core{Server} dashboard{Dashboard} files{Files} news{News} notes{Notes} notifications{Notifications} other{}}'**
String appImplementationName(String app);

/// No description provided for @loginAgain.
Expand Down
1 change: 1 addition & 0 deletions packages/neon/neon/lib/l10n/localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class NeonLocalizationsEn extends NeonLocalizations {
{
'nextcloud': 'Nextcloud',
'core': 'Server',
'dashboard': 'Dashboard',
'files': 'Files',
'news': 'News',
'notes': 'Notes',
Expand Down
11 changes: 8 additions & 3 deletions packages/neon/neon/lib/src/blocs/apps.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,14 @@ class AppsBloc extends InteractiveBloc implements AppsBlocEvents, AppsBlocStates
/// Returns null when no app is supported by the server.
String? _getInitialAppFallback() {
final supportedApps = appImplementations.value.requireData;
if (supportedApps.tryFind(AppIDs.files) != null) {
return AppIDs.files;
} else if (supportedApps.isNotEmpty) {

for (final fallback in {AppIDs.dashboard, AppIDs.files}) {
if (supportedApps.tryFind(fallback) != null) {
return fallback;
}
}

if (supportedApps.isNotEmpty) {
return supportedApps.first.id;
}

Expand Down
10 changes: 10 additions & 0 deletions packages/neon/neon_dashboard/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: "ead455963c12b453cdb2358cad34969c76daf180"
channel: "stable"

project_type: package
1 change: 1 addition & 0 deletions packages/neon/neon_dashboard/LICENSE
5 changes: 5 additions & 0 deletions packages/neon/neon_dashboard/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include: package:neon_lints/flutter.yaml

analyzer:
exclude:
- lib/l10n/**
Binary file added packages/neon/neon_dashboard/assets/app.svg.vec
Binary file not shown.
Empty file.
6 changes: 6 additions & 0 deletions packages/neon/neon_dashboard/l10n.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
arb-dir: lib/l10n
template-arb-file: en.arb
output-localization-file: localizations.dart
synthetic-package: false
output-dir: lib/l10n
nullable-getter: false
4 changes: 4 additions & 0 deletions packages/neon/neon_dashboard/lib/l10n/en.arb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"@@locale": "en",
"noEntries": "No entries"
}
125 changes: 125 additions & 0 deletions packages/neon/neon_dashboard/lib/l10n/localizations.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import 'dart:async';

import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:intl/intl.dart' as intl;

import 'localizations_en.dart';

/// Callers can lookup localized strings with an instance of AppLocalizations
/// returned by `AppLocalizations.of(context)`.
///
/// Applications need to include `AppLocalizations.delegate()` in their app's
/// `localizationDelegates` list, and the locales they support in the app's
/// `supportedLocales` list. For example:
///
/// ```dart
/// import 'l10n/localizations.dart';
///
/// return MaterialApp(
/// localizationsDelegates: AppLocalizations.localizationsDelegates,
/// supportedLocales: AppLocalizations.supportedLocales,
/// home: MyApplicationHome(),
/// );
/// ```
///
/// ## Update pubspec.yaml
///
/// Please make sure to update your pubspec.yaml to include the following
/// packages:
///
/// ```yaml
/// dependencies:
/// # Internationalization support.
/// flutter_localizations:
/// sdk: flutter
/// intl: any # Use the pinned version from flutter_localizations
///
/// # Rest of dependencies
/// ```
///
/// ## iOS Applications
///
/// iOS applications define key application metadata, including supported
/// locales, in an Info.plist file that is built into the application bundle.
/// To configure the locales supported by your app, you’ll need to edit this
/// file.
///
/// First, open your project’s ios/Runner.xcworkspace Xcode workspace file.
/// Then, in the Project Navigator, open the Info.plist file under the Runner
/// project’s Runner folder.
///
/// Next, select the Information Property List item, select Add Item from the
/// Editor menu, then select Localizations from the pop-up menu.
///
/// Select and expand the newly-created Localizations item then, for each
/// locale your application supports, add a new item and select the locale
/// you wish to add from the pop-up menu in the Value field. This list should
/// be consistent with the languages listed in the AppLocalizations.supportedLocales
/// property.
abstract class AppLocalizations {
AppLocalizations(String locale) : localeName = intl.Intl.canonicalizedLocale(locale.toString());

final String localeName;

static AppLocalizations of(BuildContext context) {
return Localizations.of<AppLocalizations>(context, AppLocalizations)!;
}

static const LocalizationsDelegate<AppLocalizations> delegate = _AppLocalizationsDelegate();

/// A list of this localizations delegate along with the default localizations
/// delegates.
///
/// Returns a list of localizations delegates containing this delegate along with
/// GlobalMaterialLocalizations.delegate, GlobalCupertinoLocalizations.delegate,
/// and GlobalWidgetsLocalizations.delegate.
///
/// Additional delegates can be added by appending to this list in
/// MaterialApp. This list does not have to be used at all if a custom list
/// of delegates is preferred or required.
static const List<LocalizationsDelegate<dynamic>> localizationsDelegates = <LocalizationsDelegate<dynamic>>[
delegate,
GlobalMaterialLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
];

/// A list of this localizations delegate's supported locales.
static const List<Locale> supportedLocales = <Locale>[Locale('en')];

/// No description provided for @noEntries.
///
/// In en, this message translates to:
/// **'No entries'**
String get noEntries;
}

class _AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations> {
const _AppLocalizationsDelegate();

@override
Future<AppLocalizations> load(Locale locale) {
return SynchronousFuture<AppLocalizations>(lookupAppLocalizations(locale));
}

@override
bool isSupported(Locale locale) => <String>['en'].contains(locale.languageCode);

@override
bool shouldReload(_AppLocalizationsDelegate old) => false;
}

AppLocalizations lookupAppLocalizations(Locale locale) {
// Lookup logic when only language code is specified.
switch (locale.languageCode) {
case 'en':
return AppLocalizationsEn();
}

throw FlutterError('AppLocalizations.delegate failed to load unsupported locale "$locale". This is likely '
'an issue with the localizations generation tool. Please file an issue '
'on GitHub with a reproducible sample app and the gen-l10n configuration '
'that was used.');
}
9 changes: 9 additions & 0 deletions packages/neon/neon_dashboard/lib/l10n/localizations_en.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import 'localizations.dart';

/// The translations for English (`en`).
class AppLocalizationsEn extends AppLocalizations {
AppLocalizationsEn([String locale = 'en']) : super(locale);

@override
String get noEntries => 'No entries';
}
1 change: 1 addition & 0 deletions packages/neon/neon_dashboard/lib/neon_dashboard.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'src/app.dart';
44 changes: 44 additions & 0 deletions packages/neon/neon_dashboard/lib/src/app.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:neon/models.dart';
import 'package:neon_dashboard/l10n/localizations.dart';
import 'package:neon_dashboard/src/blocs/dashboard.dart';
import 'package:neon_dashboard/src/options.dart';
import 'package:neon_dashboard/src/pages/main.dart';
import 'package:neon_dashboard/src/routes.dart';
import 'package:nextcloud/core.dart' as core;
import 'package:nextcloud/nextcloud.dart';

/// Implementation of the server `dashboard` app.
class DashboardApp extends AppImplementation<DashboardBloc, DashboardAppSpecificOptions> {
/// Creates a new Dashboard app implementation instance.
DashboardApp();

@override
final String id = AppIDs.dashboard;

@override
final LocalizationsDelegate<AppLocalizations> localizationsDelegate = AppLocalizations.delegate;

@override
final List<Locale> supportedLocales = AppLocalizations.supportedLocales;

@override
late final DashboardAppSpecificOptions options = DashboardAppSpecificOptions(storage);

@override
DashboardBloc buildBloc(final Account account) => DashboardBloc(account);

@override
final Widget page = const DashboardMainPage();

@override
final RouteBase route = $dashboardAppRoute;

@override
(bool?, String?) isSupported(
final Account account,
final core.OcsGetCapabilitiesResponseApplicationJson_Ocs_Data capabilities,
) =>
const (null, null);
}
Loading

0 comments on commit 279e17f

Please sign in to comment.