Skip to content

Commit

Permalink
20240328 update2
Browse files Browse the repository at this point in the history
  • Loading branch information
neko0xff committed Mar 28, 2024
1 parent f16556a commit 9b99512
Show file tree
Hide file tree
Showing 23 changed files with 393 additions and 140 deletions.
29 changes: 19 additions & 10 deletions src/demo/viewapp_master/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,29 +1,38 @@
// ignore_for_file: avoid_web_libraries_in_flutter, use_key_in_widget_constructors, camel_case_types, depend_on_referenced_packages

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:pwa_install/pwa_install.dart';
import 'package:local_notifier/local_notifier.dart';
import 'package:viewapp_master/pages/out/about.dart';
import 'package:viewapp_master/pages/user/forget.dart';
import 'package:viewapp_master/pages/user/login.dart';
import 'package:viewapp_master/pages/user/register.dart';
import 'package:viewapp_master/pages/user/updateUser.dart';


var focusedcolor = Colors.yellow;
var backcolor = Colors.black26;

void main() async {
PWAInstall().setup(installCallback: () {
debugPrint('APP INSTALLED!');
});
WidgetsFlutterBinding.ensureInitialized();

// Check for PWA install prompt support (if necessary)
if (defaultTargetPlatform == TargetPlatform.android) {
PWAInstall().setup(installCallback: () {
debugPrint('APP INSTALLED!');
});
PWAInstall().promptInstall_();
}else if(defaultTargetPlatform == TargetPlatform.iOS){
PWAInstall().setup(installCallback: () {
debugPrint('APP INSTALLED!');
});
PWAInstall().promptInstall_();
}

runApp(viewAppMain());
await Future.delayed(const Duration(seconds: 1));
/* localNotifier: Only Windows,Linux.macOS */
await localNotifier.setup(
appName: 'View App master v3',
shortcutPolicy:
ShortcutPolicy.requireCreate, // shortcutPolicy: 仅适用于 Windows
);

}

class viewAppMain extends StatelessWidget {
Expand Down
5 changes: 3 additions & 2 deletions src/demo/viewapp_master/lib/pages/btn/view/Cfoot_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ class btn1 extends StatelessWidget {
Navigator.push(
context, MaterialPageRoute(builder: (context) => CfootTraffic_DB()));
},
child: Text('交通', textAlign: TextAlign.center));
//交通
child: Text('產品流通', textAlign: TextAlign.center));
}
}

Expand All @@ -115,7 +116,7 @@ class btn2 extends StatelessWidget {
Navigator.push(
context, MaterialPageRoute(builder: (context) => CfootOther_DB()));
},
child: Text('其它', textAlign: TextAlign.center));
child: Text('其它計算', textAlign: TextAlign.center));
}
}

Expand Down
6 changes: 0 additions & 6 deletions src/demo/viewapp_master/lib/pages/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// ignore_for_file: must_be_immutable, duplicate_ignore, non_constant_identifier_names, prefer_const_constructors, prefer_const_literals_to_create_immutables

import 'package:flutter/material.dart';
import 'package:local_notifier/local_notifier.dart';
import 'package:viewapp_master/class/user.dart';
import 'package:viewapp_master/modules/PreferencesUtil.dart';
import 'package:viewapp_master/pages/out/control.dart';
Expand Down Expand Up @@ -98,18 +97,13 @@ class DrawerMenu extends StatelessWidget {

class BtnLogOut extends StatelessWidget {
BtnLogOut({super.key});
LocalNotification notification = LocalNotification(
title: "提示",
body: "現在使用者己登出",
);

@override
Widget build(BuildContext context) {
return ListTile(
leading: const CircleAvatar(child: Icon(Icons.arrow_back)),
title: const Text('登出'),
onTap: () {
notification.show(); //for Windows,Linux.macOS
toLoginPage(context);
},
);
Expand Down
34 changes: 14 additions & 20 deletions src/demo/viewapp_master/lib/pages/user/login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:local_notifier/local_notifier.dart';
import 'package:viewapp_master/class/user.dart';
import 'package:viewapp_master/modules/PreferencesUtil.dart';
import 'package:viewapp_master/pages/home.dart';
Expand All @@ -23,7 +22,7 @@ class LoginPage extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Scaffold(
return const Scaffold(
backgroundColor: Colors.white,
body: InputGet(),
);
Expand All @@ -39,11 +38,11 @@ class InputGet extends StatelessWidget {
child: Column(
children: <Widget>[
wallpaperLogin(),
SizedBox(height: 20.0),
LoginStr(),
SizedBox(height: 20.0),
btnView(),
SizedBox(height: 20.0),
const SizedBox(height: 20.0),
const LoginStr(),
const SizedBox(height: 20.0),
const btnView(),
const SizedBox(height: 20.0),
],
),
);
Expand All @@ -54,10 +53,10 @@ class LoginStr extends StatelessWidget {
const LoginStr({Key? key});
@override
Widget build(BuildContext context) {
return Column(
return const Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: const <Widget>[
children: <Widget>[
tbServerSource(),
SizedBox(height: 10),
tbUsername(),
Expand All @@ -77,8 +76,8 @@ class tbServerSource extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 5.0),
child: TextFormField(
controller: serverSourceStr,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.info),
decoration: const InputDecoration(
prefixIcon: Icon(Icons.info),
labelText: "Server",
hintText: "Your Server Address",
enabledBorder:
Expand All @@ -99,8 +98,8 @@ class tbUsername extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 5.0),
child: TextFormField(
controller: usernameStr,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.person),
decoration: const InputDecoration(
prefixIcon: Icon(Icons.person),
labelText: "Username",
hintText: "Your account username",
enabledBorder:
Expand All @@ -122,8 +121,8 @@ class tbPassword extends StatelessWidget {
child: TextFormField(
controller: passwordStr,
obscureText: true,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.lock),
decoration: const InputDecoration(
prefixIcon: Icon(Icons.lock),
labelText: "Password",
hintText: "Your account password",
enabledBorder:
Expand Down Expand Up @@ -222,18 +221,13 @@ class btnLoginSend extends StatelessWidget {
serverSource: serverSourceStr.text,
LoginName: data["LoginName"],
username: data["username"]);
LocalNotification notification = LocalNotification(
title: "Tip",
body: "Now Login User: ${data["LoginName"]} ",
);

/*主迴圈*/
if (code == "1") {
/*save Str in local*/
PreferencesUtil.saveString('serverSource', serverSourceStr.text);
PreferencesUtil.saveString('username', data["username"]);
PreferencesUtil.saveString('LoginName', data["LoginName"]);
notification.show(); //for Windows,Linux.macOS
//Go To HomePage
Navigator.push(
context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@

#include "generated_plugin_registrant.h"

#include <local_notifier/local_notifier_plugin.h>
#include <printing/printing_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h>

void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) local_notifier_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "LocalNotifierPlugin");
local_notifier_plugin_register_with_registrar(local_notifier_registrar);
g_autoptr(FlPluginRegistrar) printing_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "PrintingPlugin");
printing_plugin_register_with_registrar(printing_registrar);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#

list(APPEND FLUTTER_PLUGIN_LIST
local_notifier
printing
url_launcher_linux
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import FlutterMacOS
import Foundation

import device_info_plus
import local_notifier
import path_provider_foundation
import printing
import share_plus
Expand All @@ -16,7 +15,6 @@ import url_launcher_macos

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
LocalNotifierPlugin.register(with: registry.registrar(forPlugin: "LocalNotifierPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
PrintingPlugin.register(with: registry.registrar(forPlugin: "PrintingPlugin"))
SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin"))
Expand Down
Loading

0 comments on commit 9b99512

Please sign in to comment.