Skip to content

Instantly share code, notes, and snippets.

@plateaukao
plateaukao / main.dart
Created August 16, 2020 03:28
dart example with AppLocalizations
import 'package:flutter/material.dart';
import 'package:l10n_demo/l10n/app_localizations.dart'; // Add this line.
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
{
"@@locale": "zh",
"hello_world": "你好,世界"
}
@plateaukao
plateaukao / app_en.arb
Last active August 16, 2020 03:25
arb file for en
{
"@@locale": "en",
"hello_world": "Hello World!",
"@hello_world": {
"description": "The conventional newborn programmer greeting"
}
}
@plateaukao
plateaukao / l10n.yml
Created August 16, 2020 03:14
sample of l10n yml
arb-dir: lib/l10n
template-arb-file: app_en.arb
output-localization-file: app_localizations.dart
@plateaukao
plateaukao / intl_pubspec.yml
Created August 16, 2020 03:12
sample of intl for flutter
dependencies:
flutter:
sdk: flutter
# Internationalization support.
flutter_localizations:
sdk: flutter
intl: 0.16.1
# the rest of your dependencies
@plateaukao
plateaukao / demo_of_longpress_pop_feature.dart
Created July 25, 2020 08:58
A dart code snippet to support longpress display popup dialog feature, when finger leaves, the popup will be closed too.
// Implement a function to create OverlayEntry
OverlayEntry getMyOverlayEntry({
@required BuildContext context,
SomeData someData,
}) {
return OverlayEntry(
builder: (context) {
return AlertDialog(child: SomeWidgetAgain());
}
);
// 建立 loadbalancer object,指定想要產生的 isolate 數目
Future<LoadBalancer> loadBalancer = LoadBalancer.create(8, IsolateRunner.spawn);
typedef Uint8List ImageProcessFunction(Uint8List bytes);
// 將 loadBalancer 相關操作包成 function。 這一步並非是必要的,可以直接使用 line 9 和 line 11。
Future<Uint8List> loadBalancerRun(ImageProcessFunction function, Uint8List bytes) async {
// 在使用 loadBalancer 時,要先 await 一下,取得資源
final lb = await loadBalancer;
// 呼叫 lb.run,執行原本 compute 在進行的工作
sequenceDiagram
Activity->>+NinjiaWebView: 1.loadUrl(normalUrl)
NinjiaWebView->>WebKitEngine: 2. trigger loading
WebKitEngine-->>NinjiaWebView: 3. onPageFinished()
NinjiaWebView->>NinjiaWebView: 4. injectCSS()
NinjiaWebView->>-NinjiaWebView: 5. loadUrl(javascript)
webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
injectCSS();
injectJS();
super.onPageFinished(view, url);
}
});
* {
color: #000000!important;
font-weight:900 !important;
border-color: #555555 !important;
scrollbar-arrow-color: #CCCCCC !important;
scrollbar-base-color: #2266AA !important;
scrollbar-shadow-color: #2266AA !important;
scrollbar-face-color: #333333 !important;
scrollbar-highlight-color: #2266AA !important;
scrollbar-dark-shadow-color: #2266AA !important;