Add some helpers and wrappers, bump libac-dart dep
This commit is contained in:
parent
edca96f33f
commit
61a9ecd382
6 changed files with 63 additions and 9 deletions
|
@ -1,11 +1,11 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class Alert extends StatelessWidget {
|
class Alert extends StatelessWidget {
|
||||||
String title;
|
final String title;
|
||||||
String body;
|
final String body;
|
||||||
Function()? dismissAction;
|
final Function()? dismissAction;
|
||||||
|
|
||||||
Alert(
|
const Alert(
|
||||||
{required this.title, required this.body, super.key, this.dismissAction});
|
{required this.title, required this.body, super.key, this.dismissAction});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -2,5 +2,19 @@ import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class LibACFlutterConstants {
|
class LibACFlutterConstants {
|
||||||
static const Color TITLEBAR_COLOR = Color.fromARGB(255, 99, 0, 0);
|
static const Color TITLEBAR_COLOR = Color.fromARGB(255, 99, 0, 0);
|
||||||
static const VERSION = "1.0.031525+0222";
|
static const VERSION = "1.0.052525+0051";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A simple helper for obtaining the theme, and allowing toggle of the dark mode state
|
||||||
|
class LibACFlutterTheme {
|
||||||
|
/// Default is true
|
||||||
|
static bool isDarkMode = true;
|
||||||
|
|
||||||
|
static ThemeData GetTheme() {
|
||||||
|
if (isDarkMode) {
|
||||||
|
return ThemeData.dark();
|
||||||
|
} else {
|
||||||
|
return ThemeData.light();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,8 @@ class HighlightTextfield extends StatelessWidget {
|
||||||
Color selected;
|
Color selected;
|
||||||
Color inactive;
|
Color inactive;
|
||||||
HighlightTextfield(
|
HighlightTextfield(
|
||||||
{super.key, required this.controller,
|
{super.key,
|
||||||
|
required this.controller,
|
||||||
required this.inputStyle,
|
required this.inputStyle,
|
||||||
required this.selected,
|
required this.selected,
|
||||||
required this.inactive});
|
required this.inactive});
|
||||||
|
|
36
lib/nbt/nbtHelpers.dart
Normal file
36
lib/nbt/nbtHelpers.dart
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
import 'package:libac_dart/nbt/SnbtIo.dart';
|
||||||
|
import 'package:libac_dart/nbt/impl/CompoundTag.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
class NBTHelper {
|
||||||
|
/// Commits NBT Data to Shared Preferences, performing all the secret magic that makes it happen
|
||||||
|
///
|
||||||
|
/// [data] - The data to be encoded and saved
|
||||||
|
/// [name] - The name to give the entry.
|
||||||
|
static Future<void> CommitNBT(
|
||||||
|
{required CompoundTag data, required String name}) async {
|
||||||
|
String encoded = SnbtIo.writeToString(data);
|
||||||
|
|
||||||
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
|
await prefs.setString(name, encoded);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// This function retrieves the NBT Data and turns it back into a CompoundTag
|
||||||
|
///
|
||||||
|
/// [name] - The name of the entry to retrieve
|
||||||
|
static Future<CompoundTag> GetNBT({required String name}) async {
|
||||||
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
|
String data = prefs.getString(name) ?? "";
|
||||||
|
if (data.isEmpty) {
|
||||||
|
return CompoundTag();
|
||||||
|
} else {
|
||||||
|
return await SnbtIo.readFromString(data) as CompoundTag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Resets and clears the persistent storage.
|
||||||
|
static Future<void> ResetPersistentNBTStore() async {
|
||||||
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
|
await prefs.clear();
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,6 +5,8 @@
|
||||||
import FlutterMacOS
|
import FlutterMacOS
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
import shared_preferences_foundation
|
||||||
|
|
||||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||||
|
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: libacflutter
|
name: libacflutter
|
||||||
description: "A new Flutter package project."
|
description: "LibAC flutter helper utilities."
|
||||||
version: 1.0.031525+0222
|
version: 1.0.052525+0051
|
||||||
homepage: https://zontreck.com
|
homepage: https://zontreck.com
|
||||||
publish_to: https://git.zontreck.com/api/packages/Packages/pub
|
publish_to: https://git.zontreck.com/api/packages/Packages/pub
|
||||||
|
|
||||||
|
@ -13,7 +13,8 @@ dependencies:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
libac_dart:
|
libac_dart:
|
||||||
hosted: https://git.zontreck.com/api/packages/Packages/pub/
|
hosted: https://git.zontreck.com/api/packages/Packages/pub/
|
||||||
version: 1.4.020325+1215
|
version: 1.4.052525+0002
|
||||||
|
shared_preferences: ^2.5.3
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue