Skip to content
Closed
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
Binary file added assets/rive/game_button.bk.riv
Binary file not shown.
Binary file modified assets/rive/game_button.riv
Binary file not shown.
Binary file added assets/rive/small_lake_on_a_rainy_day.bk.riv
Binary file not shown.
Binary file modified assets/rive/small_lake_on_a_rainy_day.riv
Binary file not shown.
32 changes: 32 additions & 0 deletions ios/Flutter/ephemeral/flutter_lldb_helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#
# Generated file, do not edit.
#

import lldb

def handle_new_rx_page(frame: lldb.SBFrame, bp_loc, extra_args, intern_dict):
"""Intercept NOTIFY_DEBUGGER_ABOUT_RX_PAGES and touch the pages."""
base = frame.register["x0"].GetValueAsAddress()
page_len = frame.register["x1"].GetValueAsUnsigned()

# Note: NOTIFY_DEBUGGER_ABOUT_RX_PAGES will check contents of the
# first page to see if handled it correctly. This makes diagnosing
# misconfiguration (e.g. missing breakpoint) easier.
data = bytearray(page_len)
data[0:8] = b'IHELPED!'

error = lldb.SBError()
frame.GetThread().GetProcess().WriteMemory(base, data, error)
if not error.Success():
print(f'Failed to write into {base}[+{page_len}]', error)
return

def __lldb_init_module(debugger: lldb.SBDebugger, _):
target = debugger.GetDummyTarget()
# Caveat: must use BreakpointCreateByRegEx here and not
# BreakpointCreateByName. For some reasons callback function does not
# get carried over from dummy target for the later.
bp = target.BreakpointCreateByRegex("^NOTIFY_DEBUGGER_ABOUT_RX_PAGES$")
bp.SetScriptCallbackFunction('{}.handle_new_rx_page'.format(__name__))
bp.SetAutoContinue(True)
print("-- LLDB integration loaded --")
5 changes: 5 additions & 0 deletions ios/Flutter/ephemeral/flutter_lldbinit
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#
# Generated file, do not edit.
#

command script import --relative-to-command-file flutter_lldb_helper.py
2 changes: 1 addition & 1 deletion lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:sozzle/core/routes/routes.dart';
import 'package:sozzle/l10n/l10n.dart';
import 'package:sozzle/l10n/arb/app_localizations.dart';
import 'package:sozzle/src/apploader/application/apploader_repository.dart';
import 'package:sozzle/src/apploader/cubit/apploader_cubit.dart';
import 'package:sozzle/src/audio/audio_controller.dart';
Expand Down
3 changes: 2 additions & 1 deletion lib/bootstrap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ Future<void> bootstrap(FutureOr<Widget> Function() builder) async {
Bloc.observer = const AppBlocObserver();

// Add cross-flavor configuration here
WidgetsFlutterBinding.ensureInitialized();
HydratedBloc.storage = await HydratedStorage.build(
storageDirectory: kIsWeb
? HydratedStorage.webStorageDirectory
: await getApplicationDocumentsDirectory(),
);
unawaited(RiveFile.initialize());
unawaited(RiveNative.init());
runApp(await builder());
}
61 changes: 32 additions & 29 deletions lib/core/common/widgets/game_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:rive/rive.dart';
import 'package:sozzle/core/extensions/rive_extensions.dart';
import 'package:sozzle/core/res/media.dart';

class GameButton extends StatefulWidget {
Expand All @@ -18,9 +17,9 @@ class GameButton extends StatefulWidget {
}

class _GameButtonState extends State<GameButton> {
RiveFile? _riveFile;
File? _riveFile;

StateMachineController? controller;
late RiveWidgetController controller;

bool clicked = false;

Expand All @@ -32,15 +31,34 @@ class _GameButtonState extends State<GameButton> {

@override
void dispose() {
controller?.dispose();
controller.dispose();
super.dispose();
}

void _preload() {
rootBundle.load(Media.gameButton).then((data) {
setState(() {
_riveFile = RiveFile.import(data);
});
Future<void> _preload() async {
final data = await rootBundle.load(Media.gameButton);
_riveFile = await File.decode(
data.buffer.asUint8List(),
riveFactory: Factory.rive,
);
controller = RiveWidgetController(_riveFile!);
_onInit(controller.artboard);
setState(() {});
}

void _onInit(Artboard artboard) {
artboard.setText('buttonText', widget.text);

final viewModelInstance = controller.dataBind(DataBind.auto());

final currentState = viewModelInstance.string('currentState');
currentState?.addListener((value) {
if (value == 'click') {
clicked = true;
} else if (value == 'rest' && clicked) {
clicked = false;
widget.onPressed?.call();
}
});
}

Expand All @@ -51,26 +69,11 @@ class _GameButtonState extends State<GameButton> {
child: SizedBox(
width: 200,
height: 50,
child: RiveAnimation.direct(
_riveFile!,
fit: BoxFit.cover,
stateMachines: const ['Button Animation'],
onInit: (artboard) {
artboard.textRun('buttonText')!.text = widget.text;
controller = StateMachineController.fromArtboard(
artboard,
'Button Animation',
onStateChange: (stateMachine, stateName) {
if (stateName == 'Click') {
clicked = true;
} else if (stateName == 'Rest' && clicked) {
clicked = false;
widget.onPressed?.call();
}
},
);
artboard.addController(controller!);
},
child: RiveWidget(
controller: controller,
fit: Fit.cover,
cursor: SystemMouseCursors.click,
// stateMachines: const ['Button Animation'],
),
),
);
Expand Down
6 changes: 0 additions & 6 deletions lib/core/extensions/rive_extensions.dart

This file was deleted.

163 changes: 163 additions & 0 deletions lib/l10n/arb/app_localizations.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
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 'app_localizations_en.dart';
import 'app_localizations_es.dart';

// ignore_for_file: type=lint

/// Callers can lookup localized strings with an instance of AppLocalizations
/// returned by `AppLocalizations.of(context)`.
///
/// Applications need to include `AppLocalizations.delegate()` in their app's
/// `localizationDelegates` list, and the locales they support in the app's
/// `supportedLocales` list. For example:
///
/// ```dart
/// import 'arb/app_localizations.dart';
///
/// return MaterialApp(
/// localizationsDelegates: AppLocalizations.localizationsDelegates,
/// supportedLocales: AppLocalizations.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 AppLocalizations.supportedLocales
/// property.
abstract class AppLocalizations {
AppLocalizations(String locale)
: localeName = intl.Intl.canonicalizedLocale(locale.toString());

final String localeName;

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

static const LocalizationsDelegate<AppLocalizations> delegate =
_AppLocalizationsDelegate();

/// 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'),
Locale('es')
];

/// No description provided for @startButton.
///
/// In en, this message translates to:
/// **'Tap to Start'**
String get startButton;

/// No description provided for @soundSettings.
///
/// In en, this message translates to:
/// **'Sound'**
String get soundSettings;

/// No description provided for @musicSettings.
///
/// In en, this message translates to:
/// **'Music'**
String get musicSettings;

/// No description provided for @darkModeSettings.
///
/// In en, this message translates to:
/// **'Dark Mode'**
String get darkModeSettings;

/// No description provided for @muteSettings.
///
/// In en, this message translates to:
/// **'Mute'**
String get muteSettings;
}

class _AppLocalizationsDelegate
extends LocalizationsDelegate<AppLocalizations> {
const _AppLocalizationsDelegate();

@override
Future<AppLocalizations> load(Locale locale) {
return SynchronousFuture<AppLocalizations>(lookupAppLocalizations(locale));
}

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

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

AppLocalizations lookupAppLocalizations(Locale locale) {
// Lookup logic when only language code is specified.
switch (locale.languageCode) {
case 'en':
return AppLocalizationsEn();
case 'es':
return AppLocalizationsEs();
}

throw FlutterError(
'AppLocalizations.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.');
}
25 changes: 25 additions & 0 deletions lib/l10n/arb/app_localizations_en.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ignore: unused_import
import 'package:intl/intl.dart' as intl;
import 'app_localizations.dart';

// ignore_for_file: type=lint

/// The translations for English (`en`).
class AppLocalizationsEn extends AppLocalizations {
AppLocalizationsEn([String locale = 'en']) : super(locale);

@override
String get startButton => 'Tap to Start';

@override
String get soundSettings => 'Sound';

@override
String get musicSettings => 'Music';

@override
String get darkModeSettings => 'Dark Mode';

@override
String get muteSettings => 'Mute';
}
25 changes: 25 additions & 0 deletions lib/l10n/arb/app_localizations_es.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ignore: unused_import
import 'package:intl/intl.dart' as intl;
import 'app_localizations.dart';

// ignore_for_file: type=lint

/// The translations for Spanish Castilian (`es`).
class AppLocalizationsEs extends AppLocalizations {
AppLocalizationsEs([String locale = 'es']) : super(locale);

@override
String get startButton => 'Tap to Start';

@override
String get soundSettings => 'Sonido';

@override
String get musicSettings => 'Música';

@override
String get darkModeSettings => 'Modo oscuro';

@override
String get muteSettings => 'Mudo';
}
4 changes: 1 addition & 3 deletions lib/l10n/l10n.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
// https://opensource.org/licenses/MIT.

import 'package:flutter/widgets.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

export 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:sozzle/l10n/arb/app_localizations.dart';

extension AppLocalizationsX on BuildContext {
AppLocalizations get l10n => AppLocalizations.of(this);
Expand Down
Loading
Loading