Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(neon_talk): Add placeholder implementation #1656

Merged
merged 1 commit into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions commitlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ rules:
- neon_news
- neon_notes
- neon_notifications
- neon_talk
- nextcloud
- nextcloud_test
- release
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.
3 changes: 3 additions & 0 deletions packages/app/lib/apps.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import 'package:built_collection/built_collection.dart';
import 'package:flutter/foundation.dart';
import 'package:neon_dashboard/neon_dashboard.dart';
import 'package:neon_files/neon_files.dart';
import 'package:neon_framework/models.dart';
import 'package:neon_news/neon_news.dart';
import 'package:neon_notes/neon_notes.dart';
import 'package:neon_notifications/neon_notifications.dart';
import 'package:neon_talk/neon_talk.dart';

/// The collection of clients enabled for the Neon app.
final BuiltSet<AppImplementation> appImplementations = BuiltSet({
Expand All @@ -13,4 +15,5 @@ final BuiltSet<AppImplementation> appImplementations = BuiltSet({
NewsApp(),
NotesApp(),
NotificationsApp(),
if (kDebugMode) TalkApp(),
});
7 changes: 7 additions & 0 deletions packages/app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,13 @@ packages:
relative: true
source: path
version: "1.0.0"
neon_talk:
dependency: "direct main"
description:
path: "../neon/neon_talk"
relative: true
source: path
version: "1.0.0"
nested:
dependency: transitive
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 @@ -34,6 +34,10 @@ dependencies:
git:
url: https://github.com/nextcloud/neon
path: packages/neon/neon_notifications
neon_talk:
git:
url: https://github.com/nextcloud/neon
path: packages/neon/neon_talk
vector_graphics: any

dev_dependencies:
Expand Down
4 changes: 3 additions & 1 deletion packages/app/pubspec_overrides.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# melos_managed_dependency_overrides: dynamite_runtime,file_icons,neon_dashboard,neon_files,neon_framework,neon_lints,neon_news,neon_notes,neon_notifications,nextcloud,sort_box,package_info_plus
# melos_managed_dependency_overrides: dynamite_runtime,file_icons,neon_dashboard,neon_files,neon_framework,neon_lints,neon_news,neon_notes,neon_notifications,nextcloud,sort_box,package_info_plus,neon_talk
dependency_overrides:
dynamite_runtime:
path: ../dynamite/dynamite_runtime
Expand Down Expand Up @@ -27,3 +27,5 @@ dependency_overrides:
url: https://github.com/fluttercommunity/plus_plugins
ref: baa336fe79c29411542fc343d332846bcd7752c1
path: packages/package_info_plus/package_info_plus
neon_talk:
path: ../neon/neon_talk
10 changes: 10 additions & 0 deletions packages/neon/neon_talk/.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_talk/LICENSE
5 changes: 5 additions & 0 deletions packages/neon/neon_talk/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_talk/assets/app.svg.vec
Binary file not shown.
Empty file.
7 changes: 7 additions & 0 deletions packages/neon/neon_talk/l10n.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
arb-dir: lib/l10n
template-arb-file: en.arb
output-localization-file: localizations.dart
synthetic-package: false
output-class: TalkLocalizations
output-dir: lib/l10n
nullable-getter: false
3 changes: 3 additions & 0 deletions packages/neon/neon_talk/lib/l10n/en.arb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"@@locale": "en"
}
119 changes: 119 additions & 0 deletions packages/neon/neon_talk/lib/l10n/localizations.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
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 TalkLocalizations
/// returned by `TalkLocalizations.of(context)`.
///
/// Applications need to include `TalkLocalizations.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: TalkLocalizations.localizationsDelegates,
/// supportedLocales: TalkLocalizations.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 TalkLocalizations.supportedLocales
/// property.
abstract class TalkLocalizations {
TalkLocalizations(String locale) : localeName = intl.Intl.canonicalizedLocale(locale.toString());

final String localeName;

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

static const LocalizationsDelegate<TalkLocalizations> delegate = _TalkLocalizationsDelegate();

/// 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')];
}

class _TalkLocalizationsDelegate extends LocalizationsDelegate<TalkLocalizations> {
const _TalkLocalizationsDelegate();

@override
Future<TalkLocalizations> load(Locale locale) {
return SynchronousFuture<TalkLocalizations>(lookupTalkLocalizations(locale));
}

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

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

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

throw FlutterError('TalkLocalizations.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.');
}
6 changes: 6 additions & 0 deletions packages/neon/neon_talk/lib/l10n/localizations_en.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import 'localizations.dart';

/// The translations for English (`en`).
class TalkLocalizationsEn extends TalkLocalizations {
TalkLocalizationsEn([String locale = 'en']) : super(locale);
}
6 changes: 6 additions & 0 deletions packages/neon/neon_talk/lib/neon_talk.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/// The Neon client for the Talk app.
///
/// Add `TalkApp()` to your runNeon command to execute this app.
library neon_talk;

export 'src/app.dart';
42 changes: 42 additions & 0 deletions packages/neon/neon_talk/lib/src/app.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import 'package:built_collection/built_collection.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:meta/meta.dart';
import 'package:neon_framework/models.dart';
import 'package:neon_talk/l10n/localizations.dart';
import 'package:neon_talk/src/blocs/talk.dart';
import 'package:neon_talk/src/options.dart';
import 'package:neon_talk/src/pages/main.dart';
import 'package:neon_talk/src/routes.dart';
import 'package:nextcloud/nextcloud.dart';

/// Implementation of the server `talk` app.
@experimental
class TalkApp extends AppImplementation<TalkBloc, TalkOptions> {
/// Creates a new Talk app implementation instance.
TalkApp();

@override
final String id = 'talk';

@override
final BuiltSet<String> additionalMatchingIDs = BuiltSet([AppIDs.spreed]);

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

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

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

@override
TalkBloc buildBloc(Account account) => TalkBloc(account);

@override
final Widget page = const TalkMainPage();

@override
final RouteBase route = $talkAppRoute;
}
19 changes: 19 additions & 0 deletions packages/neon/neon_talk/lib/src/blocs/talk.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'package:meta/meta.dart';
import 'package:neon_framework/blocs.dart';
import 'package:neon_framework/models.dart';

/// Bloc for fetching Talk rooms
sealed class TalkBloc implements InteractiveBloc {
/// Creates a new Talk Bloc instance.
@internal
Leptopoda marked this conversation as resolved.
Show resolved Hide resolved
factory TalkBloc(Account account) => _TalkBloc(account);
}

class _TalkBloc extends InteractiveBloc implements TalkBloc {
_TalkBloc(this.account);

final Account account;

@override
Future<void> refresh() async {}
}
10 changes: 10 additions & 0 deletions packages/neon/neon_talk/lib/src/options.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import 'package:neon_framework/settings.dart';

/// Settings options specific to the talk app.
class TalkOptions extends AppImplementationOptions {
/// Creates a new talk options instance.
TalkOptions(super.storage) {
super.categories = [];
super.options = [];
}
}
10 changes: 10 additions & 0 deletions packages/neon/neon_talk/lib/src/pages/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import 'package:flutter/material.dart';

/// The main page displaying the chat list.
class TalkMainPage extends StatelessWidget {
/// Creates a new Talk main page.
const TalkMainPage({super.key});

@override
Widget build(BuildContext context) => const Placeholder();
}
20 changes: 20 additions & 0 deletions packages/neon/neon_talk/lib/src/routes.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import 'package:flutter/widgets.dart';
import 'package:go_router/go_router.dart';
import 'package:neon_framework/utils.dart';
import 'package:neon_talk/src/pages/main.dart';

part 'routes.g.dart';

/// Route for the talk app.
@TypedGoRoute<TalkAppRoute>(
path: '${appsBaseRoutePrefix}talk',
name: 'talk',
)
@immutable
class TalkAppRoute extends NeonBaseAppRoute {
/// Creates a new talk app route.
const TalkAppRoute();

@override
Widget build(BuildContext context, GoRouterState state) => const TalkMainPage();
}
33 changes: 33 additions & 0 deletions packages/neon/neon_talk/lib/src/routes.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading