Vitaliy Zarubin
1 year ago
31 changed files with 177 additions and 593 deletions
@ -1,20 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2023 Open Mobile Platform LLC <community@omp.ru> |
||||
// SPDX-License-Identifier: BSD-3-Clause |
||||
import 'package:flutter/widgets.dart'; |
||||
import 'package:scoped_model/scoped_model.dart'; |
||||
import 'package:translator/translator.dart'; |
||||
|
||||
/// Model for [TranslatorPage] |
||||
class TranslatorModel extends Model { |
||||
/// Get [ScopedModel] |
||||
static TranslatorModel of(BuildContext context) => |
||||
ScopedModel.of<TranslatorModel>(context); |
||||
|
||||
final translator = GoogleTranslator(); |
||||
|
||||
Future<Translation> translate( |
||||
String value, |
||||
) async { |
||||
return await translator.translate(value, from: 'en', to: 'ru'); |
||||
} |
||||
} |
@ -1,24 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2023 Open Mobile Platform LLC <community@omp.ru> |
||||
// SPDX-License-Identifier: BSD-3-Clause |
||||
import 'package:flutter_example_packages/base/package/package_page.dart'; |
||||
import 'package:get_it/get_it.dart'; |
||||
|
||||
import 'model.dart'; |
||||
import 'page.dart'; |
||||
|
||||
/// Package values |
||||
final packageTranslator = PackagePage( |
||||
key: 'translator', |
||||
descEN: ''' |
||||
Free Google Translate API for Dart. |
||||
''', |
||||
descRU: ''' |
||||
Бесплатный API Google Translate для Dart. |
||||
''', |
||||
version: '0.1.7', |
||||
isPlatformDependent: false, |
||||
page: () => TranslatorPage(), |
||||
init: () { |
||||
GetIt.instance.registerFactory<TranslatorModel>(() => TranslatorModel()); |
||||
}, |
||||
); |
@ -1,57 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2023 Open Mobile Platform LLC <community@omp.ru> |
||||
// SPDX-License-Identifier: BSD-3-Clause |
||||
import 'package:flutter/material.dart'; |
||||
import 'package:flutter_example_packages/base/di/app_di.dart'; |
||||
import 'package:flutter_example_packages/base/package/package.dart'; |
||||
import 'package:flutter_example_packages/widgets/base/export.dart'; |
||||
import 'package:flutter_example_packages/widgets/blocks/block_info_package.dart'; |
||||
import 'package:flutter_example_packages/widgets/blocks/block_item.dart'; |
||||
import 'package:flutter_example_packages/widgets/layouts/block_layout.dart'; |
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; |
||||
|
||||
import 'model.dart'; |
||||
import 'package.dart'; |
||||
|
||||
class TranslatorPage extends AppStatefulWidget { |
||||
TranslatorPage({ |
||||
super.key, |
||||
}); |
||||
|
||||
final Package package = packageTranslator; |
||||
|
||||
@override |
||||
State<TranslatorPage> createState() => _TranslatorPageState(); |
||||
} |
||||
|
||||
class _TranslatorPageState extends AppState<TranslatorPage> { |
||||
@override |
||||
Widget buildWide( |
||||
BuildContext context, |
||||
MediaQueryData media, |
||||
AppLocalizations l10n, |
||||
) { |
||||
return BlockLayout<TranslatorModel>( |
||||
model: getIt<TranslatorModel>(), |
||||
title: widget.package.key, |
||||
builder: (context, child, model) { |
||||
return SingleChildScrollView( |
||||
child: Padding( |
||||
padding: const EdgeInsets.all(20), |
||||
child: Column( |
||||
crossAxisAlignment: CrossAxisAlignment.start, |
||||
children: [ |
||||
BlockInfoPackage(widget.package), |
||||
BlockItem( |
||||
title: l10n.translatorTitle, |
||||
desc: l10n.translatorSubtitle, |
||||
future: model.translate(l10n.translatorText), |
||||
builder: (value) => value.text, |
||||
), |
||||
], |
||||
), |
||||
), |
||||
); |
||||
}, |
||||
); |
||||
} |
||||
} |
@ -1,42 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2023 Open Mobile Platform LLC <community@omp.ru> |
||||
// SPDX-License-Identifier: BSD-3-Clause |
||||
import 'package:flutter/widgets.dart'; |
||||
import 'package:scoped_model/scoped_model.dart'; |
||||
import 'package:wakelock/wakelock.dart'; |
||||
|
||||
/// Model for [WakelockPage] |
||||
class WakelockModel extends Model { |
||||
/// Get [ScopedModel] |
||||
static WakelockModel of(BuildContext context) => |
||||
ScopedModel.of<WakelockModel>(context); |
||||
|
||||
/// Error |
||||
String? _error; |
||||
|
||||
/// Public error |
||||
String? get error => _error; |
||||
|
||||
/// Public is error |
||||
bool get isError => _error != null; |
||||
|
||||
/// Check is enable Wakelock |
||||
Future<bool?> isEnable() async { |
||||
try { |
||||
return await Wakelock.enabled; |
||||
} catch (e) { |
||||
_error = e.toString(); |
||||
} |
||||
notifyListeners(); |
||||
return null; |
||||
} |
||||
|
||||
/// Set state Wakelock |
||||
Future<void> setStateWakelock(bool enable) async { |
||||
try { |
||||
await Wakelock.toggle(enable: enable); |
||||
} catch (e) { |
||||
_error = e.toString(); |
||||
} |
||||
notifyListeners(); |
||||
} |
||||
} |
@ -1,26 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2023 Open Mobile Platform LLC <community@omp.ru> |
||||
// SPDX-License-Identifier: BSD-3-Clause |
||||
import 'package:flutter_example_packages/base/package/package_page.dart'; |
||||
import 'package:flutter_example_packages/packages/wakelock/page.dart'; |
||||
import 'package:get_it/get_it.dart'; |
||||
|
||||
import 'model.dart'; |
||||
|
||||
/// Package values |
||||
final packageWakelock = PackagePage( |
||||
key: 'wakelock', |
||||
descEN: ''' |
||||
Plugin that allows you to keep the device screen awake, i.e. |
||||
prevent the screen from sleeping. |
||||
''', |
||||
descRU: ''' |
||||
Плагин, который позволяет держать экран устройства в активном состоянии, |
||||
т. е. предотвращать переход экрана в спящий режим. |
||||
''', |
||||
version: '0.6.2', |
||||
isPlatformDependent: true, |
||||
page: () => WakelockPage(), |
||||
init: () { |
||||
GetIt.instance.registerFactory<WakelockModel>(() => WakelockModel()); |
||||
}, |
||||
); |
@ -1,89 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2023 Open Mobile Platform LLC <community@omp.ru> |
||||
// SPDX-License-Identifier: BSD-3-Clause |
||||
import 'package:flutter/material.dart'; |
||||
import 'package:flutter_example_packages/base/di/app_di.dart'; |
||||
import 'package:flutter_example_packages/base/package/package.dart'; |
||||
import 'package:flutter_example_packages/packages/wakelock/model.dart'; |
||||
import 'package:flutter_example_packages/packages/wakelock/package.dart'; |
||||
import 'package:flutter_example_packages/theme/colors.dart'; |
||||
import 'package:flutter_example_packages/widgets/base/export.dart'; |
||||
import 'package:flutter_example_packages/widgets/blocks/block_alert.dart'; |
||||
import 'package:flutter_example_packages/widgets/blocks/block_info_package.dart'; |
||||
import 'package:flutter_example_packages/widgets/layouts/block_layout.dart'; |
||||
import 'package:flutter_example_packages/widgets/texts/export.dart'; |
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; |
||||
|
||||
class WakelockPage extends AppStatefulWidget { |
||||
WakelockPage({ |
||||
super.key, |
||||
}); |
||||
|
||||
final Package package = packageWakelock; |
||||
|
||||
@override |
||||
State<WakelockPage> createState() => _WakelockPageState(); |
||||
} |
||||
|
||||
class _WakelockPageState extends AppState<WakelockPage> { |
||||
@override |
||||
Widget buildWide( |
||||
BuildContext context, |
||||
MediaQueryData media, |
||||
AppLocalizations l10n, |
||||
) { |
||||
return BlockLayout<WakelockModel>( |
||||
model: getIt<WakelockModel>(), |
||||
title: widget.package.key, |
||||
builder: (context, child, model) { |
||||
return SingleChildScrollView( |
||||
child: Padding( |
||||
padding: const EdgeInsets.all(20), |
||||
child: Column( |
||||
crossAxisAlignment: CrossAxisAlignment.start, |
||||
children: [ |
||||
BlockInfoPackage(widget.package), |
||||
BlockAlert(model.error), |
||||
if (!model.isError) |
||||
Row( |
||||
children: [ |
||||
Expanded( |
||||
flex: 1, |
||||
child: Column( |
||||
crossAxisAlignment: CrossAxisAlignment.start, |
||||
children: [ |
||||
TextTitleLarge(l10n.wakelockTitle), |
||||
const SizedBox(height: 8), |
||||
TextBodyMedium(l10n.wakelockDesc), |
||||
], |
||||
), |
||||
), |
||||
FutureBuilder<bool?>( |
||||
future: model.isEnable(), |
||||
builder: ( |
||||
BuildContext context, |
||||
AsyncSnapshot<bool?> snapshot, |
||||
) { |
||||
final value = snapshot.data ?? false; |
||||
return Expanded( |
||||
flex: 0, |
||||
child: Switch( |
||||
// This bool value toggles the switch. |
||||
value: value, |
||||
activeColor: AppColors.secondary, |
||||
onChanged: (bool value) { |
||||
model.setStateWakelock(value); |
||||
}, |
||||
), |
||||
); |
||||
}, |
||||
), |
||||
], |
||||
), |
||||
], |
||||
), |
||||
), |
||||
); |
||||
}, |
||||
); |
||||
} |
||||
} |
@ -1,30 +0,0 @@
|
||||
# Miscellaneous |
||||
*.class |
||||
*.log |
||||
*.pyc |
||||
*.swp |
||||
.DS_Store |
||||
.atom/ |
||||
.buildlog/ |
||||
.history |
||||
.svn/ |
||||
migrate_working_dir/ |
||||
|
||||
# IntelliJ related |
||||
*.iml |
||||
*.ipr |
||||
*.iws |
||||
.idea/ |
||||
|
||||
# The .vscode folder contains launch configuration and tasks you configure in |
||||
# VS Code which you may wish to be included in version control, so this line |
||||
# is commented out by default. |
||||
#.vscode/ |
||||
|
||||
# Flutter/Dart/Pub related |
||||
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. |
||||
/pubspec.lock |
||||
**/doc/api/ |
||||
.dart_tool/ |
||||
.packages |
||||
build/ |
@ -1,31 +0,0 @@
|
||||
# wakelock_aurora |
||||
|
||||
The Aurora implementation of [`wakelock`](https://pub.dev/packages/wakelock). |
||||
|
||||
## Usage |
||||
This package is not an _endorsed_ implementation of `wakelock`. |
||||
Therefore, you have to include `wakelock_aurora` alongside `wakelock` as dependencies in your `pubspec.yaml` file. |
||||
|
||||
**pubspec.yaml** |
||||
|
||||
```yaml |
||||
dependencies: |
||||
wakelock: ^0.6.2 |
||||
wakelock_aurora: |
||||
git: |
||||
url: https://gitlab.com/omprussia/flutter/flutter-plugins.git |
||||
ref: master |
||||
path: packages/wakelock/wakelock_aurora |
||||
``` |
||||
|
||||
***.dart** |
||||
|
||||
```dart |
||||
import 'package:wakelock/wakelock.dart'; |
||||
|
||||
// The following line will enable wakelock. |
||||
Wakelock.enable(); |
||||
|
||||
// The next line disables the wakelock again. |
||||
Wakelock.disable(); |
||||
``` |
@ -1,4 +0,0 @@
|
||||
# SPDX-FileCopyrightText: Copyright 2023 Open Mobile Platform LLC <community@omp.ru> |
||||
# SPDX-License-Identifier: BSD-3-Clause |
||||
|
||||
include: package:flutter_lints/flutter.yaml |
@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?> |
||||
<!DOCTYPE node PUBLIC |
||||
"-//freedesktop//DTD D-Bus Object Introspection 1.0//EN" |
||||
"http://standards.freedesktop.org/dbus/1.0/introspect.dtd"> |
||||
<node name="/com/nokia/mce/request"> |
||||
<interface name="com.nokia.mce.request"> |
||||
<method name="req_display_blanking_pause"> |
||||
</method> |
||||
</interface> |
||||
</node> |
@ -1,20 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2023 Open Mobile Platform LLC <community@omp.ru> |
||||
// SPDX-License-Identifier: BSD-3-Clause |
||||
import 'package:dbus/dbus.dart'; |
||||
|
||||
class ComNokiaMceRequest extends DBusRemoteObject { |
||||
ComNokiaMceRequest(DBusClient client, String destination, |
||||
{DBusObjectPath path = |
||||
const DBusObjectPath.unchecked('/com/nokia/mce/request')}) |
||||
: super(client, name: destination, path: path); |
||||
|
||||
/// Invokes com.nokia.mce.request.req_display_blanking_pause() |
||||
Future<void> callreq_display_blanking_pause( |
||||
{bool noAutoStart = false, |
||||
bool allowInteractiveAuthorization = false}) async { |
||||
await callMethod('com.nokia.mce.request', 'req_display_blanking_pause', [], |
||||
replySignature: DBusSignature(''), |
||||
noAutoStart: noAutoStart, |
||||
allowInteractiveAuthorization: allowInteractiveAuthorization); |
||||
} |
||||
} |
@ -1,40 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2023 Open Mobile Platform LLC <community@omp.ru> |
||||
// SPDX-License-Identifier: BSD-3-Clause |
||||
import 'dart:async'; |
||||
|
||||
import 'package:dbus/dbus.dart'; |
||||
import 'package:wakelock_platform_interface/wakelock_platform_interface.dart'; |
||||
import 'com_nokia_mce_request.dart'; |
||||
|
||||
class WakelockAurora extends WakelockPlatformInterface { |
||||
bool _enable = false; |
||||
Timer? _timer; |
||||
|
||||
static void registerWith() { |
||||
WakelockPlatformInterface.instance = WakelockAurora(); |
||||
} |
||||
|
||||
@override |
||||
Future<void> toggle({required bool enable}) async { |
||||
if (_enable != enable) { |
||||
_enable = enable; |
||||
final client = DBusClient.system(); |
||||
final request = ComNokiaMceRequest(client, 'com.nokia.mce'); |
||||
if (_timer == null) { |
||||
request.callreq_display_blanking_pause(); |
||||
_timer = Timer.periodic(const Duration(seconds: 60), (timer) { |
||||
request.callreq_display_blanking_pause(); |
||||
}); |
||||
} else { |
||||
_timer?.cancel(); |
||||
_timer = null; |
||||
} |
||||
await client.close(); |
||||
} |
||||
} |
||||
|
||||
@override |
||||
Future<bool> get enabled async { |
||||
return _enable; |
||||
} |
||||
} |
@ -1,28 +0,0 @@
|
||||
# SPDX-FileCopyrightText: Copyright 2023 Open Mobile Platform LLC <community@omp.ru> |
||||
# SPDX-License-Identifier: BSD-3-Clause |
||||
|
||||
name: wakelock_aurora |
||||
description: A new Flutter plugin project. |
||||
version: 0.0.1 |
||||
|
||||
environment: |
||||
sdk: '>=2.18.6 <3.0.0' |
||||
flutter: ">=3.0.0" |
||||
|
||||
dependencies: |
||||
flutter: |
||||
sdk: flutter |
||||
dbus: ^0.7.8 |
||||
plugin_platform_interface: ^2.0.2 |
||||
wakelock_platform_interface: ^0.3.0 |
||||
|
||||
dev_dependencies: |
||||
flutter_test: |
||||
sdk: flutter |
||||
flutter_lints: ^2.0.0 |
||||
|
||||
flutter: |
||||
plugin: |
||||
platforms: |
||||
aurora: |
||||
dartPluginClass: WakelockAurora |
Loading…
Reference in new issue