diff --git a/novelforge-project/docs/project_enhancement_completion_report.pdf b/novelforge-project/docs/project_enhancement_completion_report.pdf index 39e3ebad6f63d439d8f54478f16d29dc0d723c52..a6e6fbcf00882f25cdf661dabedf2bc943fd1f61 100644 --- a/novelforge-project/docs/project_enhancement_completion_report.pdf +++ b/novelforge-project/docs/project_enhancement_completion_report.pdf @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d3fd8415d7c16da731f6e162f118ffcee140b50d4ab5405250aa2e8127b758a3 -size 794208 +oid sha256:6101489c4f2564d988289bbf5c6bbcb69a460a07a788f9d8cebf2ab3645a73e8 +size 131 diff --git a/novelforge-project/flutter/examples/api/android/build.gradle b/novelforge-project/flutter/examples/api/android/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..bf76eafdcdc4cf9a67ed3e9484bfce14f001206b --- /dev/null +++ b/novelforge-project/flutter/examples/api/android/build.gradle @@ -0,0 +1,33 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +buildscript { + ext.kotlin_version = '1.6.10' + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:7.2.0' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" + project.evaluationDependsOn(':app') +} + +tasks.register("clean", Delete) { + delete rootProject.buildDir +} diff --git a/novelforge-project/flutter/examples/api/android/gradle.properties b/novelforge-project/flutter/examples/api/android/gradle.properties new file mode 100644 index 0000000000000000000000000000000000000000..598d13fee446372f156ecc38527b54c7cdcc8e3b --- /dev/null +++ b/novelforge-project/flutter/examples/api/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx4G +android.useAndroidX=true +android.enableJetifier=true diff --git a/novelforge-project/flutter/examples/api/android/settings.gradle b/novelforge-project/flutter/examples/api/android/settings.gradle new file mode 100644 index 0000000000000000000000000000000000000000..d3b6a4013d714b88229c524e79414b8881c70bc1 --- /dev/null +++ b/novelforge-project/flutter/examples/api/android/settings.gradle @@ -0,0 +1,15 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +include ':app' + +def localPropertiesFile = new File(rootProject.projectDir, "local.properties") +def properties = new Properties() + +assert localPropertiesFile.exists() +localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + +def flutterSdkPath = properties.getProperty("flutter.sdk") +assert flutterSdkPath != null, "flutter.sdk not set in local.properties" +apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/novelforge-project/flutter/examples/api/ios/Podfile b/novelforge-project/flutter/examples/api/ios/Podfile new file mode 100644 index 0000000000000000000000000000000000000000..279576f3884fde725622e597aa2d9bfadbab168e --- /dev/null +++ b/novelforge-project/flutter/examples/api/ios/Podfile @@ -0,0 +1,41 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '12.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/novelforge-project/flutter/examples/api/lib/material/about/about_list_tile.0.dart b/novelforge-project/flutter/examples/api/lib/material/about/about_list_tile.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..ca431cb3a01b8b3e05befd948b2b46f93cff54ac --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/about/about_list_tile.0.dart @@ -0,0 +1,81 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [AboutListTile]. + +void main() => runApp(const AboutListTileExampleApp()); + +class AboutListTileExampleApp extends StatelessWidget { + const AboutListTileExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: AboutListTileExample(), + ); + } +} + +class AboutListTileExample extends StatelessWidget { + const AboutListTileExample({super.key}); + + @override + Widget build(BuildContext context) { + final ThemeData theme = Theme.of(context); + final TextStyle textStyle = theme.textTheme.bodyMedium!; + final List aboutBoxChildren = [ + const SizedBox(height: 24), + RichText( + text: TextSpan( + children: [ + TextSpan( + style: textStyle, + text: "Flutter is Google's UI toolkit for building beautiful, " + 'natively compiled applications for mobile, web, and desktop ' + 'from a single codebase. Learn more about Flutter at '), + TextSpan(style: textStyle.copyWith(color: theme.colorScheme.primary), text: 'https://flutter.dev'), + TextSpan(style: textStyle, text: '.'), + ], + ), + ), + ]; + + return Scaffold( + appBar: AppBar( + title: const Text('Show About Example'), + ), + drawer: Drawer( + child: SingleChildScrollView( + child: SafeArea( + child: AboutListTile( + icon: const Icon(Icons.info), + applicationIcon: const FlutterLogo(), + applicationName: 'Show About Example', + applicationVersion: 'August 2019', + applicationLegalese: '\u{a9} 2014 The Flutter Authors', + aboutBoxChildren: aboutBoxChildren, + ), + ), + ), + ), + body: Center( + child: ElevatedButton( + child: const Text('Show About Example'), + onPressed: () { + showAboutDialog( + context: context, + applicationIcon: const FlutterLogo(), + applicationName: 'Show About Example', + applicationVersion: 'August 2019', + applicationLegalese: '\u{a9} 2014 The Flutter Authors', + children: aboutBoxChildren, + ); + }, + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/action_buttons/action_icon_theme.0.dart b/novelforge-project/flutter/examples/api/lib/material/action_buttons/action_icon_theme.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..20671520545c7a7ac6028098e474d12929378358 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/action_buttons/action_icon_theme.0.dart @@ -0,0 +1,121 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [ActionIconTheme]. + +void main() { + runApp(const ActionIconThemeExampleApp()); +} + +class _CustomEndDrawerIcon extends StatelessWidget { + const _CustomEndDrawerIcon(); + + @override + Widget build(BuildContext context) { + final MaterialLocalizations localization = MaterialLocalizations.of(context); + return Icon( + Icons.more_horiz, + semanticLabel: localization.openAppDrawerTooltip, + ); + } +} + +class _CustomDrawerIcon extends StatelessWidget { + const _CustomDrawerIcon(); + + @override + Widget build(BuildContext context) { + final MaterialLocalizations localization = MaterialLocalizations.of(context); + return Icon( + Icons.segment, + semanticLabel: localization.openAppDrawerTooltip, + ); + } +} + +class ActionIconThemeExampleApp extends StatelessWidget { + const ActionIconThemeExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + debugShowCheckedModeBanner: false, + theme: ThemeData( + useMaterial3: true, + actionIconTheme: ActionIconThemeData( + backButtonIconBuilder: (BuildContext context) { + return const Icon(Icons.arrow_back_ios_new_rounded); + }, + drawerButtonIconBuilder: (BuildContext context) { + return const _CustomDrawerIcon(); + }, + endDrawerButtonIconBuilder: (BuildContext context) { + return const _CustomEndDrawerIcon(); + }, + ), + ), + home: const MyHomePage(title: 'Flutter Demo Home Page'), + ); + } +} + +class MyHomePage extends StatelessWidget { + const MyHomePage({super.key, required this.title}); + + final String title; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text(title), + ), + drawer: Drawer( + child: Column( + children: [ + TextButton(child: const Text('Drawer Item'), onPressed: () {}), + ], + ), + ), + body: const Center( + child: NextPageButton(), + ), + ); + } +} + +class NextPageButton extends StatelessWidget { + const NextPageButton({super.key}); + + @override + Widget build(BuildContext context) { + return ElevatedButton.icon( + onPressed: () { + Navigator.of(context).push( + MaterialPageRoute(builder: (BuildContext context) { + return const MySecondPage(); + }), + ); + }, + icon: const Icon(Icons.arrow_forward), + label: const Text('Next page'), + ); + } +} + +class MySecondPage extends StatelessWidget { + const MySecondPage({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Second page'), + ), + endDrawer: const Drawer(), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/action_chip/action_chip.0.dart b/novelforge-project/flutter/examples/api/lib/material/action_chip/action_chip.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..27eadcb8492229f9d538a3143fcb4128c9713c96 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/action_chip/action_chip.0.dart @@ -0,0 +1,52 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flutter code sample [ActionChip]. + +import 'package:flutter/material.dart'; + +void main() => runApp(const ChipApp()); + +class ChipApp extends StatelessWidget { + const ChipApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData(colorSchemeSeed: const Color(0xff6750a4), useMaterial3: true), + home: const ActionChipExample(), + ); + } +} + +class ActionChipExample extends StatefulWidget { + const ActionChipExample({super.key}); + + @override + State createState() => _ActionChipExampleState(); +} + +class _ActionChipExampleState extends State { + bool favorite = false; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('ActionChip Sample'), + ), + body: Center( + child: ActionChip( + avatar: Icon(favorite ? Icons.favorite : Icons.favorite_border), + label: const Text('Save to favorites'), + onPressed: () { + setState(() { + favorite = !favorite; + }); + }, + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/animated_icon/animated_icon.0.dart b/novelforge-project/flutter/examples/api/lib/material/animated_icon/animated_icon.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..c63df8b9c93ca47743334d62b45319766540af19 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/animated_icon/animated_icon.0.dart @@ -0,0 +1,72 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [AnimatedIcon]. + +void main() { + runApp(const AnimatedIconApp()); +} + +class AnimatedIconApp extends StatelessWidget { + const AnimatedIconApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData( + colorSchemeSeed: const Color(0xff6750a4), + useMaterial3: true, + ), + home: const Scaffold( + body: AnimatedIconExample(), + ), + ); + } +} + +class AnimatedIconExample extends StatefulWidget { + const AnimatedIconExample({super.key}); + + @override + State createState() => _AnimatedIconExampleState(); +} + +class _AnimatedIconExampleState extends State with SingleTickerProviderStateMixin { + late AnimationController controller; + late Animation animation; + + @override + void initState() { + super.initState(); + controller = AnimationController( + vsync: this, + duration: const Duration(seconds: 2), + ) + ..forward() + ..repeat(reverse: true); + animation = Tween(begin: 0.0, end: 1.0).animate(controller); + } + + @override + void dispose() { + controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: AnimatedIcon( + icon: AnimatedIcons.menu_arrow, + progress: animation, + size: 72.0, + semanticLabel: 'Show menu', + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/animated_icon/animated_icons_data.0.dart b/novelforge-project/flutter/examples/api/lib/material/animated_icon/animated_icons_data.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..cc1ae2c6eb532345f280cb4bd8c424caec94665d --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/animated_icon/animated_icons_data.0.dart @@ -0,0 +1,105 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [AnimatedIcon]. + +final Map iconsList = { + 'add_event': AnimatedIcons.add_event, + 'arrow_menu': AnimatedIcons.arrow_menu, + 'close_menu': AnimatedIcons.close_menu, + 'ellipsis_search': AnimatedIcons.ellipsis_search, + 'event_add': AnimatedIcons.event_add, + 'home_menu': AnimatedIcons.home_menu, + 'list_view': AnimatedIcons.list_view, + 'menu_arrow': AnimatedIcons.menu_arrow, + 'menu_close': AnimatedIcons.menu_close, + 'menu_home': AnimatedIcons.menu_home, + 'pause_play': AnimatedIcons.pause_play, + 'play_pause': AnimatedIcons.play_pause, + 'search_ellipsis': AnimatedIcons.search_ellipsis, + 'view_list': AnimatedIcons.view_list, +}; + +void main() { + runApp(const AnimatedIconApp()); +} + +class AnimatedIconApp extends StatelessWidget { + const AnimatedIconApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData( + colorSchemeSeed: const Color(0xff6750a4), + useMaterial3: true, + ), + home: const Scaffold( + body: AnimatedIconExample(), + ), + ); + } +} + +class AnimatedIconExample extends StatefulWidget { + const AnimatedIconExample({super.key}); + + @override + State createState() => _AnimatedIconExampleState(); +} + +class _AnimatedIconExampleState extends State with SingleTickerProviderStateMixin { + late AnimationController controller; + late Animation animation; + + @override + void initState() { + super.initState(); + controller = AnimationController( + vsync: this, + duration: const Duration(seconds: 2), + ) + ..forward() + ..repeat(reverse: true); + animation = Tween(begin: 0.0, end: 1.0).animate(controller); + } + + @override + void dispose() { + controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: GridView( + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 4, + ), + children: iconsList.entries.map((MapEntry entry) { + return Card( + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + AnimatedIcon( + icon: entry.value, + progress: animation, + size: 72.0, + semanticLabel: entry.key, + ), + const SizedBox(height: 8.0), + Text(entry.key), + ], + ), + ), + ); + }).toList(), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/app/app.0.dart b/novelforge-project/flutter/examples/api/lib/material/app/app.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..5df0bdee35e546f203af21707902c1bef0d0e429 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/app/app.0.dart @@ -0,0 +1,87 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [MaterialApp]. + +void main() { + runApp(const MaterialAppExample()); +} + +enum AnimationStyles { defaultStyle, custom, none } +const List<(AnimationStyles, String)> animationStyleSegments = <(AnimationStyles, String)>[ + (AnimationStyles.defaultStyle, 'Default'), + (AnimationStyles.custom, 'Custom'), + (AnimationStyles.none, 'None'), +]; + +class MaterialAppExample extends StatefulWidget { + const MaterialAppExample({super.key}); + + @override + State createState() => _MaterialAppExampleState(); +} + +class _MaterialAppExampleState extends State { + Set _animationStyleSelection = {AnimationStyles.defaultStyle}; + AnimationStyle? _animationStyle; + bool isDarkTheme = false; + + @override + Widget build(BuildContext context) { + return MaterialApp( + themeAnimationStyle: _animationStyle, + themeMode: isDarkTheme ? ThemeMode.dark : ThemeMode.light, + theme: ThemeData(colorSchemeSeed: Colors.green), + darkTheme: ThemeData( + colorSchemeSeed: Colors.green, + brightness: Brightness.dark, + ), + home: Scaffold( + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SegmentedButton( + selected: _animationStyleSelection, + onSelectionChanged: (Set styles) { + setState(() { + _animationStyleSelection = styles; + switch (styles.first) { + case AnimationStyles.defaultStyle: + _animationStyle = null; + case AnimationStyles.custom: + _animationStyle = AnimationStyle( + curve: Easing.emphasizedAccelerate, + duration: const Duration(seconds: 1), + ); + case AnimationStyles.none: + _animationStyle = AnimationStyle.noAnimation; + } + }); + }, + segments: animationStyleSegments + .map>(((AnimationStyles, String) shirt) { + return ButtonSegment(value: shirt.$1, label: Text(shirt.$2)); + }) + .toList(), + ), + const SizedBox(height: 10), + OutlinedButton.icon( + onPressed: () { + setState(() { + isDarkTheme = !isDarkTheme; + }); + }, + icon: Icon(isDarkTheme ? Icons.wb_sunny : Icons.nightlight_round), + label: const Text('Switch Theme Mode'), + ), + ], + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/app_bar/app_bar.0.dart b/novelforge-project/flutter/examples/api/lib/material/app_bar/app_bar.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..e64d3b859b3a25999691196a72a602b97e62889c --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/app_bar/app_bar.0.dart @@ -0,0 +1,69 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [AppBar]. + +void main() => runApp(const AppBarApp()); + +class AppBarApp extends StatelessWidget { + const AppBarApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: AppBarExample(), + ); + } +} + +class AppBarExample extends StatelessWidget { + const AppBarExample({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('AppBar Demo'), + actions: [ + IconButton( + icon: const Icon(Icons.add_alert), + tooltip: 'Show Snackbar', + onPressed: () { + ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('This is a snackbar'))); + }, + ), + IconButton( + icon: const Icon(Icons.navigate_next), + tooltip: 'Go to the next page', + onPressed: () { + Navigator.push(context, MaterialPageRoute( + builder: (BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Next page'), + ), + body: const Center( + child: Text( + 'This is the next page', + style: TextStyle(fontSize: 24), + ), + ), + ); + }, + )); + }, + ), + ], + ), + body: const Center( + child: Text( + 'This is the home page', + style: TextStyle(fontSize: 24), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/app_bar/app_bar.1.dart b/novelforge-project/flutter/examples/api/lib/material/app_bar/app_bar.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..387ad18b7d66de3ef7b65f08e84c1fd4c7feeced --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/app_bar/app_bar.1.dart @@ -0,0 +1,124 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [AppBar]. + +final List _items = List.generate(51, (int index) => index); + +void main() => runApp(const AppBarApp()); + +class AppBarApp extends StatelessWidget { + const AppBarApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData( + colorSchemeSeed: const Color(0xff6750a4), + useMaterial3: true, + ), + home: const AppBarExample(), + ); + } +} + +class AppBarExample extends StatefulWidget { + const AppBarExample({super.key}); + + @override + State createState() => _AppBarExampleState(); +} + +class _AppBarExampleState extends State { + bool shadowColor = false; + double? scrolledUnderElevation; + + @override + Widget build(BuildContext context) { + final ColorScheme colorScheme = Theme.of(context).colorScheme; + final Color oddItemColor = colorScheme.primary.withOpacity(0.05); + final Color evenItemColor = colorScheme.primary.withOpacity(0.15); + + return Scaffold( + appBar: AppBar( + title: const Text('AppBar Demo'), + scrolledUnderElevation: scrolledUnderElevation, + shadowColor: shadowColor ? Theme.of(context).colorScheme.shadow : null, + ), + body: GridView.builder( + itemCount: _items.length, + padding: const EdgeInsets.all(8.0), + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 3, + childAspectRatio: 2.0, + mainAxisSpacing: 10.0, + crossAxisSpacing: 10.0, + ), + itemBuilder: (BuildContext context, int index) { + if (index == 0) { + return Center( + child: Text( + 'Scroll to see the Appbar in effect.', + style: Theme.of(context).textTheme.labelLarge, + textAlign: TextAlign.center, + ), + ); + } + return Container( + alignment: Alignment.center, + // tileColor: _items[index].isOdd ? oddItemColor : evenItemColor, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20.0), + color: _items[index].isOdd ? oddItemColor : evenItemColor, + ), + child: Text('Item $index'), + ); + }, + ), + bottomNavigationBar: BottomAppBar( + child: Padding( + padding: const EdgeInsets.all(8), + child: OverflowBar( + overflowAlignment: OverflowBarAlignment.center, + alignment: MainAxisAlignment.center, + overflowSpacing: 5.0, + children: [ + ElevatedButton.icon( + onPressed: () { + setState(() { + shadowColor = !shadowColor; + }); + }, + icon: Icon( + shadowColor ? Icons.visibility_off : Icons.visibility, + ), + label: const Text('shadow color'), + ), + const SizedBox(width: 5), + ElevatedButton( + onPressed: () { + if (scrolledUnderElevation == null) { + setState(() { + // Default elevation is 3.0, increment by 1.0. + scrolledUnderElevation = 4.0; + }); + } else { + setState(() { + scrolledUnderElevation = scrolledUnderElevation! + 1.0; + }); + } + }, + child: Text( + 'scrolledUnderElevation: ${scrolledUnderElevation ?? 'default'}', + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/app_bar/app_bar.2.dart b/novelforge-project/flutter/examples/api/lib/material/app_bar/app_bar.2.dart new file mode 100644 index 0000000000000000000000000000000000000000..1e0823ce6bc64fefd50218c6809a7d5086f235e4 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/app_bar/app_bar.2.dart @@ -0,0 +1,47 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [AppBar]. + +void main() => runApp(const AppBarApp()); + +class AppBarApp extends StatelessWidget { + const AppBarApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: AppBarExample(), + ); + } +} + +class AppBarExample extends StatelessWidget { + const AppBarExample({super.key}); + + @override + Widget build(BuildContext context) { + final ButtonStyle style = TextButton.styleFrom( + foregroundColor: Theme.of(context).colorScheme.onPrimary, + ); + return Scaffold( + appBar: AppBar( + actions: [ + TextButton( + style: style, + onPressed: () {}, + child: const Text('Action 1'), + ), + TextButton( + style: style, + onPressed: () {}, + child: const Text('Action 2'), + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/app_bar/app_bar.3.dart b/novelforge-project/flutter/examples/api/lib/material/app_bar/app_bar.3.dart new file mode 100644 index 0000000000000000000000000000000000000000..4f7e8f5290863039e5e0a64a1c4417cc7544ca76 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/app_bar/app_bar.3.dart @@ -0,0 +1,112 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [AppBar]. + +List titles = [ + 'Cloud', + 'Beach', + 'Sunny', +]; + +void main() => runApp(const AppBarApp()); + +class AppBarApp extends StatelessWidget { + const AppBarApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData(colorSchemeSeed: const Color(0xff6750a4), useMaterial3: true), + home: const AppBarExample(), + ); + } +} + +class AppBarExample extends StatelessWidget { + const AppBarExample({super.key}); + + @override + Widget build(BuildContext context) { + final ColorScheme colorScheme = Theme.of(context).colorScheme; + final Color oddItemColor = colorScheme.primary.withOpacity(0.05); + final Color evenItemColor = colorScheme.primary.withOpacity(0.15); + const int tabsCount = 3; + + return DefaultTabController( + initialIndex: 1, + length: tabsCount, + child: Scaffold( + appBar: AppBar( + title: const Text('AppBar Sample'), + // This check specifies which nested Scrollable's scroll notification + // should be listened to. + // + // When `ThemeData.useMaterial3` is true and scroll view has + // scrolled underneath the app bar, this updates the app bar + // background color and elevation. + // + // This sets `notification.depth == 1` to listen to the scroll + // notification from the nested `ListView.builder`. + notificationPredicate: (ScrollNotification notification) { + return notification.depth == 1; + }, + // The elevation value of the app bar when scroll view has + // scrolled underneath the app bar. + scrolledUnderElevation: 4.0, + shadowColor: Theme.of(context).shadowColor, + bottom: TabBar( + tabs: [ + Tab( + icon: const Icon(Icons.cloud_outlined), + text: titles[0], + ), + Tab( + icon: const Icon(Icons.beach_access_sharp), + text: titles[1], + ), + Tab( + icon: const Icon(Icons.brightness_5_sharp), + text: titles[2], + ), + ], + ), + ), + body: TabBarView( + children: [ + ListView.builder( + itemCount: 25, + itemBuilder: (BuildContext context, int index) { + return ListTile( + tileColor: index.isOdd ? oddItemColor : evenItemColor, + title: Text('${titles[0]} $index'), + ); + }, + ), + ListView.builder( + itemCount: 25, + itemBuilder: (BuildContext context, int index) { + return ListTile( + tileColor: index.isOdd ? oddItemColor : evenItemColor, + title: Text('${titles[1]} $index'), + ); + }, + ), + ListView.builder( + itemCount: 25, + itemBuilder: (BuildContext context, int index) { + return ListTile( + tileColor: index.isOdd ? oddItemColor : evenItemColor, + title: Text('${titles[2]} $index'), + ); + }, + ), + ], + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/app_bar/app_bar.4.dart b/novelforge-project/flutter/examples/api/lib/material/app_bar/app_bar.4.dart new file mode 100644 index 0000000000000000000000000000000000000000..a82f661c11d756807bb1b64718ca4599705c81f1 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/app_bar/app_bar.4.dart @@ -0,0 +1,149 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [AppBar.shape]. + +void main() => runApp(const AppBarExampleApp()); + +class AppBarExampleApp extends StatelessWidget { + const AppBarExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: AppBarExample(), + ); + } +} + +class AppBarExample extends StatelessWidget { + const AppBarExample({super.key}); + + @override + Widget build(BuildContext context) { + final ColorScheme colorScheme = Theme.of(context).colorScheme; + + return Scaffold( + appBar: AppBar( + shape: const CustomAppBarShape(), + backgroundColor: colorScheme.primaryContainer, + title: const Text('AppBar Sample'), + bottom: PreferredSize( + preferredSize: const Size.fromHeight(64.0), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + child: TextField( + decoration: InputDecoration( + border: OutlineInputBorder( + borderSide: BorderSide(color: colorScheme.primary), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: colorScheme.onPrimaryContainer), + ), + filled: true, + hintText: 'Enter a search term', + fillColor: colorScheme.surface, + prefixIcon: Icon( + Icons.search_rounded, + color: colorScheme.primary + ), + suffixIcon: Icon( + Icons.tune_rounded, + color: colorScheme.primary + ), + ) + ), + ), + ), + ), + body: ListView.builder( + padding: const EdgeInsets.only(top: 45.0), + itemCount: 20, + itemBuilder: (BuildContext context, int index) { + return ListTile( + title: Text('Item $index'), + ); + }, + ), + ); + } +} + +class CustomAppBarShape extends OutlinedBorder { + // Implementing the constructor allows the CustomAppBarShape to be + // properly compared when calling the `identical` method. + const CustomAppBarShape({ super.side }); + + Path _getPath(Rect rect) { + final Path path = Path(); + final Size size = Size(rect.width, rect.height * 1.5) ; + + final double p0 = size.height * 0.75; + path.lineTo(0.0, p0); + + final Offset controlPoint = Offset(size.width * 0.4, size.height); + final Offset endPoint = Offset(size.width, size.height / 2); + path.quadraticBezierTo(controlPoint.dx, controlPoint.dy, endPoint.dx, endPoint.dy); + + path.lineTo(size.width, 0.0); + path.close(); + + return path; + } + + @override + Path getOuterPath(Rect rect, {TextDirection? textDirection}) { + return _getPath(rect.inflate(side.width)); + } + + @override + Path getInnerPath(Rect rect, {TextDirection? textDirection}) { + return _getPath(rect); + } + + @override + void paint(Canvas canvas, Rect rect, {TextDirection? textDirection}) { + if (rect.isEmpty) { + return; + } + canvas.drawPath( + getOuterPath(rect, textDirection: textDirection), + side.toPaint(), + ); + } + + @override + ShapeBorder scale(double t) { + return CustomAppBarShape(side: side.scale(t)); + } + + @override + OutlinedBorder copyWith({BorderSide? side}) { + return CustomAppBarShape(side: side ?? this.side); + } + + // The lerpFrom method is necessary for the CustomAppBarShape to be + // properly animated when changing the AppBar shape and when + // the AppBar is rebuilt. + @override + ShapeBorder? lerpFrom(ShapeBorder? a, double t) { + if (a is CustomAppBarShape) { + return CustomAppBarShape(side: BorderSide.lerp(a.side, side, t)); + } + return super.lerpFrom(a, t); + } + + // The lerpTo method is necessary for the CustomAppBarShape to be + // properly animated when changing the AppBar shape and when + // the AppBar is rebuilt. + @override + ShapeBorder? lerpTo(ShapeBorder? b, double t) { + if (b is CustomAppBarShape) { + return CustomAppBarShape(side: BorderSide.lerp(b.side, side, t)); + } + return super.lerpTo(b, t); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/app_bar/sliver_app_bar.1.dart b/novelforge-project/flutter/examples/api/lib/material/app_bar/sliver_app_bar.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..46b41d81808164ee900afe69391e2c2a8d0440c9 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/app_bar/sliver_app_bar.1.dart @@ -0,0 +1,132 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [SliverAppBar]. + +void main() => runApp(const AppBarApp()); + +class AppBarApp extends StatelessWidget { + const AppBarApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: SliverAppBarExample(), + ); + } +} + +class SliverAppBarExample extends StatefulWidget { + const SliverAppBarExample({super.key}); + + @override + State createState() => _SliverAppBarExampleState(); +} + +class _SliverAppBarExampleState extends State { + bool _pinned = true; + bool _snap = false; + bool _floating = false; + +// [SliverAppBar]s are typically used in [CustomScrollView.slivers], which in +// turn can be placed in a [Scaffold.body]. + @override + Widget build(BuildContext context) { + return Scaffold( + body: CustomScrollView( + slivers: [ + SliverAppBar( + pinned: _pinned, + snap: _snap, + floating: _floating, + expandedHeight: 160.0, + flexibleSpace: const FlexibleSpaceBar( + title: Text('SliverAppBar'), + background: FlutterLogo(), + ), + ), + const SliverToBoxAdapter( + child: SizedBox( + height: 20, + child: Center( + child: Text('Scroll to see the SliverAppBar in effect.'), + ), + ), + ), + SliverList( + delegate: SliverChildBuilderDelegate( + (BuildContext context, int index) { + return Container( + color: index.isOdd ? Colors.white : Colors.black12, + height: 100.0, + child: Center( + child: Text('$index', textScaler: const TextScaler.linear(5)), + ), + ); + }, + childCount: 20, + ), + ), + ], + ), + bottomNavigationBar: BottomAppBar( + child: Padding( + padding: const EdgeInsets.all(8), + child: OverflowBar( + overflowAlignment: OverflowBarAlignment.center, + children: [ + Row( + mainAxisSize: MainAxisSize.min, + children: [ + const Text('pinned'), + Switch( + onChanged: (bool val) { + setState(() { + _pinned = val; + }); + }, + value: _pinned, + ), + ], + ), + Row( + mainAxisSize: MainAxisSize.min, + children: [ + const Text('snap'), + Switch( + onChanged: (bool val) { + setState(() { + _snap = val; + // Snapping only applies when the app bar is floating. + _floating = _floating || _snap; + }); + }, + value: _snap, + ), + ], + ), + Row( + mainAxisSize: MainAxisSize.min, + children: [ + const Text('floating'), + Switch( + onChanged: (bool val) { + setState(() { + _floating = val; + _snap = _snap && _floating; + }); + }, + value: _floating, + ), + ], + ), + ], + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/app_bar/sliver_app_bar.2.dart b/novelforge-project/flutter/examples/api/lib/material/app_bar/sliver_app_bar.2.dart new file mode 100644 index 0000000000000000000000000000000000000000..2185659dbfbc6aaf776b3389afe7fffa632f402a --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/app_bar/sliver_app_bar.2.dart @@ -0,0 +1,53 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [SliverAppBar.medium]. + +void main() { + runApp(const AppBarMediumApp()); +} + +class AppBarMediumApp extends StatelessWidget { + const AppBarMediumApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData( + useMaterial3: true, + colorSchemeSeed: const Color(0xff6750A4), + ), + home: Material( + child: CustomScrollView( + slivers: [ + SliverAppBar.medium( + leading: IconButton(icon: const Icon(Icons.menu), onPressed: () {}), + title: const Text('Medium App Bar'), + actions: [ + IconButton(icon: const Icon(Icons.more_vert), onPressed: () {}), + ], + ), + // Just some content big enough to have something to scroll. + SliverToBoxAdapter( + child: Card( + child: SizedBox( + height: 1200, + child: Padding( + padding: const EdgeInsets.fromLTRB(8, 100, 8, 100), + child: Text( + 'Here be scrolling content...', + style: Theme.of(context).textTheme.headlineSmall, + ), + ), + ), + ), + ), + ], + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/app_bar/sliver_app_bar.3.dart b/novelforge-project/flutter/examples/api/lib/material/app_bar/sliver_app_bar.3.dart new file mode 100644 index 0000000000000000000000000000000000000000..30e260202159c5c500e53884d0456a19213b8037 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/app_bar/sliver_app_bar.3.dart @@ -0,0 +1,53 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [SliverAppBar.large]. + +void main() { + runApp(const AppBarLargeApp()); +} + +class AppBarLargeApp extends StatelessWidget { + const AppBarLargeApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData( + useMaterial3: true, + colorSchemeSeed: const Color(0xff6750A4), + ), + home: Material( + child: CustomScrollView( + slivers: [ + SliverAppBar.large( + leading: IconButton(icon: const Icon(Icons.menu), onPressed: () {}), + title: const Text('Large App Bar'), + actions: [ + IconButton(icon: const Icon(Icons.more_vert), onPressed: () {}), + ], + ), + // Just some content big enough to have something to scroll. + SliverToBoxAdapter( + child: Card( + child: SizedBox( + height: 1200, + child: Padding( + padding: const EdgeInsets.fromLTRB(8, 100, 8, 100), + child: Text( + 'Here be scrolling content...', + style: Theme.of(context).textTheme.headlineSmall, + ), + ), + ), + ), + ), + ], + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/app_bar/sliver_app_bar.4.dart b/novelforge-project/flutter/examples/api/lib/material/app_bar/sliver_app_bar.4.dart new file mode 100644 index 0000000000000000000000000000000000000000..77d2773988bb5ccd0b2705c088688213fe60fbc3 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/app_bar/sliver_app_bar.4.dart @@ -0,0 +1,90 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [SliverAppBar]. + +void main() { + runApp(const StretchableSliverAppBar()); +} + +class StretchableSliverAppBar extends StatefulWidget { + const StretchableSliverAppBar({super.key}); + + @override + State createState() => + _StretchableSliverAppBarState(); +} + +class _StretchableSliverAppBarState extends State { + bool _stretch = true; + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: CustomScrollView( + physics: const BouncingScrollPhysics(), + slivers: [ + SliverAppBar( + stretch: _stretch, + onStretchTrigger: () async { + // Triggers when stretching + }, + // [stretchTriggerOffset] describes the amount of overscroll that must occur + // to trigger [onStretchTrigger] + // + // Setting [stretchTriggerOffset] to a value of 300.0 will trigger + // [onStretchTrigger] when the user has overscrolled by 300.0 pixels. + stretchTriggerOffset: 300.0, + expandedHeight: 200.0, + flexibleSpace: const FlexibleSpaceBar( + title: Text('SliverAppBar'), + background: FlutterLogo(), + ), + ), + SliverList( + delegate: SliverChildBuilderDelegate( + (BuildContext context, int index) { + return Container( + color: index.isOdd ? Colors.white : Colors.black12, + height: 100.0, + child: Center( + child: Text('$index', textScaler: const TextScaler.linear(5.0)), + ), + ); + }, + childCount: 20, + ), + ), + ], + ), + bottomNavigationBar: BottomAppBar( + child: Padding( + padding: const EdgeInsets.all(8), + child: OverflowBar( + overflowAlignment: OverflowBarAlignment.center, + alignment: MainAxisAlignment.center, + children: [ + Row( + mainAxisSize: MainAxisSize.min, + children: [ + const Text('stretch'), + Switch( + onChanged: (bool val) { + setState(() { + _stretch = val; + }); + }, + value: _stretch, + ), + ], + ), + ], + ), + ), + ), + )); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/autocomplete/autocomplete.0.dart b/novelforge-project/flutter/examples/api/lib/material/autocomplete/autocomplete.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..6c3236aaabb96b39b33091a0da2552d4893dd6df --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/autocomplete/autocomplete.0.dart @@ -0,0 +1,60 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Autocomplete]. + +void main() => runApp(const AutocompleteExampleApp()); + +class AutocompleteExampleApp extends StatelessWidget { + const AutocompleteExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Autocomplete Basic'), + ), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text('Type below to autocomplete the following possible results: ${AutocompleteBasicExample._kOptions}.'), + const AutocompleteBasicExample(), + ], + ), + ), + ), + ); + } +} + +class AutocompleteBasicExample extends StatelessWidget { + const AutocompleteBasicExample({super.key}); + + static const List _kOptions = [ + 'aardvark', + 'bobcat', + 'chameleon', + ]; + + @override + Widget build(BuildContext context) { + return Autocomplete( + optionsBuilder: (TextEditingValue textEditingValue) { + if (textEditingValue.text == '') { + return const Iterable.empty(); + } + return _kOptions.where((String option) { + return option.contains(textEditingValue.text.toLowerCase()); + }); + }, + onSelected: (String selection) { + debugPrint('You just selected $selection'); + }, + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/autocomplete/autocomplete.1.dart b/novelforge-project/flutter/examples/api/lib/material/autocomplete/autocomplete.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..abee231da462f4eb1f051936dea8db9a35d9a98d --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/autocomplete/autocomplete.1.dart @@ -0,0 +1,90 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Autocomplete]. + +void main() => runApp(const AutocompleteExampleApp()); + +class AutocompleteExampleApp extends StatelessWidget { + const AutocompleteExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Autocomplete Basic User'), + ), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text('Type below to autocomplete the following possible results: ${AutocompleteBasicUserExample._userOptions}.'), + const AutocompleteBasicUserExample(), + ], + ), + ), + ), + ); + } +} + +@immutable +class User { + const User({ + required this.email, + required this.name, + }); + + final String email; + final String name; + + @override + String toString() { + return '$name, $email'; + } + + @override + bool operator ==(Object other) { + if (other.runtimeType != runtimeType) { + return false; + } + return other is User && other.name == name && other.email == email; + } + + @override + int get hashCode => Object.hash(email, name); +} + +class AutocompleteBasicUserExample extends StatelessWidget { + const AutocompleteBasicUserExample({super.key}); + + static const List _userOptions = [ + User(name: 'Alice', email: 'alice@example.com'), + User(name: 'Bob', email: 'bob@example.com'), + User(name: 'Charlie', email: 'charlie123@gmail.com'), + ]; + + static String _displayStringForOption(User option) => option.name; + + @override + Widget build(BuildContext context) { + return Autocomplete( + displayStringForOption: _displayStringForOption, + optionsBuilder: (TextEditingValue textEditingValue) { + if (textEditingValue.text == '') { + return const Iterable.empty(); + } + return _userOptions.where((User option) { + return option.toString().contains(textEditingValue.text.toLowerCase()); + }); + }, + onSelected: (User selection) { + debugPrint('You just selected ${_displayStringForOption(selection)}'); + }, + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/autocomplete/autocomplete.2.dart b/novelforge-project/flutter/examples/api/lib/material/autocomplete/autocomplete.2.dart new file mode 100644 index 0000000000000000000000000000000000000000..85082969e865f3b0a6871c087cee50b2968a8c78 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/autocomplete/autocomplete.2.dart @@ -0,0 +1,95 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Autocomplete] that shows how to fetch the options +/// from a remote API. + +const Duration fakeAPIDuration = Duration(seconds: 1); + +void main() => runApp(const AutocompleteExampleApp()); + +class AutocompleteExampleApp extends StatelessWidget { + const AutocompleteExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Autocomplete - async'), + ), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text('Type below to autocomplete the following possible results: ${_FakeAPI._kOptions}.'), + const _AsyncAutocomplete(), + ], + ), + ), + ), + ); + } +} + +class _AsyncAutocomplete extends StatefulWidget { + const _AsyncAutocomplete(); + + @override + State<_AsyncAutocomplete > createState() => _AsyncAutocompleteState(); +} + +class _AsyncAutocompleteState extends State<_AsyncAutocomplete > { + // The query currently being searched for. If null, there is no pending + // request. + String? _searchingWithQuery; + + // The most recent options received from the API. + late Iterable _lastOptions = []; + + @override + Widget build(BuildContext context) { + return Autocomplete( + optionsBuilder: (TextEditingValue textEditingValue) async { + _searchingWithQuery = textEditingValue.text; + final Iterable options = await _FakeAPI.search(_searchingWithQuery!); + + // If another search happened after this one, throw away these options. + // Use the previous options intead and wait for the newer request to + // finish. + if (_searchingWithQuery != textEditingValue.text) { + return _lastOptions; + } + + _lastOptions = options; + return options; + }, + onSelected: (String selection) { + debugPrint('You just selected $selection'); + }, + ); + } +} + +// Mimics a remote API. +class _FakeAPI { + static const List _kOptions = [ + 'aardvark', + 'bobcat', + 'chameleon', + ]; + + // Searches the options, but injects a fake "network" delay. + static Future> search(String query) async { + await Future.delayed(fakeAPIDuration); // Fake 1 second delay. + if (query == '') { + return const Iterable.empty(); + } + return _kOptions.where((String option) { + return option.contains(query.toLowerCase()); + }); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/autocomplete/autocomplete.3.dart b/novelforge-project/flutter/examples/api/lib/material/autocomplete/autocomplete.3.dart new file mode 100644 index 0000000000000000000000000000000000000000..60ccea126d5e10aa49eda1bc1c61451c276f2f61 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/autocomplete/autocomplete.3.dart @@ -0,0 +1,172 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Autocomplete] that demonstrates fetching the +/// options asynchronously and debouncing the network calls. + +const Duration fakeAPIDuration = Duration(seconds: 1); +const Duration debounceDuration = Duration(milliseconds: 500); + +void main() => runApp(const AutocompleteExampleApp()); + +class AutocompleteExampleApp extends StatelessWidget { + const AutocompleteExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Autocomplete - async and debouncing'), + ), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text('Type below to autocomplete the following possible results: ${_FakeAPI._kOptions}.'), + const _AsyncAutocomplete(), + ], + ), + ), + ), + ); + } +} + +class _AsyncAutocomplete extends StatefulWidget { + const _AsyncAutocomplete(); + + @override + State<_AsyncAutocomplete > createState() => _AsyncAutocompleteState(); +} + +class _AsyncAutocompleteState extends State<_AsyncAutocomplete > { + // The query currently being searched for. If null, there is no pending + // request. + String? _currentQuery; + + // The most recent options received from the API. + late Iterable _lastOptions = []; + + late final _Debounceable?, String> _debouncedSearch; + + // Calls the "remote" API to search with the given query. Returns null when + // the call has been made obsolete. + Future?> _search(String query) async { + _currentQuery = query; + + // In a real application, there should be some error handling here. + final Iterable options = await _FakeAPI.search(_currentQuery!); + + // If another search happened after this one, throw away these options. + if (_currentQuery != query) { + return null; + } + _currentQuery = null; + + return options; + } + + @override + void initState() { + super.initState(); + _debouncedSearch = _debounce?, String>(_search); + } + + @override + Widget build(BuildContext context) { + return Autocomplete( + optionsBuilder: (TextEditingValue textEditingValue) async { + final Iterable? options = await _debouncedSearch(textEditingValue.text); + if (options == null) { + return _lastOptions; + } + _lastOptions = options; + return options; + }, + onSelected: (String selection) { + debugPrint('You just selected $selection'); + }, + ); + } +} + +// Mimics a remote API. +class _FakeAPI { + static const List _kOptions = [ + 'aardvark', + 'bobcat', + 'chameleon', + ]; + + // Searches the options, but injects a fake "network" delay. + static Future> search(String query) async { + await Future.delayed(fakeAPIDuration); // Fake 1 second delay. + if (query == '') { + return const Iterable.empty(); + } + return _kOptions.where((String option) { + return option.contains(query.toLowerCase()); + }); + } +} + +typedef _Debounceable = Future Function(T parameter); + +/// Returns a new function that is a debounced version of the given function. +/// +/// This means that the original function will be called only after no calls +/// have been made for the given Duration. +_Debounceable _debounce(_Debounceable function) { + _DebounceTimer? debounceTimer; + + return (T parameter) async { + if (debounceTimer != null && !debounceTimer!.isCompleted) { + debounceTimer!.cancel(); + } + debounceTimer = _DebounceTimer(); + try { + await debounceTimer!.future; + } catch (error) { + if (error is _CancelException) { + return null; + } + rethrow; + } + return function(parameter); + }; +} + +// A wrapper around Timer used for debouncing. +class _DebounceTimer { + _DebounceTimer( + ) { + _timer = Timer(debounceDuration, _onComplete); + } + + late final Timer _timer; + final Completer _completer = Completer(); + + void _onComplete() { + _completer.complete(); + } + + Future get future => _completer.future; + + bool get isCompleted => _completer.isCompleted; + + void cancel() { + _timer.cancel(); + _completer.completeError(const _CancelException()); + } +} + +// An exception indicating that the timer was canceled. +class _CancelException implements Exception { + const _CancelException(); +} diff --git a/novelforge-project/flutter/examples/api/lib/material/autocomplete/autocomplete.4.dart b/novelforge-project/flutter/examples/api/lib/material/autocomplete/autocomplete.4.dart new file mode 100644 index 0000000000000000000000000000000000000000..a44107b6d2b9a1a84ca1df2ce2b41ee1c969ee4a --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/autocomplete/autocomplete.4.dart @@ -0,0 +1,234 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Autocomplete] that demonstrates fetching the +/// options asynchronously and debouncing the network calls, including handling +/// network errors. + +void main() => runApp(const AutocompleteExampleApp()); + +const Duration fakeAPIDuration = Duration(seconds: 1); +const Duration debounceDuration = Duration(milliseconds: 500); + +class AutocompleteExampleApp extends StatelessWidget { + const AutocompleteExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Autocomplete - async, debouncing, and network errors'), + ), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text('Type below to autocomplete the following possible results: ${_FakeAPI._kOptions}.'), + const SizedBox(height: 32.0), + const _AsyncAutocomplete(), + ], + ), + ), + ), + ); + } +} + +class _AsyncAutocomplete extends StatefulWidget { + const _AsyncAutocomplete(); + + @override + State<_AsyncAutocomplete > createState() => _AsyncAutocompleteState(); +} + +class _AsyncAutocompleteState extends State<_AsyncAutocomplete > { + // The query currently being searched for. If null, there is no pending + // request. + String? _currentQuery; + + // The most recent options received from the API. + late Iterable _lastOptions = []; + + late final _Debounceable?, String> _debouncedSearch; + + // Whether to consider the fake network to be offline. + bool _networkEnabled = true; + + // A network error was received on the most recent query. + bool _networkError = false; + + // Calls the "remote" API to search with the given query. Returns null when + // the call has been made obsolete. + Future?> _search(String query) async { + _currentQuery = query; + + late final Iterable options; + try { + options = await _FakeAPI.search(_currentQuery!, _networkEnabled); + } catch (error) { + if (error is _NetworkException) { + setState(() { + _networkError = true; + }); + return []; + } + rethrow; + } + + // If another search happened after this one, throw away these options. + if (_currentQuery != query) { + return null; + } + _currentQuery = null; + + return options; + } + + @override + void initState() { + super.initState(); + _debouncedSearch = _debounce?, String>(_search); + } + + @override + Widget build(BuildContext context) { + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + _networkEnabled + ? 'Network is on, toggle to induce network errors.' + : 'Network is off, toggle to allow requests to go through.', + ), + Switch( + value: _networkEnabled, + onChanged: (bool? value) { + setState(() { + _networkEnabled = !_networkEnabled; + }); + }, + ), + const SizedBox( + height: 32.0, + ), + Autocomplete( + fieldViewBuilder: (BuildContext context, TextEditingController controller, FocusNode focusNode, VoidCallback onFieldSubmitted) { + return TextFormField( + decoration: InputDecoration( + errorText: _networkError ? 'Network error, please try again.' : null, + ), + controller: controller, + focusNode: focusNode, + onFieldSubmitted: (String value) { + onFieldSubmitted(); + }, + ); + }, + optionsBuilder: (TextEditingValue textEditingValue) async { + setState(() { + _networkError = false; + }); + final Iterable? options = await _debouncedSearch(textEditingValue.text); + if (options == null) { + return _lastOptions; + } + _lastOptions = options; + return options; + }, + onSelected: (String selection) { + debugPrint('You just selected $selection'); + }, + ), + ], + ); + } +} + +// Mimics a remote API. +class _FakeAPI { + static const List _kOptions = [ + 'aardvark', + 'bobcat', + 'chameleon', + ]; + + // Searches the options, but injects a fake "network" delay. + static Future> search(String query, bool networkEnabled) async { + await Future.delayed(fakeAPIDuration); // Fake 1 second delay. + if (!networkEnabled) { + throw const _NetworkException(); + } + if (query == '') { + return const Iterable.empty(); + } + return _kOptions.where((String option) { + return option.contains(query.toLowerCase()); + }); + } +} + +typedef _Debounceable = Future Function(T parameter); + +/// Returns a new function that is a debounced version of the given function. +/// +/// This means that the original function will be called only after no calls +/// have been made for the given Duration. +_Debounceable _debounce(_Debounceable function) { + _DebounceTimer? debounceTimer; + + return (T parameter) async { + if (debounceTimer != null && !debounceTimer!.isCompleted) { + debounceTimer!.cancel(); + } + debounceTimer = _DebounceTimer(); + try { + await debounceTimer!.future; + } catch (error) { + if (error is _CancelException) { + return null; + } + rethrow; + } + return function(parameter); + }; +} + +// A wrapper around Timer used for debouncing. +class _DebounceTimer { + _DebounceTimer( + ) { + _timer = Timer(debounceDuration, _onComplete); + } + + late final Timer _timer; + final Completer _completer = Completer(); + + void _onComplete() { + _completer.complete(); + } + + Future get future => _completer.future; + + bool get isCompleted => _completer.isCompleted; + + void cancel() { + _timer.cancel(); + _completer.completeError(const _CancelException()); + } +} + +// An exception indicating that the timer was canceled. +class _CancelException implements Exception { + const _CancelException(); +} + +// An exception indicating that a network request has failed. +class _NetworkException implements Exception { + const _NetworkException(); +} diff --git a/novelforge-project/flutter/examples/api/lib/material/badge/badge.0.dart b/novelforge-project/flutter/examples/api/lib/material/badge/badge.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..bf0e177baa24a380e2e105b4abdc4d973deee27a --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/badge/badge.0.dart @@ -0,0 +1,54 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Badge]. + +void main() => runApp(const BadgeExampleApp()); + +class BadgeExampleApp extends StatelessWidget { + const BadgeExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('Badge Sample')), + body: const BadgeExample(), + ), + ); + } +} + +class BadgeExample extends StatelessWidget { + const BadgeExample({super.key}); + + @override + Widget build(BuildContext context) { + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + IconButton( + icon: const Badge( + label: Text('Your label'), + backgroundColor: Colors.blueAccent, + child: Icon(Icons.receipt), + ), + onPressed: () {}, + ), + const SizedBox(height: 20), + IconButton( + icon: Badge.count( + count: 9999, + child: const Icon(Icons.notifications), + ), + onPressed: () {}, + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/banner/material_banner.0.dart b/novelforge-project/flutter/examples/api/lib/material/banner/material_banner.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..fc3791f89b122dd3fb421d229cada7485a53ee50 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/banner/material_banner.0.dart @@ -0,0 +1,49 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [MaterialBanner]. + +void main() => runApp(const MaterialBannerExampleApp()); + +class MaterialBannerExampleApp extends StatelessWidget { + const MaterialBannerExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: MaterialBannerExample(), + ); + } +} + +class MaterialBannerExample extends StatelessWidget { + const MaterialBannerExample({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('The MaterialBanner is below'), + ), + body: const MaterialBanner( + padding: EdgeInsets.all(20), + content: Text('Hello, I am a Material Banner'), + leading: Icon(Icons.agriculture_outlined), + backgroundColor: Color(0xFFE0E0E0), + actions: [ + TextButton( + onPressed: null, + child: Text('OPEN'), + ), + TextButton( + onPressed: null, + child: Text('DISMISS'), + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/banner/material_banner.1.dart b/novelforge-project/flutter/examples/api/lib/material/banner/material_banner.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..ddba00b82615be86aa934fc0ac96975148e30128 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/banner/material_banner.1.dart @@ -0,0 +1,52 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [MaterialBanner]. + +void main() => runApp(const MaterialBannerExampleApp()); + +class MaterialBannerExampleApp extends StatelessWidget { + const MaterialBannerExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: MaterialBannerExample(), + ); + } +} + +class MaterialBannerExample extends StatelessWidget { + const MaterialBannerExample({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('The MaterialBanner is below'), + ), + body: Center( + child: ElevatedButton( + child: const Text('Show MaterialBanner'), + onPressed: () => ScaffoldMessenger.of(context).showMaterialBanner( + const MaterialBanner( + padding: EdgeInsets.all(20), + content: Text('Hello, I am a Material Banner'), + leading: Icon(Icons.agriculture_outlined), + backgroundColor: Colors.green, + actions: [ + TextButton( + onPressed: null, + child: Text('DISMISS'), + ), + ], + ), + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/bottom_app_bar/bottom_app_bar.1.dart b/novelforge-project/flutter/examples/api/lib/material/bottom_app_bar/bottom_app_bar.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..a35c580131a24fd2cb6a2308e8f2e904c7181107 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/bottom_app_bar/bottom_app_bar.1.dart @@ -0,0 +1,157 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [BottomAppBar]. + +void main() { + runApp(const BottomAppBarDemo()); +} + +class BottomAppBarDemo extends StatefulWidget { + const BottomAppBarDemo({super.key}); + + @override + State createState() => _BottomAppBarDemoState(); +} + +class _BottomAppBarDemoState extends State { + bool _showFab = true; + bool _showNotch = true; + FloatingActionButtonLocation _fabLocation = FloatingActionButtonLocation.endDocked; + + void _onShowNotchChanged(bool value) { + setState(() { + _showNotch = value; + }); + } + + void _onShowFabChanged(bool value) { + setState(() { + _showFab = value; + }); + } + + void _onFabLocationChanged(FloatingActionButtonLocation? value) { + setState(() { + _fabLocation = value ?? FloatingActionButtonLocation.endDocked; + }); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + automaticallyImplyLeading: false, + title: const Text('Bottom App Bar Demo'), + ), + body: ListView( + padding: const EdgeInsets.only(bottom: 88), + children: [ + SwitchListTile( + title: const Text( + 'Floating Action Button', + ), + value: _showFab, + onChanged: _onShowFabChanged, + ), + SwitchListTile( + title: const Text('Notch'), + value: _showNotch, + onChanged: _onShowNotchChanged, + ), + const Padding( + padding: EdgeInsets.all(16), + child: Text('Floating action button position'), + ), + RadioListTile( + title: const Text('Docked - End'), + value: FloatingActionButtonLocation.endDocked, + groupValue: _fabLocation, + onChanged: _onFabLocationChanged, + ), + RadioListTile( + title: const Text('Docked - Center'), + value: FloatingActionButtonLocation.centerDocked, + groupValue: _fabLocation, + onChanged: _onFabLocationChanged, + ), + RadioListTile( + title: const Text('Floating - End'), + value: FloatingActionButtonLocation.endFloat, + groupValue: _fabLocation, + onChanged: _onFabLocationChanged, + ), + RadioListTile( + title: const Text('Floating - Center'), + value: FloatingActionButtonLocation.centerFloat, + groupValue: _fabLocation, + onChanged: _onFabLocationChanged, + ), + ], + ), + floatingActionButton: _showFab + ? FloatingActionButton( + onPressed: () {}, + tooltip: 'Create', + child: const Icon(Icons.add), + ) + : null, + floatingActionButtonLocation: _fabLocation, + bottomNavigationBar: _DemoBottomAppBar( + fabLocation: _fabLocation, + shape: _showNotch ? const CircularNotchedRectangle() : null, + ), + ), + ); + } +} + +class _DemoBottomAppBar extends StatelessWidget { + const _DemoBottomAppBar({ + this.fabLocation = FloatingActionButtonLocation.endDocked, + this.shape = const CircularNotchedRectangle(), + }); + + final FloatingActionButtonLocation fabLocation; + final NotchedShape? shape; + + static final List centerLocations = [ + FloatingActionButtonLocation.centerDocked, + FloatingActionButtonLocation.centerFloat, + ]; + + @override + Widget build(BuildContext context) { + return BottomAppBar( + shape: shape, + color: Colors.blue, + child: IconTheme( + data: IconThemeData(color: Theme.of(context).colorScheme.onPrimary), + child: Row( + children: [ + IconButton( + tooltip: 'Open navigation menu', + icon: const Icon(Icons.menu), + onPressed: () {}, + ), + if (centerLocations.contains(fabLocation)) const Spacer(), + IconButton( + tooltip: 'Search', + icon: const Icon(Icons.search), + onPressed: () {}, + ), + IconButton( + tooltip: 'Favorite', + icon: const Icon(Icons.favorite), + onPressed: () {}, + ), + ], + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/bottom_app_bar/bottom_app_bar.2.dart b/novelforge-project/flutter/examples/api/lib/material/bottom_app_bar/bottom_app_bar.2.dart new file mode 100644 index 0000000000000000000000000000000000000000..1aa6b981b8b51368e9e8a62d3b8a608cb2842241 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/bottom_app_bar/bottom_app_bar.2.dart @@ -0,0 +1,192 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; + +/// Flutter code sample for [BottomAppBar] with Material 3. + +void main() { + runApp(const BottomAppBarDemo()); +} + +class BottomAppBarDemo extends StatefulWidget { + const BottomAppBarDemo({super.key}); + + @override + State createState() => _BottomAppBarDemoState(); +} + +class _BottomAppBarDemoState extends State { + static const List colors = [ + Colors.yellow, + Colors.orange, + Colors.pink, + Colors.purple, + Colors.cyan, + ]; + + static final List items = List.generate( + colors.length, + (int index) => Container(color: colors[index], height: 150.0), + ).reversed.toList(); + + late ScrollController _controller; + bool _showFab = true; + bool _isElevated = true; + bool _isVisible = true; + + FloatingActionButtonLocation get _fabLocation => + _isVisible ? FloatingActionButtonLocation.endContained : FloatingActionButtonLocation.endFloat; + + void _listen() { + final ScrollDirection direction = _controller.position.userScrollDirection; + if (direction == ScrollDirection.forward) { + _show(); + } else if (direction == ScrollDirection.reverse) { + _hide(); + } + } + + void _show() { + if (!_isVisible) { + setState(() => _isVisible = true); + } + } + + void _hide() { + if (_isVisible) { + setState(() => _isVisible = false); + } + } + + void _onShowFabChanged(bool value) { + setState(() { + _showFab = value; + }); + } + + void _onElevatedChanged(bool value) { + setState(() { + _isElevated = value; + }); + } + + void _addNewItem() { + setState(() { + items.insert( + 0, + Container(color: colors[items.length % 5], height: 150.0), + ); + }); + } + + @override + void initState() { + super.initState(); + _controller = ScrollController(); + _controller.addListener(_listen); + } + + @override + void dispose() { + _controller.removeListener(_listen); + _controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData(useMaterial3: true), + home: Scaffold( + appBar: AppBar( + title: const Text('Bottom App Bar Demo'), + ), + body: Column( + children: [ + SwitchListTile( + title: const Text('Floating Action Button'), + value: _showFab, + onChanged: _onShowFabChanged, + ), + SwitchListTile( + title: const Text('Bottom App Bar Elevation'), + value: _isElevated, + onChanged: _onElevatedChanged, + ), + Expanded( + child: ListView( + controller: _controller, + children: items.toList(), + ), + ), + ], + ), + floatingActionButton: _showFab + ? FloatingActionButton( + onPressed: _addNewItem, + tooltip: 'Add New Item', + elevation: _isVisible ? 0.0 : null, + child: const Icon(Icons.add), + ) + : null, + floatingActionButtonLocation: _fabLocation, + bottomNavigationBar: _DemoBottomAppBar(isElevated: _isElevated, isVisible: _isVisible), + ), + ); + } +} + +class _DemoBottomAppBar extends StatelessWidget { + const _DemoBottomAppBar({ + required this.isElevated, + required this.isVisible, + }); + + final bool isElevated; + final bool isVisible; + + @override + Widget build(BuildContext context) { + return AnimatedContainer( + duration: const Duration(milliseconds: 200), + height: isVisible ? 80.0 : 0, + child: BottomAppBar( + elevation: isElevated ? null : 0.0, + child: Row( + children: [ + IconButton( + tooltip: 'Open popup menu', + icon: const Icon(Icons.more_vert), + onPressed: () { + final SnackBar snackBar = SnackBar( + content: const Text('Yay! A SnackBar!'), + action: SnackBarAction( + label: 'Undo', + onPressed: () {}, + ), + ); + + // Find the ScaffoldMessenger in the widget tree + // and use it to show a SnackBar. + ScaffoldMessenger.of(context).showSnackBar(snackBar); + }, + ), + IconButton( + tooltip: 'Search', + icon: const Icon(Icons.search), + onPressed: () {}, + ), + IconButton( + tooltip: 'Favorite', + icon: const Icon(Icons.favorite), + onPressed: () {}, + ), + ], + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/bottom_navigation_bar/bottom_navigation_bar.0.dart b/novelforge-project/flutter/examples/api/lib/material/bottom_navigation_bar/bottom_navigation_bar.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..4bdf47c2e2d29fb2283a4fe16e94902cac86702c --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/bottom_navigation_bar/bottom_navigation_bar.0.dart @@ -0,0 +1,83 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [BottomNavigationBar]. + +void main() => runApp(const BottomNavigationBarExampleApp()); + +class BottomNavigationBarExampleApp extends StatelessWidget { + const BottomNavigationBarExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: BottomNavigationBarExample(), + ); + } +} + +class BottomNavigationBarExample extends StatefulWidget { + const BottomNavigationBarExample({super.key}); + + @override + State createState() => _BottomNavigationBarExampleState(); +} + +class _BottomNavigationBarExampleState extends State { + int _selectedIndex = 0; + static const TextStyle optionStyle = TextStyle(fontSize: 30, fontWeight: FontWeight.bold); + static const List _widgetOptions = [ + Text( + 'Index 0: Home', + style: optionStyle, + ), + Text( + 'Index 1: Business', + style: optionStyle, + ), + Text( + 'Index 2: School', + style: optionStyle, + ), + ]; + + void _onItemTapped(int index) { + setState(() { + _selectedIndex = index; + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('BottomNavigationBar Sample'), + ), + body: Center( + child: _widgetOptions.elementAt(_selectedIndex), + ), + bottomNavigationBar: BottomNavigationBar( + items: const [ + BottomNavigationBarItem( + icon: Icon(Icons.home), + label: 'Home', + ), + BottomNavigationBarItem( + icon: Icon(Icons.business), + label: 'Business', + ), + BottomNavigationBarItem( + icon: Icon(Icons.school), + label: 'School', + ), + ], + currentIndex: _selectedIndex, + selectedItemColor: Colors.amber[800], + onTap: _onItemTapped, + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/bottom_navigation_bar/bottom_navigation_bar.1.dart b/novelforge-project/flutter/examples/api/lib/material/bottom_navigation_bar/bottom_navigation_bar.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..f60330daeddf125ae3fef8c3602406da16b97b24 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/bottom_navigation_bar/bottom_navigation_bar.1.dart @@ -0,0 +1,95 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [BottomNavigationBar]. + +void main() => runApp(const BottomNavigationBarExampleApp()); + +class BottomNavigationBarExampleApp extends StatelessWidget { + const BottomNavigationBarExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: BottomNavigationBarExample(), + ); + } +} + +class BottomNavigationBarExample extends StatefulWidget { + const BottomNavigationBarExample({super.key}); + + @override + State createState() => _BottomNavigationBarExampleState(); +} + +class _BottomNavigationBarExampleState extends State { + int _selectedIndex = 0; + static const TextStyle optionStyle = TextStyle(fontSize: 30, fontWeight: FontWeight.bold); + static const List _widgetOptions = [ + Text( + 'Index 0: Home', + style: optionStyle, + ), + Text( + 'Index 1: Business', + style: optionStyle, + ), + Text( + 'Index 2: School', + style: optionStyle, + ), + Text( + 'Index 3: Settings', + style: optionStyle, + ), + ]; + + void _onItemTapped(int index) { + setState(() { + _selectedIndex = index; + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('BottomNavigationBar Sample'), + ), + body: Center( + child: _widgetOptions.elementAt(_selectedIndex), + ), + bottomNavigationBar: BottomNavigationBar( + items: const [ + BottomNavigationBarItem( + icon: Icon(Icons.home), + label: 'Home', + backgroundColor: Colors.red, + ), + BottomNavigationBarItem( + icon: Icon(Icons.business), + label: 'Business', + backgroundColor: Colors.green, + ), + BottomNavigationBarItem( + icon: Icon(Icons.school), + label: 'School', + backgroundColor: Colors.purple, + ), + BottomNavigationBarItem( + icon: Icon(Icons.settings), + label: 'Settings', + backgroundColor: Colors.pink, + ), + ], + currentIndex: _selectedIndex, + selectedItemColor: Colors.amber[800], + onTap: _onItemTapped, + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/bottom_navigation_bar/bottom_navigation_bar.2.dart b/novelforge-project/flutter/examples/api/lib/material/bottom_navigation_bar/bottom_navigation_bar.2.dart new file mode 100644 index 0000000000000000000000000000000000000000..49e42910fa5ead2255edfb71fe76ecdfcef835d3 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/bottom_navigation_bar/bottom_navigation_bar.2.dart @@ -0,0 +1,109 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [BottomNavigationBar]. + +void main() => runApp(const BottomNavigationBarExampleApp()); + +class BottomNavigationBarExampleApp extends StatelessWidget { + const BottomNavigationBarExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: BottomNavigationBarExample(), + ); + } +} + +class BottomNavigationBarExample extends StatefulWidget { + const BottomNavigationBarExample({super.key}); + + @override + State createState() => _BottomNavigationBarExampleState(); +} + +class _BottomNavigationBarExampleState extends State { + int _selectedIndex = 0; + final ScrollController _homeController = ScrollController(); + + Widget _listViewBody() { + return ListView.separated( + controller: _homeController, + itemBuilder: (BuildContext context, int index) { + return Center( + child: Text( + 'Item $index', + ), + ); + }, + separatorBuilder: (BuildContext context, int index) => const Divider( + thickness: 1, + ), + itemCount: 50); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('BottomNavigationBar Sample'), + ), + body: _listViewBody(), + bottomNavigationBar: BottomNavigationBar( + items: const [ + BottomNavigationBarItem( + icon: Icon(Icons.home), + label: 'Home', + ), + BottomNavigationBarItem( + icon: Icon(Icons.open_in_new_rounded), + label: 'Open Dialog', + ), + ], + currentIndex: _selectedIndex, + selectedItemColor: Colors.amber[800], + onTap: (int index) { + switch (index) { + case 0: + // only scroll to top when current index is selected. + if (_selectedIndex == index) { + _homeController.animateTo( + 0.0, + duration: const Duration(milliseconds: 500), + curve: Curves.easeOut, + ); + } + case 1: + showModal(context); + } + setState( + () { + _selectedIndex = index; + }, + ); + }, + ), + ); + } + + void showModal(BuildContext context) { + showDialog( + context: context, + builder: (BuildContext context) => AlertDialog( + content: const Text('Example Dialog'), + actions: [ + TextButton( + onPressed: () { + Navigator.pop(context); + }, + child: const Text('Close'), + ) + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/bottom_sheet/show_bottom_sheet.0.dart b/novelforge-project/flutter/examples/api/lib/material/bottom_sheet/show_bottom_sheet.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..e63885485c690168c104905952e54038a02ca446 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/bottom_sheet/show_bottom_sheet.0.dart @@ -0,0 +1,101 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [showBottomSheet]. + +void main() => runApp(const BottomSheetExampleApp()); + +class BottomSheetExampleApp extends StatelessWidget { + const BottomSheetExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('Bottom Sheet Sample')), + body: const BottomSheetExample(), + ), + ); + } +} + +enum AnimationStyles { defaultStyle, custom, none } +const List<(AnimationStyles, String)> animationStyleSegments = <(AnimationStyles, String)>[ + (AnimationStyles.defaultStyle, 'Default'), + (AnimationStyles.custom, 'Custom'), + (AnimationStyles.none, 'None'), +]; + +class BottomSheetExample extends StatefulWidget { + const BottomSheetExample({super.key}); + + @override + State createState() => _BottomSheetExampleState(); +} + +class _BottomSheetExampleState extends State { + Set _animationStyleSelection = {AnimationStyles.defaultStyle}; + AnimationStyle? _animationStyle; + + @override + Widget build(BuildContext context) { + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SegmentedButton( + selected: _animationStyleSelection, + onSelectionChanged: (Set styles) { + setState(() { + _animationStyle = switch (styles.first) { + AnimationStyles.defaultStyle => null, + AnimationStyles.custom => AnimationStyle( + duration: const Duration(seconds: 3), + reverseDuration: const Duration(seconds: 1), + ), + AnimationStyles.none => AnimationStyle.noAnimation, + }; + _animationStyleSelection = styles; + }); + }, + segments: animationStyleSegments + .map>(((AnimationStyles, String) shirt) { + return ButtonSegment(value: shirt.$1, label: Text(shirt.$2)); + }) + .toList(), + ), + const SizedBox(height: 10), + ElevatedButton( + child: const Text('showBottomSheet'), + onPressed: () { + showBottomSheet( + context: context, + sheetAnimationStyle: _animationStyle, + builder: (BuildContext context) { + return SizedBox.expand( + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + const Text('Bottom sheet'), + ElevatedButton( + child: const Text('Close'), + onPressed: () => Navigator.pop(context), + ), + ], + ), + ), + ); + }, + ); + }, + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/bottom_sheet/show_modal_bottom_sheet.0.dart b/novelforge-project/flutter/examples/api/lib/material/bottom_sheet/show_modal_bottom_sheet.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..fef506c1d6de58d0a1e14c1c52ebbecb7d4f5e04 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/bottom_sheet/show_modal_bottom_sheet.0.dart @@ -0,0 +1,60 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [showModalBottomSheet]. + +void main() => runApp(const BottomSheetApp()); + +class BottomSheetApp extends StatelessWidget { + const BottomSheetApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('Bottom Sheet Sample')), + body: const BottomSheetExample(), + ), + ); + } +} + +class BottomSheetExample extends StatelessWidget { + const BottomSheetExample({super.key}); + + @override + Widget build(BuildContext context) { + return Center( + child: ElevatedButton( + child: const Text('showModalBottomSheet'), + onPressed: () { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return Container( + height: 200, + color: Colors.amber, + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + const Text('Modal BottomSheet'), + ElevatedButton( + child: const Text('Close BottomSheet'), + onPressed: () => Navigator.pop(context), + ), + ], + ), + ), + ); + }, + ); + }, + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/bottom_sheet/show_modal_bottom_sheet.1.dart b/novelforge-project/flutter/examples/api/lib/material/bottom_sheet/show_modal_bottom_sheet.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..096adc8d79f046c2de7360cd3a298384518a8189 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/bottom_sheet/show_modal_bottom_sheet.1.dart @@ -0,0 +1,63 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [showModalBottomSheet]. + +void main() => runApp(const BottomSheetApp()); + +class BottomSheetApp extends StatelessWidget { + const BottomSheetApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData( + colorSchemeSeed: const Color(0xff6750a4), + useMaterial3: true, + ), + home: Scaffold( + appBar: AppBar(title: const Text('Bottom Sheet Sample')), + body: const BottomSheetExample(), + ), + ); + } +} + +class BottomSheetExample extends StatelessWidget { + const BottomSheetExample({super.key}); + + @override + Widget build(BuildContext context) { + return Center( + child: ElevatedButton( + child: const Text('showModalBottomSheet'), + onPressed: () { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + const Text('Modal BottomSheet'), + ElevatedButton( + child: const Text('Close BottomSheet'), + onPressed: () => Navigator.pop(context), + ), + ], + ), + ), + ); + }, + ); + }, + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/bottom_sheet/show_modal_bottom_sheet.2.dart b/novelforge-project/flutter/examples/api/lib/material/bottom_sheet/show_modal_bottom_sheet.2.dart new file mode 100644 index 0000000000000000000000000000000000000000..e602c50be0f5bbb5fabe8b63482896659ac039cb --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/bottom_sheet/show_modal_bottom_sheet.2.dart @@ -0,0 +1,101 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [showModalBottomSheet]. + +void main() => runApp(const ModalBottomSheetApp()); + +class ModalBottomSheetApp extends StatelessWidget { + const ModalBottomSheetApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('Modal Bottom Sheet Sample')), + body: const ModalBottomSheetExample(), + ), + ); + } +} + +enum AnimationStyles { defaultStyle, custom, none } +const List<(AnimationStyles, String)> animationStyleSegments = <(AnimationStyles, String)>[ + (AnimationStyles.defaultStyle, 'Default'), + (AnimationStyles.custom, 'Custom'), + (AnimationStyles.none, 'None'), +]; + +class ModalBottomSheetExample extends StatefulWidget { + const ModalBottomSheetExample({super.key}); + + @override + State createState() => _ModalBottomSheetExampleState(); +} + +class _ModalBottomSheetExampleState extends State { + Set _animationStyleSelection = {AnimationStyles.defaultStyle}; + AnimationStyle? _animationStyle; + + @override + Widget build(BuildContext context) { + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SegmentedButton( + selected: _animationStyleSelection, + onSelectionChanged: (Set styles) { + setState(() { + _animationStyle = switch (styles.first) { + AnimationStyles.defaultStyle => null, + AnimationStyles.custom => AnimationStyle( + duration: const Duration(seconds: 3), + reverseDuration: const Duration(seconds: 1), + ), + AnimationStyles.none => AnimationStyle.noAnimation, + }; + _animationStyleSelection = styles; + }); + }, + segments: animationStyleSegments + .map>(((AnimationStyles, String) shirt) { + return ButtonSegment(value: shirt.$1, label: Text(shirt.$2)); + }) + .toList(), + ), + const SizedBox(height: 10), + ElevatedButton( + child: const Text('showModalBottomSheet'), + onPressed: () { + showModalBottomSheet( + context: context, + sheetAnimationStyle: _animationStyle, + builder: (BuildContext context) { + return SizedBox.expand( + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + const Text('Modal bottom sheet'), + ElevatedButton( + child: const Text('Close'), + onPressed: () => Navigator.pop(context), + ), + ], + ), + ), + ); + }, + ); + }, + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/button_style/button_style.0.dart b/novelforge-project/flutter/examples/api/lib/material/button_style/button_style.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..03a49430c40d8fe5bb8371a6b8846f4623be1f6a --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/button_style/button_style.0.dart @@ -0,0 +1,69 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [ElevatedButton]. + +void main() { + runApp(const ButtonApp()); +} + +class ButtonApp extends StatelessWidget { + const ButtonApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData(colorSchemeSeed: const Color(0xff6750a4), useMaterial3: true), + title: 'Button Types', + home: const Scaffold( + body: ButtonTypesExample(), + ), + ); + } +} + +class ButtonTypesExample extends StatelessWidget { + const ButtonTypesExample({super.key}); + + @override + Widget build(BuildContext context) { + return const Padding( + padding: EdgeInsets.all(4.0), + child: Row( + children: [ + Spacer(), + ButtonTypesGroup(enabled: true), + ButtonTypesGroup(enabled: false), + Spacer(), + ], + ), + ); + } +} + +class ButtonTypesGroup extends StatelessWidget { + const ButtonTypesGroup({super.key, required this.enabled}); + + final bool enabled; + + @override + Widget build(BuildContext context) { + final VoidCallback? onPressed = enabled ? () {} : null; + return Padding( + padding: const EdgeInsets.all(4.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + ElevatedButton(onPressed: onPressed, child: const Text('Elevated')), + FilledButton(onPressed: onPressed, child: const Text('Filled')), + FilledButton.tonal(onPressed: onPressed, child: const Text('Filled Tonal')), + OutlinedButton(onPressed: onPressed, child: const Text('Outlined')), + TextButton(onPressed: onPressed, child: const Text('Text')), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/button_style_button/button_style_button.icon_alignment.0.dart b/novelforge-project/flutter/examples/api/lib/material/button_style_button/button_style_button.icon_alignment.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..1b19ca629e6bcb3bf43434ffabef25f862105ef6 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/button_style_button/button_style_button.icon_alignment.0.dart @@ -0,0 +1,147 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for using [ButtonStyleButton.iconAlignment] parameter. + +void main() { + runApp(const ButtonStyleButtonIconAlignmentApp()); +} + +class ButtonStyleButtonIconAlignmentApp extends StatelessWidget { + const ButtonStyleButtonIconAlignmentApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: Scaffold( + body: ButtonStyleButtonIconAlignmentExample(), + ), + ); + } +} + +class ButtonStyleButtonIconAlignmentExample extends StatefulWidget { + const ButtonStyleButtonIconAlignmentExample({super.key}); + + @override + State createState() => _ButtonStyleButtonIconAlignmentExampleState(); +} + +class _ButtonStyleButtonIconAlignmentExampleState extends State { + TextDirection _textDirection = TextDirection.ltr; + IconAlignment _iconAlignment = IconAlignment.start; + + @override + Widget build(BuildContext context) { + return SafeArea( + child: Directionality( + key: const Key('Directionality'), + textDirection: _textDirection, + child: Center( + child: Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Spacer(), + OverflowBar( + spacing: 10, + overflowSpacing: 20, + alignment: MainAxisAlignment.center, + overflowAlignment: OverflowBarAlignment.center, + children: [ + ElevatedButton.icon( + onPressed: () {}, + icon: const Icon(Icons.sunny), + label: const Text('ElevatedButton'), + iconAlignment: _iconAlignment, + ), + FilledButton.icon( + onPressed: () {}, + icon: const Icon(Icons.beach_access), + label: const Text('FilledButton'), + iconAlignment: _iconAlignment, + ), + FilledButton.tonalIcon( + onPressed: () {}, + icon: const Icon(Icons.cloud), + label: const Text('FilledButton Tonal'), + iconAlignment: _iconAlignment, + ), + OutlinedButton.icon( + onPressed: () {}, + icon: const Icon(Icons.light), + label: const Text('OutlinedButton'), + iconAlignment: _iconAlignment, + ), + TextButton.icon( + onPressed: () {}, + icon: const Icon(Icons.flight_takeoff), + label: const Text('TextButton'), + iconAlignment: _iconAlignment, + ), + ], + ), + const Spacer(), + OverflowBar( + alignment: MainAxisAlignment.spaceEvenly, + overflowAlignment: OverflowBarAlignment.center, + spacing: 10, + overflowSpacing: 10, + children: [ + Column( + children: [ + const Text('Icon alignment'), + const SizedBox(height: 10), + SegmentedButton( + onSelectionChanged: (Set value) { + setState(() { + _iconAlignment = value.first; + }); + }, + selected: { _iconAlignment }, + segments: IconAlignment.values.map((IconAlignment iconAlignment) { + return ButtonSegment( + value: iconAlignment, + label: Text(iconAlignment.name), + ); + }).toList(), + ), + ], + ), + Column( + children: [ + const Text('Text direction'), + const SizedBox(height: 10), + SegmentedButton( + onSelectionChanged: (Set value) { + setState(() { + _textDirection = value.first; + }); + }, + selected: { _textDirection }, + segments: const >[ + ButtonSegment( + value: TextDirection.ltr, + label: Text('LTR'), + ), + ButtonSegment( + value: TextDirection.rtl, + label: Text('RTL'), + ), + ], + ), + ], + ), + ], + ), + const Spacer(), + ], + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/card/card.0.dart b/novelforge-project/flutter/examples/api/lib/material/card/card.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..1b90628c08fea3b6a640e787af35642b4ac60384 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/card/card.0.dart @@ -0,0 +1,60 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Card]. + +void main() => runApp(const CardExampleApp()); + +class CardExampleApp extends StatelessWidget { + const CardExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('Card Sample')), + body: const CardExample(), + ), + ); + } +} + +class CardExample extends StatelessWidget { + const CardExample({super.key}); + + @override + Widget build(BuildContext context) { + return Center( + child: Card( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const ListTile( + leading: Icon(Icons.album), + title: Text('The Enchanted Nightingale'), + subtitle: Text('Music by Julie Gable. Lyrics by Sidney Stein.'), + ), + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + TextButton( + child: const Text('BUY TICKETS'), + onPressed: () {/* ... */}, + ), + const SizedBox(width: 8), + TextButton( + child: const Text('LISTEN'), + onPressed: () {/* ... */}, + ), + const SizedBox(width: 8), + ], + ), + ], + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/card/card.1.dart b/novelforge-project/flutter/examples/api/lib/material/card/card.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..3be967d815e7368e3a269d07087661afeaba6753 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/card/card.1.dart @@ -0,0 +1,51 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Card]. + +void main() => runApp(const CardExampleApp()); + +class CardExampleApp extends StatelessWidget { + const CardExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('Card Sample')), + body: const CardExample(), + ), + ); + } +} + +class CardExample extends StatelessWidget { + const CardExample({super.key}); + + @override + Widget build(BuildContext context) { + return Center( + child: Card( + // clipBehavior is necessary because, without it, the InkWell's animation + // will extend beyond the rounded edges of the [Card] (see https://github.com/flutter/flutter/issues/109776) + // This comes with a small performance cost, and you should not set [clipBehavior] + // unless you need it. + clipBehavior: Clip.hardEdge, + child: InkWell( + splashColor: Colors.blue.withAlpha(30), + onTap: () { + debugPrint('Card tapped.'); + }, + child: const SizedBox( + width: 300, + height: 100, + child: Text('A card that can be tapped'), + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/card/card.2.dart b/novelforge-project/flutter/examples/api/lib/material/card/card.2.dart new file mode 100644 index 0000000000000000000000000000000000000000..89958726c856ade6d543aba0ff82b6ab8be21d10 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/card/card.2.dart @@ -0,0 +1,48 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Card]. + +void main() { + runApp(const CardExamplesApp()); +} + +class CardExamplesApp extends StatelessWidget { + const CardExamplesApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('Card Examples')), + body: const Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Card(child: _SampleCard(cardName: 'Elevated Card')), + Card.filled(child: _SampleCard(cardName: 'Filled Card')), + Card.outlined(child: _SampleCard(cardName: 'Outlined Card')), + ], + ), + ), + ), + ); + } +} + +class _SampleCard extends StatelessWidget { + const _SampleCard({required this.cardName}); + final String cardName; + + @override + Widget build(BuildContext context) { + return SizedBox( + width: 300, + height: 100, + child: Center(child: Text(cardName)), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/carousel/carousel.0.dart b/novelforge-project/flutter/examples/api/lib/material/carousel/carousel.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..005bed704ca9a9a978784735e2d798e9b1996a76 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/carousel/carousel.0.dart @@ -0,0 +1,77 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Carousel]. + +void main() => runApp(const CarouselExampleApp()); + +class CarouselExampleApp extends StatelessWidget { + const CarouselExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + debugShowCheckedModeBanner: false, + home: Scaffold( + appBar: AppBar( + title: const Text('Carousel Sample'), + ), + body: const CarouselExample(), + ), + ); + } +} + +class CarouselExample extends StatefulWidget { + const CarouselExample({super.key}); + + @override + State createState() => _CarouselExampleState(); +} + +class _CarouselExampleState extends State { + @override + Widget build(BuildContext context) { + return Center( + child: ConstrainedBox( + constraints: const BoxConstraints(maxHeight: 200), + child: CarouselView( + itemExtent: 330, + shrinkExtent: 200, + children: List.generate(20, (int index) { + return UncontainedLayoutCard(index: index, label: 'Item $index'); + }), + ), + ), + ); + } +} + +class UncontainedLayoutCard extends StatelessWidget { + const UncontainedLayoutCard({ + super.key, + required this.index, + required this.label, + }); + + final int index; + final String label; + + @override + Widget build(BuildContext context) { + return ColoredBox( + color: Colors.primaries[index % Colors.primaries.length].withOpacity(0.5), + child: Center( + child: Text( + label, + style: const TextStyle(color: Colors.white, fontSize: 20), + overflow: TextOverflow.clip, + softWrap: false, + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/checkbox/checkbox.0.dart b/novelforge-project/flutter/examples/api/lib/material/checkbox/checkbox.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..074e5adcdaf96de9f37ab068338976dbd526b16e --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/checkbox/checkbox.0.dart @@ -0,0 +1,62 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Checkbox]. + +void main() => runApp(const CheckboxExampleApp()); + +class CheckboxExampleApp extends StatelessWidget { + const CheckboxExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('Checkbox Sample')), + body: const Center( + child: CheckboxExample(), + ), + ), + ); + } +} + +class CheckboxExample extends StatefulWidget { + const CheckboxExample({super.key}); + + @override + State createState() => _CheckboxExampleState(); +} + +class _CheckboxExampleState extends State { + bool isChecked = false; + + @override + Widget build(BuildContext context) { + Color getColor(Set states) { + const Set interactiveStates = { + MaterialState.pressed, + MaterialState.hovered, + MaterialState.focused, + }; + if (states.any(interactiveStates.contains)) { + return Colors.blue; + } + return Colors.red; + } + + return Checkbox( + checkColor: Colors.white, + fillColor: MaterialStateProperty.resolveWith(getColor), + value: isChecked, + onChanged: (bool? value) { + setState(() { + isChecked = value!; + }); + }, + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/checkbox/checkbox.1.dart b/novelforge-project/flutter/examples/api/lib/material/checkbox/checkbox.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..9593bacf61fc1ba60f445d9e05e694969fffb8c0 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/checkbox/checkbox.1.dart @@ -0,0 +1,72 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for M3 [Checkbox] with error state. + +void main() => runApp(const CheckboxExampleApp()); + +class CheckboxExampleApp extends StatelessWidget { + const CheckboxExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData(useMaterial3: true, colorSchemeSeed: const Color(0xff6750a4)), + title: 'Checkbox Sample', + home: Scaffold( + appBar: AppBar(title: const Text('Checkbox Sample')), + body: const Center( + child: CheckboxExample(), + ), + ), + ); + } +} + +class CheckboxExample extends StatefulWidget { + const CheckboxExample({super.key}); + + @override + State createState() => _CheckboxExampleState(); +} + +class _CheckboxExampleState extends State { + bool? isChecked = true; + + @override + Widget build(BuildContext context) { + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Checkbox( + tristate: true, + value: isChecked, + onChanged: (bool? value) { + setState(() { + isChecked = value; + }); + }, + ), + Checkbox( + isError: true, + tristate: true, + value: isChecked, + onChanged: (bool? value) { + setState(() { + isChecked = value; + }); + }, + ), + Checkbox( + isError: true, + tristate: true, + value: isChecked, + onChanged: null, + ), + ], + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/checkbox_list_tile/checkbox_list_tile.0.dart b/novelforge-project/flutter/examples/api/lib/material/checkbox_list_tile/checkbox_list_tile.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..bf67c15b949abedab85bede86d76149e24020f30 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/checkbox_list_tile/checkbox_list_tile.0.dart @@ -0,0 +1,50 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/scheduler.dart' show timeDilation; + +/// Flutter code sample for [CheckboxListTile]. + +void main() => runApp(const CheckboxListTileApp()); + +class CheckboxListTileApp extends StatelessWidget { + const CheckboxListTileApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData(useMaterial3: true), + home: const CheckboxListTileExample(), + ); + } +} + +class CheckboxListTileExample extends StatefulWidget { + const CheckboxListTileExample({super.key}); + + @override + State createState() => _CheckboxListTileExampleState(); +} + +class _CheckboxListTileExampleState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: const Text('CheckboxListTile Sample')), + body: Center( + child: CheckboxListTile( + title: const Text('Animate Slowly'), + value: timeDilation != 1.0, + onChanged: (bool? value) { + setState(() { + timeDilation = value! ? 10.0 : 1.0; + }); + }, + secondary: const Icon(Icons.hourglass_empty), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/checkbox_list_tile/checkbox_list_tile.1.dart b/novelforge-project/flutter/examples/api/lib/material/checkbox_list_tile/checkbox_list_tile.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..8d3808f4e242a66b3d6c326bf9235e83220b32c5 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/checkbox_list_tile/checkbox_list_tile.1.dart @@ -0,0 +1,81 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [CheckboxListTile]. + +void main() => runApp(const CheckboxListTileApp()); + +class CheckboxListTileApp extends StatelessWidget { + const CheckboxListTileApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData(useMaterial3: true), + home: const CheckboxListTileExample(), + ); + } +} + +class CheckboxListTileExample extends StatefulWidget { + const CheckboxListTileExample({super.key}); + + @override + State createState() => _CheckboxListTileExampleState(); +} + +class _CheckboxListTileExampleState extends State { + bool checkboxValue1 = true; + bool checkboxValue2 = true; + bool checkboxValue3 = true; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: const Text('CheckboxListTile Sample')), + body: Column( + children: [ + CheckboxListTile( + value: checkboxValue1, + onChanged: (bool? value) { + setState(() { + checkboxValue1 = value!; + }); + }, + title: const Text('Headline'), + subtitle: const Text('Supporting text'), + ), + const Divider(height: 0), + CheckboxListTile( + value: checkboxValue2, + onChanged: (bool? value) { + setState(() { + checkboxValue2 = value!; + }); + }, + title: const Text('Headline'), + subtitle: const Text( + 'Longer supporting text to demonstrate how the text wraps and the checkbox is centered vertically with the text.'), + ), + const Divider(height: 0), + CheckboxListTile( + value: checkboxValue3, + onChanged: (bool? value) { + setState(() { + checkboxValue3 = value!; + }); + }, + title: const Text('Headline'), + subtitle: const Text( + "Longer supporting text to demonstrate how the text wraps and how setting 'CheckboxListTile.isThreeLine = true' aligns the checkbox to the top vertically with the text."), + isThreeLine: true, + ), + const Divider(height: 0), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/checkbox_list_tile/custom_labeled_checkbox.0.dart b/novelforge-project/flutter/examples/api/lib/material/checkbox_list_tile/custom_labeled_checkbox.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..50705bc9b00d5e27fce13a9ca4028e2f676d6ce9 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/checkbox_list_tile/custom_labeled_checkbox.0.dart @@ -0,0 +1,100 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/gestures.dart'; + +import 'package:flutter/material.dart'; + +/// Flutter code sample for custom labeled checkbox. + +void main() => runApp(const LabeledCheckboxApp()); + +class LabeledCheckboxApp extends StatelessWidget { + const LabeledCheckboxApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData(useMaterial3: true), + home: const LabeledCheckboxExample(), + ); + } +} + +class LinkedLabelCheckbox extends StatelessWidget { + const LinkedLabelCheckbox({ + super.key, + required this.label, + required this.padding, + required this.value, + required this.onChanged, + }); + + final String label; + final EdgeInsets padding; + final bool value; + final ValueChanged onChanged; + + @override + Widget build(BuildContext context) { + return Padding( + padding: padding, + child: Row( + children: [ + Expanded( + child: RichText( + text: TextSpan( + text: label, + style: const TextStyle( + color: Colors.blueAccent, + decoration: TextDecoration.underline, + ), + recognizer: TapGestureRecognizer() + ..onTap = () { + debugPrint('Label has been tapped.'); + }, + ), + ), + ), + Checkbox( + value: value, + onChanged: (bool? newValue) { + onChanged(newValue!); + }, + ), + ], + ), + ); + } +} + +class LabeledCheckboxExample extends StatefulWidget { + const LabeledCheckboxExample({super.key}); + + @override + State createState() => _LabeledCheckboxExampleState(); +} + +class _LabeledCheckboxExampleState extends State { + bool _isSelected = false; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: const Text('Custom Labeled Checkbox Sample')), + body: Center( + child: LinkedLabelCheckbox( + label: 'Linked, tappable label text', + padding: const EdgeInsets.symmetric(horizontal: 20.0), + value: _isSelected, + onChanged: (bool newValue) { + setState(() { + _isSelected = newValue; + }); + }, + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/checkbox_list_tile/custom_labeled_checkbox.1.dart b/novelforge-project/flutter/examples/api/lib/material/checkbox_list_tile/custom_labeled_checkbox.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..f1866cf09cc15e76ce86a05dfc9f504d9714da46 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/checkbox_list_tile/custom_labeled_checkbox.1.dart @@ -0,0 +1,89 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for custom labeled checkbox. + +void main() => runApp(const LabeledCheckboxApp()); + +class LabeledCheckboxApp extends StatelessWidget { + const LabeledCheckboxApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData(useMaterial3: true), + home: const LabeledCheckboxExample(), + ); + } +} + +class LabeledCheckbox extends StatelessWidget { + const LabeledCheckbox({ + super.key, + required this.label, + required this.padding, + required this.value, + required this.onChanged, + }); + + final String label; + final EdgeInsets padding; + final bool value; + final ValueChanged onChanged; + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: () { + onChanged(!value); + }, + child: Padding( + padding: padding, + child: Row( + children: [ + Expanded(child: Text(label)), + Checkbox( + value: value, + onChanged: (bool? newValue) { + onChanged(newValue!); + }, + ), + ], + ), + ), + ); + } +} + +class LabeledCheckboxExample extends StatefulWidget { + const LabeledCheckboxExample({super.key}); + + @override + State createState() => _LabeledCheckboxExampleState(); +} + +class _LabeledCheckboxExampleState extends State { + bool _isSelected = false; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: const Text('Custom Labeled Checkbox Sample')), + body: Center( + child: LabeledCheckbox( + label: 'This is the label text', + padding: const EdgeInsets.symmetric(horizontal: 20.0), + value: _isSelected, + onChanged: (bool newValue) { + setState(() { + _isSelected = newValue; + }); + }, + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/chip/chip_attributes.avatar_box_constraints.0.dart b/novelforge-project/flutter/examples/api/lib/material/chip/chip_attributes.avatar_box_constraints.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..4d409f51aa8f1f2fe398f79b7eb3a6edb598960c --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/chip/chip_attributes.avatar_box_constraints.0.dart @@ -0,0 +1,75 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [ChipAttributes.avatarBoxConstraints]. + +void main() => runApp(const AvatarBoxConstraintsApp()); + +class AvatarBoxConstraintsApp extends StatelessWidget { + const AvatarBoxConstraintsApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: Scaffold( + body: Center( + child: AvatarBoxConstraintsExample(), + ), + ), + ); + } +} + +class AvatarBoxConstraintsExample extends StatelessWidget { + const AvatarBoxConstraintsExample({super.key}); + + @override + Widget build(BuildContext context) { + return const Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + RawChip( + avatarBoxConstraints: BoxConstraints.tightForFinite(), + avatar: Icon(Icons.star), + label: SizedBox( + width: 150, + child: Text( + 'One line text.', + maxLines: 3, + overflow: TextOverflow.ellipsis, + ), + ), + ), + SizedBox(height: 10), + RawChip( + avatarBoxConstraints: BoxConstraints.tightForFinite(), + avatar: Icon(Icons.star), + label: SizedBox( + width: 150, + child: Text( + 'This text will wrap into two lines.', + maxLines: 3, + overflow: TextOverflow.ellipsis, + ), + ), + ), + SizedBox(height: 10), + RawChip( + avatarBoxConstraints: BoxConstraints.tightForFinite(), + avatar: Icon(Icons.star), + label: SizedBox( + width: 150, + child: Text( + 'This is a very long text that will wrap into three lines.', + maxLines: 3, + overflow: TextOverflow.ellipsis, + ), + ), + ), + ], + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/chip/chip_attributes.chip_animation_style.0.dart b/novelforge-project/flutter/examples/api/lib/material/chip/chip_attributes.chip_animation_style.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..03f9120385bcc1203c52cb8ac41b185c03eaa438 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/chip/chip_attributes.chip_animation_style.0.dart @@ -0,0 +1,164 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [ChipAttributes.chipAnimationStyle]. + +void main() => runApp(const ChipAnimationStyleExampleApp()); + +class ChipAnimationStyleExampleApp extends StatelessWidget { + const ChipAnimationStyleExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: Scaffold( + body: Center( + child: ChipAnimationStyleExample(), + ), + ), + ); + } +} + +class ChipAnimationStyleExample extends StatefulWidget { + const ChipAnimationStyleExample({super.key}); + + @override + State createState() => + _ChipAnimationStyleExampleState(); +} + +class _ChipAnimationStyleExampleState extends State { + bool enabled = true; + bool selected = false; + bool showCheckmark = true; + bool showDeleteIcon = true; + + @override + Widget build(BuildContext context) { + return Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Column( + mainAxisSize: MainAxisSize.min, + children: [ + FilterChip.elevated( + chipAnimationStyle: ChipAnimationStyle( + enableAnimation: AnimationStyle( + duration: const Duration(seconds: 3), + reverseDuration: const Duration(seconds: 1), + ), + ), + onSelected: !enabled ? null : (bool value) {}, + disabledColor: Colors.red.withOpacity(0.12), + backgroundColor: Colors.amber, + label: Text(enabled ? 'Enabled' : 'Disabled'), + ), + const SizedBox(height: 16), + ElevatedButton( + onPressed: () { + setState(() { + enabled = !enabled; + }); + }, + child: Text(enabled ? 'Disable' : 'Enable'), + ), + ], + ), + Column( + mainAxisSize: MainAxisSize.min, + children: [ + FilterChip.elevated( + chipAnimationStyle: ChipAnimationStyle( + selectAnimation: AnimationStyle( + duration: const Duration(seconds: 3), + reverseDuration: const Duration(seconds: 1), + ), + ), + backgroundColor: Colors.amber, + selectedColor: Colors.blue, + selected: selected, + showCheckmark: false, + onSelected: (bool value) {}, + label: Text(selected ? 'Selected' : 'Unselected'), + ), + const SizedBox(height: 16), + ElevatedButton( + onPressed: () { + setState(() { + selected = !selected; + }); + }, + child: Text(selected ? 'Unselect' : 'Select'), + ), + ], + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Column( + mainAxisSize: MainAxisSize.min, + children: [ + FilterChip.elevated( + chipAnimationStyle: ChipAnimationStyle( + avatarDrawerAnimation: AnimationStyle( + duration: const Duration(seconds: 2), + reverseDuration: const Duration(seconds: 1), + ), + ), + selected: showCheckmark, + onSelected: (bool value) {}, + label: Text(showCheckmark ? 'Checked' : 'Unchecked'), + ), + const SizedBox(height: 16), + ElevatedButton( + onPressed: () { + setState(() { + showCheckmark = !showCheckmark; + }); + }, + child: + Text(showCheckmark ? 'Hide checkmark' : 'Show checkmark'), + ), + ], + ), + Column( + mainAxisSize: MainAxisSize.min, + children: [ + FilterChip.elevated( + chipAnimationStyle: ChipAnimationStyle( + deleteDrawerAnimation: AnimationStyle( + duration: const Duration(seconds: 2), + reverseDuration: const Duration(seconds: 1), + ), + ), + onDeleted: showDeleteIcon ? () {} : null, + onSelected: (bool value) {}, + label: Text(showDeleteIcon ? 'Deletable' : 'Undeletable'), + ), + const SizedBox(height: 16), + ElevatedButton( + onPressed: () { + setState(() { + showDeleteIcon = !showDeleteIcon; + }); + }, + child: Text( + showDeleteIcon ? 'Hide delete icon' : 'Show delete icon'), + ), + ], + ), + ], + ), + ], + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/chip/deletable_chip_attributes.delete_icon_box_constraints.0.dart b/novelforge-project/flutter/examples/api/lib/material/chip/deletable_chip_attributes.delete_icon_box_constraints.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..efff540f876fc8b0ae90774ac52c41b73511a2ff --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/chip/deletable_chip_attributes.delete_icon_box_constraints.0.dart @@ -0,0 +1,75 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [DeletableChipAttributes.deleteIconBoxConstraints]. + +void main() => runApp(const DeleteIconBoxConstraintsApp()); + +class DeleteIconBoxConstraintsApp extends StatelessWidget { + const DeleteIconBoxConstraintsApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: Scaffold( + body: Center( + child: DeleteIconBoxConstraintsExample(), + ), + ), + ); + } +} + +class DeleteIconBoxConstraintsExample extends StatelessWidget { + const DeleteIconBoxConstraintsExample({super.key}); + + @override + Widget build(BuildContext context) { + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + RawChip( + deleteIconBoxConstraints: const BoxConstraints.tightForFinite(), + onDeleted: () {}, + label: const SizedBox( + width: 150, + child: Text( + 'One line text.', + maxLines: 3, + overflow: TextOverflow.ellipsis, + ), + ), + ), + const SizedBox(height: 10), + RawChip( + deleteIconBoxConstraints: const BoxConstraints.tightForFinite(), + onDeleted: () {}, + label: const SizedBox( + width: 150, + child: Text( + 'This text will wrap into two lines.', + maxLines: 3, + overflow: TextOverflow.ellipsis, + ), + ), + ), + const SizedBox(height: 10), + RawChip( + deleteIconBoxConstraints: const BoxConstraints.tightForFinite(), + onDeleted: () {}, + label: const SizedBox( + width: 150, + child: Text( + 'This is a very long text that will wrap into three lines.', + maxLines: 3, + overflow: TextOverflow.ellipsis, + ), + ), + ), + ], + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/chip/deletable_chip_attributes.on_deleted.0.dart b/novelforge-project/flutter/examples/api/lib/material/chip/deletable_chip_attributes.on_deleted.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..6c91b2de785b6dfaa828d419cd08a3a6ac50f758 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/chip/deletable_chip_attributes.on_deleted.0.dart @@ -0,0 +1,87 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [DeletableChipAttributes.onDeleted]. + +void main() => runApp(const OnDeletedExampleApp()); + +class OnDeletedExampleApp extends StatelessWidget { + const OnDeletedExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('DeletableChipAttributes.onDeleted Sample')), + body: const Center( + child: OnDeletedExample(), + ), + ), + ); + } +} + +class Actor { + const Actor(this.name, this.initials); + final String name; + final String initials; +} + +class CastList extends StatefulWidget { + const CastList({super.key}); + + @override + State createState() => CastListState(); +} + +class CastListState extends State { + final List _cast = [ + const Actor('Aaron Burr', 'AB'), + const Actor('Alexander Hamilton', 'AH'), + const Actor('Eliza Hamilton', 'EH'), + const Actor('James Madison', 'JM'), + ]; + + Iterable get actorWidgets { + return _cast.map((Actor actor) { + return Padding( + padding: const EdgeInsets.all(4.0), + child: Chip( + avatar: CircleAvatar(child: Text(actor.initials)), + label: Text(actor.name), + onDeleted: () { + setState(() { + _cast.removeWhere((Actor entry) { + return entry.name == actor.name; + }); + }); + }, + ), + ); + }); + } + + @override + Widget build(BuildContext context) { + return Wrap( + children: actorWidgets.toList(), + ); + } +} + +class OnDeletedExample extends StatefulWidget { + const OnDeletedExample({super.key}); + + @override + State createState() => _OnDeletedExampleState(); +} + +class _OnDeletedExampleState extends State { + @override + Widget build(BuildContext context) { + return const CastList(); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/choice_chip/choice_chip.0.dart b/novelforge-project/flutter/examples/api/lib/material/choice_chip/choice_chip.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..097c198380053390deb90eec78d6ab40951293bd --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/choice_chip/choice_chip.0.dart @@ -0,0 +1,70 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [ActionChoice]. + +void main() => runApp(const ChipApp()); + +class ChipApp extends StatelessWidget { + const ChipApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData(colorSchemeSeed: const Color(0xff6750a4), useMaterial3: true), + home: const ActionChoiceExample(), + ); + } +} + +class ActionChoiceExample extends StatefulWidget { + const ActionChoiceExample({super.key}); + + @override + State createState() => _ActionChoiceExampleState(); +} + +class _ActionChoiceExampleState extends State { + int? _value = 1; + + @override + Widget build(BuildContext context) { + final TextTheme textTheme = Theme.of(context).textTheme; + + return Scaffold( + appBar: AppBar( + title: const Text('ActionChoice Sample'), + ), + body: Center( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text('Choose an item', style: textTheme.labelLarge), + const SizedBox(height: 10.0), + Wrap( + spacing: 5.0, + children: List.generate( + 3, + (int index) { + return ChoiceChip( + label: Text('Item $index'), + selected: _value == index, + onSelected: (bool selected) { + setState(() { + _value = selected ? index : null; + }); + }, + ); + }, + ).toList(), + ), + ], + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/color_scheme/color_scheme.0.dart b/novelforge-project/flutter/examples/api/lib/material/color_scheme/color_scheme.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..0df4f7b5248d3f2dbc37143845e9a1acae564e31 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/color_scheme/color_scheme.0.dart @@ -0,0 +1,456 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [ColorScheme]. + +const Widget divider = SizedBox(height: 10); + +void main() => runApp(const ColorSchemeExample()); + +class ColorSchemeExample extends StatefulWidget { + const ColorSchemeExample({super.key}); + + @override + State createState() => _ColorSchemeExampleState(); +} + +class _ColorSchemeExampleState extends State { + Color selectedColor = ColorSeed.baseColor.color; + Brightness selectedBrightness = Brightness.light; + double selectedContrast = 0.0; + static const List schemeVariants = DynamicSchemeVariant.values; + + void updateTheme(Brightness brightness, Color color, double contrastLevel) { + setState(() { + selectedBrightness = brightness; + selectedColor = color; + selectedContrast = contrastLevel; + }); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + debugShowCheckedModeBanner: false, + theme: ThemeData( + colorScheme: ColorScheme.fromSeed( + seedColor: selectedColor, + brightness: selectedBrightness, + contrastLevel: selectedContrast, + ), + ), + home: Scaffold( + appBar: AppBar( + title: const Text('ColorScheme'), + actions: [ + SettingsButton( + selectedColor: selectedColor, + selectedBrightness: selectedBrightness, + selectedContrast: selectedContrast, + updateTheme: updateTheme, + ), + ], + ), + body: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.only(top: 5), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Row( + children: List.generate(schemeVariants.length, (int index) { + return ColorSchemeVariantColumn( + selectedColor: selectedColor, + brightness: selectedBrightness, + schemeVariant: schemeVariants[index], + contrastLevel: selectedContrast, + ); + }).toList(), + ), + ), + ], + ), + ), + ), + ), + ); + } +} + +class Settings extends StatefulWidget { + const Settings({ + super.key, + required this.updateTheme, + required this.selectedBrightness, + required this.selectedContrast, + required this.selectedColor, + }); + + final Brightness selectedBrightness; + final double selectedContrast; + final Color selectedColor; + + final void Function(Brightness, Color, double) updateTheme; + + @override + State createState() => _SettingsState(); +} + +class _SettingsState extends State { + late Brightness selectedBrightness = widget.selectedBrightness; + late Color selectedColor = widget.selectedColor; + late double selectedContrast = widget.selectedContrast; + + @override + Widget build(BuildContext context) { + return Theme( + data: Theme.of(context).copyWith( + colorScheme: ColorScheme.fromSeed( + seedColor: selectedColor, + contrastLevel: selectedContrast, + brightness: selectedBrightness, + )), + child: ConstrainedBox( + constraints: const BoxConstraints(maxHeight: 200), + child: Padding( + padding: const EdgeInsets.all(20.0), + child: ListView( + children: [ + Center(child: Text('Settings', style: Theme.of(context).textTheme.titleLarge)), + Row( + children: [ + const Text('Brightness: '), + Switch( + value: selectedBrightness == Brightness.light, + onChanged: (bool value) { + setState(() { + selectedBrightness = value ? Brightness.light : Brightness.dark; + }); + widget.updateTheme(selectedBrightness, selectedColor, selectedContrast); + }, + ) + ], + ), + Wrap(crossAxisAlignment: WrapCrossAlignment.center, children: [ + const Text('Seed color: '), + ...List.generate( + ColorSeed.values.length, + (int index) { + final Color itemColor = ColorSeed.values[index].color; + return IconButton( + icon: selectedColor == ColorSeed.values[index].color + ? Icon(Icons.circle, color: itemColor) + : Icon(Icons.circle_outlined, color: itemColor), + onPressed: () { + setState(() { + selectedColor = itemColor; + }); + widget.updateTheme(selectedBrightness, selectedColor, selectedContrast); + }, + ); + }, + ), + ]), + Row( + children: [ + const Text('Contrast level: '), + Expanded( + child: Slider( + divisions: 4, + label: selectedContrast.toString(), + min: -1, + value: selectedContrast, + onChanged: (double value) { + setState(() { + selectedContrast = value; + }); + widget.updateTheme(selectedBrightness, selectedColor, selectedContrast); + }, + ), + ), + ], + ), + ], + ), + ), + ), + ); + } +} + +class ColorSchemeVariantColumn extends StatelessWidget { + const ColorSchemeVariantColumn({ + super.key, + this.schemeVariant = DynamicSchemeVariant.tonalSpot, + this.brightness = Brightness.light, + this.contrastLevel = 0.0, + required this.selectedColor, + }); + + final DynamicSchemeVariant schemeVariant; + final Brightness brightness; + final double contrastLevel; + final Color selectedColor; + + @override + Widget build(BuildContext context) { + return ConstrainedBox( + constraints: const BoxConstraints.tightFor(width: 250), + child: Column( + children: [ + Padding( + padding: const EdgeInsets.symmetric(vertical: 15), + child: Text( + schemeVariant.name == 'tonalSpot' ? '${schemeVariant.name} (Default)' : schemeVariant.name, + style: const TextStyle(fontWeight: FontWeight.bold), + ), + ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 15), + child: ColorSchemeView( + colorScheme: ColorScheme.fromSeed( + seedColor: selectedColor, + brightness: brightness, + contrastLevel: contrastLevel, + dynamicSchemeVariant: schemeVariant, + ), + ), + ), + ], + ), + ); + } +} + +class ColorSchemeView extends StatelessWidget { + const ColorSchemeView({super.key, required this.colorScheme}); + + final ColorScheme colorScheme; + + @override + Widget build(BuildContext context) { + return Column( + children: [ + ColorGroup(children: [ + ColorChip('primary', colorScheme.primary, colorScheme.onPrimary), + ColorChip('onPrimary', colorScheme.onPrimary, colorScheme.primary), + ColorChip('primaryContainer', colorScheme.primaryContainer, colorScheme.onPrimaryContainer), + ColorChip( + 'onPrimaryContainer', + colorScheme.onPrimaryContainer, + colorScheme.primaryContainer, + ), + ]), + divider, + ColorGroup(children: [ + ColorChip('primaryFixed', colorScheme.primaryFixed, colorScheme.onPrimaryFixed), + ColorChip('onPrimaryFixed', colorScheme.onPrimaryFixed, colorScheme.primaryFixed), + ColorChip('primaryFixedDim', colorScheme.primaryFixedDim, colorScheme.onPrimaryFixedVariant), + ColorChip( + 'onPrimaryFixedVariant', + colorScheme.onPrimaryFixedVariant, + colorScheme.primaryFixedDim, + ), + ]), + divider, + ColorGroup(children: [ + ColorChip('secondary', colorScheme.secondary, colorScheme.onSecondary), + ColorChip('onSecondary', colorScheme.onSecondary, colorScheme.secondary), + ColorChip( + 'secondaryContainer', + colorScheme.secondaryContainer, + colorScheme.onSecondaryContainer, + ), + ColorChip( + 'onSecondaryContainer', + colorScheme.onSecondaryContainer, + colorScheme.secondaryContainer, + ), + ]), + divider, + ColorGroup(children: [ + ColorChip('secondaryFixed', colorScheme.secondaryFixed, colorScheme.onSecondaryFixed), + ColorChip('onSecondaryFixed', colorScheme.onSecondaryFixed, colorScheme.secondaryFixed), + ColorChip( + 'secondaryFixedDim', + colorScheme.secondaryFixedDim, + colorScheme.onSecondaryFixedVariant, + ), + ColorChip( + 'onSecondaryFixedVariant', + colorScheme.onSecondaryFixedVariant, + colorScheme.secondaryFixedDim, + ), + ]), + divider, + ColorGroup( + children: [ + ColorChip('tertiary', colorScheme.tertiary, colorScheme.onTertiary), + ColorChip('onTertiary', colorScheme.onTertiary, colorScheme.tertiary), + ColorChip( + 'tertiaryContainer', + colorScheme.tertiaryContainer, + colorScheme.onTertiaryContainer, + ), + ColorChip( + 'onTertiaryContainer', + colorScheme.onTertiaryContainer, + colorScheme.tertiaryContainer, + ), + ], + ), + divider, + ColorGroup(children: [ + ColorChip('tertiaryFixed', colorScheme.tertiaryFixed, colorScheme.onTertiaryFixed), + ColorChip('onTertiaryFixed', colorScheme.onTertiaryFixed, colorScheme.tertiaryFixed), + ColorChip('tertiaryFixedDim', colorScheme.tertiaryFixedDim, colorScheme.onTertiaryFixedVariant), + ColorChip( + 'onTertiaryFixedVariant', + colorScheme.onTertiaryFixedVariant, + colorScheme.tertiaryFixedDim, + ), + ]), + divider, + ColorGroup( + children: [ + ColorChip('error', colorScheme.error, colorScheme.onError), + ColorChip('onError', colorScheme.onError, colorScheme.error), + ColorChip('errorContainer', colorScheme.errorContainer, colorScheme.onErrorContainer), + ColorChip('onErrorContainer', colorScheme.onErrorContainer, colorScheme.errorContainer), + ], + ), + divider, + ColorGroup( + children: [ + ColorChip('surfaceDim', colorScheme.surfaceDim, colorScheme.onSurface), + ColorChip('surface', colorScheme.surface, colorScheme.onSurface), + ColorChip('surfaceBright', colorScheme.surfaceBright, colorScheme.onSurface), + ColorChip('surfaceContainerLowest', colorScheme.surfaceContainerLowest, colorScheme.onSurface), + ColorChip('surfaceContainerLow', colorScheme.surfaceContainerLow, colorScheme.onSurface), + ColorChip('surfaceContainer', colorScheme.surfaceContainer, colorScheme.onSurface), + ColorChip('surfaceContainerHigh', colorScheme.surfaceContainerHigh, colorScheme.onSurface), + ColorChip('surfaceContainerHighest', colorScheme.surfaceContainerHighest, colorScheme.onSurface), + ColorChip('onSurface', colorScheme.onSurface, colorScheme.surface), + ColorChip( + 'onSurfaceVariant', + colorScheme.onSurfaceVariant, + colorScheme.surfaceContainerHighest, + ), + ], + ), + divider, + ColorGroup( + children: [ + ColorChip('outline', colorScheme.outline, null), + ColorChip('shadow', colorScheme.shadow, null), + ColorChip('inverseSurface', colorScheme.inverseSurface, colorScheme.onInverseSurface), + ColorChip('onInverseSurface', colorScheme.onInverseSurface, colorScheme.inverseSurface), + ColorChip('inversePrimary', colorScheme.inversePrimary, colorScheme.primary), + ], + ), + ], + ); + } +} + +class ColorGroup extends StatelessWidget { + const ColorGroup({super.key, required this.children}); + + final List children; + + @override + Widget build(BuildContext context) { + return RepaintBoundary( + child: Card(clipBehavior: Clip.antiAlias, child: Column(children: children)), + ); + } +} + +class ColorChip extends StatelessWidget { + const ColorChip(this.label, this.color, this.onColor, {super.key}); + + final Color color; + final Color? onColor; + final String label; + + static Color contrastColor(Color color) { + final Brightness brightness = ThemeData.estimateBrightnessForColor(color); + return brightness == Brightness.dark ? Colors.white : Colors.black; + } + + @override + Widget build(BuildContext context) { + final Color labelColor = onColor ?? contrastColor(color); + return ColoredBox( + color: color, + child: Padding( + padding: const EdgeInsets.all(16), + child: Row( + children: [ + Expanded(child: Text(label, style: TextStyle(color: labelColor))), + ], + ), + ), + ); + } +} + +enum ColorSeed { + baseColor('M3 Baseline', Color(0xff6750a4)), + indigo('Indigo', Colors.indigo), + blue('Blue', Colors.blue), + teal('Teal', Colors.teal), + green('Green', Colors.green), + yellow('Yellow', Colors.yellow), + orange('Orange', Colors.orange), + deepOrange('Deep Orange', Colors.deepOrange), + pink('Pink', Colors.pink), + brightBlue('Bright Blue', Color(0xFF0000FF)), + brightGreen('Bright Green', Color(0xFF00FF00)), + brightRed('Bright Red', Color(0xFFFF0000)); + + const ColorSeed(this.label, this.color); + final String label; + final Color color; +} + +class SettingsButton extends StatelessWidget { + const SettingsButton({ + super.key, + required this.updateTheme, + required this.selectedBrightness, + required this.selectedContrast, + required this.selectedColor, + }); + + final Brightness selectedBrightness; + final double selectedContrast; + final Color selectedColor; + + final void Function(Brightness, Color, double) updateTheme; + + @override + Widget build(BuildContext context) { + return IconButton( + icon: const Icon(Icons.settings), + onPressed: () { + showModalBottomSheet( + barrierColor: Colors.transparent, + context: context, + builder: (BuildContext context) { + return Settings( + selectedColor: selectedColor, + selectedBrightness: selectedBrightness, + selectedContrast: selectedContrast, + updateTheme: updateTheme); + }, + ); + }, + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/color_scheme/dynamic_content_color.0.dart b/novelforge-project/flutter/examples/api/lib/material/color_scheme/dynamic_content_color.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..0dad9253839fadb9618528fe41d7df1588c7e534 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/color_scheme/dynamic_content_color.0.dart @@ -0,0 +1,390 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [ColorScheme.fromImageProvider] with content-based dynamic color. + +const Widget divider = SizedBox(height: 10); +const double narrowScreenWidthThreshold = 400; + +void main() => runApp(DynamicColorExample()); + +class DynamicColorExample extends StatefulWidget { + DynamicColorExample({super.key}); + + final List images = [ + const NetworkImage( + 'https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_1.png'), + const NetworkImage( + 'https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_2.png'), + const NetworkImage( + 'https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_3.png'), + const NetworkImage( + 'https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_4.png'), + const NetworkImage( + 'https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_5.png'), + const NetworkImage( + 'https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_6.png'), + ]; + + @override + State createState() => _DynamicColorExampleState(); +} + +class _DynamicColorExampleState extends State { + late ColorScheme currentColorScheme; + String currentHyperlinkImage = ''; + late int selectedImage; + late bool isLight; + late bool isLoading; + + @override + void initState() { + super.initState(); + selectedImage = 0; + isLight = true; + isLoading = true; + currentColorScheme = const ColorScheme.light(); + WidgetsBinding.instance.addPostFrameCallback((_) { + _updateImage(widget.images[selectedImage]); + isLoading = false; + }); + } + + @override + Widget build(BuildContext context) { + final ColorScheme colorScheme = currentColorScheme; + final Color selectedColor = currentColorScheme.primary; + + final ThemeData lightTheme = ThemeData( + colorSchemeSeed: selectedColor, + brightness: Brightness.light, + useMaterial3: false, + ); + final ThemeData darkTheme = ThemeData( + colorSchemeSeed: selectedColor, + brightness: Brightness.dark, + useMaterial3: false, + ); + + Widget schemeLabel(String brightness, ColorScheme colorScheme) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 15), + child: Text( + brightness, + style: TextStyle(fontWeight: FontWeight.bold, color: colorScheme.onSecondaryContainer), + ), + ); + } + + Widget schemeView(ThemeData theme) { + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 15), + child: ColorSchemeView(colorScheme: theme.colorScheme), + ); + } + + return MaterialApp( + theme: ThemeData(useMaterial3: true, colorScheme: colorScheme), + debugShowCheckedModeBanner: false, + home: Builder( + builder: (BuildContext context) => Scaffold( + appBar: AppBar( + title: const Text('Content Based Dynamic Color'), + backgroundColor: colorScheme.primary, + foregroundColor: colorScheme.onPrimary, + actions: [ + const Icon(Icons.light_mode), + Switch( + activeColor: colorScheme.primary, + activeTrackColor: colorScheme.surface, + inactiveTrackColor: colorScheme.onSecondary, + value: isLight, + onChanged: (bool value) { + setState(() { + isLight = value; + _updateImage(widget.images[selectedImage]); + }); + }) + ], + ), + body: Center( + child: isLoading + ? const CircularProgressIndicator() + : ColoredBox( + color: colorScheme.secondaryContainer, + child: Column( + children: [ + divider, + _imagesRow( + context, + widget.images, + colorScheme, + ), + divider, + Expanded( + child: ColoredBox( + color: colorScheme.background, + child: LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) { + if (constraints.maxWidth < narrowScreenWidthThreshold) { + return SingleChildScrollView( + child: Column( + children: [ + divider, + schemeLabel('Light ColorScheme', colorScheme), + schemeView(lightTheme), + divider, + divider, + schemeLabel('Dark ColorScheme', colorScheme), + schemeView(darkTheme), + ], + ), + ); + } else { + return SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.only(top: 5), + child: Column( + children: [ + Row( + children: [ + Expanded( + child: Column( + children: [ + schemeLabel('Light ColorScheme', colorScheme), + schemeView(lightTheme), + ], + ), + ), + Expanded( + child: Column( + children: [ + schemeLabel('Dark ColorScheme', colorScheme), + schemeView(darkTheme), + ], + ), + ), + ], + ), + ], + ), + ), + ); + } + }), + ), + ), + ], + ), + ), + ), + ), + ), + ); + } + + Future _updateImage(ImageProvider provider) async { + final ColorScheme newColorScheme = await ColorScheme.fromImageProvider( + provider: provider, brightness: isLight ? Brightness.light : Brightness.dark); + setState(() { + selectedImage = widget.images.indexOf(provider); + currentColorScheme = newColorScheme; + }); + } + + // For small screens, have two rows of image selection. For wide screens, + // fit them onto one row. + Widget _imagesRow(BuildContext context, List images, ColorScheme colorScheme) { + final double windowHeight = MediaQuery.of(context).size.height; + final double windowWidth = MediaQuery.of(context).size.width; + return Padding( + padding: const EdgeInsets.all(8.0), + child: LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) { + if (constraints.maxWidth > 800) { + return _adaptiveLayoutImagesRow(images, colorScheme, windowHeight); + } else { + return Column(children: [ + _adaptiveLayoutImagesRow(images.sublist(0, 3), colorScheme, windowWidth), + _adaptiveLayoutImagesRow(images.sublist(3), colorScheme, windowWidth), + ]); + } + }), + ); + } + + Widget _adaptiveLayoutImagesRow(List images, ColorScheme colorScheme, double windowWidth) { + return Row( + mainAxisAlignment: MainAxisAlignment.center, + children: images + .map( + (ImageProvider image) => Flexible( + flex: (images.length / 3).floor(), + child: GestureDetector( + onTap: () => _updateImage(image), + child: Card( + color: widget.images.indexOf(image) == selectedImage + ? colorScheme.primaryContainer + : colorScheme.background, + child: Padding( + padding: const EdgeInsets.all(5.0), + child: ConstrainedBox( + constraints: BoxConstraints(maxWidth: windowWidth * .25), + child: ClipRRect( + borderRadius: BorderRadius.circular(8.0), + child: Image(image: image), + ), + ), + ), + ), + ), + ), + ) + .toList(), + ); + } +} + +class ColorSchemeView extends StatelessWidget { + const ColorSchemeView({super.key, required this.colorScheme}); + + final ColorScheme colorScheme; + + @override + Widget build(BuildContext context) { + return Column( + children: [ + ColorGroup(children: [ + ColorChip(label: 'primary', color: colorScheme.primary, onColor: colorScheme.onPrimary), + ColorChip(label: 'onPrimary', color: colorScheme.onPrimary, onColor: colorScheme.primary), + ColorChip( + label: 'primaryContainer', color: colorScheme.primaryContainer, onColor: colorScheme.onPrimaryContainer), + ColorChip( + label: 'onPrimaryContainer', + color: colorScheme.onPrimaryContainer, + onColor: colorScheme.primaryContainer), + ]), + divider, + ColorGroup(children: [ + ColorChip(label: 'secondary', color: colorScheme.secondary, onColor: colorScheme.onSecondary), + ColorChip(label: 'onSecondary', color: colorScheme.onSecondary, onColor: colorScheme.secondary), + ColorChip( + label: 'secondaryContainer', + color: colorScheme.secondaryContainer, + onColor: colorScheme.onSecondaryContainer), + ColorChip( + label: 'onSecondaryContainer', + color: colorScheme.onSecondaryContainer, + onColor: colorScheme.secondaryContainer), + ]), + divider, + ColorGroup( + children: [ + ColorChip(label: 'tertiary', color: colorScheme.tertiary, onColor: colorScheme.onTertiary), + ColorChip(label: 'onTertiary', color: colorScheme.onTertiary, onColor: colorScheme.tertiary), + ColorChip( + label: 'tertiaryContainer', + color: colorScheme.tertiaryContainer, + onColor: colorScheme.onTertiaryContainer), + ColorChip( + label: 'onTertiaryContainer', + color: colorScheme.onTertiaryContainer, + onColor: colorScheme.tertiaryContainer), + ], + ), + divider, + ColorGroup( + children: [ + ColorChip(label: 'error', color: colorScheme.error, onColor: colorScheme.onError), + ColorChip(label: 'onError', color: colorScheme.onError, onColor: colorScheme.error), + ColorChip( + label: 'errorContainer', color: colorScheme.errorContainer, onColor: colorScheme.onErrorContainer), + ColorChip( + label: 'onErrorContainer', color: colorScheme.onErrorContainer, onColor: colorScheme.errorContainer), + ], + ), + divider, + ColorGroup( + children: [ + ColorChip(label: 'background', color: colorScheme.background, onColor: colorScheme.onBackground), + ColorChip(label: 'onBackground', color: colorScheme.onBackground, onColor: colorScheme.background), + ], + ), + divider, + ColorGroup( + children: [ + ColorChip(label: 'surface', color: colorScheme.surface, onColor: colorScheme.onSurface), + ColorChip(label: 'onSurface', color: colorScheme.onSurface, onColor: colorScheme.surface), + ColorChip( + label: 'surfaceVariant', color: colorScheme.surfaceVariant, onColor: colorScheme.onSurfaceVariant), + ColorChip( + label: 'onSurfaceVariant', color: colorScheme.onSurfaceVariant, onColor: colorScheme.surfaceVariant), + ], + ), + divider, + ColorGroup( + children: [ + ColorChip(label: 'outline', color: colorScheme.outline), + ColorChip(label: 'shadow', color: colorScheme.shadow), + ColorChip( + label: 'inverseSurface', color: colorScheme.inverseSurface, onColor: colorScheme.onInverseSurface), + ColorChip( + label: 'onInverseSurface', color: colorScheme.onInverseSurface, onColor: colorScheme.inverseSurface), + ColorChip(label: 'inversePrimary', color: colorScheme.inversePrimary, onColor: colorScheme.primary), + ], + ), + ], + ); + } +} + +class ColorGroup extends StatelessWidget { + const ColorGroup({super.key, required this.children}); + + final List children; + + @override + Widget build(BuildContext context) { + return RepaintBoundary( + child: Card(clipBehavior: Clip.antiAlias, child: Column(children: children)), + ); + } +} + +class ColorChip extends StatelessWidget { + const ColorChip({ + super.key, + required this.color, + required this.label, + this.onColor, + }); + + final Color color; + final Color? onColor; + final String label; + + static Color contrastColor(Color color) { + final Brightness brightness = ThemeData.estimateBrightnessForColor(color); + return switch (brightness) { + Brightness.dark => Colors.white, + Brightness.light => Colors.black, + }; + } + + @override + Widget build(BuildContext context) { + final Color labelColor = onColor ?? contrastColor(color); + return ColoredBox( + color: color, + child: Padding( + padding: const EdgeInsets.all(16), + child: Row( + children: [ + Expanded(child: Text(label, style: TextStyle(color: labelColor))), + ], + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/context_menu/context_menu_controller.0.dart b/novelforge-project/flutter/examples/api/lib/material/context_menu/context_menu_controller.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..99e77ec9353d25cc9373852687dfb03f5c0fc222 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/context_menu/context_menu_controller.0.dart @@ -0,0 +1,183 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This sample demonstrates allowing a context menu to be shown in a widget +// subtree in response to user gestures. + +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +void main() => runApp(const ContextMenuControllerExampleApp()); + +/// A builder that includes an Offset to draw the context menu at. +typedef ContextMenuBuilder = Widget Function(BuildContext context, Offset offset); + +class ContextMenuControllerExampleApp extends StatefulWidget { + const ContextMenuControllerExampleApp({super.key}); + + @override + State createState() => _ContextMenuControllerExampleAppState(); +} + +class _ContextMenuControllerExampleAppState extends State { + void _showDialog(BuildContext context) { + Navigator.of(context).push( + DialogRoute( + context: context, + builder: (BuildContext context) => const AlertDialog(title: Text('You clicked print!')), + ), + ); + } + + @override + void initState() { + super.initState(); + // On web, disable the browser's context menu since this example uses a custom + // Flutter-rendered context menu. + if (kIsWeb) { + BrowserContextMenu.disableContextMenu(); + } + } + + @override + void dispose() { + if (kIsWeb) { + BrowserContextMenu.enableContextMenu(); + } + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Context menu outside of text'), + ), + body: _ContextMenuRegion( + contextMenuBuilder: (BuildContext context, Offset offset) { + // The custom context menu will look like the default context menu + // on the current platform with a single 'Print' button. + return AdaptiveTextSelectionToolbar.buttonItems( + anchors: TextSelectionToolbarAnchors( + primaryAnchor: offset, + ), + buttonItems: [ + ContextMenuButtonItem( + onPressed: () { + ContextMenuController.removeAny(); + _showDialog(context); + }, + label: 'Print', + ), + ], + ); + }, + // In this case this wraps a big open space in a GestureDetector in + // order to show the context menu, but it could also wrap a single + // widget like an Image to give it a context menu. + child: ListView( + children: [ + Container(height: 20.0), + const Text( + 'Right click (desktop) or long press (mobile) anywhere, not just on this text, to show the custom menu.'), + ], + ), + ), + ), + ); + } +} + +/// Shows and hides the context menu based on user gestures. +/// +/// By default, shows the menu on right clicks and long presses. +class _ContextMenuRegion extends StatefulWidget { + /// Creates an instance of [_ContextMenuRegion]. + const _ContextMenuRegion({ + required this.child, + required this.contextMenuBuilder, + }); + + /// Builds the context menu. + final ContextMenuBuilder contextMenuBuilder; + + /// The child widget that will be listened to for gestures. + final Widget child; + + @override + State<_ContextMenuRegion> createState() => _ContextMenuRegionState(); +} + +class _ContextMenuRegionState extends State<_ContextMenuRegion> { + Offset? _longPressOffset; + + final ContextMenuController _contextMenuController = ContextMenuController(); + + static bool get _longPressEnabled { + switch (defaultTargetPlatform) { + case TargetPlatform.android: + case TargetPlatform.iOS: + return true; + case TargetPlatform.macOS: + case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: + return false; + } + } + + void _onSecondaryTapUp(TapUpDetails details) { + _show(details.globalPosition); + } + + void _onTap() { + if (!_contextMenuController.isShown) { + return; + } + _hide(); + } + + void _onLongPressStart(LongPressStartDetails details) { + _longPressOffset = details.globalPosition; + } + + void _onLongPress() { + assert(_longPressOffset != null); + _show(_longPressOffset!); + _longPressOffset = null; + } + + void _show(Offset position) { + _contextMenuController.show( + context: context, + contextMenuBuilder: (BuildContext context) { + return widget.contextMenuBuilder(context, position); + }, + ); + } + + void _hide() { + _contextMenuController.remove(); + } + + @override + void dispose() { + _hide(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return GestureDetector( + behavior: HitTestBehavior.opaque, + onSecondaryTapUp: _onSecondaryTapUp, + onTap: _onTap, + onLongPress: _longPressEnabled ? _onLongPress : null, + onLongPressStart: _longPressEnabled ? _onLongPressStart : null, + child: widget.child, + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/context_menu/editable_text_toolbar_builder.0.dart b/novelforge-project/flutter/examples/api/lib/material/context_menu/editable_text_toolbar_builder.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..138c14d4689cd3ed0ea74836091302759e13792e --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/context_menu/editable_text_toolbar_builder.0.dart @@ -0,0 +1,89 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This example demonstrates showing the default buttons, but customizing their +// appearance. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +void main() => runApp(const EditableTextToolbarBuilderExampleApp()); + +class EditableTextToolbarBuilderExampleApp extends StatefulWidget { + const EditableTextToolbarBuilderExampleApp({super.key}); + + @override + State createState() => _EditableTextToolbarBuilderExampleAppState(); +} + +class _EditableTextToolbarBuilderExampleAppState extends State { + final TextEditingController _controller = TextEditingController( + text: 'Right click (desktop) or long press (mobile) to see the menu with custom buttons.', + ); + + @override + void initState() { + super.initState(); + // On web, disable the browser's context menu since this example uses a custom + // Flutter-rendered context menu. + if (kIsWeb) { + BrowserContextMenu.disableContextMenu(); + } + } + + @override + void dispose() { + if (kIsWeb) { + BrowserContextMenu.enableContextMenu(); + } + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Custom button appearance'), + ), + body: Center( + child: Column( + children: [ + const SizedBox(height: 20.0), + TextField( + controller: _controller, + contextMenuBuilder: (BuildContext context, EditableTextState editableTextState) { + return AdaptiveTextSelectionToolbar( + anchors: editableTextState.contextMenuAnchors, + // Build the default buttons, but make them look custom. + // In a real project you may want to build different + // buttons depending on the platform. + children: editableTextState.contextMenuButtonItems.map((ContextMenuButtonItem buttonItem) { + return CupertinoButton( + borderRadius: null, + color: const Color(0xffaaaa00), + disabledColor: const Color(0xffaaaaff), + onPressed: buttonItem.onPressed, + padding: const EdgeInsets.all(10.0), + pressedOpacity: 0.7, + child: SizedBox( + width: 200.0, + child: Text( + CupertinoTextSelectionToolbarButton.getButtonLabel(context, buttonItem), + ), + ), + ); + }).toList(), + ); + }, + ), + ], + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/context_menu/editable_text_toolbar_builder.1.dart b/novelforge-project/flutter/examples/api/lib/material/context_menu/editable_text_toolbar_builder.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..c7c16f05e7a9a5453d7f131a8230d69621ad5026 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/context_menu/editable_text_toolbar_builder.1.dart @@ -0,0 +1,109 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This example demonstrates showing a custom context menu only when some +// narrowly defined text is selected. + +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +void main() => runApp(const EditableTextToolbarBuilderExampleApp()); + +const String emailAddress = 'me@example.com'; +const String text = 'Select the email address and open the menu: $emailAddress'; + +class EditableTextToolbarBuilderExampleApp extends StatefulWidget { + const EditableTextToolbarBuilderExampleApp({super.key}); + + @override + State createState() => _EditableTextToolbarBuilderExampleAppState(); +} + +class _EditableTextToolbarBuilderExampleAppState extends State { + final TextEditingController _controller = TextEditingController( + text: text, + ); + + void _showDialog(BuildContext context) { + Navigator.of(context).push( + DialogRoute( + context: context, + builder: (BuildContext context) => const AlertDialog(title: Text('You clicked send email!')), + ), + ); + } + + @override + void initState() { + super.initState(); + // On web, disable the browser's context menu since this example uses a custom + // Flutter-rendered context menu. + if (kIsWeb) { + BrowserContextMenu.disableContextMenu(); + } + } + + @override + void dispose() { + if (kIsWeb) { + BrowserContextMenu.enableContextMenu(); + } + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Custom button for emails'), + ), + body: Center( + child: Column( + children: [ + Container(height: 20.0), + TextField( + controller: _controller, + contextMenuBuilder: (BuildContext context, EditableTextState editableTextState) { + final List buttonItems = editableTextState.contextMenuButtonItems; + // Here we add an "Email" button to the default TextField + // context menu for the current platform, but only if an email + // address is currently selected. + final TextEditingValue value = _controller.value; + if (_isValidEmail(value.selection.textInside(value.text))) { + buttonItems.insert( + 0, + ContextMenuButtonItem( + label: 'Send email', + onPressed: () { + ContextMenuController.removeAny(); + _showDialog(context); + }, + ), + ); + } + return AdaptiveTextSelectionToolbar.buttonItems( + anchors: editableTextState.contextMenuAnchors, + buttonItems: buttonItems, + ); + }, + ), + ], + ), + ), + ), + ); + } +} + +bool _isValidEmail(String text) { + return RegExp( + r'(?[a-zA-Z0-9]+)' + r'@' + r'(?[a-zA-Z0-9]+)' + r'\.' + r'(?[a-zA-Z0-9]+)', + ).hasMatch(text); +} diff --git a/novelforge-project/flutter/examples/api/lib/material/context_menu/editable_text_toolbar_builder.2.dart b/novelforge-project/flutter/examples/api/lib/material/context_menu/editable_text_toolbar_builder.2.dart new file mode 100644 index 0000000000000000000000000000000000000000..25fa23637c7b88c12869de1ecad45485dcaaf0d8 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/context_menu/editable_text_toolbar_builder.2.dart @@ -0,0 +1,132 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This example demonstrates how to create a custom toolbar that retains the +// look of the default buttons for the current platform. + +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +void main() => runApp(const EditableTextToolbarBuilderExampleApp()); + +class EditableTextToolbarBuilderExampleApp extends StatefulWidget { + const EditableTextToolbarBuilderExampleApp({super.key}); + + @override + State createState() => _EditableTextToolbarBuilderExampleAppState(); +} + +class _EditableTextToolbarBuilderExampleAppState extends State { + final TextEditingController _controller = TextEditingController( + text: 'Right click (desktop) or long press (mobile) to see the menu with a custom toolbar.', + ); + + @override + void initState() { + super.initState(); + // On web, disable the browser's context menu since this example uses a custom + // Flutter-rendered context menu. + if (kIsWeb) { + BrowserContextMenu.disableContextMenu(); + } + } + + @override + void dispose() { + if (kIsWeb) { + BrowserContextMenu.enableContextMenu(); + } + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Custom toolbar, default-looking buttons'), + ), + body: Center( + child: Column( + children: [ + const SizedBox(height: 20.0), + TextField( + controller: _controller, + contextMenuBuilder: (BuildContext context, EditableTextState editableTextState) { + return _MyTextSelectionToolbar( + anchor: editableTextState.contextMenuAnchors.primaryAnchor, + // getAdaptiveButtons creates the default button widgets for + // the current platform. + children: AdaptiveTextSelectionToolbar.getAdaptiveButtons( + context, + // These buttons just close the menu when clicked. + [ + ContextMenuButtonItem( + label: 'One', + onPressed: () => ContextMenuController.removeAny(), + ), + ContextMenuButtonItem( + label: 'Two', + onPressed: () => ContextMenuController.removeAny(), + ), + ContextMenuButtonItem( + label: 'Three', + onPressed: () => ContextMenuController.removeAny(), + ), + ContextMenuButtonItem( + label: 'Four', + onPressed: () => ContextMenuController.removeAny(), + ), + ContextMenuButtonItem( + label: 'Five', + onPressed: () => ContextMenuController.removeAny(), + ), + ], + ).toList(), + ); + }, + ), + ], + ), + ), + ), + ); + } +} + +/// A simple, yet totally custom, text selection toolbar. +/// +/// Displays its children in a scrollable grid. +class _MyTextSelectionToolbar extends StatelessWidget { + const _MyTextSelectionToolbar({ + required this.anchor, + required this.children, + }); + + final Offset anchor; + final List children; + + @override + Widget build(BuildContext context) { + return Stack( + children: [ + Positioned( + top: anchor.dy, + left: anchor.dx, + child: Container( + width: 200.0, + height: 200.0, + color: Colors.cyanAccent.withOpacity(0.5), + child: GridView.count( + padding: const EdgeInsets.all(12.0), + crossAxisCount: 2, + children: children, + ), + ), + ), + ], + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/context_menu/selectable_region_toolbar_builder.0.dart b/novelforge-project/flutter/examples/api/lib/material/context_menu/selectable_region_toolbar_builder.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..a63b625c42687199156b95bed4023b850a54532d --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/context_menu/selectable_region_toolbar_builder.0.dart @@ -0,0 +1,93 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This example demonstrates a custom context menu in non-editable text using +// SelectionArea. + +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +void main() => runApp(const SelectableRegionToolbarBuilderExampleApp()); + +const String text = + 'I am some text inside of SelectionArea. Right click (desktop) or long press (mobile) me to show the customized context menu.'; + +class SelectableRegionToolbarBuilderExampleApp extends StatefulWidget { + const SelectableRegionToolbarBuilderExampleApp({super.key}); + + @override + State createState() => _SelectableRegionToolbarBuilderExampleAppState(); +} + +class _SelectableRegionToolbarBuilderExampleAppState extends State { + void _showDialog(BuildContext context) { + Navigator.of(context).push( + DialogRoute( + context: context, + builder: (BuildContext context) => const AlertDialog(title: Text('You clicked print!')), + ), + ); + } + + @override + void initState() { + super.initState(); + // On web, disable the browser's context menu since this example uses a custom + // Flutter-rendered context menu. + if (kIsWeb) { + BrowserContextMenu.disableContextMenu(); + } + } + + @override + void dispose() { + if (kIsWeb) { + BrowserContextMenu.enableContextMenu(); + } + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Context menu anywhere'), + ), + body: Center( + child: SizedBox( + width: 200.0, + child: SelectionArea( + contextMenuBuilder: ( + BuildContext context, + SelectableRegionState selectableRegionState, + ) { + return AdaptiveTextSelectionToolbar.buttonItems( + anchors: selectableRegionState.contextMenuAnchors, + buttonItems: [ + ...selectableRegionState.contextMenuButtonItems, + ContextMenuButtonItem( + onPressed: () { + ContextMenuController.removeAny(); + _showDialog(context); + }, + label: 'Print', + ), + ], + ); + }, + child: ListView( + children: const [ + SizedBox(height: 20.0), + Text(text), + ], + ), + ), + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/data_table/data_table.0.dart b/novelforge-project/flutter/examples/api/lib/material/data_table/data_table.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..2d1ff244bc803df54d4e25410d413fc4c8262e4c --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/data_table/data_table.0.dart @@ -0,0 +1,82 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [DataTable]. + +void main() => runApp(const DataTableExampleApp()); + +class DataTableExampleApp extends StatelessWidget { + const DataTableExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('DataTable Sample')), + body: const DataTableExample(), + ), + ); + } +} + +class DataTableExample extends StatelessWidget { + const DataTableExample({super.key}); + + @override + Widget build(BuildContext context) { + return DataTable( + columns: const [ + DataColumn( + label: Expanded( + child: Text( + 'Name', + style: TextStyle(fontStyle: FontStyle.italic), + ), + ), + ), + DataColumn( + label: Expanded( + child: Text( + 'Age', + style: TextStyle(fontStyle: FontStyle.italic), + ), + ), + ), + DataColumn( + label: Expanded( + child: Text( + 'Role', + style: TextStyle(fontStyle: FontStyle.italic), + ), + ), + ), + ], + rows: const [ + DataRow( + cells: [ + DataCell(Text('Sarah')), + DataCell(Text('19')), + DataCell(Text('Student')), + ], + ), + DataRow( + cells: [ + DataCell(Text('Janine')), + DataCell(Text('43')), + DataCell(Text('Professor')), + ], + ), + DataRow( + cells: [ + DataCell(Text('William')), + DataCell(Text('27')), + DataCell(Text('Associate Professor')), + ], + ), + ], + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/data_table/data_table.1.dart b/novelforge-project/flutter/examples/api/lib/material/data_table/data_table.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..36690d3617496fdc04f33f68d3805759a97c12c0 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/data_table/data_table.1.dart @@ -0,0 +1,71 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [DataTable]. + +void main() => runApp(const DataTableExampleApp()); + +class DataTableExampleApp extends StatelessWidget { + const DataTableExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('DataTable Sample')), + body: const DataTableExample(), + ), + ); + } +} + +class DataTableExample extends StatefulWidget { + const DataTableExample({super.key}); + + @override + State createState() => _DataTableExampleState(); +} + +class _DataTableExampleState extends State { + static const int numItems = 20; + List selected = List.generate(numItems, (int index) => false); + + @override + Widget build(BuildContext context) { + return SingleChildScrollView( + child: DataTable( + columns: const [ + DataColumn( + label: Text('Number'), + ), + ], + rows: List.generate( + numItems, + (int index) => DataRow( + color: MaterialStateProperty.resolveWith((Set states) { + // All rows will have the same selected color. + if (states.contains(MaterialState.selected)) { + return Theme.of(context).colorScheme.primary.withOpacity(0.08); + } + // Even rows will have a grey color. + if (index.isEven) { + return Colors.grey.withOpacity(0.3); + } + return null; // Use default value for other states and odd rows. + }), + cells: [DataCell(Text('Row $index'))], + selected: selected[index], + onSelectChanged: (bool? value) { + setState(() { + selected[index] = value!; + }); + }, + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/date_picker/date_picker_theme_day_shape.0.dart b/novelforge-project/flutter/examples/api/lib/material/date_picker/date_picker_theme_day_shape.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..41cd9812df266844def02514f4856a3509aa0b2d --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/date_picker/date_picker_theme_day_shape.0.dart @@ -0,0 +1,64 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [DatePickerThemeData]. + +void main() => runApp(const DatePickerApp()); + +class DatePickerApp extends StatelessWidget { + const DatePickerApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData( + datePickerTheme: DatePickerThemeData( + todayBackgroundColor: const MaterialStatePropertyAll(Colors.amber), + todayForegroundColor: const MaterialStatePropertyAll(Colors.black), + todayBorder: const BorderSide(width: 2), + dayShape: MaterialStatePropertyAll( + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8.0), + ), + ), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16.0), + ), + ), + ), + home: const DatePickerExample(), + ); + } +} + +class DatePickerExample extends StatefulWidget { + const DatePickerExample({super.key}); + + @override + State createState() => _DatePickerExampleState(); +} + +class _DatePickerExampleState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: OutlinedButton( + onPressed: () { + showDatePicker( + context: context, + initialDate: DateTime(2021, 1, 20), + currentDate: DateTime(2021, 1, 15), + firstDate: DateTime(2021), + lastDate: DateTime(2022), + ); + }, + child: const Text('Open Date Picker'), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/date_picker/show_date_picker.0.dart b/novelforge-project/flutter/examples/api/lib/material/date_picker/show_date_picker.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..cd6b8d5fae194dcc0a70293c3499bda4fbff77d0 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/date_picker/show_date_picker.0.dart @@ -0,0 +1,101 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [showDatePicker]. + +void main() => runApp(const DatePickerApp()); + +class DatePickerApp extends StatelessWidget { + const DatePickerApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData(useMaterial3: true), + restorationScopeId: 'app', + home: const DatePickerExample(restorationId: 'main'), + ); + } +} + +class DatePickerExample extends StatefulWidget { + const DatePickerExample({super.key, this.restorationId}); + + final String? restorationId; + + @override + State createState() => _DatePickerExampleState(); +} + +/// RestorationProperty objects can be used because of RestorationMixin. +class _DatePickerExampleState extends State with RestorationMixin { + // In this example, the restoration ID for the mixin is passed in through + // the [StatefulWidget]'s constructor. + @override + String? get restorationId => widget.restorationId; + + final RestorableDateTime _selectedDate = RestorableDateTime(DateTime(2021, 7, 25)); + late final RestorableRouteFuture _restorableDatePickerRouteFuture = RestorableRouteFuture( + onComplete: _selectDate, + onPresent: (NavigatorState navigator, Object? arguments) { + return navigator.restorablePush( + _datePickerRoute, + arguments: _selectedDate.value.millisecondsSinceEpoch, + ); + }, + ); + + @pragma('vm:entry-point') + static Route _datePickerRoute( + BuildContext context, + Object? arguments, + ) { + return DialogRoute( + context: context, + builder: (BuildContext context) { + return DatePickerDialog( + restorationId: 'date_picker_dialog', + initialEntryMode: DatePickerEntryMode.calendarOnly, + initialDate: DateTime.fromMillisecondsSinceEpoch(arguments! as int), + firstDate: DateTime(2021), + lastDate: DateTime(2022), + ); + }, + ); + } + + @override + void restoreState(RestorationBucket? oldBucket, bool initialRestore) { + registerForRestoration(_selectedDate, 'selected_date'); + registerForRestoration(_restorableDatePickerRouteFuture, 'date_picker_route_future'); + } + + void _selectDate(DateTime? newSelectedDate) { + if (newSelectedDate != null) { + setState(() { + _selectedDate.value = newSelectedDate; + ScaffoldMessenger.of(context).showSnackBar(SnackBar( + content: + Text('Selected: ${_selectedDate.value.day}/${_selectedDate.value.month}/${_selectedDate.value.year}'), + )); + }); + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: OutlinedButton( + onPressed: () { + _restorableDatePickerRouteFuture.present(); + }, + child: const Text('Open Date Picker'), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/date_picker/show_date_range_picker.0.dart b/novelforge-project/flutter/examples/api/lib/material/date_picker/show_date_range_picker.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..9efd6d037c3838190e21526047e4901b3dac816a --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/date_picker/show_date_range_picker.0.dart @@ -0,0 +1,112 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [showDateRangePicker]. + +void main() => runApp(const DatePickerApp()); + +class DatePickerApp extends StatelessWidget { + const DatePickerApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData(useMaterial3: true), + restorationScopeId: 'app', + home: const DatePickerExample(restorationId: 'main'), + ); + } +} + +class DatePickerExample extends StatefulWidget { + const DatePickerExample({super.key, this.restorationId}); + + final String? restorationId; + + @override + State createState() => _DatePickerExampleState(); +} + +/// RestorationProperty objects can be used because of RestorationMixin. +class _DatePickerExampleState extends State with RestorationMixin { + // In this example, the restoration ID for the mixin is passed in through + // the [StatefulWidget]'s constructor. + @override + String? get restorationId => widget.restorationId; + + final RestorableDateTimeN _startDate = RestorableDateTimeN(DateTime(2021)); + final RestorableDateTimeN _endDate = RestorableDateTimeN(DateTime(2021, 1, 5)); + late final RestorableRouteFuture _restorableDateRangePickerRouteFuture = + RestorableRouteFuture( + onComplete: _selectDateRange, + onPresent: (NavigatorState navigator, Object? arguments) { + return navigator.restorablePush(_dateRangePickerRoute, arguments: { + 'initialStartDate': _startDate.value?.millisecondsSinceEpoch, + 'initialEndDate': _endDate.value?.millisecondsSinceEpoch, + }); + }, + ); + + void _selectDateRange(DateTimeRange? newSelectedDate) { + if (newSelectedDate != null) { + setState(() { + _startDate.value = newSelectedDate.start; + _endDate.value = newSelectedDate.end; + }); + } + } + + @override + void restoreState(RestorationBucket? oldBucket, bool initialRestore) { + registerForRestoration(_startDate, 'start_date'); + registerForRestoration(_endDate, 'end_date'); + registerForRestoration(_restorableDateRangePickerRouteFuture, 'date_picker_route_future'); + } + + @pragma('vm:entry-point') + static Route _dateRangePickerRoute( + BuildContext context, + Object? arguments, + ) { + return DialogRoute( + context: context, + builder: (BuildContext context) { + return DateRangePickerDialog( + restorationId: 'date_picker_dialog', + initialDateRange: _initialDateTimeRange(arguments! as Map), + firstDate: DateTime(2021), + currentDate: DateTime(2021, 1, 25), + lastDate: DateTime(2022), + ); + }, + ); + } + + static DateTimeRange? _initialDateTimeRange(Map arguments) { + if (arguments['initialStartDate'] != null && arguments['initialEndDate'] != null) { + return DateTimeRange( + start: DateTime.fromMillisecondsSinceEpoch(arguments['initialStartDate'] as int), + end: DateTime.fromMillisecondsSinceEpoch(arguments['initialEndDate'] as int), + ); + } + + return null; + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: OutlinedButton( + onPressed: () { + _restorableDateRangePickerRouteFuture.present(); + }, + child: const Text('Open Date Range Picker'), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/dialog/adaptive_alert_dialog.0.dart b/novelforge-project/flutter/examples/api/lib/material/dialog/adaptive_alert_dialog.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..08b760cfb313d5d27b5ebd67eaae555fda43a2a2 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/dialog/adaptive_alert_dialog.0.dart @@ -0,0 +1,76 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +/// Flutter code sample for [AlertDialog]. + +void main() => runApp(const AdaptiveAlertDialogApp()); + +class AdaptiveAlertDialogApp extends StatelessWidget { + const AdaptiveAlertDialogApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + // Try this: set the platform to TargetPlatform.android and see the difference + theme: ThemeData(platform: TargetPlatform.iOS, useMaterial3: true), + home: Scaffold( + appBar: AppBar(title: const Text('AlertDialog Sample')), + body: const Center( + child: AdaptiveDialogExample(), + ), + ), + ); + } +} + +class AdaptiveDialogExample extends StatelessWidget { + const AdaptiveDialogExample({super.key}); + + Widget adaptiveAction({ + required BuildContext context, + required VoidCallback onPressed, + required Widget child + }) { + final ThemeData theme = Theme.of(context); + switch (theme.platform) { + case TargetPlatform.android: + case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: + return TextButton(onPressed: onPressed, child: child); + case TargetPlatform.iOS: + case TargetPlatform.macOS: + return CupertinoDialogAction(onPressed: onPressed, child: child); + } + } + + @override + Widget build(BuildContext context) { + return TextButton( + onPressed: () => showAdaptiveDialog( + context: context, + builder: (BuildContext context) => AlertDialog.adaptive( + title: const Text('AlertDialog Title'), + content: const Text('AlertDialog description'), + actions: [ + adaptiveAction( + context: context, + onPressed: () => Navigator.pop(context, 'Cancel'), + child: const Text('Cancel'), + ), + adaptiveAction( + context: context, + onPressed: () => Navigator.pop(context, 'OK'), + child: const Text('OK'), + ), + ], + ), + ), + child: const Text('Show Dialog'), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/dialog/alert_dialog.0.dart b/novelforge-project/flutter/examples/api/lib/material/dialog/alert_dialog.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..82b0708bbe76c588a93dc003f2f31c80de435759 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/dialog/alert_dialog.0.dart @@ -0,0 +1,53 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [AlertDialog]. + +void main() => runApp(const AlertDialogExampleApp()); + +class AlertDialogExampleApp extends StatelessWidget { + const AlertDialogExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('AlertDialog Sample')), + body: const Center( + child: DialogExample(), + ), + ), + ); + } +} + +class DialogExample extends StatelessWidget { + const DialogExample({super.key}); + + @override + Widget build(BuildContext context) { + return TextButton( + onPressed: () => showDialog( + context: context, + builder: (BuildContext context) => AlertDialog( + title: const Text('AlertDialog Title'), + content: const Text('AlertDialog description'), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context, 'Cancel'), + child: const Text('Cancel'), + ), + TextButton( + onPressed: () => Navigator.pop(context, 'OK'), + child: const Text('OK'), + ), + ], + ), + ), + child: const Text('Show Dialog'), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/dialog/alert_dialog.1.dart b/novelforge-project/flutter/examples/api/lib/material/dialog/alert_dialog.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..0785b5ed09d64c7dca464c17434810d0f00c6c95 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/dialog/alert_dialog.1.dart @@ -0,0 +1,54 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [AlertDialog]. + +void main() => runApp(const AlertDialogExampleApp()); + +class AlertDialogExampleApp extends StatelessWidget { + const AlertDialogExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData(colorSchemeSeed: const Color(0xff6750a4), useMaterial3: true), + home: Scaffold( + appBar: AppBar(title: const Text('AlertDialog Sample')), + body: const Center( + child: DialogExample(), + ), + ), + ); + } +} + +class DialogExample extends StatelessWidget { + const DialogExample({super.key}); + + @override + Widget build(BuildContext context) { + return TextButton( + onPressed: () => showDialog( + context: context, + builder: (BuildContext context) => AlertDialog( + title: const Text('AlertDialog Title'), + content: const Text('AlertDialog description'), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context, 'Cancel'), + child: const Text('Cancel'), + ), + TextButton( + onPressed: () => Navigator.pop(context, 'OK'), + child: const Text('OK'), + ), + ], + ), + ), + child: const Text('Show Dialog'), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/dialog/dialog.0.dart b/novelforge-project/flutter/examples/api/lib/material/dialog/dialog.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..4dbda85c56dfec8e8d6dce9b9fa4519fca3e3d8c --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/dialog/dialog.0.dart @@ -0,0 +1,86 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Dialog]. + +void main() => runApp(const DialogExampleApp()); + +class DialogExampleApp extends StatelessWidget { + const DialogExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('Dialog Sample')), + body: const Center( + child: DialogExample(), + ), + ), + ); + } +} + +class DialogExample extends StatelessWidget { + const DialogExample({super.key}); + + @override + Widget build(BuildContext context) { + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + TextButton( + onPressed: () => showDialog( + context: context, + builder: (BuildContext context) => Dialog( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text('This is a typical dialog.'), + const SizedBox(height: 15), + TextButton( + onPressed: () { + Navigator.pop(context); + }, + child: const Text('Close'), + ), + ], + ), + ), + ), + ), + child: const Text('Show Dialog'), + ), + const SizedBox(height: 10), + TextButton( + onPressed: () => showDialog( + context: context, + builder: (BuildContext context) => Dialog.fullscreen( + child: Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text('This is a fullscreen dialog.'), + const SizedBox(height: 15), + TextButton( + onPressed: () { + Navigator.pop(context); + }, + child: const Text('Close'), + ), + ], + ), + ), + ), + child: const Text('Show Fullscreen Dialog'), + ), + ], + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/dialog/show_dialog.0.dart b/novelforge-project/flutter/examples/api/lib/material/dialog/show_dialog.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..614e40b3503af9a5a399f08f807efd9a6c99d008 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/dialog/show_dialog.0.dart @@ -0,0 +1,74 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [showDialog]. + +void main() => runApp(const ShowDialogExampleApp()); + +class ShowDialogExampleApp extends StatelessWidget { + const ShowDialogExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: DialogExample(), + ); + } +} + +class DialogExample extends StatelessWidget { + const DialogExample({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: const Text('showDialog Sample')), + body: Center( + child: OutlinedButton( + onPressed: () => _dialogBuilder(context), + child: const Text('Open Dialog'), + ), + ), + ); + } + + Future _dialogBuilder(BuildContext context) { + return showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Basic dialog title'), + content: const Text( + 'A dialog is a type of modal window that\n' + 'appears in front of app content to\n' + 'provide critical information, or prompt\n' + 'for a decision to be made.', + ), + actions: [ + TextButton( + style: TextButton.styleFrom( + textStyle: Theme.of(context).textTheme.labelLarge, + ), + child: const Text('Disable'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + TextButton( + style: TextButton.styleFrom( + textStyle: Theme.of(context).textTheme.labelLarge, + ), + child: const Text('Enable'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/dialog/show_dialog.1.dart b/novelforge-project/flutter/examples/api/lib/material/dialog/show_dialog.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..73b6807da31c0c92cc2ac6146f4cdbf165d32efe --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/dialog/show_dialog.1.dart @@ -0,0 +1,75 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [showDialog]. + +void main() => runApp(const ShowDialogExampleApp()); + +class ShowDialogExampleApp extends StatelessWidget { + const ShowDialogExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData(colorSchemeSeed: const Color(0xff6750a4), useMaterial3: true), + home: const DialogExample(), + ); + } +} + +class DialogExample extends StatelessWidget { + const DialogExample({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: const Text('showDialog Sample')), + body: Center( + child: OutlinedButton( + onPressed: () => _dialogBuilder(context), + child: const Text('Open Dialog'), + ), + ), + ); + } + + Future _dialogBuilder(BuildContext context) { + return showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Basic dialog title'), + content: const Text( + 'A dialog is a type of modal window that\n' + 'appears in front of app content to\n' + 'provide critical information, or prompt\n' + 'for a decision to be made.', + ), + actions: [ + TextButton( + style: TextButton.styleFrom( + textStyle: Theme.of(context).textTheme.labelLarge, + ), + child: const Text('Disable'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + TextButton( + style: TextButton.styleFrom( + textStyle: Theme.of(context).textTheme.labelLarge, + ), + child: const Text('Enable'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/dialog/show_dialog.2.dart b/novelforge-project/flutter/examples/api/lib/material/dialog/show_dialog.2.dart new file mode 100644 index 0000000000000000000000000000000000000000..f76a84ea618301790e23fd18fbd6c46f470862ed --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/dialog/show_dialog.2.dart @@ -0,0 +1,78 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [showDialog]. + +void main() => runApp(const ShowDialogExampleApp()); + +class ShowDialogExampleApp extends StatelessWidget { + const ShowDialogExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + restorationScopeId: 'app', + home: DialogExample(), + ); + } +} + +class DialogExample extends StatelessWidget { + const DialogExample({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: const Text('AlertDialog Sample')), + body: Center( + child: OutlinedButton( + onPressed: () { + Navigator.of(context).restorablePush(_dialogBuilder); + }, + child: const Text('Open Dialog'), + ), + ), + ); + } + + @pragma('vm:entry-point') + static Route _dialogBuilder(BuildContext context, Object? arguments) { + return DialogRoute( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Basic dialog title'), + content: const Text( + 'A dialog is a type of modal window that\n' + 'appears in front of app content to\n' + 'provide critical information, or prompt\n' + 'for a decision to be made.', + ), + actions: [ + TextButton( + style: TextButton.styleFrom( + textStyle: Theme.of(context).textTheme.labelLarge, + ), + child: const Text('Disable'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + TextButton( + style: TextButton.styleFrom( + textStyle: Theme.of(context).textTheme.labelLarge, + ), + child: const Text('Enable'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/divider/divider.0.dart b/novelforge-project/flutter/examples/api/lib/material/divider/divider.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..15cb5af017644c0227814052f4711056ac0dab10 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/divider/divider.0.dart @@ -0,0 +1,73 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Divider]. + +void main() => runApp(const DividerExampleApp()); + +class DividerExampleApp extends StatelessWidget { + const DividerExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('Divider Sample')), + body: const DividerExample(), + ), + ); + } +} + +class DividerExample extends StatelessWidget { + const DividerExample({super.key}); + + @override + Widget build(BuildContext context) { + return Center( + child: Column( + children: [ + const Expanded( + child: ColoredBox( + color: Colors.amber, + child: Center( + child: Text('Above'), + ), + ), + ), + const Divider( + height: 20, + thickness: 5, + indent: 20, + endIndent: 0, + color: Colors.black, + ), + // Subheader example from Material spec. + // https://material.io/components/dividers#types + Container( + padding: const EdgeInsets.only(left: 20), + child: Align( + alignment: AlignmentDirectional.centerStart, + child: Text( + 'Subheader', + style: Theme.of(context).textTheme.bodySmall, + textAlign: TextAlign.start, + ), + ), + ), + Expanded( + child: ColoredBox( + color: Theme.of(context).colorScheme.primary, + child: const Center( + child: Text('Below'), + ), + ), + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/divider/divider.1.dart b/novelforge-project/flutter/examples/api/lib/material/divider/divider.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..ae91b18d013d0a53d7eb3e3991ae5bd3da8c55fb --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/divider/divider.1.dart @@ -0,0 +1,52 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Divider]. + +void main() => runApp(const DividerExampleApp()); + +class DividerExampleApp extends StatelessWidget { + const DividerExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData(colorSchemeSeed: const Color(0xff6750a4), useMaterial3: true), + home: Scaffold( + appBar: AppBar(title: const Text('Divider Sample')), + body: const DividerExample(), + ), + ); + } +} + +class DividerExample extends StatelessWidget { + const DividerExample({super.key}); + + @override + Widget build(BuildContext context) { + return const Center( + child: Padding( + padding: EdgeInsets.all(16.0), + child: Column( + children: [ + Expanded( + child: Card( + child: SizedBox.expand(), + ), + ), + Divider(), + Expanded( + child: Card( + child: SizedBox.expand(), + ), + ), + ], + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/divider/vertical_divider.0.dart b/novelforge-project/flutter/examples/api/lib/material/divider/vertical_divider.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..cf1c9887558c248adb80598dfdd31fbd15978ae8 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/divider/vertical_divider.0.dart @@ -0,0 +1,61 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [VerticalDivider]. + +void main() => runApp(const VerticalDividerExampleApp()); + +class VerticalDividerExampleApp extends StatelessWidget { + const VerticalDividerExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('VerticalDivider Sample')), + body: const DividerExample(), + ), + ); + } +} + +class DividerExample extends StatelessWidget { + const DividerExample({super.key}); + + @override + Widget build(BuildContext context) { + return Container( + padding: const EdgeInsets.all(10), + child: Row( + children: [ + Expanded( + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.deepPurpleAccent, + ), + ), + ), + const VerticalDivider( + width: 20, + thickness: 1, + indent: 20, + endIndent: 0, + color: Colors.grey, + ), + Expanded( + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.deepOrangeAccent, + ), + ), + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/divider/vertical_divider.1.dart b/novelforge-project/flutter/examples/api/lib/material/divider/vertical_divider.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..a272b7e62e1cdcae0c2de542d735dcfad3e5ad65 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/divider/vertical_divider.1.dart @@ -0,0 +1,52 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Divider]. + +void main() => runApp(const VerticalDividerExampleApp()); + +class VerticalDividerExampleApp extends StatelessWidget { + const VerticalDividerExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData(colorSchemeSeed: const Color(0xff6750a4), useMaterial3: true), + home: Scaffold( + appBar: AppBar(title: const Text('Divider Sample')), + body: const DividerExample(), + ), + ); + } +} + +class DividerExample extends StatelessWidget { + const DividerExample({super.key}); + + @override + Widget build(BuildContext context) { + return const Center( + child: Padding( + padding: EdgeInsets.all(16.0), + child: Row( + children: [ + Expanded( + child: Card( + child: SizedBox.expand(), + ), + ), + VerticalDivider(), + Expanded( + child: Card( + child: SizedBox.expand(), + ), + ), + ], + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/drawer/drawer.0.dart b/novelforge-project/flutter/examples/api/lib/material/drawer/drawer.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..46c96ac435bb772c94804ba606396194af8b2082 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/drawer/drawer.0.dart @@ -0,0 +1,90 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Drawer]. + +void main() => runApp(const DrawerApp()); + +class DrawerApp extends StatelessWidget { + const DrawerApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData(useMaterial3: true), + home: const DrawerExample(), + ); + } +} + +class DrawerExample extends StatefulWidget { + const DrawerExample({super.key}); + + @override + State createState() => _DrawerExampleState(); +} + +class _DrawerExampleState extends State { + String selectedPage = ''; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Drawer Example'), + ), + drawer: Drawer( + child: ListView( + padding: EdgeInsets.zero, + children: [ + const DrawerHeader( + decoration: BoxDecoration( + color: Colors.blue, + ), + child: Text( + 'Drawer Header', + style: TextStyle( + color: Colors.white, + fontSize: 24, + ), + ), + ), + ListTile( + leading: const Icon(Icons.message), + title: const Text('Messages'), + onTap: () { + setState(() { + selectedPage = 'Messages'; + }); + }, + ), + ListTile( + leading: const Icon(Icons.account_circle), + title: const Text('Profile'), + onTap: () { + setState(() { + selectedPage = 'Profile'; + }); + }, + ), + ListTile( + leading: const Icon(Icons.settings), + title: const Text('Settings'), + onTap: () { + setState(() { + selectedPage = 'Settings'; + }); + }, + ), + ], + ), + ), + body: Center( + child: Text('Page: $selectedPage'), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/dropdown/dropdown_button.0.dart b/novelforge-project/flutter/examples/api/lib/material/dropdown/dropdown_button.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..15d1ccb60133436be27da08bfbc86143d03b0ed6 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/dropdown/dropdown_button.0.dart @@ -0,0 +1,64 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [DropdownButton]. + +const List list = ['One', 'Two', 'Three', 'Four']; + +void main() => runApp(const DropdownButtonApp()); + +class DropdownButtonApp extends StatelessWidget { + const DropdownButtonApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('DropdownButton Sample')), + body: const Center( + child: DropdownButtonExample(), + ), + ), + ); + } +} + +class DropdownButtonExample extends StatefulWidget { + const DropdownButtonExample({super.key}); + + @override + State createState() => _DropdownButtonExampleState(); +} + +class _DropdownButtonExampleState extends State { + String dropdownValue = list.first; + + @override + Widget build(BuildContext context) { + return DropdownButton( + value: dropdownValue, + icon: const Icon(Icons.arrow_downward), + elevation: 16, + style: const TextStyle(color: Colors.deepPurple), + underline: Container( + height: 2, + color: Colors.deepPurpleAccent, + ), + onChanged: (String? value) { + // This is called when the user selects an item. + setState(() { + dropdownValue = value!; + }); + }, + items: list.map>((String value) { + return DropdownMenuItem( + value: value, + child: Text(value), + ); + }).toList(), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/dropdown/dropdown_button.selected_item_builder.0.dart b/novelforge-project/flutter/examples/api/lib/material/dropdown/dropdown_button.selected_item_builder.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..1c4f832e7f161ba52575de3400f763b6c7d1ede3 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/dropdown/dropdown_button.selected_item_builder.0.dart @@ -0,0 +1,85 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [DropdownButton.selectedItemBuilder]. + +Map cities = { + 'New York': 'NYC', + 'Los Angeles': 'LA', + 'San Francisco': 'SF', + 'Chicago': 'CH', + 'Miami': 'MI', +}; + +void main() => runApp(const DropdownButtonApp()); + +class DropdownButtonApp extends StatelessWidget { + const DropdownButtonApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('DropdownButton Sample')), + body: const Center(child: DropdownButtonExample()), + ), + ); + } +} + +class DropdownButtonExample extends StatefulWidget { + const DropdownButtonExample({super.key}); + + @override + State createState() => _DropdownButtonExampleState(); +} + +class _DropdownButtonExampleState extends State { + String selectedItem = cities.keys.first; + + @override + Widget build(BuildContext context) { + return Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text('Select a city:', style: Theme.of(context).textTheme.bodyLarge), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 8.0), + child: DropdownButton( + value: selectedItem, + onChanged: (String? value) { + // This is called when the user selects an item. + setState(() => selectedItem = value!); + }, + selectedItemBuilder: (BuildContext context) { + return cities.values.map((String item) { + // This is the widget that will be shown when you select an item. + // Here custom text style, alignment and layout size can be applied + // to selected item string. + return Container( + alignment: Alignment.centerLeft, + constraints: const BoxConstraints(minWidth: 100), + child: Text( + item, + style: const TextStyle(color: Colors.blue, fontWeight: FontWeight.w600), + ), + ); + }).toList(); + }, + items: cities.keys.map>((String item) { + return DropdownMenuItem( + value: item, + child: Text(item), + ); + }).toList(), + ), + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/dropdown/dropdown_button.style.0.dart b/novelforge-project/flutter/examples/api/lib/material/dropdown/dropdown_button.style.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..825e9fc6e30e29eb848b4c7138d8b0fff6119ce9 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/dropdown/dropdown_button.style.0.dart @@ -0,0 +1,73 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [DropdownButton.style]. + +void main() => runApp(const DropdownButtonApp()); + +class DropdownButtonApp extends StatelessWidget { + const DropdownButtonApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('DropdownButton Sample')), + body: const DropdownButtonExample(), + ), + ); + } +} + +class DropdownButtonExample extends StatefulWidget { + const DropdownButtonExample({super.key}); + + @override + State createState() => _DropdownButtonExampleState(); +} + +class _DropdownButtonExampleState extends State { + List options = ['One', 'Two', 'Three', 'Four']; + String dropdownValue = 'One'; + + @override + Widget build(BuildContext context) { + return Container( + alignment: Alignment.center, + color: Colors.blue, + child: DropdownButton( + value: dropdownValue, + onChanged: (String? value) { + // This is called when the user selects an item. + setState(() { + dropdownValue = value!; + }); + }, + style: const TextStyle(color: Colors.blue), + selectedItemBuilder: (BuildContext context) { + // This is the widget that will be shown when you select an item. + // Here custom text style, alignment and layout size can be applied + // to selected item string. + return options.map((String value) { + return Align( + alignment: Alignment.centerLeft, + child: Text( + dropdownValue, + style: const TextStyle(color: Colors.white), + ), + ); + }).toList(); + }, + items: options.map>((String value) { + return DropdownMenuItem( + value: value, + child: Text(value), + ); + }).toList(), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/dropdown_menu/dropdown_menu.0.dart b/novelforge-project/flutter/examples/api/lib/material/dropdown_menu/dropdown_menu.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..e7b1ea9b3db3d3d692b3db4510837981b5e6a463 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/dropdown_menu/dropdown_menu.0.dart @@ -0,0 +1,152 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +// Flutter code sample for [DropdownMenu]s. The first dropdown menu +// has the default outlined border and demos using the +// [DropdownMenuEntry] style parameter to customize its appearance. +// The second dropdown menu customizes the appearance of the dropdown +// menu's text field with its [InputDecorationTheme] parameter. + +void main() { + runApp(const DropdownMenuExample()); +} + +// DropdownMenuEntry labels and values for the first dropdown menu. +enum ColorLabel { + blue('Blue', Colors.blue), + pink('Pink', Colors.pink), + green('Green', Colors.green), + yellow('Orange', Colors.orange), + grey('Grey', Colors.grey); + + const ColorLabel(this.label, this.color); + final String label; + final Color color; +} + +// DropdownMenuEntry labels and values for the second dropdown menu. +enum IconLabel { + smile('Smile', Icons.sentiment_satisfied_outlined), + cloud( + 'Cloud', + Icons.cloud_outlined, + ), + brush('Brush', Icons.brush_outlined), + heart('Heart', Icons.favorite); + + const IconLabel(this.label, this.icon); + final String label; + final IconData icon; +} + +class DropdownMenuExample extends StatefulWidget { + const DropdownMenuExample({super.key}); + + @override + State createState() => _DropdownMenuExampleState(); +} + +class _DropdownMenuExampleState extends State { + final TextEditingController colorController = TextEditingController(); + final TextEditingController iconController = TextEditingController(); + ColorLabel? selectedColor; + IconLabel? selectedIcon; + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData( + useMaterial3: true, + colorSchemeSeed: Colors.green, + ), + home: Scaffold( + body: SafeArea( + child: Column( + children: [ + Padding( + padding: const EdgeInsets.symmetric(vertical: 20), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + DropdownMenu( + initialSelection: ColorLabel.green, + controller: colorController, + // requestFocusOnTap is enabled/disabled by platforms when it is null. + // On mobile platforms, this is false by default. Setting this to true will + // trigger focus request on the text field and virtual keyboard will appear + // afterward. On desktop platforms however, this defaults to true. + requestFocusOnTap: true, + label: const Text('Color'), + onSelected: (ColorLabel? color) { + setState(() { + selectedColor = color; + }); + }, + dropdownMenuEntries: ColorLabel.values.map>( + (ColorLabel color) { + return DropdownMenuEntry( + value: color, + label: color.label, + enabled: color.label != 'Grey', + style: MenuItemButton.styleFrom( + foregroundColor: color.color, + ), + ); + } + ).toList(), + ), + const SizedBox(width: 24), + DropdownMenu( + controller: iconController, + enableFilter: true, + requestFocusOnTap: true, + leadingIcon: const Icon(Icons.search), + label: const Text('Icon'), + inputDecorationTheme: const InputDecorationTheme( + filled: true, + contentPadding: EdgeInsets.symmetric(vertical: 5.0), + ), + onSelected: (IconLabel? icon) { + setState(() { + selectedIcon = icon; + }); + }, + dropdownMenuEntries: IconLabel.values.map>( + (IconLabel icon) { + return DropdownMenuEntry( + value: icon, + label: icon.label, + leadingIcon: Icon(icon.icon), + ); + }, + ).toList(), + ), + ], + ), + ), + if (selectedColor != null && selectedIcon != null) + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text('You selected a ${selectedColor?.label} ${selectedIcon?.label}'), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 5), + child: Icon( + selectedIcon?.icon, + color: selectedColor?.color, + ), + ) + ], + ) + else + const Text('Please select a color and an icon.') + ], + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/dropdown_menu/dropdown_menu.1.dart b/novelforge-project/flutter/examples/api/lib/material/dropdown_menu/dropdown_menu.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..dbb22177f3d98d781dbe9dbf1bac30ceec63e678 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/dropdown_menu/dropdown_menu.1.dart @@ -0,0 +1,58 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [DropdownMenu]. + +const List list = ['One', 'Two', 'Three', 'Four']; + +void main() => runApp(const DropdownMenuApp()); + +class DropdownMenuApp extends StatelessWidget { + const DropdownMenuApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData(useMaterial3:true), + home: Scaffold( + appBar: AppBar(title: const Text('DropdownMenu Sample')), + body: const Center( + child: DropdownMenuExample(), + ), + ), + ); + } +} + +class DropdownMenuExample extends StatefulWidget { + const DropdownMenuExample({super.key}); + + @override + State createState() => _DropdownMenuExampleState(); +} + +class _DropdownMenuExampleState extends State { + String dropdownValue = list.first; + + @override + Widget build(BuildContext context) { + return DropdownMenu( + initialSelection: list.first, + onSelected: (String? value) { + // This is called when the user selects an item. + setState(() { + dropdownValue = value!; + }); + }, + dropdownMenuEntries: list.map>((String value) { + return DropdownMenuEntry( + value: value, + label: value + ); + }).toList(), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/dropdown_menu/dropdown_menu.2.dart b/novelforge-project/flutter/examples/api/lib/material/dropdown_menu/dropdown_menu.2.dart new file mode 100644 index 0000000000000000000000000000000000000000..4fbe137cb5fe538068899a936c197915bb147e62 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/dropdown_menu/dropdown_menu.2.dart @@ -0,0 +1,169 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [DropdownMenu]. + +const List list = ['One', 'Two', 'Three', 'Four']; + +void main() => runApp(const DropdownMenuApp()); + +class DropdownMenuApp extends StatelessWidget { + const DropdownMenuApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('DropdownMenu Sample')), + body: const Center( + child: DropdownMenuExample(), + ), + ), + ); + } +} + +class DropdownMenuExample extends StatefulWidget { + const DropdownMenuExample({super.key}); + + @override + State createState() => _DropdownMenuExampleState(); +} + +class _DropdownMenuExampleState extends State { + String dropdownValue = list.first; + + @override + Widget build(BuildContext context) { + final ColorScheme colorScheme = Theme.of(context).colorScheme; + + return ListView( + children: [ + ListTile( + tileColor: colorScheme.primaryContainer, + title: const Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('enabled: true'), + Text('requestFocusOnTap: true'), + ], + ), + subtitle: Column( + children: [ + DropdownMenu( + requestFocusOnTap: true, + initialSelection: list.first, + expandedInsets: EdgeInsets.zero, + onSelected: (String? value) { + setState(() { + dropdownValue = value!; + }); + }, + dropdownMenuEntries: + list.map>((String value) { + return DropdownMenuEntry(value: value, label: value); + }).toList(), + ), + const Text('Text cursor is shown when hovering over the DropdownMenu.'), + ], + ), + ), + const SizedBox(height: 20), + ListTile( + tileColor: colorScheme.primaryContainer, + title: const Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('enabled: true'), + Text('requestFocusOnTap: false'), + ], + ), + subtitle: Column( + children: [ + DropdownMenu( + requestFocusOnTap: false, + initialSelection: list.first, + expandedInsets: EdgeInsets.zero, + onSelected: (String? value) { + setState(() { + dropdownValue = value!; + }); + }, + dropdownMenuEntries: + list.map>((String value) { + return DropdownMenuEntry(value: value, label: value); + }).toList(), + ), + const Text('Clickable cursor is shown when hovering over the DropdownMenu.'), + ], + ), + ), + const SizedBox(height: 20), + ListTile( + tileColor: colorScheme.onInverseSurface, + title: const Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('enabled: false'), + Text('requestFocusOnTap: true'), + ], + ), + subtitle: Column( + children: [ + DropdownMenu( + enabled: false, + requestFocusOnTap: true, + initialSelection: list.first, + expandedInsets: EdgeInsets.zero, + onSelected: (String? value) { + setState(() { + dropdownValue = value!; + }); + }, + dropdownMenuEntries: + list.map>((String value) { + return DropdownMenuEntry(value: value, label: value); + }).toList(), + ), + const Text('Default cursor is shown when hovering over the DropdownMenu.'), + ], + ), + ), + const SizedBox(height: 20), + ListTile( + tileColor: colorScheme.onInverseSurface, + title: const Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('enabled: false'), + Text('requestFocusOnTap: false'), + ], + ), + subtitle: Column( + children: [ + DropdownMenu( + enabled: false, + requestFocusOnTap: false, + initialSelection: list.first, + expandedInsets: EdgeInsets.zero, + onSelected: (String? value) { + setState(() { + dropdownValue = value!; + }); + }, + dropdownMenuEntries: + list.map>((String value) { + return DropdownMenuEntry(value: value, label: value); + }).toList(), + ), + const Text('Default cursor is shown when hovering over the DropdownMenu.'), + ], + ), + ), + ], + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/dropdown_menu/dropdown_menu_entry_label_widget.0.dart b/novelforge-project/flutter/examples/api/lib/material/dropdown_menu/dropdown_menu_entry_label_widget.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..a4c77c624450311de561cdfa7738e173e5f5c7e4 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/dropdown_menu/dropdown_menu_entry_label_widget.0.dart @@ -0,0 +1,91 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for the [DropdownMenuEntry] `labelWidget` property. + +enum ColorItem { + blue('Blue', Colors.blue), + pink('Pink', Colors.pink), + green('Green', Colors.green), + yellow('Yellow', Colors.yellow), + grey('Grey', Colors.grey); + + const ColorItem(this.label, this.color); + final String label; + final Color color; +} + +class DropdownMenuEntryLabelWidgetExample extends StatefulWidget { + const DropdownMenuEntryLabelWidgetExample({ super.key }); + + @override + State createState() => _DropdownMenuEntryLabelWidgetExampleState(); +} + +class _DropdownMenuEntryLabelWidgetExampleState extends State { + late final TextEditingController controller; + + @override + void initState() { + super.initState(); + controller = TextEditingController(); + } + + @override + void dispose() { + controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + // Created by Google Bard from 'create a lyrical phrase of about 25 words that begins with "is a color"'. + const String longText = 'is a color that sings of hope, A hue that shines like gold. It is the color of dreams, A shade that never grows old.'; + + return Scaffold( + body: Center( + child: DropdownMenu( + width: 300, + controller: controller, + initialSelection: ColorItem.green, + label: const Text('Color'), + onSelected: (ColorItem? color) { + print('Selected $color'); + }, + dropdownMenuEntries: ColorItem.values.map>((ColorItem item) { + final String labelText = '${item.label} $longText\n'; + return DropdownMenuEntry( + value: item, + label: labelText, + // Try commenting the labelWidget out or changing + // the labelWidget's Text parameters. + labelWidget: Text( + labelText, + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + ); + }).toList(), + ), + ), + ); + } +} + +class DropdownMenuEntryLabelWidgetExampleApp extends StatelessWidget { + const DropdownMenuEntryLabelWidgetExampleApp({ super.key }); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: DropdownMenuEntryLabelWidgetExample(), + ); + } +} + +void main() { + runApp(const DropdownMenuEntryLabelWidgetExampleApp()); +} diff --git a/novelforge-project/flutter/examples/api/lib/material/elevated_button/elevated_button.0.dart b/novelforge-project/flutter/examples/api/lib/material/elevated_button/elevated_button.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..ece62f42a94ba13c9536a3ab04a8eb192cb703b0 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/elevated_button/elevated_button.0.dart @@ -0,0 +1,56 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [ElevatedButton]. + +void main() => runApp(const ElevatedButtonExampleApp()); + +class ElevatedButtonExampleApp extends StatelessWidget { + const ElevatedButtonExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('ElevatedButton Sample')), + body: const ElevatedButtonExample(), + ), + ); + } +} + +class ElevatedButtonExample extends StatefulWidget { + const ElevatedButtonExample({super.key}); + + @override + State createState() => _ElevatedButtonExampleState(); +} + +class _ElevatedButtonExampleState extends State { + @override + Widget build(BuildContext context) { + final ButtonStyle style = ElevatedButton.styleFrom(textStyle: const TextStyle(fontSize: 20)); + + return Center( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + ElevatedButton( + style: style, + onPressed: null, + child: const Text('Disabled'), + ), + const SizedBox(height: 30), + ElevatedButton( + style: style, + onPressed: () {}, + child: const Text('Enabled'), + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/expansion_panel/expansion_panel_list.0.dart b/novelforge-project/flutter/examples/api/lib/material/expansion_panel/expansion_panel_list.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..6fb02ad07408fadb02448bc17f0b08feb67fd3d1 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/expansion_panel/expansion_panel_list.0.dart @@ -0,0 +1,94 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [ExpansionPanelList]. + +void main() => runApp(const ExpansionPanelListExampleApp()); + +class ExpansionPanelListExampleApp extends StatelessWidget { + const ExpansionPanelListExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('ExpansionPanelList Sample')), + body: const ExpansionPanelListExample(), + ), + ); + } +} + +// stores ExpansionPanel state information +class Item { + Item({ + required this.expandedValue, + required this.headerValue, + this.isExpanded = false, + }); + + String expandedValue; + String headerValue; + bool isExpanded; +} + +List generateItems(int numberOfItems) { + return List.generate(numberOfItems, (int index) { + return Item( + headerValue: 'Panel $index', + expandedValue: 'This is item number $index', + ); + }); +} + +class ExpansionPanelListExample extends StatefulWidget { + const ExpansionPanelListExample({super.key}); + + @override + State createState() => _ExpansionPanelListExampleState(); +} + +class _ExpansionPanelListExampleState extends State { + final List _data = generateItems(8); + + @override + Widget build(BuildContext context) { + return SingleChildScrollView( + child: Container( + child: _buildPanel(), + ), + ); + } + + Widget _buildPanel() { + return ExpansionPanelList( + expansionCallback: (int index, bool isExpanded) { + setState(() { + _data[index].isExpanded = isExpanded; + }); + }, + children: _data.map((Item item) { + return ExpansionPanel( + headerBuilder: (BuildContext context, bool isExpanded) { + return ListTile( + title: Text(item.headerValue), + ); + }, + body: ListTile( + title: Text(item.expandedValue), + subtitle: const Text('To delete this panel, tap the trash can icon'), + trailing: const Icon(Icons.delete), + onTap: () { + setState(() { + _data.removeWhere((Item currentItem) => item == currentItem); + }); + }), + isExpanded: item.isExpanded, + ); + }).toList(), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/expansion_panel/expansion_panel_list.expansion_panel_list_radio.0.dart b/novelforge-project/flutter/examples/api/lib/material/expansion_panel/expansion_panel_list.expansion_panel_list_radio.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..db7ec03f4ee866f5a88cebb8afefdbc1dbb6c4d1 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/expansion_panel/expansion_panel_list.expansion_panel_list_radio.0.dart @@ -0,0 +1,90 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [ExpansionPanelList.ExpansionPanelList.radio]. + +void main() => runApp(const ExpansionPanelListRadioExampleApp()); + +class ExpansionPanelListRadioExampleApp extends StatelessWidget { + const ExpansionPanelListRadioExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('ExpansionPanelList.radio Sample')), + body: const ExpansionPanelListRadioExample(), + ), + ); + } +} + +// stores ExpansionPanel state information +class Item { + Item({ + required this.id, + required this.expandedValue, + required this.headerValue, + }); + + int id; + String expandedValue; + String headerValue; +} + +List generateItems(int numberOfItems) { + return List.generate(numberOfItems, (int index) { + return Item( + id: index, + headerValue: 'Panel $index', + expandedValue: 'This is item number $index', + ); + }); +} + +class ExpansionPanelListRadioExample extends StatefulWidget { + const ExpansionPanelListRadioExample({super.key}); + + @override + State createState() => _ExpansionPanelListRadioExampleState(); +} + +class _ExpansionPanelListRadioExampleState extends State { + final List _data = generateItems(8); + + @override + Widget build(BuildContext context) { + return SingleChildScrollView( + child: Container( + child: _buildPanel(), + ), + ); + } + + Widget _buildPanel() { + return ExpansionPanelList.radio( + initialOpenPanelValue: 2, + children: _data.map((Item item) { + return ExpansionPanelRadio( + value: item.id, + headerBuilder: (BuildContext context, bool isExpanded) { + return ListTile( + title: Text(item.headerValue), + ); + }, + body: ListTile( + title: Text(item.expandedValue), + subtitle: const Text('To delete this panel, tap the trash can icon'), + trailing: const Icon(Icons.delete), + onTap: () { + setState(() { + _data.removeWhere((Item currentItem) => item == currentItem); + }); + })); + }).toList(), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/expansion_tile/expansion_tile.0.dart b/novelforge-project/flutter/examples/api/lib/material/expansion_tile/expansion_tile.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..384c88912f6265c2a9c9287172da9ac94ef2dc99 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/expansion_tile/expansion_tile.0.dart @@ -0,0 +1,73 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [ExpansionTile]. + +void main() => runApp(const ExpansionTileApp()); + +class ExpansionTileApp extends StatelessWidget { + const ExpansionTileApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData(useMaterial3: true), + home: Scaffold( + appBar: AppBar(title: const Text('ExpansionTile Sample')), + body: const ExpansionTileExample(), + ), + ); + } +} + +class ExpansionTileExample extends StatefulWidget { + const ExpansionTileExample({super.key}); + + @override + State createState() => _ExpansionTileExampleState(); +} + +class _ExpansionTileExampleState extends State { + bool _customTileExpanded = false; + + @override + Widget build(BuildContext context) { + return Column( + children: [ + const ExpansionTile( + title: Text('ExpansionTile 1'), + subtitle: Text('Trailing expansion arrow icon'), + children: [ + ListTile(title: Text('This is tile number 1')), + ], + ), + ExpansionTile( + title: const Text('ExpansionTile 2'), + subtitle: const Text('Custom expansion arrow icon'), + trailing: Icon( + _customTileExpanded ? Icons.arrow_drop_down_circle : Icons.arrow_drop_down, + ), + children: const [ + ListTile(title: Text('This is tile number 2')), + ], + onExpansionChanged: (bool expanded) { + setState(() { + _customTileExpanded = expanded; + }); + }, + ), + const ExpansionTile( + title: Text('ExpansionTile 3'), + subtitle: Text('Leading expansion arrow icon'), + controlAffinity: ListTileControlAffinity.leading, + children: [ + ListTile(title: Text('This is tile number 3')), + ], + ), + ], + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/expansion_tile/expansion_tile.1.dart b/novelforge-project/flutter/examples/api/lib/material/expansion_tile/expansion_tile.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..76799ec9899cd86b7b65934266faf6ab8ed18cf1 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/expansion_tile/expansion_tile.1.dart @@ -0,0 +1,83 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [ExpansionTile] and [ExpansionTileController]. + +void main() { + runApp(const ExpansionTileControllerApp()); +} + +class ExpansionTileControllerApp extends StatefulWidget { + const ExpansionTileControllerApp({super.key}); + + @override + State createState() => _ExpansionTileControllerAppState(); +} + +class _ExpansionTileControllerAppState extends State { + final ExpansionTileController controller = ExpansionTileController(); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData(useMaterial3: true), + home: Scaffold( + appBar: AppBar(title: const Text('ExpansionTileController Sample')), + body: Column( + children: [ + // A controller has been provided to the ExpansionTile because it's + // going to be accessed from a component that is not within the + // tile's BuildContext. + ExpansionTile( + controller: controller, + title: const Text('ExpansionTile with explicit controller.'), + children: [ + Container( + alignment: Alignment.center, + padding: const EdgeInsets.all(24), + child: const Text('ExpansionTile Contents'), + ), + ], + ), + const SizedBox(height: 8), + ElevatedButton( + child: const Text('Expand/Collapse the Tile Above'), + onPressed: () { + if (controller.isExpanded) { + controller.collapse(); + } else { + controller.expand(); + } + }, + ), + const SizedBox(height: 48), + // A controller has not been provided to the ExpansionTile because + // the automatically created one can be retrieved via the tile's BuildContext. + ExpansionTile( + title: const Text('ExpansionTile with implicit controller.'), + children: [ + Builder( + builder: (BuildContext context) { + return Container( + padding: const EdgeInsets.all(24), + alignment: Alignment.center, + child: ElevatedButton( + child: const Text('Collapse This Tile'), + onPressed: () { + return ExpansionTileController.of(context).collapse(); + }, + ), + ); + }, + ), + ], + ), + ], + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/expansion_tile/expansion_tile.2.dart b/novelforge-project/flutter/examples/api/lib/material/expansion_tile/expansion_tile.2.dart new file mode 100644 index 0000000000000000000000000000000000000000..1d6f6c4e4a579c3fed8ba05d1c57f27890dc82ad --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/expansion_tile/expansion_tile.2.dart @@ -0,0 +1,78 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [ExpansionTile] and [AnimationStyle]. + +void main() { + runApp(const ExpansionTileAnimationStyleApp()); +} + +enum AnimationStyles { defaultStyle, custom, none } +const List<(AnimationStyles, String)> animationStyleSegments = <(AnimationStyles, String)>[ + (AnimationStyles.defaultStyle, 'Default'), + (AnimationStyles.custom, 'Custom'), + (AnimationStyles.none, 'None'), +]; + +class ExpansionTileAnimationStyleApp extends StatefulWidget { + const ExpansionTileAnimationStyleApp({super.key}); + + @override + State createState() => _ExpansionTileAnimationStyleAppState(); +} + +class _ExpansionTileAnimationStyleAppState extends State { + Set _animationStyleSelection = {AnimationStyles.defaultStyle}; + AnimationStyle? _animationStyle; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: SafeArea( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SegmentedButton( + selected: _animationStyleSelection, + onSelectionChanged: (Set styles) { + setState(() { + _animationStyleSelection = styles; + switch (styles.first) { + case AnimationStyles.defaultStyle: + _animationStyle = null; + case AnimationStyles.custom: + _animationStyle = AnimationStyle( + curve: Easing.emphasizedAccelerate, + duration: Durations.extralong1, + ); + case AnimationStyles.none: + _animationStyle = AnimationStyle.noAnimation; + } + }); + }, + segments: animationStyleSegments + .map>(((AnimationStyles, String) shirt) { + return ButtonSegment(value: shirt.$1, label: Text(shirt.$2)); + }) + .toList(), + ), + const SizedBox(height: 20), + ExpansionTile( + expansionAnimationStyle: _animationStyle, + title: const Text('ExpansionTile'), + children: const [ + ListTile(title: Text('Expanded Item 1')), + ListTile(title: Text('Expanded Item 2')), + ], + ) + ], + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/filled_button/filled_button.0.dart b/novelforge-project/flutter/examples/api/lib/material/filled_button/filled_button.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..7b0ca199ea144f37095ab946a0c6e8696641b5f1 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/filled_button/filled_button.0.dart @@ -0,0 +1,61 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [FilledButton]. + +void main() { + runApp(const FilledButtonApp()); +} + +class FilledButtonApp extends StatelessWidget { + const FilledButtonApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData(colorSchemeSeed: const Color(0xff6750a4), useMaterial3: true), + home: Scaffold( + appBar: AppBar(title: const Text('FilledButton Sample')), + body: Center( + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Column(children: [ + const SizedBox(height: 30), + const Text('Filled'), + const SizedBox(height: 15), + FilledButton( + onPressed: () {}, + child: const Text('Enabled'), + ), + const SizedBox(height: 30), + const FilledButton( + onPressed: null, + child: Text('Disabled'), + ), + ]), + const SizedBox(width: 30), + Column(children: [ + const SizedBox(height: 30), + const Text('Filled tonal'), + const SizedBox(height: 15), + FilledButton.tonal( + onPressed: () {}, + child: const Text('Enabled'), + ), + const SizedBox(height: 30), + const FilledButton.tonal( + onPressed: null, + child: Text('Disabled'), + ), + ]) + ], + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/filter_chip/filter_chip.0.dart b/novelforge-project/flutter/examples/api/lib/material/filter_chip/filter_chip.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..acf72b1db4050dcd0a19a915f04f6d206546c3f0 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/filter_chip/filter_chip.0.dart @@ -0,0 +1,77 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [FilterChip]. + +enum ExerciseFilter { walking, running, cycling, hiking } + +void main() => runApp(const ChipApp()); + +class ChipApp extends StatelessWidget { + const ChipApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData(useMaterial3: true), + home: Scaffold( + appBar: AppBar( + title: const Text('FilterChip Sample'), + ), + body: const FilterChipExample(), + ), + ); + } +} + +class FilterChipExample extends StatefulWidget { + const FilterChipExample({super.key}); + + @override + State createState() => _FilterChipExampleState(); +} + +class _FilterChipExampleState extends State { + Set filters = {}; + + @override + Widget build(BuildContext context) { + final TextTheme textTheme = Theme.of(context).textTheme; + + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text('Choose an exercise', style: textTheme.labelLarge), + const SizedBox(height: 5.0), + Wrap( + spacing: 5.0, + children: ExerciseFilter.values.map((ExerciseFilter exercise) { + return FilterChip( + label: Text(exercise.name), + selected: filters.contains(exercise), + onSelected: (bool selected) { + setState(() { + if (selected) { + filters.add(exercise); + } else { + filters.remove(exercise); + } + }); + }, + ); + }).toList(), + ), + const SizedBox(height: 10.0), + Text( + 'Looking for: ${filters.map((ExerciseFilter e) => e.name).join(', ')}', + style: textTheme.labelLarge, + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/flexible_space_bar/flexible_space_bar.0.dart b/novelforge-project/flutter/examples/api/lib/material/flexible_space_bar/flexible_space_bar.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..b1649afa0b93bbc0367c28d921f63cad15dcd163 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/flexible_space_bar/flexible_space_bar.0.dart @@ -0,0 +1,79 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [FlexibleSpaceBar]. + +void main() => runApp(const MaterialApp(home: FlexibleSpaceBarExampleApp())); + +class FlexibleSpaceBarExampleApp extends StatelessWidget { + const FlexibleSpaceBarExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: CustomScrollView( + physics: const BouncingScrollPhysics(parent: AlwaysScrollableScrollPhysics()), + slivers: [ + SliverAppBar( + stretch: true, + onStretchTrigger: () { + // Function callback for stretch + return Future.value(); + }, + expandedHeight: 300.0, + flexibleSpace: FlexibleSpaceBar( + stretchModes: const [ + StretchMode.zoomBackground, + StretchMode.blurBackground, + StretchMode.fadeTitle, + ], + centerTitle: true, + title: const Text('Flight Report'), + background: Stack( + fit: StackFit.expand, + children: [ + Image.network( + 'https://flutter.github.io/assets-for-api-docs/assets/widgets/owl-2.jpg', + fit: BoxFit.cover, + ), + const DecoratedBox( + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment(0.0, 0.5), + end: Alignment.center, + colors: [ + Color(0x60000000), + Color(0x00000000), + ], + ), + ), + ), + ], + ), + ), + ), + SliverList( + delegate: SliverChildListDelegate( + const [ + ListTile( + leading: Icon(Icons.wb_sunny), + title: Text('Sunday'), + subtitle: Text('sunny, h: 80, l: 65'), + ), + ListTile( + leading: Icon(Icons.wb_sunny), + title: Text('Monday'), + subtitle: Text('sunny, h: 80, l: 65'), + ), + // ListTiles++ + ], + ), + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/floating_action_button/floating_action_button.0.dart b/novelforge-project/flutter/examples/api/lib/material/floating_action_button/floating_action_button.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..30a0b3295ffaa093ada5f0156ce00b36d94c8bfc --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/floating_action_button/floating_action_button.0.dart @@ -0,0 +1,62 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [FloatingActionButton]. + +void main() { + runApp(const FloatingActionButtonExampleApp()); +} + +class FloatingActionButtonExampleApp extends StatelessWidget { + const FloatingActionButtonExampleApp({ super.key }); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData(useMaterial3: true), + home: const FloatingActionButtonExample(), + ); + } +} + +class FloatingActionButtonExample extends StatefulWidget { + const FloatingActionButtonExample({ super.key }); + + @override + State createState() => _FloatingActionButtonExampleState(); +} + +class _FloatingActionButtonExampleState extends State { + // The FAB's foregroundColor, backgroundColor, and shape + static const List<(Color?, Color? background, ShapeBorder?)> customizations = <(Color?, Color?, ShapeBorder?)>[ + (null, null, null), // The FAB uses its default for null parameters. + (null, Colors.green, null), + (Colors.white, Colors.green, null), + (Colors.white, Colors.green, CircleBorder()), + ]; + int index = 0; // Selects the customization. + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('FloatingActionButton Sample'), + ), + body: const Center(child: Text('Press the button below!')), + floatingActionButton: FloatingActionButton( + onPressed: () { + setState(() { + index = (index + 1) % customizations.length; + }); + }, + foregroundColor: customizations[index].$1, + backgroundColor: customizations[index].$2, + shape: customizations[index].$3, + child: const Icon(Icons.navigation), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/floating_action_button/floating_action_button.1.dart b/novelforge-project/flutter/examples/api/lib/material/floating_action_button/floating_action_button.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..3aef595986a5fd6e264535461ac0a75fb04192ba --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/floating_action_button/floating_action_button.1.dart @@ -0,0 +1,106 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [FloatingActionButton]. + +void main() => runApp(const FloatingActionButtonExampleApp()); + +class FloatingActionButtonExampleApp extends StatelessWidget { + const FloatingActionButtonExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData(useMaterial3: true), + home: const FloatingActionButtonExample(), + ); + } +} + +class FloatingActionButtonExample extends StatelessWidget { + const FloatingActionButtonExample({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('FloatingActionButton Sample'), + ), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text('Small'), + const SizedBox(width: 16), + // An example of the small floating action button. + // + // https://m3.material.io/components/floating-action-button/specs#669a1be8-7271-48cb-a74d-dd502d73bda4 + FloatingActionButton.small( + onPressed: () { + // Add your onPressed code here! + }, + child: const Icon(Icons.add), + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text('Regular'), + const SizedBox(width: 16), + // An example of the regular floating action button. + // + // https://m3.material.io/components/floating-action-button/specs#71504201-7bd1-423d-8bb7-07e0291743e5 + FloatingActionButton( + onPressed: () { + // Add your onPressed code here! + }, + child: const Icon(Icons.add), + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text('Large'), + const SizedBox(width: 16), + // An example of the large floating action button. + // + // https://m3.material.io/components/floating-action-button/specs#9d7d3d6a-bab7-47cb-be32-5596fbd660fe + FloatingActionButton.large( + onPressed: () { + // Add your onPressed code here! + }, + child: const Icon(Icons.add), + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text('Extended'), + const SizedBox(width: 16), + // An example of the extended floating action button. + // + // https://m3.material.io/components/extended-fab/specs#686cb8af-87c9-48e8-a3e1-db9da6f6c69b + FloatingActionButton.extended( + onPressed: () { + // Add your onPressed code here! + }, + label: const Text('Add'), + icon: const Icon(Icons.add), + ), + ], + ), + ], + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/floating_action_button/floating_action_button.2.dart b/novelforge-project/flutter/examples/api/lib/material/floating_action_button/floating_action_button.2.dart new file mode 100644 index 0000000000000000000000000000000000000000..dda2e9b6db284e1fa5258e2f4c9d06fdbd536165 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/floating_action_button/floating_action_button.2.dart @@ -0,0 +1,104 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [FloatingActionButton]. + +void main() => runApp(const FloatingActionButtonExampleApp()); + +class FloatingActionButtonExampleApp extends StatelessWidget { + const FloatingActionButtonExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData(useMaterial3: true), + home: const FloatingActionButtonExample(), + ); + } +} + +class FloatingActionButtonExample extends StatelessWidget { + const FloatingActionButtonExample({super.key}); + + @override + Widget build(BuildContext context) { + final ColorScheme colorScheme = Theme.of(context).colorScheme; + + Widget titleBox(String title) { + return DecoratedBox( + decoration: BoxDecoration( + color: colorScheme.inverseSurface, + borderRadius: BorderRadius.circular(4), + ), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), + child: Text(title, style: TextStyle(color: colorScheme.onInverseSurface)), + ), + ); + } + + return Scaffold( + appBar: AppBar( + title: const Text('FAB Additional Color Mappings'), + ), + body: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + // Surface color mapping. + Column( + mainAxisSize: MainAxisSize.min, + children: [ + FloatingActionButton.large( + foregroundColor: colorScheme.primary, + backgroundColor: colorScheme.surface, + onPressed: () { + // Add your onPressed code here! + }, + child: const Icon(Icons.edit_outlined), + ), + const SizedBox(height: 20), + titleBox('Surface'), + ], + ), + // Secondary color mapping. + Column( + mainAxisSize: MainAxisSize.min, + children: [ + FloatingActionButton.large( + foregroundColor: colorScheme.onSecondaryContainer, + backgroundColor: colorScheme.secondaryContainer, + onPressed: () { + // Add your onPressed code here! + }, + child: const Icon(Icons.edit_outlined), + ), + const SizedBox(height: 20), + titleBox('Secondary'), + ], + ), + // Tertiary color mapping. + Column( + mainAxisSize: MainAxisSize.min, + children: [ + FloatingActionButton.large( + foregroundColor: colorScheme.onTertiaryContainer, + backgroundColor: colorScheme.tertiaryContainer, + onPressed: () { + // Add your onPressed code here! + }, + child: const Icon(Icons.edit_outlined), + ), + const SizedBox(height: 20), + titleBox('Tertiary'), + ], + ), + ], + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/floating_action_button_location/standard_fab_location.0.dart b/novelforge-project/flutter/examples/api/lib/material/floating_action_button_location/standard_fab_location.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..ce77bf7a5f34dd6b51ea6595a9a6b1c28b9b269c --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/floating_action_button_location/standard_fab_location.0.dart @@ -0,0 +1,49 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [StandardFabLocation]. + +void main() => runApp(const StandardFabLocationExampleApp()); + +class StandardFabLocationExampleApp extends StatelessWidget { + const StandardFabLocationExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: StandardFabLocationExample(), + ); + } +} + +class AlmostEndFloatFabLocation extends StandardFabLocation with FabEndOffsetX, FabFloatOffsetY { + @override + double getOffsetX(ScaffoldPrelayoutGeometry scaffoldGeometry, double adjustment) { + final double directionalAdjustment = scaffoldGeometry.textDirection == TextDirection.ltr ? -50.0 : 50.0; + return super.getOffsetX(scaffoldGeometry, adjustment) + directionalAdjustment; + } +} + +class StandardFabLocationExample extends StatelessWidget { + const StandardFabLocationExample({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Home page'), + ), + floatingActionButton: FloatingActionButton( + onPressed: () { + debugPrint('FAB pressed.'); + }, + tooltip: 'Increment', + child: const Icon(Icons.add), + ), + floatingActionButtonLocation: AlmostEndFloatFabLocation(), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/icon_button/icon_button.0.dart b/novelforge-project/flutter/examples/api/lib/material/icon_button/icon_button.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..309d4ce475a797b3e77b91609d70f76e4b92f673 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/icon_button/icon_button.0.dart @@ -0,0 +1,55 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [IconButton]. + +void main() => runApp(const IconButtonExampleApp()); + +class IconButtonExampleApp extends StatelessWidget { + const IconButtonExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('IconButton Sample')), + body: const Center( + child: IconButtonExample(), + ), + ), + ); + } +} + +double _volume = 0.0; + +class IconButtonExample extends StatefulWidget { + const IconButtonExample({super.key}); + + @override + State createState() => _IconButtonExampleState(); +} + +class _IconButtonExampleState extends State { + @override + Widget build(BuildContext context) { + return Column( + mainAxisSize: MainAxisSize.min, + children: [ + IconButton( + icon: const Icon(Icons.volume_up), + tooltip: 'Increase volume by 10', + onPressed: () { + setState(() { + _volume += 10; + }); + }, + ), + Text('Volume : $_volume'), + ], + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/icon_button/icon_button.1.dart b/novelforge-project/flutter/examples/api/lib/material/icon_button/icon_button.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..2bc28d1acf89c888f9454f5ae106194f29c9aece --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/icon_button/icon_button.1.dart @@ -0,0 +1,48 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [IconButton]. + +void main() => runApp(const IconButtonExampleApp()); + +class IconButtonExampleApp extends StatelessWidget { + const IconButtonExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('IconButton Sample')), + body: const IconButtonExample(), + ), + ); + } +} + +class IconButtonExample extends StatelessWidget { + const IconButtonExample({super.key}); + + @override + @override + Widget build(BuildContext context) { + return Material( + color: Colors.white, + child: Center( + child: Ink( + decoration: const ShapeDecoration( + color: Colors.lightBlue, + shape: CircleBorder(), + ), + child: IconButton( + icon: const Icon(Icons.android), + color: Colors.white, + onPressed: () {}, + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/icon_button/icon_button.2.dart b/novelforge-project/flutter/examples/api/lib/material/icon_button/icon_button.2.dart new file mode 100644 index 0000000000000000000000000000000000000000..e057781c2ddb9e37f0b91ffab296ec2d43717451 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/icon_button/icon_button.2.dart @@ -0,0 +1,75 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [IconButton]. + +void main() { + runApp(const IconButtonApp()); +} + +class IconButtonApp extends StatelessWidget { + const IconButtonApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData(colorSchemeSeed: const Color(0xff6750a4), useMaterial3: true), + title: 'Icon Button Types', + home: const Scaffold( + body: ButtonTypesExample(), + ), + ); + } +} + +class ButtonTypesExample extends StatelessWidget { + const ButtonTypesExample({super.key}); + + @override + Widget build(BuildContext context) { + return const Padding( + padding: EdgeInsets.all(4.0), + child: Row( + children: [ + Spacer(), + ButtonTypesGroup(enabled: true), + ButtonTypesGroup(enabled: false), + Spacer(), + ], + ), + ); + } +} + +class ButtonTypesGroup extends StatelessWidget { + const ButtonTypesGroup({super.key, required this.enabled}); + + final bool enabled; + + @override + Widget build(BuildContext context) { + final VoidCallback? onPressed = enabled ? () {} : null; + + return Padding( + padding: const EdgeInsets.all(4.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + IconButton(icon: const Icon(Icons.filter_drama), onPressed: onPressed), + + // Filled icon button + IconButton.filled(onPressed: onPressed, icon: const Icon(Icons.filter_drama)), + + // Filled tonal icon button + IconButton.filledTonal(onPressed: onPressed, icon: const Icon(Icons.filter_drama)), + + // Outlined icon button + IconButton.outlined(onPressed: onPressed, icon: const Icon(Icons.filter_drama)), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/icon_button/icon_button.3.dart b/novelforge-project/flutter/examples/api/lib/material/icon_button/icon_button.3.dart new file mode 100644 index 0000000000000000000000000000000000000000..00ff53fa66433d28872ce3ec801a0584611ea39f --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/icon_button/icon_button.3.dart @@ -0,0 +1,140 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [IconButton] with toggle feature. + +void main() { + runApp(const IconButtonToggleApp()); +} + +class IconButtonToggleApp extends StatelessWidget { + const IconButtonToggleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData( + colorSchemeSeed: const Color(0xff6750a4), + useMaterial3: true, + ), + title: 'Icon Button Types', + home: const Scaffold( + body: DemoIconToggleButtons(), + ), + ); + } +} + +class DemoIconToggleButtons extends StatefulWidget { + const DemoIconToggleButtons({super.key}); + + @override + State createState() => _DemoIconToggleButtonsState(); +} + +class _DemoIconToggleButtonsState extends State { + bool standardSelected = false; + bool filledSelected = false; + bool tonalSelected = false; + bool outlinedSelected = false; + + @override + Widget build(BuildContext context) { + return Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + IconButton( + isSelected: standardSelected, + icon: const Icon(Icons.settings_outlined), + selectedIcon: const Icon(Icons.settings), + onPressed: () { + setState(() { + standardSelected = !standardSelected; + }); + }, + ), + const SizedBox(width: 10), + IconButton( + isSelected: standardSelected, + icon: const Icon(Icons.settings_outlined), + selectedIcon: const Icon(Icons.settings), + onPressed: null, + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + IconButton.filled( + isSelected: filledSelected, + icon: const Icon(Icons.settings_outlined), + selectedIcon: const Icon(Icons.settings), + onPressed: () { + setState(() { + filledSelected = !filledSelected; + }); + }, + ), + const SizedBox(width: 10), + IconButton.filled( + isSelected: filledSelected, + icon: const Icon(Icons.settings_outlined), + selectedIcon: const Icon(Icons.settings), + onPressed: null, + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + IconButton.filledTonal( + isSelected: tonalSelected, + icon: const Icon(Icons.settings_outlined), + selectedIcon: const Icon(Icons.settings), + onPressed: () { + setState(() { + tonalSelected = !tonalSelected; + }); + }, + ), + const SizedBox(width: 10), + IconButton.filledTonal( + isSelected: tonalSelected, + icon: const Icon(Icons.settings_outlined), + selectedIcon: const Icon(Icons.settings), + onPressed: null, + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + IconButton.outlined( + isSelected: outlinedSelected, + icon: const Icon(Icons.settings_outlined), + selectedIcon: const Icon(Icons.settings), + onPressed: () { + setState(() { + outlinedSelected = !outlinedSelected; + }); + }, + ), + const SizedBox(width: 10), + IconButton.outlined( + isSelected: outlinedSelected, + icon: const Icon(Icons.settings_outlined), + selectedIcon: const Icon(Icons.settings), + onPressed: null, + ), + ], + ), + ], + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/material/ink/ink.image_clip.0.dart b/novelforge-project/flutter/examples/api/lib/material/ink/ink.image_clip.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..c4a58d959d28a1f6a1bb117a0a5c7237edaef7e4 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/material/ink/ink.image_clip.0.dart @@ -0,0 +1,56 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Image.frameBuilder]. + +void main() { + runApp( + MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('Image.frameBuilder Sample')), + body: const Center( + child: ImageClipExample( + image: NetworkImage('https://flutter.github.io/assets-for-api-docs/assets/widgets/puffin.jpg'), + ), + ), + ), + ), + ); +} + +class ImageClipExample extends StatelessWidget { + const ImageClipExample({super.key, required this.image}); + + final ImageProvider image; + + @override + Widget build(BuildContext context) { + return ClipRRect( + borderRadius: BorderRadius.circular(100), + child: Ink.image( + fit: BoxFit.fill, + width: 300, + height: 300, + image: image, + child: InkWell( + onTap: () {/* ... */}, + child: const Align( + child: Padding( + padding: EdgeInsets.all(10.0), + child: Text( + 'PUFFIN', + style: TextStyle( + fontWeight: FontWeight.w900, + color: Colors.white, + ), + ), + ), + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/painting/axis_direction/axis_direction.0.dart b/novelforge-project/flutter/examples/api/lib/painting/axis_direction/axis_direction.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..e48fd0918e11622e72da2169dc7ad7b9ee16232e --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/painting/axis_direction/axis_direction.0.dart @@ -0,0 +1,188 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [AxisDirection]s. + +void main() => runApp(const ExampleApp()); + +class ExampleApp extends StatelessWidget { + const ExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: MyWidget(), + ); + } +} + +class MyWidget extends StatefulWidget { + const MyWidget({super.key}); + + @override + State createState() => _MyWidgetState(); +} + +class _MyWidgetState extends State { + final List _alphabet = [ + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', + 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + ]; + final Widget _spacer = const SizedBox.square(dimension: 10); + AxisDirection _axisDirection = AxisDirection.down; + + Widget _getArrows() { + final Widget arrow; + switch (_axisDirection) { + case AxisDirection.up: + arrow = const Icon(Icons.arrow_upward_rounded); + return Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [arrow, arrow], + ); + case AxisDirection.down: + arrow = const Icon(Icons.arrow_downward_rounded); + return Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [arrow, arrow], + ); + case AxisDirection.left: + arrow = const Icon(Icons.arrow_back_rounded); + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [arrow, arrow], + ); + case AxisDirection.right: + arrow = const Icon(Icons.arrow_forward_rounded); + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [arrow, arrow], + ); + } + } + + void _onAxisDirectionChanged(AxisDirection? axisDirection) { + if (axisDirection != null && axisDirection != _axisDirection) { + setState(() { + // Respond to change in axis direction. + _axisDirection = axisDirection; + }); + } + } + + Widget _getLeading() { + return Container( + color: Colors.blue[100], + padding: const EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text(axisDirectionToAxis(_axisDirection).toString()), + _spacer, + Text(_axisDirection.toString()), + _spacer, + const Text('GrowthDirection.forward'), + _spacer, + _getArrows(), + ], + ), + ); + } + + Widget _getRadioRow() { + return DefaultTextStyle( + style: const TextStyle(fontWeight: FontWeight.bold, color: Colors.white), + child: RadioTheme( + data: RadioThemeData( + fillColor: MaterialStateProperty.all(Colors.white), + ), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Radio( + value: AxisDirection.up, + groupValue: _axisDirection, + onChanged: _onAxisDirectionChanged, + ), + const Text('up'), + _spacer, + Radio( + value: AxisDirection.down, + groupValue: _axisDirection, + onChanged: _onAxisDirectionChanged, + ), + const Text('down'), + _spacer, + Radio( + value: AxisDirection.left, + groupValue: _axisDirection, + onChanged: _onAxisDirectionChanged, + ), + const Text('left'), + _spacer, + Radio( + value: AxisDirection.right, + groupValue: _axisDirection, + onChanged: _onAxisDirectionChanged, + ), + const Text('right'), + _spacer, + ], + ), + ), + ), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('AxisDirections'), + bottom: PreferredSize( + preferredSize: const Size.fromHeight(50), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: _getRadioRow(), + ), + ), + ), + // Also works for ListView.builder, which creates a SliverList for itself. + // A CustomScrollView allows multiple slivers to be composed together. + body: CustomScrollView( + // This method is available to conveniently determine if an scroll + // view is reversed by its AxisDirection. + reverse: axisDirectionIsReversed(_axisDirection), + // This method is available to conveniently convert an AxisDirection + // into its Axis. + scrollDirection: axisDirectionToAxis(_axisDirection), + slivers: [ + SliverList.builder( + itemCount: 27, + itemBuilder: (BuildContext context, int index) { + final Widget child; + if (index == 0) { + child = _getLeading(); + } else { + child = Container( + color: index.isEven ? Colors.amber[100] : Colors.amberAccent, + padding: const EdgeInsets.all(8.0), + child: Center(child: Text(_alphabet[index - 1])), + ); + } + return Padding( + padding: const EdgeInsets.all(8.0), + child: child, + ); + }, + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/painting/borders/border_side.stroke_align.0.dart b/novelforge-project/flutter/examples/api/lib/painting/borders/border_side.stroke_align.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..1ba11404c7f615172b6dee287bc67a67ef85e49f --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/painting/borders/border_side.stroke_align.0.dart @@ -0,0 +1,202 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [BorderSide.strokeAlign]. + +void main() => runApp(const StrokeAlignApp()); + +class StrokeAlignApp extends StatelessWidget { + const StrokeAlignApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp(home: StrokeAlignExample()); + } +} + +class StrokeAlignExample extends StatefulWidget { + const StrokeAlignExample({super.key}); + + @override + State createState() => _StrokeAlignExampleState(); +} + +class _StrokeAlignExampleState extends State with TickerProviderStateMixin { + late final AnimationController animation; + + @override + void initState() { + super.initState(); + animation = AnimationController(vsync: this, duration: const Duration(seconds: 1)); + animation.repeat(reverse: true); + animation.addListener(_markDirty); + } + + @override + void dispose() { + animation.dispose(); + super.dispose(); + } + + void _markDirty() { + setState(() {}); + } + + static const double borderWidth = 10; + static const double cornerRadius = 10; + static const Color borderColor = Color(0x8000b4fc); + + @override + Widget build(BuildContext context) { + return Material( + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + BorderedBox( + shape: StadiumBorder( + side: BorderSide( + color: borderColor, + width: borderWidth, + strokeAlign: (animation.value * 2) - 1, + ), + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + BorderedBox( + shape: CircleBorder( + side: BorderSide( + color: borderColor, + width: borderWidth, + strokeAlign: (animation.value * 2) - 1, + ), + ), + ), + BorderedBox( + shape: OvalBorder( + side: BorderSide( + color: borderColor, + width: borderWidth, + strokeAlign: (animation.value * 2) - 1, + ), + ), + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + BorderedBox( + shape: BeveledRectangleBorder( + side: BorderSide( + color: borderColor, + width: borderWidth, + strokeAlign: (animation.value * 2) - 1, + ), + ), + ), + BorderedBox( + shape: BeveledRectangleBorder( + borderRadius: BorderRadius.circular(cornerRadius), + side: BorderSide( + color: borderColor, + width: borderWidth, + strokeAlign: (animation.value * 2) - 1, + ), + ), + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + BorderedBox( + shape: RoundedRectangleBorder( + side: BorderSide( + color: borderColor, + width: borderWidth, + strokeAlign: (animation.value * 2) - 1, + ), + ), + ), + BorderedBox( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(cornerRadius), + side: BorderSide( + color: borderColor, + width: borderWidth, + strokeAlign: (animation.value * 2) - 1, + ), + ), + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + BorderedBox( + shape: StarBorder( + side: BorderSide( + color: borderColor, + width: borderWidth, + strokeAlign: (animation.value * 2) - 1, + ), + ), + ), + BorderedBox( + shape: StarBorder( + pointRounding: 1, + innerRadiusRatio: 0.5, + points: 8, + side: BorderSide( + color: borderColor, + width: borderWidth, + strokeAlign: (animation.value * 2) - 1, + ), + ), + ), + BorderedBox( + shape: StarBorder.polygon( + sides: 6, + pointRounding: 0.5, + side: BorderSide( + color: borderColor, + width: borderWidth, + strokeAlign: (animation.value * 2) - 1, + ), + ), + ), + ], + ), + ], + ), + ), + ); + } +} + +class BorderedBox extends StatelessWidget { + const BorderedBox({ + super.key, + required this.shape, + }); + + final ShapeBorder shape; + + @override + Widget build(BuildContext context) { + return Container( + width: 100, + height: 50, + decoration: ShapeDecoration( + color: const Color(0xff012677), + shape: shape, + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/painting/gradient/linear_gradient.0.dart b/novelforge-project/flutter/examples/api/lib/painting/gradient/linear_gradient.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..503bdaeb349592dbdf8e342adc480dd69f574480 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/painting/gradient/linear_gradient.0.dart @@ -0,0 +1,53 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [LinearGradient]. + +void main() => runApp(const LinearGradientExampleApp()); + +class LinearGradientExampleApp extends StatelessWidget { + const LinearGradientExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp(home: MoodyGradient()); + } +} + +class MoodyGradient extends StatelessWidget { + const MoodyGradient({super.key}); + + @override + Widget build(BuildContext context) { + return Material( + child: Container( + decoration: const BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment(0.8, 1), + colors: [ + Color(0xff1f005c), + Color(0xff5b0060), + Color(0xff870160), + Color(0xffac255e), + Color(0xffca485c), + Color(0xffe16b5c), + Color(0xfff39060), + Color(0xffffb56b), + ], // Gradient from https://learnui.design/tools/gradient-generator.html + tileMode: TileMode.mirror, + ), + ), + child: const Center( + child: Text( + 'From Night to Day', + style: TextStyle(fontSize: 24, color: Colors.white), + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/painting/image_provider/image_provider.0.dart b/novelforge-project/flutter/examples/api/lib/painting/image_provider/image_provider.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..86349f15c0d0fc45f94658bea1b8c20a75f889fd --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/painting/image_provider/image_provider.0.dart @@ -0,0 +1,104 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; +import 'dart:io'; +import 'dart:ui' as ui; + +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; + +@immutable +class CustomNetworkImage extends ImageProvider { + const CustomNetworkImage(this.url); + + final String url; + + @override + Future obtainKey(ImageConfiguration configuration) { + final Uri result = Uri.parse(url).replace( + queryParameters: { + 'dpr': '${configuration.devicePixelRatio}', + 'locale': '${configuration.locale?.toLanguageTag()}', + 'platform': '${configuration.platform?.name}', + 'width': '${configuration.size?.width}', + 'height': '${configuration.size?.height}', + 'bidi': '${configuration.textDirection?.name}', + }, + ); + return SynchronousFuture(result); + } + + static HttpClient get _httpClient { + HttpClient? client; + assert(() { + if (debugNetworkImageHttpClientProvider != null) { + client = debugNetworkImageHttpClientProvider!(); + } + return true; + }()); + return client ?? HttpClient()..autoUncompress = false; + } + + @override + ImageStreamCompleter loadImage(Uri key, ImageDecoderCallback decode) { + final StreamController chunkEvents = StreamController(); + debugPrint('Fetching "$key"...'); + return MultiFrameImageStreamCompleter( + codec: _httpClient.getUrl(key) + .then((HttpClientRequest request) => request.close()) + .then((HttpClientResponse response) { + return consolidateHttpClientResponseBytes( + response, + onBytesReceived: (int cumulative, int? total) { + chunkEvents.add(ImageChunkEvent( + cumulativeBytesLoaded: cumulative, + expectedTotalBytes: total, + )); + }, + ); + }) + .catchError((Object e, StackTrace stack) { + scheduleMicrotask(() { + PaintingBinding.instance.imageCache.evict(key); + }); + return Future.error(e, stack); + }) + .whenComplete(chunkEvents.close) + .then(ui.ImmutableBuffer.fromUint8List) + .then(decode), + chunkEvents: chunkEvents.stream, + scale: 1.0, + debugLabel: '"key"', + informationCollector: () => [ + DiagnosticsProperty('Image provider', this), + DiagnosticsProperty('URL', key), + ], + ); + } + + @override + String toString() => '${objectRuntimeType(this, 'CustomNetworkImage')}("$url")'; +} + +void main() => runApp(const ExampleApp()); + +class ExampleApp extends StatelessWidget { + const ExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: LayoutBuilder( + builder: (BuildContext context, BoxConstraints constraints) { + return Image( + image: const CustomNetworkImage('https://flutter.github.io/assets-for-api-docs/assets/widgets/flamingos.jpg'), + width: constraints.hasBoundedWidth ? constraints.maxWidth : null, + height: constraints.hasBoundedHeight ? constraints.maxHeight : null, + ); + }, + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/painting/linear_border/linear_border.0.dart b/novelforge-project/flutter/examples/api/lib/painting/linear_border/linear_border.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..510a65236eb9feb53d7fab5fc05c4803f2278910 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/painting/linear_border/linear_border.0.dart @@ -0,0 +1,302 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Examples for [LinearBorder] and [LinearBorderEdge]. + +void main() { + runApp(const ExampleApp()); +} + +class ExampleApp extends StatelessWidget { + const ExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData.light(useMaterial3: true), + home: const Directionality( + // TRY THIS: Switch to TextDirection.rtl to see how the borders change. + textDirection: TextDirection.ltr, + child: Home(), + ), + ); + } +} + +class SampleCard extends StatelessWidget { + const SampleCard({super.key, required this.title, required this.subtitle, required this.children}); + + final String title; + final String subtitle; + final List children; + + @override + Widget build(BuildContext context) { + final ThemeData theme = Theme.of(context); + final TextTheme textTheme = theme.textTheme; + final ColorScheme colorScheme = theme.colorScheme; + + return Card( + child: Padding( + padding: const EdgeInsets.all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text(title, style: textTheme.titleMedium), + Text(subtitle, style: textTheme.bodyMedium!.copyWith(color: colorScheme.secondary)), + const SizedBox(height: 16), + Row( + children: List.generate(children.length * 2 - 1, (int index) { + return index.isEven ? children[index ~/ 2] : const SizedBox(width: 16); + }), + ), + ], + ), + ), + ); + } +} + +class Home extends StatefulWidget { + const Home({super.key}); + + @override + State createState() => _HomeState(); +} + +class _HomeState extends State { + final LinearBorder shape0 = LinearBorder.top(); + final LinearBorder shape1 = LinearBorder.top(size: 0); + late LinearBorder shape = shape0; + + @override + Widget build(BuildContext context) { + final ColorScheme colorScheme = Theme.of(context).colorScheme; + final BorderSide primarySide0 = BorderSide(width: 0, color: colorScheme.inversePrimary); // hairline + final BorderSide primarySide2 = BorderSide(width: 2, color: colorScheme.onPrimaryContainer); + final BorderSide primarySide3 = BorderSide(width: 3, color: colorScheme.inversePrimary); + + return Scaffold( + body: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(16), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + // Demonstrates using LinearBorder.bottom() to define + // an underline border for the standard button types. + // The underline's color and width is defined by the ButtonStyle's + // side parameter. The side can also be specified as a + // LinearBorder parameter and if both are specified then the + // ButtonStyle's side is used. This set up makes it possible + // for a button theme to specify the shape and for individual + // buttons to specify the shape border's color and width. + SampleCard( + title: 'LinearBorder.bottom()', + subtitle: 'Standard button widgets', + children: [ + TextButton( + style: TextButton.styleFrom( + side: primarySide3, + shape: LinearBorder.bottom(), + ), + onPressed: () {}, + child: const Text('Text'), + ), + OutlinedButton( + style: OutlinedButton.styleFrom( + side: primarySide3, + shape: LinearBorder.bottom(), + ), + onPressed: () {}, + child: const Text('Outlined'), + ), + ElevatedButton( + style: ElevatedButton.styleFrom( + side: primarySide3, + shape: LinearBorder.bottom(), + ), + onPressed: () {}, + child: const Text('Elevated'), + ), + ], + ), + const SizedBox(height: 32), + // Demonstrates creating LinearBorders with a single edge + // by using the convenience constructors like LinearBorder.start(). + // The edges are drawn with a BorderSide with width:0, which + // means that a "hairline" line is stroked. Wider borders are + // drawn with filled rectangles. + SampleCard( + title: 'LinearBorder', + subtitle: 'Convenience constructors', + children: [ + TextButton( + style: TextButton.styleFrom( + side: primarySide0, + shape: LinearBorder.start(), + ), + onPressed: () {}, + child: const Text('Start()'), + ), + TextButton( + style: TextButton.styleFrom( + side: primarySide0, + shape: LinearBorder.end(), + ), + onPressed: () {}, + child: const Text('End()'), + ), + TextButton( + style: TextButton.styleFrom( + side: primarySide0, + shape: LinearBorder.top(), + ), + onPressed: () {}, + child: const Text('Top()'), + ), + TextButton( + style: TextButton.styleFrom( + side: primarySide0, + shape: LinearBorder.bottom(), + ), + onPressed: () {}, + child: const Text('Bottom()'), + ), + ], + ), + const SizedBox(height: 32), + // Demonstrates creating LinearBorders with a single edge + // that's smaller than the button's bounding box. The size + // parameter specifies a percentage of the available space + // and alignment is -1 for start-alignment, 0 for centered, + // and 1 for end-alignment. + SampleCard( + title: 'LinearBorder', + subtitle: 'Size and alignment parameters', + children: [ + TextButton( + style: TextButton.styleFrom( + side: primarySide2, + shape: LinearBorder.bottom( + size: 0.5, + ), + ), + onPressed: () {}, + child: const Text('Center'), + ), + TextButton( + style: TextButton.styleFrom( + side: primarySide2, + shape: LinearBorder.bottom( + size: 0.75, + alignment: -1, + ), + ), + onPressed: () {}, + child: const Text('Start'), + ), + TextButton( + style: TextButton.styleFrom( + side: primarySide2, + shape: LinearBorder.bottom( + size: 0.75, + alignment: 1, + ), + ), + onPressed: () {}, + child: const Text('End'), + ), + ], + ), + const SizedBox(height: 32), + // Demonstrates creating LinearBorders with more than one edge. + // In these cases the default constructor is used and each edge + // is defined with one LinearBorderEdge object. + SampleCard( + title: 'LinearBorder', + subtitle: 'LinearBorderEdge parameters', + children: [ + TextButton( + style: TextButton.styleFrom( + side: primarySide0, + shape: const LinearBorder( + top: LinearBorderEdge(), + bottom: LinearBorderEdge(), + ), + ), + onPressed: () {}, + child: const Text('Horizontal'), + ), + TextButton( + style: TextButton.styleFrom( + side: primarySide0, + shape: const LinearBorder( + start: LinearBorderEdge(), + end: LinearBorderEdge(), + ), + ), + onPressed: () {}, + child: const Text('Vertical'), + ), + TextButton( + style: TextButton.styleFrom( + side: primarySide0, + shape: const LinearBorder( + start: LinearBorderEdge(), + bottom: LinearBorderEdge(), + ), + ), + onPressed: () {}, + child: const Text('Corner'), + ), + ], + ), + const SizedBox(height: 32), + // Demonstrates that changing properties of LinearBorders + // causes them to animate to their new configuration. + SampleCard( + title: 'Interpolation', + subtitle: 'LinearBorder.top() => LinearBorder.top(size: 0)', + children: [ + IconButton( + icon: const Icon(Icons.play_arrow), + onPressed: () { + setState(() { + shape = shape == shape0 ? shape1 : shape0; + }); + }, + ), + TextButton( + style: TextButton.styleFrom( + side: primarySide3, + shape: shape, + ), + onPressed: () {}, + child: const Text('Press Play'), + ), + TextButton( + style: ButtonStyle( + side: MaterialStateProperty.resolveWith((Set states) { + return states.contains(MaterialState.hovered) ? primarySide3 : null; + }), + shape: MaterialStateProperty.resolveWith((Set states) { + return states.contains(MaterialState.hovered) ? shape0 : shape1; + }), + ), + onPressed: () {}, + child: const Text('Hover'), + ), + ], + ), + ], + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/painting/star_border/star_border.0.dart b/novelforge-project/flutter/examples/api/lib/painting/star_border/star_border.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..a89c7f6a9f1eb74550cc5ce6f826c4c8abc3d420 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/painting/star_border/star_border.0.dart @@ -0,0 +1,453 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// An example showing usage of [StarBorder]. + +import 'package:flutter/material.dart'; + +const int _kParameterPrecision = 2; + +void main() => runApp(const StarBorderApp()); + +class StarBorderApp extends StatelessWidget { + const StarBorderApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('StarBorder Example'), + backgroundColor: const Color(0xff323232), + ), + body: const StarBorderExample(), + ), + ); + } +} + +class StarBorderExample extends StatefulWidget { + const StarBorderExample({super.key}); + + @override + State createState() => _StarBorderExampleState(); +} + +class _StarBorderExampleState extends State { + final OptionModel _model = OptionModel(); + final TextEditingController _textController = TextEditingController(); + + @override + void initState() { + super.initState(); + _model.addListener(_modelChanged); + } + + @override + void dispose() { + _model.removeListener(_modelChanged); + _textController.dispose(); + super.dispose(); + } + + void _modelChanged() { + setState(() {}); + } + + @override + Widget build(BuildContext context) { + return DefaultTextStyle( + style: const TextStyle( + color: Colors.black, + fontSize: 14.0, + fontFamily: 'Roboto', + fontStyle: FontStyle.normal, + ), + child: ListView( + children: [ + ColoredBox( + color: Colors.grey.shade200, + child: Options(_model), + ), + Padding( + padding: const EdgeInsets.all(18.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + child: ExampleBorder( + border: StarBorder( + side: const BorderSide(), + points: _model.points, + innerRadiusRatio: _model.innerRadiusRatio, + pointRounding: _model.pointRounding, + valleyRounding: _model.valleyRounding, + rotation: _model.rotation, + squash: _model.squash, + ), + title: 'Star', + ), + ), + Expanded( + child: ExampleBorder( + border: StarBorder.polygon( + side: const BorderSide(), + sides: _model.points, + pointRounding: _model.pointRounding, + rotation: _model.rotation, + squash: _model.squash, + ), + title: 'Polygon', + ), + ), + ], + ), + ), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Container( + color: Colors.black12, + margin: const EdgeInsets.all(16.0), + padding: const EdgeInsets.all(16.0), + child: SelectableText(_model.starCode), + ), + ), + Expanded( + child: Container( + color: Colors.black12, + margin: const EdgeInsets.all(16.0), + padding: const EdgeInsets.all(16.0), + child: SelectableText(_model.polygonCode), + ), + ), + ], + ), + ], + ), + ); + } +} + +class ExampleBorder extends StatelessWidget { + const ExampleBorder({ + super.key, + required this.border, + required this.title, + }); + + final StarBorder border; + final String title; + + @override + Widget build(BuildContext context) { + return Container( + alignment: Alignment.center, + padding: const EdgeInsets.all(20), + width: 150, + height: 100, + decoration: ShapeDecoration( + color: Colors.blue.shade100, + shape: border, + ), + child: Text(title), + ); + } +} + +class Options extends StatefulWidget { + const Options(this.model, {super.key}); + + final OptionModel model; + + @override + State createState() => _OptionsState(); +} + +class _OptionsState extends State { + @override + void initState() { + super.initState(); + widget.model.addListener(_modelChanged); + } + + @override + void didUpdateWidget(Options oldWidget) { + super.didUpdateWidget(oldWidget); + if (widget.model != oldWidget.model) { + oldWidget.model.removeListener(_modelChanged); + widget.model.addListener(_modelChanged); + } + } + + @override + void dispose() { + super.dispose(); + widget.model.removeListener(_modelChanged); + } + + void _modelChanged() { + setState(() {}); + } + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.fromLTRB(5.0, 0.0, 5.0, 10.0), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Row( + children: [ + Expanded( + child: ControlSlider( + label: 'Point Rounding', + value: widget.model.pointRounding, + onChanged: (double value) { + widget.model.pointRounding = value; + }, + ), + ), + Expanded( + child: ControlSlider( + label: 'Valley Rounding', + value: widget.model.valleyRounding, + onChanged: (double value) { + widget.model.valleyRounding = value; + }, + ), + ), + ], + ), + Row( + children: [ + Expanded( + child: ControlSlider( + label: 'Squash', + value: widget.model.squash, + onChanged: (double value) { + widget.model.squash = value; + }, + ), + ), + Expanded( + child: ControlSlider( + label: 'Rotation', + value: widget.model.rotation, + max: 360, + onChanged: (double value) { + widget.model.rotation = value; + }, + ), + ), + ], + ), + Row( + children: [ + Expanded( + child: Row( + children: [ + Expanded( + child: ControlSlider( + label: 'Points', + value: widget.model.points, + min: 3, + max: 20, + precision: 1, + onChanged: (double value) { + widget.model.points = value; + }, + ), + ), + Tooltip( + message: 'Round the number of points to the nearest integer.', + child: Padding( + padding: const EdgeInsets.all(8.0), + child: OutlinedButton( + child: const Text('Nearest'), + onPressed: () { + widget.model.points = widget.model.points.roundToDouble(); + }, + ), + ), + ), + ], + ), + ), + Expanded( + child: ControlSlider( + label: 'Inner Radius', + value: widget.model.innerRadiusRatio, + onChanged: (double value) { + widget.model.innerRadiusRatio = value; + }, + ), + ), + ], + ), + ElevatedButton( + onPressed: () { + widget.model.reset(); + }, + child: const Text('Reset'), + ), + ], + ), + ); + } +} + +class OptionModel extends ChangeNotifier { + double get pointRounding => _pointRounding; + double _pointRounding = 0.0; + set pointRounding(double value) { + if (value != _pointRounding) { + _pointRounding = value; + if (_valleyRounding + _pointRounding > 1) { + _valleyRounding = 1.0 - _pointRounding; + } + notifyListeners(); + } + } + + double get valleyRounding => _valleyRounding; + double _valleyRounding = 0.0; + set valleyRounding(double value) { + if (value != _valleyRounding) { + _valleyRounding = value; + if (_valleyRounding + _pointRounding > 1) { + _pointRounding = 1.0 - _valleyRounding; + } + notifyListeners(); + } + } + + double get squash => _squash; + double _squash = 0.0; + set squash(double value) { + if (value != _squash) { + _squash = value; + notifyListeners(); + } + } + + double get rotation => _rotation; + double _rotation = 0.0; + set rotation(double value) { + if (value != _rotation) { + _rotation = value; + notifyListeners(); + } + } + + double get innerRadiusRatio => _innerRadiusRatio; + double _innerRadiusRatio = 0.4; + set innerRadiusRatio(double value) { + if (value != _innerRadiusRatio) { + _innerRadiusRatio = value.clamp(0.0001, double.infinity); + notifyListeners(); + } + } + + double get points => _points; + double _points = 5; + set points(double value) { + if (value != _points) { + _points = value; + notifyListeners(); + } + } + + String get starCode { + return 'Container(\n' + ' decoration: ShapeDecoration(\n' + ' shape: StarBorder(\n' + ' points: ${points.toStringAsFixed(_kParameterPrecision)},\n' + ' rotation: ${rotation.toStringAsFixed(_kParameterPrecision)},\n' + ' innerRadiusRatio: ${innerRadiusRatio.toStringAsFixed(_kParameterPrecision)},\n' + ' pointRounding: ${pointRounding.toStringAsFixed(_kParameterPrecision)},\n' + ' valleyRounding: ${valleyRounding.toStringAsFixed(_kParameterPrecision)},\n' + ' squash: ${squash.toStringAsFixed(_kParameterPrecision)},\n' + ' ),\n' + ' ),\n' + ');'; + } + + String get polygonCode { + return 'Container(\n' + ' decoration: ShapeDecoration(\n' + ' shape: StarBorder.polygon(\n' + ' sides: ${points.toStringAsFixed(_kParameterPrecision)},\n' + ' rotation: ${rotation.toStringAsFixed(_kParameterPrecision)},\n' + ' cornerRounding: ${pointRounding.toStringAsFixed(_kParameterPrecision)},\n' + ' squash: ${squash.toStringAsFixed(_kParameterPrecision)},\n' + ' ),\n' + ' ),\n' + ');'; + } + + void reset() { + final OptionModel defaultModel = OptionModel(); + _pointRounding = defaultModel.pointRounding; + _valleyRounding = defaultModel.valleyRounding; + _rotation = defaultModel.rotation; + _squash = defaultModel.squash; + _innerRadiusRatio = defaultModel._innerRadiusRatio; + _points = defaultModel.points; + notifyListeners(); + } +} + +class ControlSlider extends StatelessWidget { + const ControlSlider({ + super.key, + required this.label, + required this.value, + required this.onChanged, + this.min = 0.0, + this.max = 1.0, + this.precision = _kParameterPrecision, + }); + + final String label; + final double value; + final void Function(double value) onChanged; + final double min; + final double max; + final int precision; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.all(4.0), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Expanded( + flex: 2, + child: Text( + label, + textAlign: TextAlign.end, + ), + ), + Expanded( + flex: 5, + child: Slider( + onChanged: onChanged, + min: min, + max: max, + value: value, + ), + ), + Expanded( + child: Text( + value.toStringAsFixed(precision), + ), + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/rendering/box/parent_data.0.dart b/novelforge-project/flutter/examples/api/lib/rendering/box/parent_data.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..0063f0e54427d17d464629593a85aaeb7ec9fd0d --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/rendering/box/parent_data.0.dart @@ -0,0 +1,394 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; + +void main() => runApp(const SampleApp()); + +class SampleApp extends StatefulWidget { + const SampleApp({super.key}); + + @override + State createState() => _SampleAppState(); +} + +class _SampleAppState extends State { + // This can be toggled using buttons in the UI to change which layout render object is used. + bool _compact = false; + + // This is the content we show in the rendering. + // + // Headline and Paragraph are simple custom widgets defined below. + // + // Any widget _could_ be specified here, and would render fine. + // The Headline and Paragraph widgets are used so that the renderer + // can distinguish between the kinds of content and use different + // spacing between different children. + static const List body = [ + Headline('Bugs that improve T for future bugs'), + Paragraph( + 'The best bugs to fix are those that make us more productive ' + 'in the future. Reducing test flakiness, reducing technical ' + 'debt, increasing the number of team members who are able to ' + 'review code confidently and well: this all makes future bugs ' + 'easier to fix, which is a huge multiplier to our overall ' + 'effectiveness and thus to developer happiness.', + ), + Headline('Bugs affecting more people are more valuable (maximize N)'), + Paragraph( + 'We will make more people happier if we fix a bug experienced by more people.' + ), + Paragraph( + 'One thing to be careful about is to think about the number of ' + 'people we are ignoring in our metrics. For example, if we had ' + 'a bug that prevented our product from working on Windows, we ' + 'would have no Windows users, so the bug would affect nobody. ' + 'However, fixing the bug would enable millions of developers ' + "to use our product, and that's the number that counts." + ), + Headline('Bugs with greater impact on developers are more valuable (maximize ΔH)'), + Paragraph( + 'A slight improvement to the user experience is less valuable ' + 'than a greater improvement. For example, if our application, ' + 'under certain conditions, shows a message with a typo, and ' + 'then crashes because of an off-by-one error in the code, ' + 'fixing the crash is a higher priority than fixing the typo.' + ), + ]; + + // This is the description of the demo's interface. + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Custom Render Boxes'), + // There are two buttons over to the top right of the demo that let you + // toggle between the two rendering modes. + actions: [ + IconButton( + icon: const Icon(Icons.density_small), + isSelected: _compact, + onPressed: () { + setState(() { _compact = true; }); + }, + ), + IconButton( + icon: const Icon(Icons.density_large), + isSelected: !_compact, + onPressed: () { + setState(() { _compact = false; }); + }, + ), + ], + ), + body: SingleChildScrollView( + padding: const EdgeInsets.symmetric(horizontal: 30.0, vertical: 20.0), + // CompactLayout and OpenLayout are the two rendering widgets defined below. + child: _compact ? const CompactLayout(children: body) : const OpenLayout(children: body), + ), + ), + ); + } +} + +// Headline and Paragraph are just wrappers around the Text widget, but they +// also introduce a TextCategory widget that the CompactLayout and OpenLayout +// widgets can read to determine what kind of child is being rendered. + +class Headline extends StatelessWidget { + const Headline(this.text, { super.key }); + + final String text; + + @override + Widget build(BuildContext context) { + return TextCategory( + category: 'headline', + child: Text(text, style: Theme.of(context).textTheme.titleLarge), + ); + } +} + +class Paragraph extends StatelessWidget { + const Paragraph(this.text, { super.key }); + + final String text; + + @override + Widget build(BuildContext context) { + return TextCategory( + category: 'paragraph', + child: Text(text, style: Theme.of(context).textTheme.bodyLarge), + ); + } +} + +// This is the ParentDataWidget that allows us to specify what kind of child +// is being rendered. It allows information to be shared with the render object +// without violating the principle of agnostic composition (wherein parents should +// work with any child, not only support a fixed set of children). +class TextCategory extends ParentDataWidget { + const TextCategory({ super.key, required this.category, required super.child }); + + final String category; + + @override + void applyParentData(RenderObject renderObject) { + final TextFlowParentData parentData = renderObject.parentData! as TextFlowParentData; + if (parentData.category != category) { + parentData.category = category; + renderObject.parent!.markNeedsLayout(); + } + } + + @override + Type get debugTypicalAncestorWidgetClass => OpenLayout; +} + +// This is one of the two layout variants. It is a widget that defers to +// a render object defined below (RenderCompactLayout). +class CompactLayout extends MultiChildRenderObjectWidget { + const CompactLayout({ super.key, super.children }); + + @override + RenderCompactLayout createRenderObject(BuildContext context) { + return RenderCompactLayout(); + } + + @override + void updateRenderObject(BuildContext context, RenderCompactLayout renderObject) { + // nothing to update + } +} + +// This is the other of the two layout variants. It is a widget that defers to a +// render object defined below (RenderOpenLayout). +class OpenLayout extends MultiChildRenderObjectWidget { + const OpenLayout({ super.key, super.children }); + + @override + RenderOpenLayout createRenderObject(BuildContext context) { + return RenderOpenLayout(); + } + + @override + void updateRenderObject(BuildContext context, RenderOpenLayout renderObject) { + // nothing to update + } +} + +// This is the data structure that contains the kind of data that can be +// passed to the parent to label the child. It is literally stored on +// the RenderObject child, in its "parentData" field. +class TextFlowParentData extends ContainerBoxParentData { + String category = ''; +} + +// This is the bulk of the layout logic. (It's similar to RenderListBody, +// but only supports vertical layout.) It has no properties. +// +// This is an abstract class that is then extended by RenderCompactLayout and +// RenderOpenLayout to get different layouts based on the children's categories, +// as stored in the ParentData structure defined above. +// +// The documentation for the RenderBox class and its members provides much +// more detail on how to implement each of the methods below. +abstract class RenderTextFlow extends RenderBox + with ContainerRenderObjectMixin, + RenderBoxContainerDefaultsMixin { + RenderTextFlow({ List? children }) { + addAll(children); + } + + @override + void setupParentData(RenderBox child) { + if (child.parentData is! TextFlowParentData) { + child.parentData = TextFlowParentData(); + } + } + + // This is the function that is overridden by the subclasses to do the + // actual decision about the space to use between children. + double spacingBetween(String before, String after); + + // The next few functions are the layout functions. In each case we walk the + // children, calling each one to determine the geometry of the child, and use + // that to determine the layout. + + // The first two functions compute the intrinsic width of the render object, + // as seen when using the IntrinsicWidth widget. + // + // They essentially defer to the widest child. + + @override + double computeMinIntrinsicWidth(double height) { + double width = 0.0; + RenderBox? child = firstChild; + while (child != null) { + final double childWidth = child.getMinIntrinsicWidth(height); + if (childWidth > width) { + width = childWidth; + } + child = childAfter(child); + } + return width; + } + + @override + double computeMaxIntrinsicWidth(double height) { + double width = 0.0; + RenderBox? child = firstChild; + while (child != null) { + final double childWidth = child.getMaxIntrinsicWidth(height); + if (childWidth > width) { + width = childWidth; + } + child = childAfter(child); + } + return width; + } + + // The next two functions compute the intrinsic height of the render object, + // as seen when using the IntrinsicHeight widget. + // + // They add up the height contributed by each child. + // + // They have to take into account the categories of the children and the + // spacing that will be added, hence the slightly more elaborate logic. + + @override + double computeMinIntrinsicHeight(double width) { + String? previousCategory; + double height = 0.0; + RenderBox? child = firstChild; + while (child != null) { + final String category = (child.parentData! as TextFlowParentData).category; + if (previousCategory != null) { + height += spacingBetween(previousCategory, category); + } + height += child.getMinIntrinsicHeight(width); + previousCategory = category; + child = childAfter(child); + } + return height; + } + + @override + double computeMaxIntrinsicHeight(double width) { + String? previousCategory; + double height = 0.0; + RenderBox? child = firstChild; + while (child != null) { + final String category = (child.parentData! as TextFlowParentData).category; + if (previousCategory != null) { + height += spacingBetween(previousCategory, category); + } + height += child.getMaxIntrinsicHeight(width); + previousCategory = category; + child = childAfter(child); + } + return height; + } + + // This function implements the baseline logic. Because this class does + // nothing special, we just defer to the default implementation in the + // RenderBoxContainerDefaultsMixin utility class. + + @override + double? computeDistanceToActualBaseline(TextBaseline baseline) { + return defaultComputeDistanceToFirstActualBaseline(baseline); + } + + // Next we have a function similar to the intrinsic methods, but for both axes + // at the same time. + + @override + Size computeDryLayout(BoxConstraints constraints) { + final BoxConstraints innerConstraints = BoxConstraints.tightFor(width: constraints.maxWidth); + String? previousCategory; + double y = 0.0; + RenderBox? child = firstChild; + while (child != null) { + final String category = (child.parentData! as TextFlowParentData).category; + if (previousCategory != null) { + y += spacingBetween(previousCategory, category); + } + final Size childSize = child.getDryLayout(innerConstraints); + y += childSize.height; + previousCategory = category; + child = childAfter(child); + } + return constraints.constrain(Size(constraints.maxWidth, y)); + } + + // This is the core of the layout logic. Most of the time, this is the only + // function that will be called. It computes the size and position of each + // child, and stores it (in the parent data, as it happens!) for use during + // the paint phase. + + @override + void performLayout() { + final BoxConstraints innerConstraints = BoxConstraints.tightFor(width: constraints.maxWidth); + String? previousCategory; + double y = 0.0; + RenderBox? child = firstChild; + while (child != null) { + final String category = (child.parentData! as TextFlowParentData).category; + if (previousCategory != null) { + // This is where we call the function that computes the spacing between + // the different children. The arguments are the categories, obtained + // from the parentData property of each child. + y += spacingBetween(previousCategory, category); + } + child.layout(innerConstraints, parentUsesSize: true); + (child.parentData! as TextFlowParentData).offset = Offset(0.0, y); + y += child.size.height; + previousCategory = category; + child = childAfter(child); + } + size = constraints.constrain(Size(constraints.maxWidth, y)); + } + + // Hit testing is normal for this widget, so we defer to the default implementation. + @override + bool hitTestChildren(BoxHitTestResult result, { required Offset position }) { + return defaultHitTestChildren(result, position: position); + } + + // Painting is normal for this widget, so we defer to the default + // implementation. The default implementation expects to find the positions + // configured in the parentData property of each child, which is why we + // configure it that way in performLayout above. + @override + void paint(PaintingContext context, Offset offset) { + defaultPaint(context, offset); + } +} + +// Finally we have the two render objects that implement the two layouts in this demo. + +class RenderOpenLayout extends RenderTextFlow { + @override + double spacingBetween(String before, String after) { + if (after == 'headline') { + return 20.0; + } + if (before == 'headline') { + return 5.0; + } + return 10.0; + } +} + +class RenderCompactLayout extends RenderTextFlow { + @override + double spacingBetween(String before, String after) { + if (after == 'headline') { + return 4.0; + } + return 2.0; + } +} diff --git a/novelforge-project/flutter/examples/api/lib/rendering/growth_direction/growth_direction.0.dart b/novelforge-project/flutter/examples/api/lib/rendering/growth_direction/growth_direction.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..d5ca03e434f649440c1e3fb9323d140ce23ebdb0 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/rendering/growth_direction/growth_direction.0.dart @@ -0,0 +1,223 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; + +/// Flutter code sample for [GrowthDirection]s. + +void main() => runApp(const ExampleApp()); + +class ExampleApp extends StatelessWidget { + const ExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: MyWidget(), + ); + } +} + +class MyWidget extends StatefulWidget { + const MyWidget({super.key}); + + @override + State createState() => _MyWidgetState(); +} + +class _MyWidgetState extends State { + final List _alphabet = [ + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', + 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + ]; + final Widget _spacer = const SizedBox.square(dimension: 10); + final UniqueKey _center = UniqueKey(); + AxisDirection _axisDirection = AxisDirection.down; + + Widget _getArrows(AxisDirection axisDirection) { + final Widget arrow; + switch (axisDirection) { + case AxisDirection.up: + arrow = const Icon(Icons.arrow_upward_rounded); + return Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [arrow, arrow], + ); + case AxisDirection.down: + arrow = const Icon(Icons.arrow_downward_rounded); + return Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [arrow, arrow], + ); + case AxisDirection.left: + arrow = const Icon(Icons.arrow_back_rounded); + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [arrow, arrow], + ); + case AxisDirection.right: + arrow = const Icon(Icons.arrow_forward_rounded); + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [arrow, arrow], + ); + } + } + + void _onAxisDirectionChanged(AxisDirection? axisDirection) { + if (axisDirection != null && axisDirection != _axisDirection) { + setState(() { + // Respond to change in axis direction. + _axisDirection = axisDirection; + }); + } + } + + Widget _getLeading(SliverConstraints constraints, bool isForward) { + return Container( + color: isForward ? Colors.orange[300] : Colors.green[400], + padding: const EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text(constraints.axis.toString()), + _spacer, + Text(constraints.axisDirection.toString()), + _spacer, + Text(constraints.growthDirection.toString()), + _spacer, + _getArrows( + isForward + ? _axisDirection + // This method is available to conveniently flip an AxisDirection + // into its opposite direction. + : flipAxisDirection(_axisDirection), + ), + ], + ), + ); + } + + Widget _getRadioRow() { + return DefaultTextStyle( + style: const TextStyle(fontWeight: FontWeight.bold, color: Colors.white), + child: RadioTheme( + data: RadioThemeData( + fillColor: MaterialStateProperty.all(Colors.white), + ), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Radio( + value: AxisDirection.up, + groupValue: _axisDirection, + onChanged: _onAxisDirectionChanged, + ), + const Text('up'), + _spacer, + Radio( + value: AxisDirection.down, + groupValue: _axisDirection, + onChanged: _onAxisDirectionChanged, + ), + const Text('down'), + _spacer, + Radio( + value: AxisDirection.left, + groupValue: _axisDirection, + onChanged: _onAxisDirectionChanged, + ), + const Text('left'), + _spacer, + Radio( + value: AxisDirection.right, + groupValue: _axisDirection, + onChanged: _onAxisDirectionChanged, + ), + const Text('right'), + _spacer, + ], + ), + ), + ), + ); + } + + Widget _getList({required bool isForward}) { + // The SliverLayoutBuilder is not necessary, and is here to allow us to see + // the SliverConstraints & directional information that is provided to the + // SliverList when laying out. + return SliverLayoutBuilder( + builder: (BuildContext context, SliverConstraints constraints) { + return SliverList.builder( + itemCount: 27, + itemBuilder: (BuildContext context, int index) { + final Widget child; + if (index == 0) { + child = _getLeading(constraints, isForward); + } else { + child = Container( + color: isForward + ? (index.isEven ? Colors.amber[100] : Colors.amberAccent) + : (index.isEven ? Colors.green[100] : Colors.lightGreen), + padding: const EdgeInsets.all(8.0), + child: Center(child: Text(_alphabet[index - 1])), + ); + } + return Padding( + padding: const EdgeInsets.all(8.0), + child: child, + ); + }, + ); + }, + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('GrowthDirections'), + bottom: PreferredSize( + preferredSize: const Size.fromHeight(50), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: _getRadioRow(), + ), + ), + ), + body: CustomScrollView( + // This method is available to conveniently determine if an scroll + // view is reversed by its AxisDirection. + reverse: axisDirectionIsReversed(_axisDirection), + // This method is available to conveniently convert an AxisDirection + // into its Axis. + scrollDirection: axisDirectionToAxis(_axisDirection), + // Places the leading edge of the center sliver in the middle of the + // viewport. Changing this value between 0.0 (the default) and 1.0 + // changes the position of the inflection point between GrowthDirections + // in the viewport when the slivers are laid out. + anchor: 0.5, + center: _center, + slivers: [ + _getList(isForward: false), + SliverToBoxAdapter( + // This sliver will be located at the anchor. The scroll position + // will progress in either direction from this point. + key: _center, + child: const Padding( + padding: EdgeInsets.all(8.0), + child: Center(child: Text('0', style: TextStyle(fontWeight: FontWeight.bold))), + ), + ), + _getList(isForward: true), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/rendering/scroll_direction/scroll_direction.0.dart b/novelforge-project/flutter/examples/api/lib/rendering/scroll_direction/scroll_direction.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..6eb3c9c913049fcc50052860221fc1f2bdbd9073 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/rendering/scroll_direction/scroll_direction.0.dart @@ -0,0 +1,204 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; + +/// Flutter code sample for [ScrollDirection]. + +void main() => runApp(const ExampleApp()); + +class ExampleApp extends StatelessWidget { + const ExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: MyWidget(), + ); + } +} + +class MyWidget extends StatefulWidget { + const MyWidget({super.key}); + + @override + State createState() => _MyWidgetState(); +} + +class _MyWidgetState extends State { + final List alphabet = [ + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', + 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + ]; + final Widget spacer = const SizedBox.square(dimension: 10); + ScrollDirection scrollDirection = ScrollDirection.idle; + AxisDirection _axisDirection = AxisDirection.down; + + Widget _getArrows() { + final Widget arrow; + switch (_axisDirection) { + case AxisDirection.up: + arrow = const Icon(Icons.arrow_upward_rounded); + return Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [arrow, arrow], + ); + case AxisDirection.down: + arrow = const Icon(Icons.arrow_downward_rounded); + return Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [arrow, arrow], + ); + case AxisDirection.left: + arrow = const Icon(Icons.arrow_back_rounded); + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [arrow, arrow], + ); + case AxisDirection.right: + arrow = const Icon(Icons.arrow_forward_rounded); + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [arrow, arrow], + ); + } + } + + void _onAxisDirectionChanged(AxisDirection? axisDirection) { + if (axisDirection != null && axisDirection != _axisDirection) { + setState(() { + // Respond to change in axis direction. + _axisDirection = axisDirection; + }); + } + } + + Widget _getLeading() { + return Container( + color: Colors.blue[100], + padding: const EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text(axisDirectionToAxis(_axisDirection).toString()), + spacer, + Text(_axisDirection.toString()), + spacer, + const Text('GrowthDirection.forward'), + spacer, + Text(scrollDirection.toString()), + spacer, + _getArrows(), + ], + ), + ); + } + + Widget _getRadioRow() { + return DefaultTextStyle( + style: const TextStyle(fontWeight: FontWeight.bold, color: Colors.white), + child: RadioTheme( + data: RadioThemeData( + fillColor: MaterialStateProperty.all(Colors.white), + ), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Radio( + value: AxisDirection.up, + groupValue: _axisDirection, + onChanged: _onAxisDirectionChanged, + ), + const Text('up'), + spacer, + Radio( + value: AxisDirection.down, + groupValue: _axisDirection, + onChanged: _onAxisDirectionChanged, + ), + const Text('down'), + spacer, + Radio( + value: AxisDirection.left, + groupValue: _axisDirection, + onChanged: _onAxisDirectionChanged, + ), + const Text('left'), + spacer, + Radio( + value: AxisDirection.right, + groupValue: _axisDirection, + onChanged: _onAxisDirectionChanged, + ), + const Text('right'), + spacer, + ], + ), + ), + ), + ); + } + + bool _handleNotification(UserScrollNotification notification) { + if (notification.direction != scrollDirection) { + setState(() { + scrollDirection = notification.direction; + }); + } + return false; + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('ScrollDirections'), + bottom: PreferredSize( + preferredSize: const Size.fromHeight(50), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: _getRadioRow(), + ), + ), + ), + body: NotificationListener( + onNotification: _handleNotification, + // Also works for ListView.builder, which creates a SliverList for itself. + // A CustomScrollView allows multiple slivers to be composed together. + child: CustomScrollView( + // This method is available to conveniently determine if an scroll + // view is reversed by its AxisDirection. + reverse: axisDirectionIsReversed(_axisDirection), + // This method is available to conveniently convert an AxisDirection + // into its Axis. + scrollDirection: axisDirectionToAxis(_axisDirection), + slivers: [ + SliverList.builder( + itemCount: 27, + itemBuilder: (BuildContext context, int index) { + final Widget child; + if (index == 0) { + child = _getLeading(); + } else { + child = Container( + color: index.isEven ? Colors.amber[100] : Colors.amberAccent, + padding: const EdgeInsets.all(8.0), + child: Center(child: Text(alphabet[index - 1])), + ); + } + return Padding( + padding: const EdgeInsets.all(8.0), + child: child, + ); + }, + ), + ], + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/rendering/sliver_grid/sliver_grid_delegate_with_fixed_cross_axis_count.0.dart b/novelforge-project/flutter/examples/api/lib/rendering/sliver_grid/sliver_grid_delegate_with_fixed_cross_axis_count.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..e35b2d9202454706c1cef354bb12b8433abdb57e --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/rendering/sliver_grid/sliver_grid_delegate_with_fixed_cross_axis_count.0.dart @@ -0,0 +1,42 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [SliverGridDelegateWithFixedCrossAxisCount]. + +void main() => runApp(const SliverGridDelegateWithFixedCrossAxisCountExampleApp()); + +class SliverGridDelegateWithFixedCrossAxisCountExampleApp extends StatelessWidget { + const SliverGridDelegateWithFixedCrossAxisCountExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('SliverGridDelegateWithFixedCrossAxisCount Sample')), + body: const SliverGridDelegateWithFixedCrossAxisCountExample(), + ), + ); + } +} + +class SliverGridDelegateWithFixedCrossAxisCountExample extends StatelessWidget { + const SliverGridDelegateWithFixedCrossAxisCountExample({super.key}); + + @override + Widget build(BuildContext context) { + return GridView( + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 4, + childAspectRatio: 0.5, + ), + children: List.generate(20, (int i) { + return Builder(builder: (BuildContext context) { + return Text('$i'); + }); + }), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/rendering/sliver_grid/sliver_grid_delegate_with_fixed_cross_axis_count.1.dart b/novelforge-project/flutter/examples/api/lib/rendering/sliver_grid/sliver_grid_delegate_with_fixed_cross_axis_count.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..399cc64ff4a2caa58bc32fa92be5a93f8d91ffc9 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/rendering/sliver_grid/sliver_grid_delegate_with_fixed_cross_axis_count.1.dart @@ -0,0 +1,42 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [SliverGridDelegateWithFixedCrossAxisCount]. + +void main() => runApp(const SliverGridDelegateWithFixedCrossAxisCountExampleApp()); + +class SliverGridDelegateWithFixedCrossAxisCountExampleApp extends StatelessWidget { + const SliverGridDelegateWithFixedCrossAxisCountExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('SliverGridDelegateWithFixedCrossAxisCount Sample')), + body: const SliverGridDelegateWithFixedCrossAxisCountExample(), + ), + ); + } +} + +class SliverGridDelegateWithFixedCrossAxisCountExample extends StatelessWidget { + const SliverGridDelegateWithFixedCrossAxisCountExample({super.key}); + + @override + Widget build(BuildContext context) { + return GridView( + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 4, + mainAxisExtent: 150.0, + ), + children: List.generate(20, (int i) { + return Builder(builder: (BuildContext context) { + return Text('$i'); + }); + }), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/sample_templates/cupertino.0.dart b/novelforge-project/flutter/examples/api/lib/sample_templates/cupertino.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..174ddfd5e46de02d605e8b7628d83404ab58155d --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/sample_templates/cupertino.0.dart @@ -0,0 +1,67 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This is a template file for illustrating best practices when creating a +// Flutter API example that uses the Cupertino library. To use it, copy the file +// to your destination filename, search/replace 'Placeholder' with the name of +// the class this is an example for, delete this block, and implement your +// example. +// +// The name and location of this file should be: +// +// examples/api/lib///..dart +// +// So, if your example is the third example of the Foo.bar function in the +// "baz.dart" file in the cupertino library, then the filename for your example +// should be: +// +// examples/api/lib/cupertino/baz/foo_bar.2.dart +// +// and its associated test should be in: +// +// examples/api/test/cupertino/baz/foo_bar.2_test.dart +// +// The following doc comment should remain, and be a doc comment so that the +// symbol will be linked in the IDE. Don't use the whole description of the +// example, since that should already be in the API docs where this example is +// referenced, and we don't want the two descriptions to diverge. If this sample +// is referenced more than once, link back to the instance the example file is +// named for. + +import 'package:flutter/cupertino.dart'; + +/// Flutter code sample for [Placeholder]. + +void main() { + runApp(const SampleApp()); +} + +class SampleApp extends StatelessWidget { + const SampleApp({super.key}); + @override + Widget build(BuildContext context) { + return const CupertinoApp( + home: PlaceholderExample(), + ); + } +} + +/// Include comments about each class, and make them dartdoc comments, so that +/// links (e.g. [Placeholder]) are active in IDEs. +/// +/// Name the classes appropriately for the example (don't leave it as +/// "PlaceholderExample"!). +class PlaceholderExample extends StatelessWidget { + const PlaceholderExample({super.key}); + + @override + Widget build(BuildContext context) { + // Since this is an example, add plenty of comments, explaining things that + // both a newcomer and an experienced user might want to know. + // + // TRY THIS: Prefix things with "TRY THIS" in places in the example that + // might be interesting to modify when exploring what the code does. + return const Placeholder(); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/sample_templates/material.0.dart b/novelforge-project/flutter/examples/api/lib/sample_templates/material.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..83252cf66692860c10a3076ae3de9f8360f5dcdb --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/sample_templates/material.0.dart @@ -0,0 +1,69 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This is a template file for illustrating best practices when creating a +// Flutter API example that uses the Material library. To use it, copy the file +// to your destination filename, search/replace 'Placeholder' with the name of +// the class this is an example for, delete this block, and implement your +// example. +// +// The name and location of this file should be: +// +// examples/api/lib///..dart +// +// So, if your example is the third example of the Foo.bar function in the +// "baz.dart" file in the material library, then the filename for your example +// should be: +// +// examples/api/lib/material/baz/foo_bar.2.dart +// +// and its associated test should be in: +// +// examples/api/test/material/baz/foo_bar.2_test.dart +// +// The following doc comment should remain, and be a doc comment so that the +// symbol will be linked in the IDE. Don't use the whole description of the +// example, since that should already be in the API docs where this example is +// referenced, and we don't want the two descriptions to diverge. If this sample +// is referenced more than once, link back to the instance the example file is +// named for. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Placeholder]. + +void main() { + runApp(const SampleApp()); +} + +class SampleApp extends StatelessWidget { + const SampleApp({super.key}); + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: Scaffold( + body: PlaceholderExample(), + ), + ); + } +} + +/// Include comments about each class, and make them dartdoc comments, so that +/// links (e.g. [Placeholder]) are active in IDEs. +/// +/// Name the classes appropriately for the example (don't leave it as +/// "PlaceholderExample"!). +class PlaceholderExample extends StatelessWidget { + const PlaceholderExample({super.key}); + + @override + Widget build(BuildContext context) { + // Since this is an example, add plenty of comments, explaining things that + // both a newcomer and an experienced user might want to know. + // + // TRY THIS: Prefix things with "TRY THIS" in places in the example that + // might be interesting to modify when exploring what the code does. + return const Placeholder(); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/sample_templates/widgets.0.dart b/novelforge-project/flutter/examples/api/lib/sample_templates/widgets.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..2bc5dd343a366d79663287b569fff3b0ce6cb17e --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/sample_templates/widgets.0.dart @@ -0,0 +1,70 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This is a template file for illustrating best practices when creating a +// Flutter API example that uses the Widgets library. To use it, copy the file +// to your destination filename, search/replace 'Placeholder' with the name of +// the class this is an example for, delete this block, and implement your +// example. +// +// The name and location of this file should be: +// +// examples/api/lib///..dart +// +// So, if your example is the third example of the Foo.bar function in the +// "baz.dart" file in the widgets library, then the filename for your example +// should be: +// +// examples/api/lib/widgets/baz/foo_bar.2.dart +// +// and its (required) associated test should be in: +// +// examples/api/test/widgets/baz/foo_bar.2_test.dart +// +// The following doc comment should remain, and be a doc comment so that the +// symbol will be linked in the IDE. Don't use the whole description of the +// example, since that should already be in the API docs where this example is +// referenced, and we don't want the two descriptions to diverge. If this sample +// is referenced more than once, link back to the instance the example file is +// named for. + +import 'package:flutter/widgets.dart'; + +/// Flutter code sample for [Placeholder]. + +void main() { + runApp(const SampleApp()); +} + +class SampleApp extends StatelessWidget { + const SampleApp({super.key}); + @override + Widget build(BuildContext context) { + return WidgetsApp( + color: const Color(0xffffffff), + builder: (BuildContext context, Widget? child) { + return const PlaceholderExample(); + }, + ); + } +} + +/// Include comments about each class, and make them dartdoc comments, so that +/// links (e.g. [Placeholder]) are active in IDEs. +/// +/// Name the classes appropriately for the example (don't leave it as +/// "PlaceholderExample"!). +class PlaceholderExample extends StatelessWidget { + const PlaceholderExample({super.key}); + + @override + Widget build(BuildContext context) { + // Since this is an example, add plenty of comments, explaining things that + // both a newcomer and an experienced user might want to know. + // + // TRY THIS: Prefix things with "TRY THIS" in places in the example that + // might be interesting to modify when exploring what the code does. + return const Placeholder(); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/services/binding/handle_request_app_exit.0.dart b/novelforge-project/flutter/examples/api/lib/services/binding/handle_request_app_exit.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..3757b315c09ece8c057f5c17f2ee223d5018f51a --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/services/binding/handle_request_app_exit.0.dart @@ -0,0 +1,109 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:ui'; + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +/// Flutter code sample for [ServicesBinding.handleRequestAppExit]. + +void main() { + runApp(const ApplicationExitExample()); +} + +class ApplicationExitExample extends StatelessWidget { + const ApplicationExitExample({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: Scaffold(body: Body()), + ); + } +} + +class Body extends StatefulWidget { + const Body({super.key}); + + @override + State createState() => _BodyState(); +} + +class _BodyState extends State with WidgetsBindingObserver { + bool _shouldExit = false; + String lastResponse = 'No exit requested yet'; + + @override + void initState() { + super.initState(); + WidgetsBinding.instance.addObserver(this); + } + + @override + void dispose() { + WidgetsBinding.instance.removeObserver(this); + super.dispose(); + } + + Future _quit() async { + final AppExitType exitType = _shouldExit ? AppExitType.required : AppExitType.cancelable; + setState(() { + lastResponse = 'App requesting ${exitType.name} exit'; + }); + await ServicesBinding.instance.exitApplication(exitType); + } + + @override + Future didRequestAppExit() async { + final AppExitResponse response = _shouldExit ? AppExitResponse.exit : AppExitResponse.cancel; + setState(() { + lastResponse = 'App responded ${response.name} to exit request'; + }); + return response; + } + + void _radioChanged(bool? value) { + value ??= true; + if (_shouldExit == value) { + return; + } + setState(() { + _shouldExit = value!; + }); + } + + @override + Widget build(BuildContext context) { + return Center( + child: SizedBox( + width: 300, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + RadioListTile( + title: const Text('Do Not Allow Exit'), + groupValue: _shouldExit, + value: false, + onChanged: _radioChanged, + ), + RadioListTile( + title: const Text('Allow Exit'), + groupValue: _shouldExit, + value: true, + onChanged: _radioChanged, + ), + const SizedBox(height: 30), + ElevatedButton( + onPressed: _quit, + child: const Text('Quit'), + ), + const SizedBox(height: 30), + Text(lastResponse), + ], + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/services/keyboard_key/logical_keyboard_key.0.dart b/novelforge-project/flutter/examples/api/lib/services/keyboard_key/logical_keyboard_key.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..4dc3d8febda1eca804f114611c9851b2eb16f312 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/services/keyboard_key/logical_keyboard_key.0.dart @@ -0,0 +1,95 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +/// Flutter code sample for [LogicalKeyboardKey]. + +void main() => runApp(const KeyExampleApp()); + +class KeyExampleApp extends StatelessWidget { + const KeyExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('Key Handling Example')), + body: const MyKeyExample(), + ), + ); + } +} + +class MyKeyExample extends StatefulWidget { + const MyKeyExample({super.key}); + + @override + State createState() => _MyKeyExampleState(); +} + +class _MyKeyExampleState extends State { + // The node used to request the keyboard focus. + final FocusNode _focusNode = FocusNode(); + // The message to display. + String? _message; + + // Focus nodes need to be disposed. + @override + void dispose() { + _focusNode.dispose(); + super.dispose(); + } + + // Handles the key events from the Focus widget and updates the + // _message. + KeyEventResult _handleKeyEvent(FocusNode node, KeyEvent event) { + setState(() { + if (event.logicalKey == LogicalKeyboardKey.keyQ) { + _message = 'Pressed the "Q" key!'; + } else { + if (kReleaseMode) { + _message = 'Not a Q: Pressed 0x${event.logicalKey.keyId.toRadixString(16)}'; + } else { + // As the name implies, the debugName will only print useful + // information in debug mode. + _message = 'Not a Q: Pressed ${event.logicalKey.debugName}'; + } + } + }); + return event.logicalKey == LogicalKeyboardKey.keyQ ? KeyEventResult.handled : KeyEventResult.ignored; + } + + @override + Widget build(BuildContext context) { + final TextTheme textTheme = Theme.of(context).textTheme; + return Container( + color: Colors.white, + alignment: Alignment.center, + child: DefaultTextStyle( + style: textTheme.headlineMedium!, + child: Focus( + focusNode: _focusNode, + onKeyEvent: _handleKeyEvent, + child: ListenableBuilder( + listenable: _focusNode, + builder: (BuildContext context, Widget? child) { + if (!_focusNode.hasFocus) { + return GestureDetector( + onTap: () { + FocusScope.of(context).requestFocus(_focusNode); + }, + child: const Text('Click to focus'), + ); + } + return Text(_message ?? 'Press a key'); + }, + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/services/keyboard_key/physical_keyboard_key.0.dart b/novelforge-project/flutter/examples/api/lib/services/keyboard_key/physical_keyboard_key.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..5e1d635b426c70d0fb765ca7ed119a4c77f58832 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/services/keyboard_key/physical_keyboard_key.0.dart @@ -0,0 +1,95 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +/// Flutter code sample for [PhysicalKeyboardKey]. + +void main() => runApp(const KeyExampleApp()); + +class KeyExampleApp extends StatelessWidget { + const KeyExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('PhysicalKeyboardKey Example')), + body: const MyPhysicalKeyExample(), + ), + ); + } +} + +class MyPhysicalKeyExample extends StatefulWidget { + const MyPhysicalKeyExample({super.key}); + + @override + State createState() => _MyPhysicalKeyExampleState(); +} + +class _MyPhysicalKeyExampleState extends State { +// The node used to request the keyboard focus. + final FocusNode _focusNode = FocusNode(); +// The message to display. + String? _message; + +// Focus nodes need to be disposed. + @override + void dispose() { + _focusNode.dispose(); + super.dispose(); + } + +// Handles the key events from the RawKeyboardListener and update the +// _message. + KeyEventResult _handleKeyEvent(FocusNode node, KeyEvent event) { + setState(() { + if (event.physicalKey == PhysicalKeyboardKey.keyA) { + _message = 'Pressed the key next to CAPS LOCK!'; + } else { + if (kReleaseMode) { + _message = 'Not the key next to CAPS LOCK: Pressed 0x${event.physicalKey.usbHidUsage.toRadixString(16)}'; + } else { + // As the name implies, the debugName will only print useful + // information in debug mode. + _message = 'Not the key next to CAPS LOCK: Pressed ${event.physicalKey.debugName}'; + } + } + }); + return event.physicalKey == PhysicalKeyboardKey.keyA ? KeyEventResult.handled : KeyEventResult.ignored; + } + + @override + Widget build(BuildContext context) { + final TextTheme textTheme = Theme.of(context).textTheme; + return Container( + color: Colors.white, + alignment: Alignment.center, + child: DefaultTextStyle( + style: textTheme.headlineMedium!, + child: Focus( + focusNode: _focusNode, + onKeyEvent: _handleKeyEvent, + child: ListenableBuilder( + listenable: _focusNode, + builder: (BuildContext context, Widget? child) { + if (!_focusNode.hasFocus) { + return GestureDetector( + onTap: () { + FocusScope.of(context).requestFocus(_focusNode); + }, + child: const Text('Click to focus'), + ); + } + return Text(_message ?? 'Press a key'); + }, + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/services/mouse_cursor/mouse_cursor.0.dart b/novelforge-project/flutter/examples/api/lib/services/mouse_cursor/mouse_cursor.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..e5db8fe766ffc352eb277935cbffa1acc5dd95bd --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/services/mouse_cursor/mouse_cursor.0.dart @@ -0,0 +1,44 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [MouseCursor]. + +void main() => runApp(const MouseCursorExampleApp()); + +class MouseCursorExampleApp extends StatelessWidget { + const MouseCursorExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('MouseCursor Code Sample')), + body: const MouseCursorExample(), + ), + ); + } +} + +class MouseCursorExample extends StatelessWidget { + const MouseCursorExample({super.key}); + + @override + Widget build(BuildContext context) { + return Center( + child: MouseRegion( + cursor: SystemMouseCursors.text, + child: Container( + width: 200, + height: 100, + decoration: BoxDecoration( + color: Colors.blue, + border: Border.all(color: Colors.yellow), + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/services/system_chrome/system_chrome.set_system_u_i_overlay_style.0.dart b/novelforge-project/flutter/examples/api/lib/services/system_chrome/system_chrome.set_system_u_i_overlay_style.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..4aaca41f3f870f1937f52d6593f0b98c48fe75aa --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/services/system_chrome/system_chrome.set_system_u_i_overlay_style.0.dart @@ -0,0 +1,70 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:math' as math; + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +/// Flutter code sample for [AppBar.systemOverlayStyle]. + +void main() => runApp(const SystemOverlayStyleApp()); + +class SystemOverlayStyleApp extends StatelessWidget { + const SystemOverlayStyleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData( + useMaterial3: true, + brightness: Brightness.light, + ), + home: const SystemOverlayStyleExample(), + ); + } +} + +class SystemOverlayStyleExample extends StatefulWidget { + const SystemOverlayStyleExample({super.key}); + + @override + State createState() => _SystemOverlayStyleExampleState(); +} + +class _SystemOverlayStyleExampleState extends State { + final math.Random _random = math.Random(); + SystemUiOverlayStyle _currentStyle = SystemUiOverlayStyle.light; + + void _changeColor() { + final Color color = Color.fromRGBO( + _random.nextInt(255), + _random.nextInt(255), + _random.nextInt(255), + 1.0, + ); + setState(() { + _currentStyle = SystemUiOverlayStyle.dark.copyWith( + statusBarColor: color, + systemNavigationBarColor: color, + ); + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('SystemUiOverlayStyle Sample'), + systemOverlayStyle: _currentStyle, + ), + body: Center( + child: ElevatedButton( + onPressed: _changeColor, + child: const Text('Change Color'), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/services/system_chrome/system_chrome.set_system_u_i_overlay_style.1.dart b/novelforge-project/flutter/examples/api/lib/services/system_chrome/system_chrome.set_system_u_i_overlay_style.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..6cb5fca2cc042c79015e86603b3282991f6c64e3 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/services/system_chrome/system_chrome.set_system_u_i_overlay_style.1.dart @@ -0,0 +1,83 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:math' as math; + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +/// Flutter code sample for setting the [SystemUiOverlayStyle] with an [AnnotatedRegion]. + +void main() => runApp(const SystemOverlayStyleApp()); + +class SystemOverlayStyleApp extends StatelessWidget { + const SystemOverlayStyleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData( + useMaterial3: true, + brightness: Brightness.light, + ), + home: const SystemOverlayStyleExample(), + ); + } +} + +class SystemOverlayStyleExample extends StatefulWidget { + const SystemOverlayStyleExample({super.key}); + + @override + State createState() => _SystemOverlayStyleExampleState(); +} + +class _SystemOverlayStyleExampleState extends State { + final math.Random _random = math.Random(); + SystemUiOverlayStyle _currentStyle = SystemUiOverlayStyle.light; + + void _changeColor() { + final Color color = Color.fromRGBO( + _random.nextInt(255), + _random.nextInt(255), + _random.nextInt(255), + 1.0, + ); + setState(() { + _currentStyle = SystemUiOverlayStyle.dark.copyWith( + statusBarColor: color, + systemNavigationBarColor: color, + ); + }); + } + + @override + Widget build(BuildContext context) { + return AnnotatedRegion( + value: _currentStyle, + child: Scaffold( + body: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.all(16.0), + child: Text( + 'SystemUiOverlayStyle Sample', + style: Theme.of(context).textTheme.titleLarge, + ), + ), + Expanded( + child: Center( + child: ElevatedButton( + onPressed: _changeColor, + child: const Text('Change Color'), + ), + ), + ), + ], + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/services/text_input/text_input_control.0.dart b/novelforge-project/flutter/examples/api/lib/services/text_input/text_input_control.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..64c508dd35b6b30b294313a1d2dcf3db1adddb14 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/services/text_input/text_input_control.0.dart @@ -0,0 +1,167 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +/// Flutter code sample for [TextInputControl]. + +void main() => runApp(const TextInputControlExampleApp()); + +class TextInputControlExampleApp extends StatelessWidget { + const TextInputControlExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: TextInputControlExample(), + ); + } +} + +class TextInputControlExample extends StatefulWidget { + const TextInputControlExample({super.key}); + + @override + MyStatefulWidgetState createState() => MyStatefulWidgetState(); +} + +class MyStatefulWidgetState extends State { + final TextEditingController _controller = TextEditingController(); + final FocusNode _focusNode = FocusNode(); + + @override + void dispose() { + super.dispose(); + _controller.dispose(); + _focusNode.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: TextField( + autofocus: true, + controller: _controller, + focusNode: _focusNode, + decoration: InputDecoration( + suffix: IconButton( + icon: const Icon(Icons.clear), + tooltip: 'Clear and unfocus', + onPressed: () { + _controller.clear(); + _focusNode.unfocus(); + }, + ), + ), + ), + ), + bottomSheet: const MyVirtualKeyboard(), + ); + } +} + +class MyVirtualKeyboard extends StatefulWidget { + const MyVirtualKeyboard({super.key}); + + @override + MyVirtualKeyboardState createState() => MyVirtualKeyboardState(); +} + +class MyVirtualKeyboardState extends State { + final MyTextInputControl _inputControl = MyTextInputControl(); + + @override + void initState() { + super.initState(); + _inputControl.register(); + } + + @override + void dispose() { + super.dispose(); + _inputControl.unregister(); + } + + void _handleKeyPress(String key) { + _inputControl.processUserInput(key); + } + + @override + Widget build(BuildContext context) { + return ValueListenableBuilder( + valueListenable: _inputControl.visible, + builder: (_, bool visible, __) { + return Visibility( + visible: visible, + child: FocusScope( + canRequestFocus: false, + child: TextFieldTapRegion( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + for (final String key in ['A', 'B', 'C']) + ElevatedButton( + child: Text(key), + onPressed: () => _handleKeyPress(key), + ), + ], + ), + ), + ), + ); + }, + ); + } +} + +class MyTextInputControl with TextInputControl { + TextEditingValue _editingState = TextEditingValue.empty; + final ValueNotifier _visible = ValueNotifier(false); + + /// The input control's visibility state for updating the visual presentation. + ValueListenable get visible => _visible; + + /// Register the input control. + void register() => TextInput.setInputControl(this); + + /// Restore the original platform input control. + void unregister() => TextInput.restorePlatformInputControl(); + + @override + void show() => _visible.value = true; + + @override + void hide() => _visible.value = false; + + @override + void setEditingState(TextEditingValue value) => _editingState = value; + + /// Process user input. + /// + /// Updates the internal editing state by inserting the input text, + /// and by replacing the current selection if any. + void processUserInput(String input) { + _editingState = _editingState.copyWith( + text: _insertText(input), + selection: _replaceSelection(input), + ); + + // Request the attached client to update accordingly. + TextInput.updateEditingValue(_editingState); + } + + String _insertText(String input) { + final String text = _editingState.text; + final TextSelection selection = _editingState.selection; + return text.replaceRange(selection.start, selection.end, input); + } + + TextSelection _replaceSelection(String input) { + final TextSelection selection = _editingState.selection; + return TextSelection.collapsed(offset: selection.start + input.length); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.0.dart b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..cc657cf1289bdf6be599cb730386d5e7158c3c55 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.0.dart @@ -0,0 +1,78 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [FontFeature]. + +void main() => runApp(const ExampleApp()); + +class ExampleApp extends StatelessWidget { + const ExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: ExampleWidget(), + ); + } +} + +final TextStyle titleStyle = TextStyle( + fontSize: 18, + fontFeatures: const [FontFeature.enable('smcp')], + color: Colors.blueGrey[600], +); + +class ExampleWidget extends StatelessWidget { + const ExampleWidget({super.key}); + + @override + Widget build(BuildContext context) { + // The Cardo, Milonga and Raleway Dots fonts can be downloaded from Google + // Fonts (https://www.google.com/fonts). + return Scaffold( + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Spacer(flex: 5), + Text('regular numbers have their place:', style: titleStyle), + const Text('The 1972 cup final was a 1-1 draw.', + style: TextStyle( + fontFamily: 'Cardo', + fontSize: 24, + )), + const Spacer(), + Text('but old-style figures blend well with lower case:', style: titleStyle), + const Text('The 1972 cup final was a 1-1 draw.', + style: TextStyle( + fontFamily: 'Cardo', fontSize: 24, fontFeatures: [FontFeature.oldstyleFigures()])), + const Spacer(), + const Divider(), + const Spacer(), + Text('fractions look better with a custom ligature:', style: titleStyle), + const Text('Add 1/2 tsp of flour and stir.', + style: TextStyle( + fontFamily: 'Milonga', + fontSize: 24, + fontFeatures: [FontFeature.alternativeFractions()])), + const Spacer(), + const Divider(), + const Spacer(), + Text('multiple stylistic sets in one font:', style: titleStyle), + const Text('Raleway Dots', style: TextStyle(fontFamily: 'Raleway Dots', fontSize: 48)), + Text('Raleway Dots', + style: TextStyle( + fontFeatures: [FontFeature.stylisticSet(1)], + fontFamily: 'Raleway Dots', + fontSize: 48, + )), + const Spacer(flex: 5), + ], + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_alternative.0.dart b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_alternative.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..95491a10a946b7b1f54fa76b89ce3c906669a769 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_alternative.0.dart @@ -0,0 +1,40 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/widgets.dart'; + +/// Flutter code sample for [FontFeature.FontFeature.alternative]. + +void main() => runApp(const ExampleApp()); + +class ExampleApp extends StatelessWidget { + const ExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return WidgetsApp( + builder: (BuildContext context, Widget? navigator) => const ExampleWidget(), + color: const Color(0xffffffff), + ); + } +} + +class ExampleWidget extends StatelessWidget { + const ExampleWidget({super.key}); + + @override + Widget build(BuildContext context) { + // The Raleway font can be downloaded from Google Fonts + // (https://www.google.com/fonts). + return const Text( + 'The infamous Tuna Torture.', + style: TextStyle( + fontFamily: 'Raleway', + fontFeatures: [ + FontFeature.alternative(1), // or 2, or 3, or... + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_alternative_fractions.0.dart b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_alternative_fractions.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..62e365970538b0a6892733f14908b3837c3bffd2 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_alternative_fractions.0.dart @@ -0,0 +1,40 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/widgets.dart'; + +/// Flutter code sample for [FontFeature.FontFeature.alternativeFractions]. + +void main() => runApp(const ExampleApp()); + +class ExampleApp extends StatelessWidget { + const ExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return WidgetsApp( + builder: (BuildContext context, Widget? navigator) => const ExampleWidget(), + color: const Color(0xffffffff), + ); + } +} + +class ExampleWidget extends StatelessWidget { + const ExampleWidget({super.key}); + + @override + Widget build(BuildContext context) { + // The Ubuntu Mono font can be downloaded from Google Fonts + // (https://www.google.com/fonts). + return const Text( + 'Fractions: 1/2 2/3 3/4 4/5', + style: TextStyle( + fontFamily: 'Ubuntu Mono', + fontFeatures: [ + FontFeature.alternativeFractions(), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_case_sensitive_forms.0.dart b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_case_sensitive_forms.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..8ad787769d25fe838f7764bb3d209e67ac876e6f --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_case_sensitive_forms.0.dart @@ -0,0 +1,40 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/widgets.dart'; + +/// Flutter code sample for [FontFeature.FontFeature.caseSensitiveForms]. + +void main() => runApp(const ExampleApp()); + +class ExampleApp extends StatelessWidget { + const ExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return WidgetsApp( + builder: (BuildContext context, Widget? navigator) => const ExampleWidget(), + color: const Color(0xffffffff), + ); + } +} + +class ExampleWidget extends StatelessWidget { + const ExampleWidget({super.key}); + + @override + Widget build(BuildContext context) { + // The Piazzolla font can be downloaded from Google Fonts + // (https://www.google.com/fonts). + return const Text( + '(A) [A] {A} «A» A/B A•B', + style: TextStyle( + fontFamily: 'Piazzolla', + fontFeatures: [ + FontFeature.caseSensitiveForms(), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_character_variant.0.dart b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_character_variant.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..0acf1621faa8f30606158903a7276cde7e93e9a4 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_character_variant.0.dart @@ -0,0 +1,42 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/widgets.dart'; + +/// Flutter code sample for [FontFeature.FontFeature.characterVariant]. + +void main() => runApp(const ExampleApp()); + +class ExampleApp extends StatelessWidget { + const ExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return WidgetsApp( + builder: (BuildContext context, Widget? navigator) => const ExampleWidget(), + color: const Color(0xffffffff), + ); + } +} + +class ExampleWidget extends StatelessWidget { + const ExampleWidget({super.key}); + + @override + Widget build(BuildContext context) { + // The Source Code Pro font can be downloaded from Google Fonts + // (https://www.google.com/fonts). + return Text( + 'aáâ β gǵĝ θб Iiíî Ll', + style: TextStyle( + fontFamily: 'Source Code Pro', + fontFeatures: [ + FontFeature.characterVariant(1), + FontFeature.characterVariant(2), + FontFeature.characterVariant(4), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_contextual_alternates.0.dart b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_contextual_alternates.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..f71d8f3b186c266125d374d1fc4e3b5891812963 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_contextual_alternates.0.dart @@ -0,0 +1,40 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/widgets.dart'; + +/// Flutter code sample for [FontFeature.FontFeature.contextualAlternates]. + +void main() => runApp(const ExampleApp()); + +class ExampleApp extends StatelessWidget { + const ExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return WidgetsApp( + builder: (BuildContext context, Widget? navigator) => const ExampleWidget(), + color: const Color(0xffffffff), + ); + } +} + +class ExampleWidget extends StatelessWidget { + const ExampleWidget({super.key}); + + @override + Widget build(BuildContext context) { + // The Barriecito font can be downloaded from Google Fonts + // (https://www.google.com/fonts). + return const Text( + "Ooohh, we weren't going to tell him that.", + style: TextStyle( + fontFamily: 'Barriecito', + fontFeatures: [ + FontFeature.contextualAlternates(), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_denominator.0.dart b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_denominator.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..e62a9dd2679efd141765617a1b22f6c50e79df10 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_denominator.0.dart @@ -0,0 +1,40 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/widgets.dart'; + +/// Flutter code sample for [FontFeature.FontFeature.denominator]. + +void main() => runApp(const ExampleApp()); + +class ExampleApp extends StatelessWidget { + const ExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return WidgetsApp( + builder: (BuildContext context, Widget? navigator) => const ExampleWidget(), + color: const Color(0xffffffff), + ); + } +} + +class ExampleWidget extends StatelessWidget { + const ExampleWidget({super.key}); + + @override + Widget build(BuildContext context) { + // The Piazzolla font can be downloaded from Google Fonts + // (https://www.google.com/fonts). + return const Text( + 'Fractions: 1/2 2/3 3/4 4/5', + style: TextStyle( + fontFamily: 'Piazzolla', + fontFeatures: [ + FontFeature.denominator(), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_fractions.0.dart b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_fractions.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..c77c679dc6ee346604e415aa0af398b37b0edcf4 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_fractions.0.dart @@ -0,0 +1,40 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/widgets.dart'; + +/// Flutter code sample for [FontFeature.FontFeature.fractions]. + +void main() => runApp(const ExampleApp()); + +class ExampleApp extends StatelessWidget { + const ExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return WidgetsApp( + builder: (BuildContext context, Widget? navigator) => const ExampleWidget(), + color: const Color(0xffffffff), + ); + } +} + +class ExampleWidget extends StatelessWidget { + const ExampleWidget({super.key}); + + @override + Widget build(BuildContext context) { + // The Ubuntu Mono font can be downloaded from Google Fonts + // (https://www.google.com/fonts). + return const Text( + 'Fractions: 1/2 2/3 3/4 4/5', + style: TextStyle( + fontFamily: 'Ubuntu Mono', + fontFeatures: [ + FontFeature.fractions(), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_historical_forms.0.dart b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_historical_forms.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..3de92ab69838af01816ad354200bd7ff8cc30b52 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_historical_forms.0.dart @@ -0,0 +1,41 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/widgets.dart'; + +/// Flutter code sample for [FontFeature.FontFeature.historicalForms]. + +void main() => runApp(const ExampleApp()); + +class ExampleApp extends StatelessWidget { + const ExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return WidgetsApp( + builder: (BuildContext context, Widget? navigator) => const ExampleWidget(), + color: const Color(0xffffffff), + ); + } +} + +class ExampleWidget extends StatelessWidget { + const ExampleWidget({super.key}); + + @override + Widget build(BuildContext context) { + // The Cardo font can be downloaded from Google Fonts + // (https://www.google.com/fonts). + return const Text( + 'VIBRANT fish assisted his business.', + style: TextStyle( + fontFamily: 'Sorts Mill Goudy', + fontFeatures: [ + FontFeature.historicalForms(), // Enables "hist". + // Use FontFeature.historicalLigatures() to enable "hlig" as well. + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_historical_ligatures.0.dart b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_historical_ligatures.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..9418c31d21d09c441c16d2dbc50d0d558303ac4f --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_historical_ligatures.0.dart @@ -0,0 +1,41 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/widgets.dart'; + +/// Flutter code sample for [FontFeature.FontFeature.historicalLigatures]. + +void main() => runApp(const ExampleApp()); + +class ExampleApp extends StatelessWidget { + const ExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return WidgetsApp( + builder: (BuildContext context, Widget? navigator) => const ExampleWidget(), + color: const Color(0xffffffff), + ); + } +} + +class ExampleWidget extends StatelessWidget { + const ExampleWidget({super.key}); + + @override + Widget build(BuildContext context) { + // The Cardo font can be downloaded from Google Fonts + // (https://www.google.com/fonts). + return const Text( + 'VIBRANT fish assisted his business.', + style: TextStyle( + fontFamily: 'Sorts Mill Goudy', + fontFeatures: [ + FontFeature.historicalForms(), // Enables "hist". + FontFeature.historicalLigatures(), // Enables "hlig". + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_lining_figures.0.dart b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_lining_figures.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..3a82a31533f1b01434c508972b17cc9bec490c10 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_lining_figures.0.dart @@ -0,0 +1,40 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/widgets.dart'; + +/// Flutter code sample for [FontFeature.FontFeature.liningFigures]. + +void main() => runApp(const ExampleApp()); + +class ExampleApp extends StatelessWidget { + const ExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return WidgetsApp( + builder: (BuildContext context, Widget? navigator) => const ExampleWidget(), + color: const Color(0xffffffff), + ); + } +} + +class ExampleWidget extends StatelessWidget { + const ExampleWidget({super.key}); + + @override + Widget build(BuildContext context) { + // The Sorts Mill Goudy font can be downloaded from Google Fonts + // (https://www.google.com/fonts). + return const Text( + 'CALL 311-555-2368 NOW!', + style: TextStyle( + fontFamily: 'Sorts Mill Goudy', + fontFeatures: [ + FontFeature.liningFigures(), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_locale_aware.0.dart b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_locale_aware.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..ca34cd4281af69bdffc9288f53c5c7c3abe507c5 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_locale_aware.0.dart @@ -0,0 +1,38 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/widgets.dart'; + +/// Flutter code sample for [FontFeature.FontFeature.localeAware]. + +void main() => runApp(const ExampleApp()); + +class ExampleApp extends StatelessWidget { + const ExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return WidgetsApp( + builder: (BuildContext context, Widget? navigator) => const ExampleWidget(), + color: const Color(0xffffffff), + ); + } +} + +class ExampleWidget extends StatelessWidget { + const ExampleWidget({super.key}); + + @override + Widget build(BuildContext context) { + // The Noto family of fonts can be downloaded from Google Fonts + // (https://www.google.com/fonts). + return const Text( + '次 化 刃 直 入 令', + locale: Locale('zh', 'CN'), // or Locale('ja'), Locale('ko'), Locale('zh', 'TW'), etc + style: TextStyle( + fontFamily: 'Noto Sans', + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_notational_forms.0.dart b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_notational_forms.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..42e1354d8fcf8299d460052a8822c304758015f5 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_notational_forms.0.dart @@ -0,0 +1,40 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/widgets.dart'; + +/// Flutter code sample for [FontFeature.FontFeature.notationalForms]. + +void main() => runApp(const ExampleApp()); + +class ExampleApp extends StatelessWidget { + const ExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return WidgetsApp( + builder: (BuildContext context, Widget? navigator) => const ExampleWidget(), + color: const Color(0xffffffff), + ); + } +} + +class ExampleWidget extends StatelessWidget { + const ExampleWidget({super.key}); + + @override + Widget build(BuildContext context) { + // The Gothic A1 font can be downloaded from Google Fonts + // (https://www.google.com/fonts). + return const Text( + 'abc 123', + style: TextStyle( + fontFamily: 'Gothic A1', + fontFeatures: [ + FontFeature.notationalForms(3), // circled letters and digits + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_numerators.0.dart b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_numerators.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..c16efd0b1ba2f3875ef508264b8d43ee361590e8 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_numerators.0.dart @@ -0,0 +1,41 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/widgets.dart'; + +/// Flutter code sample for [FontFeature.FontFeature.numerators]. + +void main() => runApp(const ExampleApp()); + +class ExampleApp extends StatelessWidget { + const ExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return WidgetsApp( + builder: (BuildContext context, Widget? navigator) => const ExampleWidget(), + color: const Color(0xffffffff), + ); + } +} + +/// This is the stateless widget that the main application instantiates. +class ExampleWidget extends StatelessWidget { + const ExampleWidget({super.key}); + + @override + Widget build(BuildContext context) { + // The Piazzolla font can be downloaded from Google Fonts + // (https://www.google.com/fonts). + return const Text( + 'Fractions: 1/2 2/3 3/4 4/5', + style: TextStyle( + fontFamily: 'Piazzolla', + fontFeatures: [ + FontFeature.numerators(), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_oldstyle_figures.0.dart b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_oldstyle_figures.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..9649d0f2b293e7e5f69b045aa33f47c6460795a7 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_oldstyle_figures.0.dart @@ -0,0 +1,40 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/widgets.dart'; + +/// Flutter code sample for [FontFeature.FontFeature.oldstyleFigures]. + +void main() => runApp(const ExampleApp()); + +class ExampleApp extends StatelessWidget { + const ExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return WidgetsApp( + builder: (BuildContext context, Widget? navigator) => const ExampleWidget(), + color: const Color(0xffffffff), + ); + } +} + +class ExampleWidget extends StatelessWidget { + const ExampleWidget({super.key}); + + @override + Widget build(BuildContext context) { + // The Piazzolla font can be downloaded from Google Fonts + // (https://www.google.com/fonts). + return const Text( + 'Call 311-555-2368 now!', + style: TextStyle( + fontFamily: 'Piazzolla', + fontFeatures: [ + FontFeature.oldstyleFigures(), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_ordinal_forms.0.dart b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_ordinal_forms.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..dbec73a0978c80f6801675bb03cabd176b5380f3 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_ordinal_forms.0.dart @@ -0,0 +1,40 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/widgets.dart'; + +/// Flutter code sample for [FontFeature.FontFeature.ordinalForms]. + +void main() => runApp(const ExampleApp()); + +class ExampleApp extends StatelessWidget { + const ExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return WidgetsApp( + builder: (BuildContext context, Widget? navigator) => const ExampleWidget(), + color: const Color(0xffffffff), + ); + } +} + +class ExampleWidget extends StatelessWidget { + const ExampleWidget({super.key}); + + @override + Widget build(BuildContext context) { + // The Piazzolla font can be downloaded from Google Fonts + // (https://www.google.com/fonts). + return const Text( + '1st, 2nd, 3rd, 4th...', + style: TextStyle( + fontFamily: 'Piazzolla', + fontFeatures: [ + FontFeature.ordinalForms(), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_proportional_figures.0.dart b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_proportional_figures.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..283f747f797d2bf16382599ae747758fb45d566f --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_proportional_figures.0.dart @@ -0,0 +1,40 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/widgets.dart'; + +/// Flutter code sample for [FontFeature.FontFeature.proportionalFigures]. + +void main() => runApp(const ExampleApp()); + +class ExampleApp extends StatelessWidget { + const ExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return WidgetsApp( + builder: (BuildContext context, Widget? navigator) => const ExampleWidget(), + color: const Color(0xffffffff), + ); + } +} + +class ExampleWidget extends StatelessWidget { + const ExampleWidget({super.key}); + + @override + Widget build(BuildContext context) { + // The Kufam font can be downloaded from Google Fonts + // (https://www.google.com/fonts). + return const Text( + 'Call 311-555-2368 now!', + style: TextStyle( + fontFamily: 'Kufam', + fontFeatures: [ + FontFeature.proportionalFigures(), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_scientific_inferiors.0.dart b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_scientific_inferiors.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..a9f63f14d9e01fd121354eea9cfe190b2fb9bd70 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_scientific_inferiors.0.dart @@ -0,0 +1,40 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/widgets.dart'; + +/// Flutter code sample for [FontFeature.FontFeature.scientificInferiors]. + +void main() => runApp(const ExampleApp()); + +class ExampleApp extends StatelessWidget { + const ExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return WidgetsApp( + builder: (BuildContext context, Widget? navigator) => const ExampleWidget(), + color: const Color(0xffffffff), + ); + } +} + +class ExampleWidget extends StatelessWidget { + const ExampleWidget({super.key}); + + @override + Widget build(BuildContext context) { + // The Piazzolla font can be downloaded from Google Fonts + // (https://www.google.com/fonts). + return const Text( + 'C8H10N4O2', + style: TextStyle( + fontFamily: 'Piazzolla', + fontFeatures: [ + FontFeature.scientificInferiors(), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_slashed_zero.0.dart b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_slashed_zero.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..44bcbfa4df60611cbb444155673991e66b1ed258 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_slashed_zero.0.dart @@ -0,0 +1,40 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/widgets.dart'; + +/// Flutter code sample for [FontFeature.FontFeature.slashedZero]. + +void main() => runApp(const ExampleApp()); + +class ExampleApp extends StatelessWidget { + const ExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return WidgetsApp( + builder: (BuildContext context, Widget? navigator) => const ExampleWidget(), + color: const Color(0xffffffff), + ); + } +} + +class ExampleWidget extends StatelessWidget { + const ExampleWidget({super.key}); + + @override + Widget build(BuildContext context) { + // The Source Code Pro font can be downloaded from Google Fonts + // (https://www.google.com/fonts). + return const Text( + 'One million is: 1,000,000.00', + style: TextStyle( + fontFamily: 'Source Code Pro', + fontFeatures: [ + FontFeature.slashedZero(), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_stylistic_alternates.0.dart b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_stylistic_alternates.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..021320b8064a5c65d1a7b25d02065dd20f90245b --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_stylistic_alternates.0.dart @@ -0,0 +1,40 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/widgets.dart'; + +/// Flutter code sample for [FontFeature.FontFeature.stylisticAlternates]. + +void main() => runApp(const ExampleApp()); + +class ExampleApp extends StatelessWidget { + const ExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return WidgetsApp( + builder: (BuildContext context, Widget? navigator) => const ExampleWidget(), + color: const Color(0xffffffff), + ); + } +} + +class ExampleWidget extends StatelessWidget { + const ExampleWidget({super.key}); + + @override + Widget build(BuildContext context) { + // The Source Code Pro font can be downloaded from Google Fonts + // (https://www.google.com/fonts). + return const Text( + r'Agile Game - $100 initial bet', + style: TextStyle( + fontFamily: 'Source Code Pro', + fontFeatures: [ + FontFeature.stylisticAlternates(), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_stylistic_set.0.dart b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_stylistic_set.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..23699b963b4e111e12697dd486374e8341b28079 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_stylistic_set.0.dart @@ -0,0 +1,42 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/widgets.dart'; + +/// Flutter code sample for [FontFeature.FontFeature.stylisticSet]. + +void main() => runApp(const ExampleApp()); + +class ExampleApp extends StatelessWidget { + const ExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return WidgetsApp( + builder: (BuildContext context, Widget? navigator) => const ExampleWidget(), + color: const Color(0xffffffff), + ); + } +} + +class ExampleWidget extends StatelessWidget { + const ExampleWidget({super.key}); + + @override + Widget build(BuildContext context) { + // The Source Code Pro font can be downloaded from Google Fonts + // (https://www.google.com/fonts). + return Text( + 'aáâ β gǵĝ θб Iiíî Ll', + style: TextStyle( + fontFamily: 'Source Code Pro', + fontFeatures: [ + FontFeature.stylisticSet(2), + FontFeature.stylisticSet(3), + FontFeature.stylisticSet(4), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_stylistic_set.1.dart b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_stylistic_set.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..b4c64e4986b53247a5207884fe2092d0b832643c --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_stylistic_set.1.dart @@ -0,0 +1,41 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/widgets.dart'; + +/// Flutter code sample for [FontFeature.FontFeature.stylisticSet]. + +void main() => runApp(const ExampleApp()); + +class ExampleApp extends StatelessWidget { + const ExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return WidgetsApp( + builder: (BuildContext context, Widget? navigator) => const ExampleWidget(), + color: const Color(0xffffffff), + ); + } +} + +class ExampleWidget extends StatelessWidget { + const ExampleWidget({super.key}); + + @override + Widget build(BuildContext context) { + // The Piazzolla font can be downloaded from Google Fonts + // (https://www.google.com/fonts). + return Text( + '-> MCMXCVII <-', // 1997 + style: TextStyle( + fontFamily: 'Piazzolla', + fontFeatures: [ + FontFeature.stylisticSet(1), + FontFeature.stylisticSet(2), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_subscripts.0.dart b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_subscripts.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..0151b88b56255a8583da807414a0eb30df3b689b --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_subscripts.0.dart @@ -0,0 +1,40 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/widgets.dart'; + +/// Flutter code sample for [FontFeature.FontFeature.subscripts]. + +void main() => runApp(const ExampleApp()); + +class ExampleApp extends StatelessWidget { + const ExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return WidgetsApp( + builder: (BuildContext context, Widget? navigator) => const ExampleWidget(), + color: const Color(0xffffffff), + ); + } +} + +class ExampleWidget extends StatelessWidget { + const ExampleWidget({super.key}); + + @override + Widget build(BuildContext context) { + // The Piazzolla font can be downloaded from Google Fonts + // (https://www.google.com/fonts). + return const Text( + 'Line from x1,y1 to x2,y2', + style: TextStyle( + fontFamily: 'Piazzolla', + fontFeatures: [ + FontFeature.subscripts(), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_superscripts.0.dart b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_superscripts.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..8eef9141b65b1e06ac8e503a705c952eba22491c --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_superscripts.0.dart @@ -0,0 +1,40 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/widgets.dart'; + +/// Flutter code sample for [FontFeature.FontFeature.superscripts]. + +void main() => runApp(const ExampleApp()); + +class ExampleApp extends StatelessWidget { + const ExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return WidgetsApp( + builder: (BuildContext context, Widget? navigator) => const ExampleWidget(), + color: const Color(0xffffffff), + ); + } +} + +class ExampleWidget extends StatelessWidget { + const ExampleWidget({super.key}); + + @override + Widget build(BuildContext context) { + // The Sorts Mill Goudy font can be downloaded from Google Fonts + // (https://www.google.com/fonts). + return const Text( + 'The isotope 238U decays to 206Pb', + style: TextStyle( + fontFamily: 'Sorts Mill Goudy', + fontFeatures: [ + FontFeature.superscripts(), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_swash.0.dart b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_swash.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..d47c031257252053cae08f2cc6780dcb8119dce1 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_swash.0.dart @@ -0,0 +1,40 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/widgets.dart'; + +/// Flutter code sample for [FontFeature.FontFeature.swash]. + +void main() => runApp(const ExampleApp()); + +class ExampleApp extends StatelessWidget { + const ExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return WidgetsApp( + builder: (BuildContext context, Widget? navigator) => const ExampleWidget(), + color: const Color(0xffffffff), + ); + } +} + +class ExampleWidget extends StatelessWidget { + const ExampleWidget({super.key}); + + @override + Widget build(BuildContext context) { + // The BioRhyme Expanded font can be downloaded from Google Fonts + // (https://www.google.com/fonts). + return const Text( + 'Queer & Romantic', + style: TextStyle( + fontFamily: 'BioRhyme Expanded', + fontFeatures: [ + FontFeature.swash(), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_tabular_figures.0.dart b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_tabular_figures.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..db7cc099405e390637e72d38dd6a4762f57b4531 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/ui/text/font_feature.font_feature_tabular_figures.0.dart @@ -0,0 +1,40 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/widgets.dart'; + +/// Flutter code sample for [dart]:ui FontFeature.FontFeature.tabularFigures. + +void main() => runApp(const ExampleApp()); + +class ExampleApp extends StatelessWidget { + const ExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return WidgetsApp( + builder: (BuildContext context, Widget? navigator) => const ExampleWidget(), + color: const Color(0xffffffff), + ); + } +} + +class ExampleWidget extends StatelessWidget { + const ExampleWidget({super.key}); + + @override + Widget build(BuildContext context) { + // The Piazzolla font can be downloaded from Google Fonts + // (https://www.google.com/fonts). + return const Text( + 'Call 311-555-2368 now!', + style: TextStyle( + fontFamily: 'Piazzolla', + fontFeatures: [ + FontFeature.tabularFigures(), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/actions/action.action_overridable.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/actions/action.action_overridable.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..3304e0f24547be9bb6a1788514ed85bef418e94f --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/actions/action.action_overridable.0.dart @@ -0,0 +1,89 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +/// Flutter code sample for [Action.Action.overridable]. + +void main() { + runApp( + const MaterialApp( + home: Scaffold( + body: Center(child: VerificationCodeGenerator()), + ), + ), + ); +} + +const CopyTextIntent copyTextIntent = CopyTextIntent._(); + +class CopyTextIntent extends Intent { + const CopyTextIntent._(); +} + +class CopyableText extends StatelessWidget { + const CopyableText({super.key, required this.text}); + + final String text; + + void _copy(CopyTextIntent intent) => Clipboard.setData(ClipboardData(text: text)); + + @override + Widget build(BuildContext context) { + final Action defaultCopyAction = CallbackAction(onInvoke: _copy); + return Shortcuts( + shortcuts: const { + SingleActivator(LogicalKeyboardKey.keyC, control: true): copyTextIntent + }, + child: Actions( + actions: >{ + // The Action is made overridable so the VerificationCodeGenerator + // widget can override how copying is handled. + CopyTextIntent: Action.overridable(defaultAction: defaultCopyAction, context: context), + }, + child: Focus( + autofocus: true, + child: DefaultTextStyle.merge( + style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold), + child: Text(text), + ), + ), + ), + ); + } +} + +class VerificationCodeGenerator extends StatelessWidget { + const VerificationCodeGenerator({super.key}); + + void _copy(CopyTextIntent intent) { + debugPrint('Content copied'); + Clipboard.setData(const ClipboardData(text: '111222333')); + } + + @override + Widget build(BuildContext context) { + return Actions( + actions: >{CopyTextIntent: CallbackAction(onInvoke: _copy)}, + child: const Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text('Press Ctrl-C to Copy'), + SizedBox(height: 10), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + CopyableText(text: '111'), + SizedBox(width: 5), + CopyableText(text: '222'), + SizedBox(width: 5), + CopyableText(text: '333'), + ], + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/actions/action_listener.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/actions/action_listener.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..d4866a60e319dfd3ad71ab773a712a5475c8dd51 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/actions/action_listener.0.dart @@ -0,0 +1,107 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [ActionListener]. + +void main() => runApp(const ActionListenerExampleApp()); + +class ActionListenerExampleApp extends StatelessWidget { + const ActionListenerExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('ActionListener Sample')), + body: const Center( + child: ActionListenerExample(), + ), + ), + ); + } +} + +class ActionListenerExample extends StatefulWidget { + const ActionListenerExample({super.key}); + + @override + State createState() => _ActionListenerExampleState(); +} + +class _ActionListenerExampleState extends State { + bool _on = false; + late final MyAction _myAction; + + @override + void initState() { + super.initState(); + _myAction = MyAction(); + } + + void _toggleState() { + setState(() { + _on = !_on; + }); + } + + @override + Widget build(BuildContext context) { + return Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: OutlinedButton( + onPressed: _toggleState, + child: Text(_on ? 'Disable' : 'Enable'), + ), + ), + if (_on) + Padding( + padding: const EdgeInsets.all(8.0), + child: ActionListener( + listener: (Action action) { + if (action.intentType == MyIntent) { + ScaffoldMessenger.of(context).showSnackBar(const SnackBar( + content: Text('Action Listener Called'), + )); + } + }, + action: _myAction, + child: ElevatedButton( + onPressed: () => const ActionDispatcher().invokeAction(_myAction, const MyIntent()), + child: const Text('Call Action Listener'), + ), + ), + ), + if (!_on) Container(), + ], + ); + } +} + +class MyAction extends Action { + @override + void addActionListener(ActionListenerCallback listener) { + super.addActionListener(listener); + debugPrint('Action Listener was added'); + } + + @override + void removeActionListener(ActionListenerCallback listener) { + super.removeActionListener(listener); + debugPrint('Action Listener was removed'); + } + + @override + void invoke(covariant MyIntent intent) { + notifyActionListeners(); + } +} + +class MyIntent extends Intent { + const MyIntent(); +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/actions/actions.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/actions/actions.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..9752b07cfa6b38cded7887865ad2e9ab975214dd --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/actions/actions.0.dart @@ -0,0 +1,173 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Actions]. + +void main() => runApp(const ActionsExampleApp()); + +class ActionsExampleApp extends StatelessWidget { + const ActionsExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('Actions Sample')), + body: const Center( + child: ActionsExample(), + ), + ), + ); + } +} + +// A simple model class that notifies listeners when it changes. +class Model { + ValueNotifier isDirty = ValueNotifier(false); + ValueNotifier data = ValueNotifier(0); + + int save() { + if (isDirty.value) { + debugPrint('Saved Data: ${data.value}'); + isDirty.value = false; + } + return data.value; + } + + void setValue(int newValue) { + isDirty.value = data.value != newValue; + data.value = newValue; + } +} + +class ModifyIntent extends Intent { + const ModifyIntent(this.value); + + final int value; +} + +// An Action that modifies the model by setting it to the value that it gets +// from the Intent passed to it when invoked. +class ModifyAction extends Action { + ModifyAction(this.model); + + final Model model; + + @override + void invoke(covariant ModifyIntent intent) { + model.setValue(intent.value); + } +} + +// An intent for saving data. +class SaveIntent extends Intent { + const SaveIntent(); +} + +// An Action that saves the data in the model it is created with. +class SaveAction extends Action { + SaveAction(this.model); + + final Model model; + + @override + int invoke(covariant SaveIntent intent) => model.save(); +} + +class SaveButton extends StatefulWidget { + const SaveButton(this.valueNotifier, {super.key}); + + final ValueNotifier valueNotifier; + + @override + State createState() => _SaveButtonState(); +} + +class _SaveButtonState extends State { + int savedValue = 0; + + @override + Widget build(BuildContext context) { + return ListenableBuilder( + listenable: widget.valueNotifier, + builder: (BuildContext context, Widget? child) { + return TextButton.icon( + icon: const Icon(Icons.save), + label: Text('$savedValue'), + style: ButtonStyle( + foregroundColor: MaterialStatePropertyAll( + widget.valueNotifier.value ? Colors.red : Colors.green, + ), + ), + onPressed: () { + setState(() { + savedValue = Actions.invoke(context, const SaveIntent())! as int; + }); + }, + ); + }, + ); + } +} + +class ActionsExample extends StatefulWidget { + const ActionsExample({super.key}); + + @override + State createState() => _ActionsExampleState(); +} + +class _ActionsExampleState extends State { + Model model = Model(); + int count = 0; + + @override + Widget build(BuildContext context) { + return Actions( + actions: >{ + ModifyIntent: ModifyAction(model), + SaveIntent: SaveAction(model), + }, + child: Builder( + builder: (BuildContext context) { + return Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + const Spacer(), + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + IconButton( + icon: const Icon(Icons.exposure_plus_1), + onPressed: () { + Actions.invoke(context, ModifyIntent(++count)); + }, + ), + ListenableBuilder( + listenable: model.data, + builder: (BuildContext context, Widget? child) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Text('${model.data.value}', style: Theme.of(context).textTheme.headlineMedium), + ); + }), + IconButton( + icon: const Icon(Icons.exposure_minus_1), + onPressed: () { + Actions.invoke(context, ModifyIntent(--count)); + }, + ), + ], + ), + SaveButton(model.isDirty), + const Spacer(), + ], + ); + }, + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/actions/focusable_action_detector.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/actions/focusable_action_detector.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..1043b0fa8bac91be3a6de01da43fbac83ea1e3c0 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/actions/focusable_action_detector.0.dart @@ -0,0 +1,145 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +/// Flutter code sample for [FocusableActionDetector]. + +void main() => runApp(const FocusableActionDetectorExampleApp()); + +class FocusableActionDetectorExampleApp extends StatelessWidget { + const FocusableActionDetectorExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: FocusableActionDetectorExample(), + ); + } +} + +class FadButton extends StatefulWidget { + const FadButton({ + super.key, + required this.onPressed, + required this.child, + }); + + final VoidCallback onPressed; + final Widget child; + + @override + State createState() => _FadButtonState(); +} + +class _FadButtonState extends State { + bool _focused = false; + bool _hovering = false; + bool _on = false; + late final Map> _actionMap; + final Map _shortcutMap = const { + SingleActivator(LogicalKeyboardKey.keyX): ActivateIntent(), + }; + + @override + void initState() { + super.initState(); + _actionMap = >{ + ActivateIntent: CallbackAction( + onInvoke: (Intent intent) => _toggleState(), + ), + }; + } + + Color get color { + Color baseColor = Colors.lightBlue; + if (_focused) { + baseColor = Color.alphaBlend(Colors.black.withOpacity(0.25), baseColor); + } + if (_hovering) { + baseColor = Color.alphaBlend(Colors.black.withOpacity(0.1), baseColor); + } + return baseColor; + } + + void _toggleState() { + setState(() { + _on = !_on; + }); + } + + void _handleFocusHighlight(bool value) { + setState(() { + _focused = value; + }); + } + + void _handleHoveHighlight(bool value) { + setState(() { + _hovering = value; + }); + } + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: _toggleState, + child: FocusableActionDetector( + actions: _actionMap, + shortcuts: _shortcutMap, + onShowFocusHighlight: _handleFocusHighlight, + onShowHoverHighlight: _handleHoveHighlight, + child: Row( + children: [ + Container( + padding: const EdgeInsets.all(10.0), + color: color, + child: widget.child, + ), + Container( + width: 30, + height: 30, + margin: const EdgeInsets.all(10.0), + color: _on ? Colors.red : Colors.transparent, + ), + ], + ), + ), + ); + } +} + +class FocusableActionDetectorExample extends StatefulWidget { + const FocusableActionDetectorExample({super.key}); + + @override + State createState() => _FocusableActionDetectorExampleState(); +} + +class _FocusableActionDetectorExampleState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('FocusableActionDetector Example'), + ), + body: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: TextButton(onPressed: () {}, child: const Text('Press Me')), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: FadButton(onPressed: () {}, child: const Text('And Me')), + ), + ], + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/animated_grid/animated_grid.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/animated_grid/animated_grid.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..3f2b55d699d98051d55be552f2c02d692996da0a --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/animated_grid/animated_grid.0.dart @@ -0,0 +1,231 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [AnimatedGrid]. + +void main() { + runApp(const AnimatedGridSample()); +} + +class AnimatedGridSample extends StatefulWidget { + const AnimatedGridSample({super.key}); + + @override + State createState() => _AnimatedGridSampleState(); +} + +class _AnimatedGridSampleState extends State { + final GlobalKey _gridKey = GlobalKey(); + late ListModel _list; + int? _selectedItem; + late int _nextItem; // The next item inserted when the user presses the '+' button. + + @override + void initState() { + super.initState(); + _list = ListModel( + listKey: _gridKey, + initialItems: [0, 1, 2, 3, 4, 5], + removedItemBuilder: _buildRemovedItem, + ); + _nextItem = 6; + } + + // Used to build list items that haven't been removed. + Widget _buildItem(BuildContext context, int index, Animation animation) { + return CardItem( + animation: animation, + item: _list[index], + selected: _selectedItem == _list[index], + onTap: () { + setState(() { + _selectedItem = _selectedItem == _list[index] ? null : _list[index]; + }); + }, + ); + } + + // Used to build an item after it has been removed from the list. This method + // is needed because a removed item remains visible until its animation has + // completed (even though it's gone as far as this ListModel is concerned). + // The widget will be used by the [AnimatedGridState.removeItem] method's + // [AnimatedGridRemovedItemBuilder] parameter. + Widget _buildRemovedItem(int item, BuildContext context, Animation animation) { + return CardItem( + animation: animation, + item: item, + removing: true, + // No gesture detector here: we don't want removed items to be interactive. + ); + } + + // Insert the "next item" into the list model. + void _insert() { + final int index = _selectedItem == null ? _list.length : _list.indexOf(_selectedItem!); + setState(() { + _list.insert(index, _nextItem++); + }); + } + + // Remove the selected item from the list model. + void _remove() { + if (_selectedItem != null) { + setState(() { + _list.removeAt(_list.indexOf(_selectedItem!)); + _selectedItem = null; + }); + } else if (_list.length > 0) { + setState(() { + _list.removeAt(_list.length - 1); + }); + } + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + debugShowCheckedModeBanner: false, + home: Scaffold( + appBar: AppBar( + title: const Text( + 'AnimatedGrid', + style: TextStyle(fontSize: 30), + ), + centerTitle: true, + leading: IconButton( + icon: const Icon(Icons.remove_circle), + iconSize: 32, + onPressed: (_list.length > 0) ? _remove : null, + tooltip: 'remove the selected item', + ), + actions: [ + IconButton( + icon: const Icon(Icons.add_circle), + iconSize: 32, + onPressed: _insert, + tooltip: 'insert a new item', + ), + ], + ), + body: Padding( + padding: const EdgeInsets.all(16.0), + child: AnimatedGrid( + key: _gridKey, + gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent( + maxCrossAxisExtent: 100.0, + mainAxisSpacing: 10.0, + crossAxisSpacing: 10.0, + ), + initialItemCount: _list.length, + itemBuilder: _buildItem, + ), + ), + ), + ); + } +} + +typedef RemovedItemBuilder = Widget Function(T item, BuildContext context, Animation animation); + +/// Keeps a Dart [List] in sync with an [AnimatedGrid]. +/// +/// The [insert] and [removeAt] methods apply to both the internal list and +/// the animated list that belongs to [listKey]. +/// +/// This class only exposes as much of the Dart List API as is needed by the +/// sample app. More list methods are easily added, however methods that +/// mutate the list must make the same changes to the animated list in terms +/// of [AnimatedGridState.insertItem] and [AnimatedGrid.removeItem]. +class ListModel { + ListModel({ + required this.listKey, + required this.removedItemBuilder, + Iterable? initialItems, + }) : _items = List.from(initialItems ?? []); + + final GlobalKey listKey; + final RemovedItemBuilder removedItemBuilder; + final List _items; + + AnimatedGridState? get _animatedGrid => listKey.currentState; + + void insert(int index, E item) { + _items.insert(index, item); + _animatedGrid!.insertItem( + index, + duration: const Duration(milliseconds: 500), + ); + } + + E removeAt(int index) { + final E removedItem = _items.removeAt(index); + if (removedItem != null) { + _animatedGrid!.removeItem( + index, + (BuildContext context, Animation animation) { + return removedItemBuilder(removedItem, context, animation); + }, + ); + } + return removedItem; + } + + int get length => _items.length; + + E operator [](int index) => _items[index]; + + int indexOf(E item) => _items.indexOf(item); +} + +/// Displays its integer item as 'item N' on a Card whose color is based on +/// the item's value. +/// +/// The text is displayed in bright green if [selected] is +/// true. This widget's height is based on the [animation] parameter, it +/// varies from 0 to 128 as the animation varies from 0.0 to 1.0. +class CardItem extends StatelessWidget { + const CardItem({ + super.key, + this.onTap, + this.selected = false, + this.removing = false, + required this.animation, + required this.item, + }) : assert(item >= 0); + + final Animation animation; + final VoidCallback? onTap; + final int item; + final bool selected; + final bool removing; + + @override + Widget build(BuildContext context) { + TextStyle textStyle = Theme.of(context).textTheme.headlineMedium!; + if (selected) { + textStyle = textStyle.copyWith(color: Colors.lightGreenAccent[400]); + } + return Padding( + padding: const EdgeInsets.all(2.0), + child: ScaleTransition( + scale: CurvedAnimation(parent: animation, curve: removing ? Curves.easeInOut : Curves.bounceOut), + child: GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: onTap, + child: SizedBox( + height: 80.0, + child: Card( + color: Colors.primaries[item % Colors.primaries.length], + child: Center( + child: Text('${item + 1}', style: textStyle), + ), + ), + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/animated_grid/sliver_animated_grid.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/animated_grid/sliver_animated_grid.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..65c9a0ee618ba009336002e3ae649e5a71a44427 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/animated_grid/sliver_animated_grid.0.dart @@ -0,0 +1,229 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [SliverAnimatedGrid]. + +void main() => runApp(const SliverAnimatedGridSample()); + +class SliverAnimatedGridSample extends StatefulWidget { + const SliverAnimatedGridSample({super.key}); + + @override + State createState() => _SliverAnimatedGridSampleState(); +} + +class _SliverAnimatedGridSampleState extends State { + final GlobalKey _listKey = GlobalKey(); + final GlobalKey _scaffoldKey = GlobalKey(); + final GlobalKey _scaffoldMessengerKey = GlobalKey(); + late ListModel _list; + int? _selectedItem; + late int _nextItem; // The next item inserted when the user presses the '+' button. + + @override + void initState() { + super.initState(); + _list = ListModel( + listKey: _listKey, + initialItems: [0, 1, 2, 3, 4, 5], + removedItemBuilder: _buildRemovedItem, + ); + _nextItem = 6; + } + + // Used to build list items that haven't been removed. + Widget _buildItem(BuildContext context, int index, Animation animation) { + return CardItem( + animation: animation, + item: _list[index], + selected: _selectedItem == _list[index], + onTap: () { + setState(() { + _selectedItem = _selectedItem == _list[index] ? null : _list[index]; + }); + }, + ); + } + + // Used to build an item after it has been removed from the list. This + // method is needed because a removed item remains visible until its + // animation has completed (even though it's gone as far this ListModel is + // concerned). The widget will be used by the + // [AnimatedGridState.removeItem] method's + // [AnimatedGridRemovedItemBuilder] parameter. + Widget _buildRemovedItem(int item, BuildContext context, Animation animation) { + return CardItem( + animation: animation, + removing: true, + item: item, + ); + } + + // Insert the "next item" into the list model. + void _insert() { + final int index = _selectedItem == null ? _list.length : _list.indexOf(_selectedItem!); + _list.insert(index, _nextItem++); + } + + // Remove the selected item from the list model. + void _remove() { + if (_selectedItem != null) { + _list.removeAt(_list.indexOf(_selectedItem!)); + } else { + _list.removeAt(_list.length - 1); + } + setState(() { + _selectedItem = null; + }); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + scaffoldMessengerKey: _scaffoldMessengerKey, + debugShowCheckedModeBanner: false, + home: Scaffold( + key: _scaffoldKey, + body: CustomScrollView( + slivers: [ + SliverAppBar( + title: const Text( + 'SliverAnimatedGrid', + style: TextStyle(fontSize: 30), + ), + expandedHeight: 60, + centerTitle: true, + backgroundColor: Colors.amber[900], + leading: IconButton( + icon: const Icon(Icons.remove_circle), + onPressed: _remove, + tooltip: 'Remove the selected item, or the last item if none selected.', + iconSize: 32, + ), + actions: [ + IconButton( + icon: const Icon(Icons.add_circle), + onPressed: _insert, + tooltip: 'Insert a new item.', + iconSize: 32, + ), + ], + ), + SliverAnimatedGrid( + key: _listKey, + initialItemCount: _list.length, + gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent( + maxCrossAxisExtent: 100.0, + mainAxisSpacing: 10.0, + crossAxisSpacing: 10.0, + ), + itemBuilder: _buildItem, + ), + ], + ), + ), + ); + } +} + +typedef RemovedItemBuilder = Widget Function(int item, BuildContext context, Animation animation); + +// Keeps a Dart [List] in sync with an [AnimatedGrid]. +// +// The [insert] and [removeAt] methods apply to both the internal list and +// the animated list that belongs to [listKey]. +// +// This class only exposes as much of the Dart List API as is needed by the +// sample app. More list methods are easily added, however methods that +// mutate the list must make the same changes to the animated list in terms +// of [AnimatedGridState.insertItem] and [AnimatedGrid.removeItem]. +class ListModel { + ListModel({ + required this.listKey, + required this.removedItemBuilder, + Iterable? initialItems, + }) : _items = List.from(initialItems ?? []); + + final GlobalKey listKey; + final RemovedItemBuilder removedItemBuilder; + final List _items; + + SliverAnimatedGridState get _animatedGrid => listKey.currentState!; + + void insert(int index, E item) { + _items.insert(index, item); + _animatedGrid.insertItem(index); + } + + E removeAt(int index) { + final E removedItem = _items.removeAt(index); + if (removedItem != null) { + _animatedGrid.removeItem( + index, + (BuildContext context, Animation animation) => removedItemBuilder(index, context, animation), + ); + } + return removedItem; + } + + int get length => _items.length; + + E operator [](int index) => _items[index]; + + int indexOf(E item) => _items.indexOf(item); +} + +// Displays its integer item as 'Item N' on a Card whose color is based on +// the item's value. +// +// The card turns gray when [selected] is true. This widget's height +// is based on the [animation] parameter. It varies as the animation value +// transitions from 0.0 to 1.0. +class CardItem extends StatelessWidget { + const CardItem({ + super.key, + this.onTap, + this.selected = false, + this.removing = false, + required this.animation, + required this.item, + }) : assert(item >= 0); + + final Animation animation; + final VoidCallback? onTap; + final int item; + final bool selected; + final bool removing; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.only( + left: 2.0, + right: 2.0, + top: 2.0, + ), + child: ScaleTransition( + scale: CurvedAnimation(parent: animation, curve: removing ? Curves.easeInOut : Curves.bounceOut), + child: GestureDetector( + onTap: onTap, + child: SizedBox( + height: 80.0, + child: Card( + color: selected ? Colors.black12 : Colors.primaries[item % Colors.primaries.length], + child: Center( + child: Text( + (item + 1).toString(), + style: Theme.of(context).textTheme.headlineMedium, + ), + ), + ), + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/animated_list/animated_list.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/animated_list/animated_list.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..c59a2435a5432ae018b2157dfb4f55980e5ceb1e --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/animated_list/animated_list.0.dart @@ -0,0 +1,209 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [AnimatedList]. + +void main() { + runApp(const AnimatedListSample()); +} + +class AnimatedListSample extends StatefulWidget { + const AnimatedListSample({super.key}); + + @override + State createState() => _AnimatedListSampleState(); +} + +class _AnimatedListSampleState extends State { + final GlobalKey _listKey = GlobalKey(); + late ListModel _list; + int? _selectedItem; + late int _nextItem; // The next item inserted when the user presses the '+' button. + + @override + void initState() { + super.initState(); + _list = ListModel( + listKey: _listKey, + initialItems: [0, 1, 2], + removedItemBuilder: _buildRemovedItem, + ); + _nextItem = 3; + } + + // Used to build list items that haven't been removed. + Widget _buildItem(BuildContext context, int index, Animation animation) { + return CardItem( + animation: animation, + item: _list[index], + selected: _selectedItem == _list[index], + onTap: () { + setState(() { + _selectedItem = _selectedItem == _list[index] ? null : _list[index]; + }); + }, + ); + } + + /// The builder function used to build items that have been removed. + /// + /// Used to build an item after it has been removed from the list. This method + /// is needed because a removed item remains visible until its animation has + /// completed (even though it's gone as far as this ListModel is concerned). + /// The widget will be used by the [AnimatedListState.removeItem] method's + /// [AnimatedRemovedItemBuilder] parameter. + Widget _buildRemovedItem(int item, BuildContext context, Animation animation) { + return CardItem( + animation: animation, + item: item, + // No gesture detector here: we don't want removed items to be interactive. + ); + } + + // Insert the "next item" into the list model. + void _insert() { + final int index = _selectedItem == null ? _list.length : _list.indexOf(_selectedItem!); + _list.insert(index, _nextItem++); + } + + // Remove the selected item from the list model. + void _remove() { + if (_selectedItem != null) { + _list.removeAt(_list.indexOf(_selectedItem!)); + setState(() { + _selectedItem = null; + }); + } + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('AnimatedList'), + actions: [ + IconButton( + icon: const Icon(Icons.add_circle), + onPressed: _insert, + tooltip: 'insert a new item', + ), + IconButton( + icon: const Icon(Icons.remove_circle), + onPressed: _remove, + tooltip: 'remove the selected item', + ), + ], + ), + body: Padding( + padding: const EdgeInsets.all(16.0), + child: AnimatedList( + key: _listKey, + initialItemCount: _list.length, + itemBuilder: _buildItem, + ), + ), + ), + ); + } +} + +typedef RemovedItemBuilder = Widget Function(T item, BuildContext context, Animation animation); + +/// Keeps a Dart [List] in sync with an [AnimatedList]. +/// +/// The [insert] and [removeAt] methods apply to both the internal list and +/// the animated list that belongs to [listKey]. +/// +/// This class only exposes as much of the Dart List API as is needed by the +/// sample app. More list methods are easily added, however methods that +/// mutate the list must make the same changes to the animated list in terms +/// of [AnimatedListState.insertItem] and [AnimatedList.removeItem]. +class ListModel { + ListModel({ + required this.listKey, + required this.removedItemBuilder, + Iterable? initialItems, + }) : _items = List.from(initialItems ?? []); + + final GlobalKey listKey; + final RemovedItemBuilder removedItemBuilder; + final List _items; + + AnimatedListState? get _animatedList => listKey.currentState; + + void insert(int index, E item) { + _items.insert(index, item); + _animatedList!.insertItem(index); + } + + E removeAt(int index) { + final E removedItem = _items.removeAt(index); + if (removedItem != null) { + _animatedList!.removeItem( + index, + (BuildContext context, Animation animation) { + return removedItemBuilder(removedItem, context, animation); + }, + ); + } + return removedItem; + } + + int get length => _items.length; + + E operator [](int index) => _items[index]; + + int indexOf(E item) => _items.indexOf(item); +} + +/// Displays its integer item as 'item N' on a Card whose color is based on +/// the item's value. +/// +/// The text is displayed in bright green if [selected] is +/// true. This widget's height is based on the [animation] parameter, it +/// varies from 0 to 128 as the animation varies from 0.0 to 1.0. +class CardItem extends StatelessWidget { + const CardItem({ + super.key, + this.onTap, + this.selected = false, + required this.animation, + required this.item, + }) : assert(item >= 0); + + final Animation animation; + final VoidCallback? onTap; + final int item; + final bool selected; + + @override + Widget build(BuildContext context) { + TextStyle textStyle = Theme.of(context).textTheme.headlineMedium!; + if (selected) { + textStyle = textStyle.copyWith(color: Colors.lightGreenAccent[400]); + } + return Padding( + padding: const EdgeInsets.all(2.0), + child: SizeTransition( + sizeFactor: animation, + child: GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: onTap, + child: SizedBox( + height: 80.0, + child: Card( + color: Colors.primaries[item % Colors.primaries.length], + child: Center( + child: Text('Item $item', style: textStyle), + ), + ), + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/animated_list/animated_list_separated.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/animated_list/animated_list_separated.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..c330e6f473761c64cef2707478e57ace9c9f663b --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/animated_list/animated_list_separated.0.dart @@ -0,0 +1,278 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [AnimatedList.separated]. + +void main() { + runApp(const AnimatedListSeparatedSample()); +} + +class AnimatedListSeparatedSample extends StatefulWidget { + const AnimatedListSeparatedSample({super.key}); + + @override + State createState() => _AnimatedListSeparatedSampleState(); +} + +class _AnimatedListSeparatedSampleState extends State { + final GlobalKey _listKey = GlobalKey(); + late ListModel _list; + int? _selectedItem; + late int _nextItem; // The next item inserted when the user presses the '+' button. + + @override + void initState() { + super.initState(); + _list = ListModel( + listKey: _listKey, + initialItems: [0, 1, 2], + removedItemBuilder: _buildRemovedItem, + ); + _nextItem = 3; + } + + // Used to build list items that haven't been removed. + Widget _buildItem(BuildContext context, int index, Animation animation) { + return CardItem( + animation: animation, + item: _list[index], + selected: _selectedItem == _list[index], + onTap: () { + setState(() { + _selectedItem = _selectedItem == _list[index] ? null : _list[index]; + }); + }, + ); + } + + // Used to build separators for items that haven't been removed. + Widget _buildSeparator(BuildContext context, int index, Animation animation) { + return ItemSeparator( + animation: animation, + item: _list[index], + ); + } + + /// The builder function used to build items that have been removed. + /// + /// Used to build an item after it has been removed from the list. This method + /// is needed because a removed item remains visible until its animation has + /// completed (even though it's gone as far as this ListModel is concerned). + /// The widget will be used by the [AnimatedListState.removeItem] method's + /// `itemBuilder` parameter. + Widget _buildRemovedItem(int item, BuildContext context, Animation animation) { + return CardItem( + animation: animation, + item: item, + // No gesture detector here: we don't want removed items to be interactive. + ); + } + + /// The builder function used to build a separator for an item that has been removed. + /// + /// Used to build a separator after the corresponding item has been removed from the list. + /// This method is needed because the separator of a removed item remains visible until its animation has completed. + /// The widget will be passed to [AnimatedList.separated] + /// via the [AnimatedList.removedSeparatorBuilder] parameter and used + /// in the [AnimatedListState.removeItem] method. + /// + /// The item parameter is null, because the corresponding item will + /// have been removed from the list model by the time this builder is called. + Widget _buildRemovedSeparator(BuildContext context, int index, Animation animation) { + return SizeTransition( + sizeFactor: animation, + child: ItemSeparator( + animation: animation, + item: null, + ) + ); + } + + // Insert the "next item" into the list model. + void _insert() { + final int index = _selectedItem == null ? _list.length : _list.indexOf(_selectedItem!); + _list.insert(index, _nextItem); + _nextItem++; + } + + // Remove the selected item from the list model. + void _remove() { + if (_selectedItem != null) { + _list.removeAt(_list.indexOf(_selectedItem!)); + setState(() { + _selectedItem = null; + }); + } + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('AnimatedList.separated'), + actions: [ + IconButton( + icon: const Icon(Icons.add_circle), + onPressed: _insert, + tooltip: 'insert a new item', + ), + IconButton( + icon: const Icon(Icons.remove_circle), + onPressed: _remove, + tooltip: 'remove the selected item', + ), + ], + ), + body: Padding( + padding: const EdgeInsets.all(16.0), + child: AnimatedList.separated( + key: _listKey, + initialItemCount: _list.length, + itemBuilder: _buildItem, + separatorBuilder: _buildSeparator, + removedSeparatorBuilder: _buildRemovedSeparator, + ), + ), + ), + ); + } +} + +typedef RemovedItemBuilder = Widget Function(T item, BuildContext context, Animation animation); + +/// Keeps a Dart [List] in sync with an [AnimatedList.separated]. +/// +/// The [insert] and [removeAt] methods apply to both the internal list and +/// the animated list that belongs to [listKey]. +/// +/// This class only exposes as much of the Dart List API as is needed by the +/// sample app. More list methods are easily added, however methods that +/// mutate the list must make the same changes to the animated list in terms +/// of [AnimatedListState.insertItem] and [AnimatedListState.removeItem]. +class ListModel { + ListModel({ + required this.listKey, + required this.removedItemBuilder, + Iterable? initialItems, + }) : _items = List.from(initialItems ?? []); + + final GlobalKey listKey; + final RemovedItemBuilder removedItemBuilder; + final List _items; + + AnimatedListState? get _animatedList => listKey.currentState; + + void insert(int index, E item) { + _items.insert(index, item); + _animatedList!.insertItem(index); + } + + E removeAt(int index) { + final E removedItem = _items.removeAt(index); + if (removedItem != null) { + _animatedList!.removeItem( + index, + (BuildContext context, Animation animation) { + return removedItemBuilder(removedItem, context, animation); + }, + ); + } + return removedItem; + } + + int get length => _items.length; + + E operator [](int index) => _items[index]; + + int indexOf(E item) => _items.indexOf(item); +} + +/// Displays its integer item as 'item N' on a Card whose color is based on +/// the item's value. +/// +/// The text is displayed in bright green if [selected] is +/// true. This widget's height is based on the [animation] parameter, it +/// varies from 0 to 80 as the animation varies from 0.0 to 1.0. +class CardItem extends StatelessWidget { + const CardItem({ + super.key, + this.onTap, + this.selected = false, + required this.animation, + required this.item, + }) : assert(item >= 0); + + final Animation animation; + final VoidCallback? onTap; + final int item; + final bool selected; + + @override + Widget build(BuildContext context) { + TextStyle textStyle = Theme.of(context).textTheme.headlineMedium!; + if (selected) { + textStyle = textStyle.copyWith(color: Colors.lightGreenAccent[400]); + } + return Padding( + padding: const EdgeInsets.all(2.0), + child: SizeTransition( + sizeFactor: animation, + child: GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: onTap, + child: SizedBox( + height: 80.0, + child: Card( + color: Colors.primaries[item % Colors.primaries.length], + child: Center( + child: Text('Item $item', style: textStyle), + ), + ), + ), + ), + ), + ); + } +} + +/// Displays its integer item as 'separator N' on a Card whose color is based on +/// the corresponding item's value. +/// +/// When the item parameter is null, the separator is displayed as 'Removing separator' with a default color. +/// +/// This widget's height is based on the [animation] parameter, it +/// varies from 0 to 40 as the animation varies from 0.0 to 1.0. +class ItemSeparator extends StatelessWidget { + const ItemSeparator({ + super.key, + required this.animation, + required this.item, + }) : assert(item == null || item >= 0); + + final Animation animation; + final int? item; + + @override + Widget build(BuildContext context) { + final TextStyle textStyle = Theme.of(context).textTheme.headlineSmall!; + return Padding( + padding: const EdgeInsets.all(2.0), + child: SizeTransition( + sizeFactor: animation, + child: SizedBox( + height: 40.0, + child: Card( + color: item == null ? Colors.grey : Colors.primaries[item! % Colors.primaries.length], + child: Center( + child: Text(item == null ? 'Removing separator' : 'Separator $item', style: textStyle), + ), + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/animated_list/sliver_animated_list.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/animated_list/sliver_animated_list.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..182b24b8f6c497eb6012846e2b443758a7e63561 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/animated_list/sliver_animated_list.0.dart @@ -0,0 +1,226 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [SliverAnimatedList]. + +void main() => runApp(const SliverAnimatedListSample()); + +class SliverAnimatedListSample extends StatefulWidget { + const SliverAnimatedListSample({super.key}); + + @override + State createState() => _SliverAnimatedListSampleState(); +} + +class _SliverAnimatedListSampleState extends State { + final GlobalKey _listKey = GlobalKey(); + final GlobalKey _scaffoldKey = GlobalKey(); + final GlobalKey _scaffoldMessengerKey = GlobalKey(); + late ListModel _list; + int? _selectedItem; + late int _nextItem; // The next item inserted when the user presses the '+' button. + + @override + void initState() { + super.initState(); + _list = ListModel( + listKey: _listKey, + initialItems: [0, 1, 2], + removedItemBuilder: _buildRemovedItem, + ); + _nextItem = 3; + } + + // Used to build list items that haven't been removed. + Widget _buildItem(BuildContext context, int index, Animation animation) { + return CardItem( + animation: animation, + item: _list[index], + selected: _selectedItem == _list[index], + onTap: () { + setState(() { + _selectedItem = _selectedItem == _list[index] ? null : _list[index]; + }); + }, + ); + } + + /// The builder function used to build items that have been removed. + /// + /// Used to build an item after it has been removed from the list. This method + /// is needed because a removed item remains visible until its animation has + /// completed (even though it's gone as far this ListModel is concerned). The + /// widget will be used by the [AnimatedListState.removeItem] method's + /// [AnimatedRemovedItemBuilder] parameter. + Widget _buildRemovedItem(int item, BuildContext context, Animation animation) { + return CardItem( + animation: animation, + item: item, + ); + } + + // Insert the "next item" into the list model. + void _insert() { + final int index = _selectedItem == null ? _list.length : _list.indexOf(_selectedItem!); + _list.insert(index, _nextItem++); + } + + // Remove the selected item from the list model. + void _remove() { + if (_selectedItem != null) { + _list.removeAt(_list.indexOf(_selectedItem!)); + setState(() { + _selectedItem = null; + }); + } else { + _scaffoldMessengerKey.currentState!.showSnackBar(const SnackBar( + content: Text( + 'Select an item to remove from the list.', + style: TextStyle(fontSize: 20), + ), + )); + } + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + scaffoldMessengerKey: _scaffoldMessengerKey, + home: Scaffold( + key: _scaffoldKey, + body: CustomScrollView( + slivers: [ + SliverAppBar( + title: const Text( + 'SliverAnimatedList', + style: TextStyle(fontSize: 30), + ), + expandedHeight: 60, + centerTitle: true, + backgroundColor: Colors.amber[900], + leading: IconButton( + icon: const Icon(Icons.add_circle), + onPressed: _insert, + tooltip: 'Insert a new item.', + iconSize: 32, + ), + actions: [ + IconButton( + icon: const Icon(Icons.remove_circle), + onPressed: _remove, + tooltip: 'Remove the selected item.', + iconSize: 32, + ), + ], + ), + SliverAnimatedList( + key: _listKey, + initialItemCount: _list.length, + itemBuilder: _buildItem, + ), + ], + ), + ), + ); + } +} + +typedef RemovedItemBuilder = Widget Function(E item, BuildContext context, Animation animation); + +// Keeps a Dart [List] in sync with an [AnimatedList]. +// +// The [insert] and [removeAt] methods apply to both the internal list and +// the animated list that belongs to [listKey]. +// +// This class only exposes as much of the Dart List API as is needed by the +// sample app. More list methods are easily added, however methods that +// mutate the list must make the same changes to the animated list in terms +// of [AnimatedListState.insertItem] and [AnimatedList.removeItem]. +class ListModel { + ListModel({ + required this.listKey, + required this.removedItemBuilder, + Iterable? initialItems, + }) : _items = List.from(initialItems ?? []); + + final GlobalKey listKey; + final RemovedItemBuilder removedItemBuilder; + final List _items; + + SliverAnimatedListState get _animatedList => listKey.currentState!; + + void insert(int index, E item) { + _items.insert(index, item); + _animatedList.insertItem(index); + } + + E removeAt(int index) { + final E removedItem = _items.removeAt(index); + if (removedItem != null) { + _animatedList.removeItem( + index, + (BuildContext context, Animation animation) => removedItemBuilder(removedItem, context, animation), + ); + } + return removedItem; + } + + int get length => _items.length; + + E operator [](int index) => _items[index]; + + int indexOf(E item) => _items.indexOf(item); +} + +// Displays its integer item as 'Item N' on a Card whose color is based on +// the item's value. +// +// The card turns gray when [selected] is true. This widget's height +// is based on the [animation] parameter. It varies as the animation value +// transitions from 0.0 to 1.0. +class CardItem extends StatelessWidget { + const CardItem({ + super.key, + this.onTap, + this.selected = false, + required this.animation, + required this.item, + }) : assert(item >= 0); + + final Animation animation; + final VoidCallback? onTap; + final int item; + final bool selected; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.only( + left: 2.0, + right: 2.0, + top: 2.0, + ), + child: SizeTransition( + sizeFactor: animation, + child: GestureDetector( + onTap: onTap, + child: SizedBox( + height: 80.0, + child: Card( + color: selected ? Colors.black12 : Colors.primaries[item % Colors.primaries.length], + child: Center( + child: Text( + 'Item $item', + style: Theme.of(context).textTheme.headlineMedium, + ), + ), + ), + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/animated_size/animated_size.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/animated_size/animated_size.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..76f53b359ab451db5387c61a762380230d83a7ee --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/animated_size/animated_size.0.dart @@ -0,0 +1,59 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [AnimatedSize]. + +void main() => runApp(const AnimatedSizeExampleApp()); + +class AnimatedSizeExampleApp extends StatelessWidget { + const AnimatedSizeExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('AnimatedSize Sample')), + body: const Center( + child: AnimatedSizeExample(), + ), + ), + ); + } +} + +class AnimatedSizeExample extends StatefulWidget { + const AnimatedSizeExample({super.key}); + + @override + State createState() => _AnimatedSizeExampleState(); +} + +class _AnimatedSizeExampleState extends State { + double _size = 50.0; + bool _large = false; + + void _updateSize() { + setState(() { + _size = _large ? 250.0 : 100.0; + _large = !_large; + }); + } + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: () => _updateSize(), + child: ColoredBox( + color: Colors.amberAccent, + child: AnimatedSize( + curve: Curves.easeIn, + duration: const Duration(seconds: 1), + child: FlutterLogo(size: _size), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/animated_switcher/animated_switcher.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/animated_switcher/animated_switcher.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..14055674a74c7441a55c68cbb808a495bdf4dc49 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/animated_switcher/animated_switcher.0.dart @@ -0,0 +1,65 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [AnimatedSwitcher]. + +void main() => runApp(const AnimatedSwitcherExampleApp()); + +class AnimatedSwitcherExampleApp extends StatelessWidget { + const AnimatedSwitcherExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: AnimatedSwitcherExample(), + ); + } +} + +class AnimatedSwitcherExample extends StatefulWidget { + const AnimatedSwitcherExample({super.key}); + + @override + State createState() => _AnimatedSwitcherExampleState(); +} + +class _AnimatedSwitcherExampleState extends State { + int _count = 0; + + @override + Widget build(BuildContext context) { + return ColoredBox( + color: Colors.white, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + AnimatedSwitcher( + duration: const Duration(milliseconds: 500), + transitionBuilder: (Widget child, Animation animation) { + return ScaleTransition(scale: animation, child: child); + }, + child: Text( + '$_count', + // This key causes the AnimatedSwitcher to interpret this as a "new" + // child each time the count changes, so that it will begin its animation + // when the count changes. + key: ValueKey(_count), + style: Theme.of(context).textTheme.headlineMedium, + ), + ), + ElevatedButton( + child: const Text('Increment'), + onPressed: () { + setState(() { + _count += 1; + }); + }, + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/app/widgets_app.widgets_app.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/app/widgets_app.widgets_app.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..82a8d00e866b46ec12ceb8970e7d42b3f8b78486 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/app/widgets_app.widgets_app.0.dart @@ -0,0 +1,27 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [WidgetsApp]. + +void main() => runApp(const WidgetsAppExampleApp()); + +class WidgetsAppExampleApp extends StatelessWidget { + const WidgetsAppExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return WidgetsApp( + title: 'Example', + color: const Color(0xFF000000), + home: const Center(child: Text('Hello World')), + pageRouteBuilder: (RouteSettings settings, WidgetBuilder builder) => PageRouteBuilder( + settings: settings, + pageBuilder: (BuildContext context, Animation animation, Animation secondaryAnimation) => + builder(context), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/app_lifecycle_listener/app_lifecycle_listener.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/app_lifecycle_listener/app_lifecycle_listener.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..09ad44d79f117d91919e33b4e42e82e5b2421ca9 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/app_lifecycle_listener/app_lifecycle_listener.0.dart @@ -0,0 +1,100 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/scheduler.dart'; + +/// Flutter code sample for [AppLifecycleListener]. + +void main() { + runApp(const AppLifecycleListenerExample()); +} + +class AppLifecycleListenerExample extends StatelessWidget { + const AppLifecycleListenerExample({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: Scaffold(body: AppLifecycleDisplay()), + ); + } +} + +class AppLifecycleDisplay extends StatefulWidget { + const AppLifecycleDisplay({super.key}); + + @override + State createState() => _AppLifecycleDisplayState(); +} + +class _AppLifecycleDisplayState extends State { + late final AppLifecycleListener _listener; + final ScrollController _scrollController = ScrollController(); + final List _states = []; + late AppLifecycleState? _state; + + @override + void initState() { + super.initState(); + _state = SchedulerBinding.instance.lifecycleState; + _listener = AppLifecycleListener( + onShow: () => _handleTransition('show'), + onResume: () => _handleTransition('resume'), + onHide: () => _handleTransition('hide'), + onInactive: () => _handleTransition('inactive'), + onPause: () => _handleTransition('pause'), + onDetach: () => _handleTransition('detach'), + onRestart: () => _handleTransition('restart'), + // This fires for each state change. Callbacks above fire only for + // specific state transitions. + onStateChange: _handleStateChange, + ); + if (_state != null) { + _states.add(_state!.name); + } + } + + @override + void dispose() { + _listener.dispose(); + super.dispose(); + } + + void _handleTransition(String name) { + setState(() { + _states.add(name); + }); + _scrollController.animateTo( + _scrollController.position.maxScrollExtent, + duration: const Duration(milliseconds: 200), + curve: Curves.easeOut, + ); + } + + void _handleStateChange(AppLifecycleState state) { + setState(() { + _state = state; + }); + } + + @override + Widget build(BuildContext context) { + return Center( + child: SizedBox( + width: 300, + child: SingleChildScrollView( + controller: _scrollController, + child: Column( + children: [ + Text('Current State: ${_state ?? 'Not initialized yet'}'), + const SizedBox(height: 30), + Text('State History:\n ${_states.join('\n ')}'), + ], + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/app_lifecycle_listener/app_lifecycle_listener.1.dart b/novelforge-project/flutter/examples/api/lib/widgets/app_lifecycle_listener/app_lifecycle_listener.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..c35945e12a663f857c64ffe0ff3f0270278b2c35 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/app_lifecycle_listener/app_lifecycle_listener.1.dart @@ -0,0 +1,108 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:ui'; + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +/// Flutter code sample for [AppLifecycleListener]. + +void main() { + runApp(const AppLifecycleListenerExample()); +} + +class AppLifecycleListenerExample extends StatelessWidget { + const AppLifecycleListenerExample({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: Scaffold(body: ApplicationExitControl()), + ); + } +} + +class ApplicationExitControl extends StatefulWidget { + const ApplicationExitControl({super.key}); + + @override + State createState() => _ApplicationExitControlState(); +} + +class _ApplicationExitControlState extends State { + late final AppLifecycleListener _listener; + bool _shouldExit = false; + String _lastExitResponse = 'No exit requested yet'; + + @override + void initState() { + super.initState(); + _listener = AppLifecycleListener( + onExitRequested: _handleExitRequest, + ); + } + + @override + void dispose() { + _listener.dispose(); + super.dispose(); + } + + Future _quit() async { + final AppExitType exitType = _shouldExit ? AppExitType.required : AppExitType.cancelable; + await ServicesBinding.instance.exitApplication(exitType); + } + + Future _handleExitRequest() async { + final AppExitResponse response = _shouldExit ? AppExitResponse.exit : AppExitResponse.cancel; + setState(() { + _lastExitResponse = 'App responded ${response.name} to exit request'; + }); + return response; + } + + void _radioChanged(bool? value) { + value ??= true; + if (_shouldExit == value) { + return; + } + setState(() { + _shouldExit = value!; + }); + } + + @override + Widget build(BuildContext context) { + return Center( + child: SizedBox( + width: 300, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + RadioListTile( + title: const Text('Do Not Allow Exit'), + groupValue: _shouldExit, + value: false, + onChanged: _radioChanged, + ), + RadioListTile( + title: const Text('Allow Exit'), + groupValue: _shouldExit, + value: true, + onChanged: _radioChanged, + ), + const SizedBox(height: 30), + ElevatedButton( + onPressed: _quit, + child: const Text('Quit'), + ), + const SizedBox(height: 30), + Text('Exit Request: $_lastExitResponse'), + ], + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/async/future_builder.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/async/future_builder.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..5684432725b77e52ffdc41bd51adc008b09cda5c --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/async/future_builder.0.dart @@ -0,0 +1,91 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [FutureBuilder]. + +void main() => runApp(const FutureBuilderExampleApp()); + +class FutureBuilderExampleApp extends StatelessWidget { + const FutureBuilderExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: FutureBuilderExample(), + ); + } +} + +class FutureBuilderExample extends StatefulWidget { + const FutureBuilderExample({super.key}); + + @override + State createState() => _FutureBuilderExampleState(); +} + +class _FutureBuilderExampleState extends State { + final Future _calculation = Future.delayed( + const Duration(seconds: 2), + () => 'Data Loaded', + ); + + @override + Widget build(BuildContext context) { + return DefaultTextStyle( + style: Theme.of(context).textTheme.displayMedium!, + textAlign: TextAlign.center, + child: FutureBuilder( + future: _calculation, // a previously-obtained Future or null + builder: (BuildContext context, AsyncSnapshot snapshot) { + List children; + if (snapshot.hasData) { + children = [ + const Icon( + Icons.check_circle_outline, + color: Colors.green, + size: 60, + ), + Padding( + padding: const EdgeInsets.only(top: 16), + child: Text('Result: ${snapshot.data}'), + ), + ]; + } else if (snapshot.hasError) { + children = [ + const Icon( + Icons.error_outline, + color: Colors.red, + size: 60, + ), + Padding( + padding: const EdgeInsets.only(top: 16), + child: Text('Error: ${snapshot.error}'), + ), + ]; + } else { + children = const [ + SizedBox( + width: 60, + height: 60, + child: CircularProgressIndicator(), + ), + Padding( + padding: EdgeInsets.only(top: 16), + child: Text('Awaiting result...'), + ), + ]; + } + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: children, + ), + ); + }, + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/async/stream_builder.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/async/stream_builder.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..552763aaaf6d9c50354732c9943f2b05474af6e2 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/async/stream_builder.0.dart @@ -0,0 +1,135 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [StreamBuilder]. + +void main() => runApp(const StreamBuilderExampleApp()); + +class StreamBuilderExampleApp extends StatelessWidget { + const StreamBuilderExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: StreamBuilderExample(), + ); + } +} + +class StreamBuilderExample extends StatefulWidget { + const StreamBuilderExample({super.key}); + + @override + State createState() => _StreamBuilderExampleState(); +} + +class _StreamBuilderExampleState extends State { + final Stream _bids = (() { + late final StreamController controller; + controller = StreamController( + onListen: () async { + await Future.delayed(const Duration(seconds: 1)); + controller.add(1); + await Future.delayed(const Duration(seconds: 1)); + await controller.close(); + }, + ); + return controller.stream; + })(); + + @override + Widget build(BuildContext context) { + return DefaultTextStyle( + style: Theme.of(context).textTheme.displayMedium!, + textAlign: TextAlign.center, + child: Container( + alignment: FractionalOffset.center, + color: Colors.white, + child: StreamBuilder( + stream: _bids, + builder: (BuildContext context, AsyncSnapshot snapshot) { + List children; + if (snapshot.hasError) { + children = [ + const Icon( + Icons.error_outline, + color: Colors.red, + size: 60, + ), + Padding( + padding: const EdgeInsets.only(top: 16), + child: Text('Error: ${snapshot.error}'), + ), + Padding( + padding: const EdgeInsets.only(top: 8), + child: Text('Stack trace: ${snapshot.stackTrace}'), + ), + ]; + } else { + switch (snapshot.connectionState) { + case ConnectionState.none: + children = const [ + Icon( + Icons.info, + color: Colors.blue, + size: 60, + ), + Padding( + padding: EdgeInsets.only(top: 16), + child: Text('Select a lot'), + ), + ]; + case ConnectionState.waiting: + children = const [ + SizedBox( + width: 60, + height: 60, + child: CircularProgressIndicator(), + ), + Padding( + padding: EdgeInsets.only(top: 16), + child: Text('Awaiting bids...'), + ), + ]; + case ConnectionState.active: + children = [ + const Icon( + Icons.check_circle_outline, + color: Colors.green, + size: 60, + ), + Padding( + padding: const EdgeInsets.only(top: 16), + child: Text('\$${snapshot.data}'), + ), + ]; + case ConnectionState.done: + children = [ + const Icon( + Icons.info, + color: Colors.blue, + size: 60, + ), + Padding( + padding: const EdgeInsets.only(top: 16), + child: Text('\$${snapshot.data} (closed)'), + ), + ]; + } + } + + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: children, + ); + }, + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/autocomplete/raw_autocomplete.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/autocomplete/raw_autocomplete.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..1cf37060a13747bbd5dd4a59e35b406f621c1de4 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/autocomplete/raw_autocomplete.0.dart @@ -0,0 +1,92 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [RawAutocomplete]. + +void main() => runApp(const AutocompleteExampleApp()); + +class AutocompleteExampleApp extends StatelessWidget { + const AutocompleteExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('RawAutocomplete Basic'), + ), + body: const Center( + child: AutocompleteBasicExample(), + ), + ), + ); + } +} + +class AutocompleteBasicExample extends StatelessWidget { + const AutocompleteBasicExample({super.key}); + + static const List _options = [ + 'aardvark', + 'bobcat', + 'chameleon', + ]; + + @override + Widget build(BuildContext context) { + return RawAutocomplete( + optionsBuilder: (TextEditingValue textEditingValue) { + return _options.where((String option) { + return option.contains(textEditingValue.text.toLowerCase()); + }); + }, + fieldViewBuilder: ( + BuildContext context, + TextEditingController textEditingController, + FocusNode focusNode, + VoidCallback onFieldSubmitted, + ) { + return TextFormField( + controller: textEditingController, + focusNode: focusNode, + onFieldSubmitted: (String value) { + onFieldSubmitted(); + }, + ); + }, + optionsViewBuilder: ( + BuildContext context, + AutocompleteOnSelected onSelected, + Iterable options, + ) { + return Align( + alignment: Alignment.topLeft, + child: Material( + elevation: 4.0, + child: SizedBox( + height: 200.0, + child: ListView.builder( + padding: const EdgeInsets.all(8.0), + itemCount: options.length, + itemBuilder: (BuildContext context, int index) { + final String option = options.elementAt(index); + return GestureDetector( + onTap: () { + onSelected(option); + }, + child: ListTile( + title: Text(option), + ), + ); + }, + ), + ), + ), + ); + }, + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/autocomplete/raw_autocomplete.1.dart b/novelforge-project/flutter/examples/api/lib/widgets/autocomplete/raw_autocomplete.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..2d6a68691b9990363b5295db7fe52878695cef6b --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/autocomplete/raw_autocomplete.1.dart @@ -0,0 +1,121 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [RawAutocomplete]. + +void main() => runApp(const AutocompleteExampleApp()); + +class AutocompleteExampleApp extends StatelessWidget { + const AutocompleteExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('RawAutocomplete Custom Type'), + ), + body: const Center( + child: AutocompleteCustomTypeExample(), + ), + ), + ); + } +} + +// An example of a type that someone might want to autocomplete a list of. +@immutable +class User { + const User({ + required this.email, + required this.name, + }); + + final String email; + final String name; + + @override + String toString() { + return '$name, $email'; + } + + @override + bool operator ==(Object other) { + if (other.runtimeType != runtimeType) { + return false; + } + return other is User && other.name == name && other.email == email; + } + + @override + int get hashCode => Object.hash(email, name); +} + +class AutocompleteCustomTypeExample extends StatelessWidget { + const AutocompleteCustomTypeExample({super.key}); + + static const List _userOptions = [ + User(name: 'Alice', email: 'alice@example.com'), + User(name: 'Bob', email: 'bob@example.com'), + User(name: 'Charlie', email: 'charlie123@gmail.com'), + ]; + + static String _displayStringForOption(User option) => option.name; + + @override + Widget build(BuildContext context) { + return RawAutocomplete( + optionsBuilder: (TextEditingValue textEditingValue) { + return _userOptions.where((User option) { + // Search based on User.toString, which includes both name and + // email, even though the display string is just the name. + return option.toString().contains(textEditingValue.text.toLowerCase()); + }); + }, + displayStringForOption: _displayStringForOption, + fieldViewBuilder: ( + BuildContext context, + TextEditingController textEditingController, + FocusNode focusNode, + VoidCallback onFieldSubmitted, + ) { + return TextFormField( + controller: textEditingController, + focusNode: focusNode, + onFieldSubmitted: (String value) { + onFieldSubmitted(); + }, + ); + }, + optionsViewBuilder: (BuildContext context, AutocompleteOnSelected onSelected, Iterable options) { + return Align( + alignment: Alignment.topLeft, + child: Material( + elevation: 4.0, + child: SizedBox( + height: 200.0, + child: ListView.builder( + padding: const EdgeInsets.all(8.0), + itemCount: options.length, + itemBuilder: (BuildContext context, int index) { + final User option = options.elementAt(index); + return GestureDetector( + onTap: () { + onSelected(option); + }, + child: ListTile( + title: Text(_displayStringForOption(option)), + ), + ); + }, + ), + ), + ), + ); + }, + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/autocomplete/raw_autocomplete.2.dart b/novelforge-project/flutter/examples/api/lib/widgets/autocomplete/raw_autocomplete.2.dart new file mode 100644 index 0000000000000000000000000000000000000000..8d64360d5a22585c9ee36dbf0ce0dca7c28070f8 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/autocomplete/raw_autocomplete.2.dart @@ -0,0 +1,193 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [RawAutocomplete]. + +void main() => runApp(const AutocompleteExampleApp()); + +class AutocompleteExampleApp extends StatelessWidget { + const AutocompleteExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('RawAutocomplete Form'), + ), + body: const Center( + child: AutocompleteFormExample(), + ), + ), + ); + } +} + +class AutocompleteFormExample extends StatefulWidget { + const AutocompleteFormExample({super.key}); + + @override + AutocompleteFormExampleState createState() => AutocompleteFormExampleState(); +} + +class AutocompleteFormExampleState extends State { + final GlobalKey _formKey = GlobalKey(); + final TextEditingController _textEditingController = TextEditingController(); + String? _dropdownValue; + String? _autocompleteSelection; + + static const List _options = [ + 'aardvark', + 'bobcat', + 'chameleon', + ]; + + @override + Widget build(BuildContext context) { + return Form( + key: _formKey, + child: Column( + children: [ + DropdownButtonFormField( + value: _dropdownValue, + icon: const Icon(Icons.arrow_downward), + hint: const Text('This is a regular DropdownButtonFormField'), + elevation: 16, + style: const TextStyle(color: Colors.deepPurple), + onChanged: (String? newValue) { + setState(() { + _dropdownValue = newValue; + }); + }, + items: ['One', 'Two', 'Free', 'Four'].map>((String value) { + return DropdownMenuItem( + value: value, + child: Text(value), + ); + }).toList(), + validator: (String? value) { + if (value == null) { + return 'Must make a selection.'; + } + return null; + }, + ), + TextFormField( + controller: _textEditingController, + decoration: const InputDecoration( + hintText: 'This is a regular TextFormField', + ), + validator: (String? value) { + if (value == null || value.isEmpty) { + return "Can't be empty."; + } + return null; + }, + ), + RawAutocomplete( + optionsBuilder: (TextEditingValue textEditingValue) { + return _options.where((String option) { + return option.contains(textEditingValue.text.toLowerCase()); + }); + }, + onSelected: (String selection) { + setState(() { + _autocompleteSelection = selection; + }); + }, + fieldViewBuilder: ( + BuildContext context, + TextEditingController textEditingController, + FocusNode focusNode, + VoidCallback onFieldSubmitted, + ) { + return TextFormField( + controller: textEditingController, + decoration: const InputDecoration( + hintText: 'This is a RawAutocomplete!', + ), + focusNode: focusNode, + onFieldSubmitted: (String value) { + onFieldSubmitted(); + }, + validator: (String? value) { + if (!_options.contains(value)) { + return 'Nothing selected.'; + } + return null; + }, + ); + }, + optionsViewBuilder: ( + BuildContext context, + AutocompleteOnSelected onSelected, + Iterable options, + ) { + return Align( + alignment: Alignment.topLeft, + child: Material( + elevation: 4.0, + child: SizedBox( + height: 200.0, + child: ListView.builder( + padding: const EdgeInsets.all(8.0), + itemCount: options.length, + itemBuilder: (BuildContext context, int index) { + final String option = options.elementAt(index); + return GestureDetector( + onTap: () { + onSelected(option); + }, + child: ListTile( + title: Text(option), + ), + ); + }, + ), + ), + ), + ); + }, + ), + ElevatedButton( + onPressed: () { + FocusScope.of(context).unfocus(); + if (!_formKey.currentState!.validate()) { + return; + } + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Successfully submitted'), + content: SingleChildScrollView( + child: ListBody( + children: [ + Text('DropdownButtonFormField: "$_dropdownValue"'), + Text('TextFormField: "${_textEditingController.text}"'), + Text('RawAutocomplete: "$_autocompleteSelection"'), + ], + ), + ), + actions: [ + TextButton( + child: const Text('Ok'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + }, + child: const Text('Submit'), + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/autocomplete/raw_autocomplete.focus_node.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/autocomplete/raw_autocomplete.focus_node.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..c8d5d27cc051c9f6e291bfa9a67058bb3b131602 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/autocomplete/raw_autocomplete.focus_node.0.dart @@ -0,0 +1,92 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [RawAutocomplete.focusNode]. + +void main() => runApp(const AutocompleteExampleApp()); + +class AutocompleteExampleApp extends StatelessWidget { + const AutocompleteExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: RawAutocompleteSplit(), + ); + } +} + +const List _options = [ + 'aardvark', + 'bobcat', + 'chameleon', +]; + +class RawAutocompleteSplit extends StatefulWidget { + const RawAutocompleteSplit({super.key}); + + @override + RawAutocompleteSplitState createState() => RawAutocompleteSplitState(); +} + +class RawAutocompleteSplitState extends State { + final TextEditingController _textEditingController = TextEditingController(); + final FocusNode _focusNode = FocusNode(); + final GlobalKey _autocompleteKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + // This is where the real field is being built. + title: TextFormField( + controller: _textEditingController, + focusNode: _focusNode, + decoration: const InputDecoration( + hintText: 'Split RawAutocomplete App', + ), + onFieldSubmitted: (String value) { + RawAutocomplete.onFieldSubmitted(_autocompleteKey); + }, + ), + ), + body: Align( + alignment: Alignment.topLeft, + child: RawAutocomplete( + key: _autocompleteKey, + focusNode: _focusNode, + textEditingController: _textEditingController, + optionsBuilder: (TextEditingValue textEditingValue) { + return _options.where((String option) { + return option.contains(textEditingValue.text.toLowerCase()); + }).toList(); + }, + optionsViewBuilder: ( + BuildContext context, + AutocompleteOnSelected onSelected, + Iterable options, + ) { + return Material( + elevation: 4.0, + child: ListView( + children: options + .map((String option) => GestureDetector( + onTap: () { + onSelected(option); + }, + child: ListTile( + title: Text(option), + ), + )) + .toList(), + ), + ); + }, + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/autofill/autofill_group.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/autofill/autofill_group.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..3b0c397c3b03ffd40a17e031d6015f9b34eacd46 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/autofill/autofill_group.0.dart @@ -0,0 +1,125 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [AutofillGroup]. + +void main() => runApp(const AutofillGroupExampleApp()); + +class AutofillGroupExampleApp extends StatelessWidget { + const AutofillGroupExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('AutofillGroup Sample')), + body: const AutofillGroupExample(), + ), + ); + } +} + +class AutofillGroupExample extends StatefulWidget { + const AutofillGroupExample({super.key}); + + @override + State createState() => _AutofillGroupExampleState(); +} + +class _AutofillGroupExampleState extends State { + bool isSameAddress = true; + final TextEditingController shippingAddress1 = TextEditingController(); + final TextEditingController shippingAddress2 = TextEditingController(); + final TextEditingController billingAddress1 = TextEditingController(); + final TextEditingController billingAddress2 = TextEditingController(); + + final TextEditingController creditCardNumber = TextEditingController(); + final TextEditingController creditCardSecurityCode = TextEditingController(); + + final TextEditingController phoneNumber = TextEditingController(); + + @override + Widget build(BuildContext context) { + return ListView( + children: [ + const Text('Shipping address'), + // The address fields are grouped together as some platforms are + // capable of autofilling all of these fields in one go. + AutofillGroup( + child: Column( + children: [ + TextField( + controller: shippingAddress1, + autofillHints: const [AutofillHints.streetAddressLine1], + ), + TextField( + controller: shippingAddress2, + autofillHints: const [AutofillHints.streetAddressLine2], + ), + ], + ), + ), + const Text('Billing address'), + Checkbox( + value: isSameAddress, + onChanged: (bool? newValue) { + if (newValue != null) { + setState(() { + isSameAddress = newValue; + }); + } + }, + ), + // Again the address fields are grouped together for the same reason. + if (!isSameAddress) + AutofillGroup( + child: Column( + children: [ + TextField( + controller: billingAddress1, + autofillHints: const [ + AutofillHints.streetAddressLine1, + ], + ), + TextField( + controller: billingAddress2, + autofillHints: const [ + AutofillHints.streetAddressLine2, + ], + ), + ], + ), + ), + const Text('Credit Card Information'), + // The credit card number and the security code are grouped together + // as some platforms are capable of autofilling both fields. + AutofillGroup( + child: Column( + children: [ + TextField( + controller: creditCardNumber, + autofillHints: const [AutofillHints.creditCardNumber], + ), + TextField( + controller: creditCardSecurityCode, + autofillHints: const [ + AutofillHints.creditCardSecurityCode, + ], + ), + ], + ), + ), + const Text('Contact Phone Number'), + // The phone number field can still be autofilled despite lacking an + // `AutofillScope`. + TextField( + controller: phoneNumber, + autofillHints: const [AutofillHints.telephoneNumber], + ), + ], + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/basic/absorb_pointer.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/basic/absorb_pointer.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..d18c36bd877f46976e420ae9554b1cfcd8df73c7 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/basic/absorb_pointer.0.dart @@ -0,0 +1,59 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [AbsorbPointer]. + +void main() => runApp(const AbsorbPointerApp()); + +class AbsorbPointerApp extends StatelessWidget { + const AbsorbPointerApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('AbsorbPointer Sample')), + body: const Center( + child: AbsorbPointerExample(), + ), + ), + ); + } +} + +class AbsorbPointerExample extends StatelessWidget { + const AbsorbPointerExample({super.key}); + + @override + Widget build(BuildContext context) { + return Stack( + alignment: AlignmentDirectional.center, + children: [ + SizedBox( + width: 200.0, + height: 100.0, + child: ElevatedButton( + onPressed: () {}, + child: null, + ), + ), + SizedBox( + width: 100.0, + height: 200.0, + child: AbsorbPointer( + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.blue.shade200, + ), + onPressed: () {}, + child: null, + ), + ), + ), + ], + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/basic/aspect_ratio.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/basic/aspect_ratio.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..4c4e56a51ae62f8323d7cf8c7390794129740f8f --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/basic/aspect_ratio.0.dart @@ -0,0 +1,43 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [AspectRatio]. + +void main() => runApp(const AspectRatioApp()); + +class AspectRatioApp extends StatelessWidget { + const AspectRatioApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('AspectRatio Sample')), + body: const AspectRatioExample(), + ), + ); + } +} + +class AspectRatioExample extends StatelessWidget { + const AspectRatioExample({super.key}); + + @override + Widget build(BuildContext context) { + return Container( + color: Colors.blue, + alignment: Alignment.center, + width: double.infinity, + height: 100.0, + child: AspectRatio( + aspectRatio: 16 / 9, + child: Container( + color: Colors.green, + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/basic/aspect_ratio.1.dart b/novelforge-project/flutter/examples/api/lib/widgets/basic/aspect_ratio.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..a7c823edc1d805eb3f7a1774c37807d78efd1e9c --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/basic/aspect_ratio.1.dart @@ -0,0 +1,45 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [AspectRatio]. + +void main() => runApp(const AspectRatioApp()); + +class AspectRatioApp extends StatelessWidget { + const AspectRatioApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('AspectRatio Sample')), + body: const AspectRatioExample(), + ), + ); + } +} + +class AspectRatioExample extends StatelessWidget { + const AspectRatioExample({super.key}); + + @override + Widget build(BuildContext context) { + return Container( + color: Colors.blue, + alignment: Alignment.center, + width: 100.0, + height: 100.0, + child: AspectRatio( + aspectRatio: 2.0, + child: Container( + width: 100.0, + height: 50.0, + color: Colors.green, + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/basic/aspect_ratio.2.dart b/novelforge-project/flutter/examples/api/lib/widgets/basic/aspect_ratio.2.dart new file mode 100644 index 0000000000000000000000000000000000000000..23ec8e6d2607b9f481aed4a52b5344392bc19165 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/basic/aspect_ratio.2.dart @@ -0,0 +1,45 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [AspectRatio]. + +void main() => runApp(const AspectRatioApp()); + +class AspectRatioApp extends StatelessWidget { + const AspectRatioApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('AspectRatio Sample')), + body: const AspectRatioExample(), + ), + ); + } +} + +class AspectRatioExample extends StatelessWidget { + const AspectRatioExample({super.key}); + + @override + Widget build(BuildContext context) { + return Container( + color: Colors.blue, + alignment: Alignment.center, + width: 100.0, + height: 100.0, + child: AspectRatio( + aspectRatio: 0.5, + child: Container( + width: 100.0, + height: 50.0, + color: Colors.green, + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/basic/clip_rrect.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/basic/clip_rrect.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..da55a5d9410d96c3b92c158e6fc15750977abcd6 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/basic/clip_rrect.0.dart @@ -0,0 +1,78 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [ClipRRect]. + +void main() => runApp(const ClipRRectApp()); + +class ClipRRectApp extends StatelessWidget { + const ClipRRectApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('ClipRRect Sample')), + body: const ClipRRectExample(), + ), + ); + } +} + +class ClipRRectExample extends StatelessWidget { + const ClipRRectExample({super.key}); + + @override + Widget build(BuildContext context) { + const TextStyle style = TextStyle(color: Colors.white); + + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Container( + alignment: Alignment.center, + constraints: const BoxConstraints( + maxWidth: 300, + maxHeight: 100, + ), + color: Colors.blue, + child: const Text('No ClipRRect', style: style), + ), + ClipRRect( + borderRadius: BorderRadius.circular(30.0), + child: Container( + alignment: Alignment.center, + constraints: const BoxConstraints( + maxWidth: 300, + maxHeight: 100, + ), + color: Colors.green, + child: const Text('ClipRRect', style: style), + ), + ), + ClipRRect( + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(10.0), + topRight: Radius.circular(20.0), + bottomRight: Radius.circular(30.0), + bottomLeft: Radius.circular(40.0), + ), + child: Container( + alignment: Alignment.center, + constraints: const BoxConstraints( + maxWidth: 300, + maxHeight: 100, + ), + color: Colors.purple, + child: const Text('ClipRRect', style: style), + ), + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/basic/clip_rrect.1.dart b/novelforge-project/flutter/examples/api/lib/widgets/basic/clip_rrect.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..686115a8d87e42602311dd14f6043f7c99cff6a2 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/basic/clip_rrect.1.dart @@ -0,0 +1,63 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [ClipRRect]. + +void main() => runApp(const ClipRRectApp()); + +class ClipRRectApp extends StatelessWidget { + const ClipRRectApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('ClipRRect Sample')), + body: const ClipRRectExample(), + ), + ); + } +} + +class ClipRRectExample extends StatelessWidget { + const ClipRRectExample({super.key}); + + @override + Widget build(BuildContext context) { + return Container( + padding: const EdgeInsets.all(40.0), + constraints: const BoxConstraints.expand(), + // Add a FittedBox to make ClipRRect sized accordingly to the image it contains + child: FittedBox( + child: ClipRRect( + borderRadius: BorderRadius.circular(40.0), + child: const _FakedImage(), + ), + ), + ); + } +} + +// A widget exposing the FlutterLogo as a 400x400 image. +// +// It can be replaced by a NetworkImage if internet connection is available, e.g. : +// const Image( +// image: NetworkImage( +// 'https://flutter.github.io/assets-for-api-docs/assets/widgets/owl.jpg'), +// ); +class _FakedImage extends StatelessWidget { + const _FakedImage(); + + @override + Widget build(BuildContext context) { + return Container( + // Set constraints as if it were a 400x400 image + constraints: BoxConstraints.tight(const Size(400, 400)), + color: Colors.blueGrey, + child: const FlutterLogo(), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/basic/custom_multi_child_layout.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/basic/custom_multi_child_layout.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..800e8330ef1993fe182d53b09b7780d3efcdb0ed --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/basic/custom_multi_child_layout.0.dart @@ -0,0 +1,120 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [CustomMultiChildLayout]. + +void main() => runApp(const CustomMultiChildLayoutApp()); + +class CustomMultiChildLayoutApp extends StatelessWidget { + const CustomMultiChildLayoutApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: Directionality( + // TRY THIS: Try changing the direction here and hot-reloading to + // see the layout change. + textDirection: TextDirection.ltr, + child: Scaffold( + body: CustomMultiChildLayoutExample(), + ), + ), + ); + } +} + +/// Lays out the children in a cascade, where the top corner of the next child +/// is a little above (`overlap`) the lower end corner of the previous child. +/// +/// Will relayout if the text direction changes. +class _CascadeLayoutDelegate extends MultiChildLayoutDelegate { + _CascadeLayoutDelegate({ + required this.colors, + required this.overlap, + required this.textDirection, + }); + + final Map colors; + final double overlap; + final TextDirection textDirection; + + // Perform layout will be called when re-layout is needed. + @override + void performLayout(Size size) { + final double columnWidth = size.width / colors.length; + Offset childPosition = Offset.zero; + switch (textDirection) { + case TextDirection.rtl: + childPosition += Offset(size.width, 0); + case TextDirection.ltr: + break; + } + for (final String color in colors.keys) { + // layoutChild must be called exactly once for each child. + final Size currentSize = layoutChild( + color, + BoxConstraints(maxHeight: size.height, maxWidth: columnWidth), + ); + // positionChild must be called to change the position of a child from + // what it was in the previous layout. Each child starts at (0, 0) for the + // first layout. + switch (textDirection) { + case TextDirection.rtl: + positionChild(color, childPosition - Offset(currentSize.width, 0)); + childPosition += Offset(-currentSize.width, currentSize.height - overlap); + case TextDirection.ltr: + positionChild(color, childPosition); + childPosition += Offset(currentSize.width, currentSize.height - overlap); + } + } + } + + // shouldRelayout is called to see if the delegate has changed and requires a + // layout to occur. Should only return true if the delegate state itself + // changes: changes in the CustomMultiChildLayout attributes will + // automatically cause a relayout, like any other widget. + @override + bool shouldRelayout(_CascadeLayoutDelegate oldDelegate) { + return oldDelegate.textDirection != textDirection || oldDelegate.overlap != overlap; + } +} + +class CustomMultiChildLayoutExample extends StatelessWidget { + const CustomMultiChildLayoutExample({super.key}); + + static const Map _colors = { + 'Red': Colors.red, + 'Green': Colors.green, + 'Blue': Colors.blue, + 'Cyan': Colors.cyan, + }; + + @override + Widget build(BuildContext context) { + return CustomMultiChildLayout( + delegate: _CascadeLayoutDelegate( + colors: _colors, + overlap: 30.0, + textDirection: Directionality.of(context), + ), + children: [ + // Create all of the colored boxes in the colors map. + for (final MapEntry entry in _colors.entries) + // The "id" can be any Object, not just a String. + LayoutId( + id: entry.key, + child: Container( + color: entry.value, + width: 100.0, + height: 100.0, + alignment: Alignment.center, + child: Text(entry.key), + ), + ), + ], + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/basic/expanded.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/basic/expanded.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..e705d4b325df41ef790afd835d9721700ad11675 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/basic/expanded.0.dart @@ -0,0 +1,55 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Expanded]. + +void main() => runApp(const ExpandedApp()); + +class ExpandedApp extends StatelessWidget { + const ExpandedApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Expanded Column Sample'), + ), + body: const ExpandedExample(), + ), + ); + } +} + +class ExpandedExample extends StatelessWidget { + const ExpandedExample({super.key}); + + @override + Widget build(BuildContext context) { + return Center( + child: Column( + children: [ + Container( + color: Colors.blue, + height: 100, + width: 100, + ), + Expanded( + child: Container( + color: Colors.amber, + width: 100, + ), + ), + Container( + color: Colors.blue, + height: 100, + width: 100, + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/basic/expanded.1.dart b/novelforge-project/flutter/examples/api/lib/widgets/basic/expanded.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..ed0dbececabbea4c0661aaeb3c6760310b12ab89 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/basic/expanded.1.dart @@ -0,0 +1,57 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Expanded]. + +void main() => runApp(const ExpandedApp()); + +class ExpandedApp extends StatelessWidget { + const ExpandedApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Expanded Row Sample'), + ), + body: const ExpandedExample(), + ), + ); + } +} + +class ExpandedExample extends StatelessWidget { + const ExpandedExample({super.key}); + + @override + Widget build(BuildContext context) { + return Center( + child: Row( + children: [ + Expanded( + flex: 2, + child: Container( + color: Colors.amber, + height: 100, + ), + ), + Container( + color: Colors.blue, + height: 100, + width: 50, + ), + Expanded( + child: Container( + color: Colors.amber, + height: 100, + ), + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/basic/fitted_box.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/basic/fitted_box.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..364de3a988def4e5f873404ad2afbd2acaecf8e0 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/basic/fitted_box.0.dart @@ -0,0 +1,44 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [FittedBox]. + +void main() => runApp(const FittedBoxApp()); + +class FittedBoxApp extends StatelessWidget { + const FittedBoxApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('FittedBox Sample')), + body: const Center( + child: FittedBoxExample(), + ), + ), + ); + } +} + +class FittedBoxExample extends StatelessWidget { + const FittedBoxExample({super.key}); + + @override + Widget build(BuildContext context) { + return Container( + height: 400, + width: 300, + color: Colors.blue, + child: const FittedBox( + // TRY THIS: Try changing the fit types to see how they change the way + // the placeholder fits into the container. + fit: BoxFit.fill, + child: Placeholder(), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/basic/flow.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/basic/flow.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..8a7c600ac62bedd631bbb95d6043b4d5125ed2a4 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/basic/flow.0.dart @@ -0,0 +1,116 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Flow]. + +void main() => runApp(const FlowApp()); + +class FlowApp extends StatelessWidget { + const FlowApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Flow Example'), + ), + body: const FlowMenu(), + ), + ); + } +} + +class FlowMenu extends StatefulWidget { + const FlowMenu({super.key}); + + @override + State createState() => _FlowMenuState(); +} + +class _FlowMenuState extends State with SingleTickerProviderStateMixin { + late AnimationController menuAnimation; + IconData lastTapped = Icons.notifications; + final List menuItems = [ + Icons.home, + Icons.new_releases, + Icons.notifications, + Icons.settings, + Icons.menu, + ]; + + void _updateMenu(IconData icon) { + if (icon != Icons.menu) { + setState(() => lastTapped = icon); + } + } + + @override + void initState() { + super.initState(); + menuAnimation = AnimationController( + duration: const Duration(milliseconds: 250), + vsync: this, + ); + } + + Widget flowMenuItem(IconData icon) { + final double buttonDiameter = MediaQuery.of(context).size.width / menuItems.length; + return Padding( + padding: const EdgeInsets.symmetric(vertical: 8.0), + child: RawMaterialButton( + fillColor: lastTapped == icon ? Colors.amber[700] : Colors.blue, + splashColor: Colors.amber[100], + shape: const CircleBorder(), + constraints: BoxConstraints.tight(Size(buttonDiameter, buttonDiameter)), + onPressed: () { + _updateMenu(icon); + menuAnimation.status == AnimationStatus.completed ? menuAnimation.reverse() : menuAnimation.forward(); + }, + child: Icon( + icon, + color: Colors.white, + size: 45.0, + ), + ), + ); + } + + @override + Widget build(BuildContext context) { + return Flow( + delegate: FlowMenuDelegate(menuAnimation: menuAnimation), + children: menuItems.map((IconData icon) => flowMenuItem(icon)).toList(), + ); + } +} + +class FlowMenuDelegate extends FlowDelegate { + FlowMenuDelegate({required this.menuAnimation}) : super(repaint: menuAnimation); + + final Animation menuAnimation; + + @override + bool shouldRepaint(FlowMenuDelegate oldDelegate) { + return menuAnimation != oldDelegate.menuAnimation; + } + + @override + void paintChildren(FlowPaintingContext context) { + double dx = 0.0; + for (int i = 0; i < context.childCount; ++i) { + dx = context.getChildSize(i)!.width * i; + context.paintChild( + i, + transform: Matrix4.translationValues( + dx * menuAnimation.value, + 0, + 0, + ), + ); + } + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/basic/fractionally_sized_box.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/basic/fractionally_sized_box.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..34e357fd31d24d2569b6bc2c876a3ec170aaf0da --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/basic/fractionally_sized_box.0.dart @@ -0,0 +1,46 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [FractionallySizedBox]. + +void main() => runApp(const FractionallySizedBoxApp()); + +class FractionallySizedBoxApp extends StatelessWidget { + const FractionallySizedBoxApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('FractionallySizedBox Sample')), + body: const FractionallySizedBoxExample(), + ), + ); + } +} + +class FractionallySizedBoxExample extends StatelessWidget { + const FractionallySizedBoxExample({super.key}); + + @override + Widget build(BuildContext context) { + return SizedBox.expand( + child: FractionallySizedBox( + widthFactor: 0.5, + heightFactor: 0.5, + alignment: FractionalOffset.center, + child: DecoratedBox( + decoration: BoxDecoration( + border: Border.all( + color: Colors.blue, + width: 4, + ), + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/basic/ignore_pointer.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/basic/ignore_pointer.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..5c9b2c3db68a1e050b77e2186985cec8d4109713 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/basic/ignore_pointer.0.dart @@ -0,0 +1,70 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [IgnorePointer]. + +void main() => runApp(const IgnorePointerApp()); + +class IgnorePointerApp extends StatelessWidget { + const IgnorePointerApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + centerTitle: true, + title: const Text('IgnorePointer Sample'), + ), + body: const Center(child: IgnorePointerExample()), + ), + ); + } +} + +class IgnorePointerExample extends StatefulWidget { + const IgnorePointerExample({super.key}); + + @override + State createState() => _IgnorePointerExampleState(); +} + +class _IgnorePointerExampleState extends State { + bool ignoring = false; + void setIgnoring(bool newValue) { + setState(() { + ignoring = newValue; + }); + } + + @override + Widget build(BuildContext context) { + return Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Text('Ignoring: $ignoring'), + IgnorePointer( + ignoring: ignoring, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + padding: const EdgeInsets.all(24.0), + ), + onPressed: () {}, + child: const Text('Click me!'), + ), + ), + FilledButton( + onPressed: () { + setIgnoring(!ignoring); + }, + child: Text( + ignoring ? 'Set ignoring to false' : 'Set ignoring to true', + ), + ), + ], + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/basic/indexed_stack.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/basic/indexed_stack.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..8d19cca4f725f0e96bb03c41480cf03ba5f61cdf --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/basic/indexed_stack.0.dart @@ -0,0 +1,139 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [IndexedStack]. + +void main() => runApp(const IndexedStackApp()); + +class IndexedStackApp extends StatelessWidget { + const IndexedStackApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('IndexedStack Sample')), + body: const IndexedStackExample(), + ), + ); + } +} + +class IndexedStackExample extends StatefulWidget { + const IndexedStackExample({super.key}); + + @override + State createState() => _IndexedStackExampleState(); +} + +class _IndexedStackExampleState extends State { + List names = ['Dash', 'John', 'Mary']; + int index = 0; + final TextEditingController fieldText = TextEditingController(); + + @override + Widget build(BuildContext context) { + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SizedBox( + width: 300, + child: TextField( + decoration: const InputDecoration( + border: OutlineInputBorder(), + hintText: 'Enter the name for a person to track', + ), + onSubmitted: (String value) { + setState(() { + names.add(value); + }); + fieldText.clear(); + }, + controller: fieldText, + ), + ), + const SizedBox(height: 50), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + onTap: () { + setState(() { + if (index == 0) { + index = names.length - 1; + } else { + index -= 1; + } + }); + }, + child: const Icon(Icons.chevron_left, key: Key('gesture1')), + ), + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + IndexedStack( + index: index, + children: [for (final String name in names) PersonTracker(name: name)], + ) + ], + ), + GestureDetector( + onTap: () { + setState(() { + if (index == names.length - 1) { + index = 0; + } else { + index += 1; + } + }); + }, + child: const Icon(Icons.chevron_right, key: Key('gesture2')), + ), + ], + ) + ], + ); + } +} + +class PersonTracker extends StatefulWidget { + const PersonTracker({super.key, required this.name}); + final String name; + @override + State createState() => _PersonTrackerState(); +} + +class _PersonTrackerState extends State { + int counter = 0; + @override + Widget build(BuildContext context) { + return Container( + key: Key(widget.name), + decoration: BoxDecoration( + color: const Color.fromARGB(255, 239, 248, 255), + border: Border.all(color: const Color.fromARGB(255, 54, 60, 244)), + borderRadius: const BorderRadius.all(Radius.circular(10)), + ), + padding: const EdgeInsets.all(16.0), + child: Column( + children: [ + Text('Name: ${widget.name}'), + Text('Score: $counter'), + TextButton.icon( + key: Key('increment${widget.name}'), + icon: const Icon(Icons.add), + onPressed: () { + setState(() { + counter += 1; + }); + }, + label: const Text('Increment'), + ) + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/basic/listener.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/basic/listener.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..1bddd9b875aa36825c6fbc2a689bf5a2bcfdc386 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/basic/listener.0.dart @@ -0,0 +1,88 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Listener]. + +void main() => runApp(const ListenerApp()); + +class ListenerApp extends StatelessWidget { + const ListenerApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('Listener Sample')), + body: const Center( + child: ListenerExample(), + ), + ), + ); + } +} + +class ListenerExample extends StatefulWidget { + const ListenerExample({super.key}); + + @override + State createState() => _ListenerExampleState(); +} + +class _ListenerExampleState extends State { + int _downCounter = 0; + int _upCounter = 0; + double x = 0.0; + double y = 0.0; + + void _incrementDown(PointerEvent details) { + _updateLocation(details); + setState(() { + _downCounter++; + }); + } + + void _incrementUp(PointerEvent details) { + _updateLocation(details); + setState(() { + _upCounter++; + }); + } + + void _updateLocation(PointerEvent details) { + setState(() { + x = details.position.dx; + y = details.position.dy; + }); + } + + @override + Widget build(BuildContext context) { + return ConstrainedBox( + constraints: BoxConstraints.tight(const Size(300.0, 200.0)), + child: Listener( + onPointerDown: _incrementDown, + onPointerMove: _updateLocation, + onPointerUp: _incrementUp, + child: ColoredBox( + color: Colors.lightBlueAccent, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text('You have pressed or released in this area this many times:'), + Text( + '$_downCounter presses\n$_upCounter releases', + style: Theme.of(context).textTheme.headlineMedium, + ), + Text( + 'The cursor is here: (${x.toStringAsFixed(2)}, ${y.toStringAsFixed(2)})', + ), + ], + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/basic/mouse_region.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/basic/mouse_region.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..253eeffc0b7d76ed70a7442a484349da30c0f43b --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/basic/mouse_region.0.dart @@ -0,0 +1,86 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [MouseRegion]. + +void main() => runApp(const MouseRegionApp()); + +class MouseRegionApp extends StatelessWidget { + const MouseRegionApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('MouseRegion Sample')), + body: const Center( + child: MouseRegionExample(), + ), + ), + ); + } +} + +class MouseRegionExample extends StatefulWidget { + const MouseRegionExample({super.key}); + + @override + State createState() => _MouseRegionExampleState(); +} + +class _MouseRegionExampleState extends State { + int _enterCounter = 0; + int _exitCounter = 0; + double x = 0.0; + double y = 0.0; + + void _incrementEnter(PointerEvent details) { + setState(() { + _enterCounter++; + }); + } + + void _incrementExit(PointerEvent details) { + setState(() { + _exitCounter++; + }); + } + + void _updateLocation(PointerEvent details) { + setState(() { + x = details.position.dx; + y = details.position.dy; + }); + } + + @override + Widget build(BuildContext context) { + return ConstrainedBox( + constraints: BoxConstraints.tight(const Size(300.0, 200.0)), + child: MouseRegion( + onEnter: _incrementEnter, + onHover: _updateLocation, + onExit: _incrementExit, + child: ColoredBox( + color: Colors.lightBlueAccent, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text('You have entered or exited this box this many times:'), + Text( + '$_enterCounter Entries\n$_exitCounter Exits', + style: Theme.of(context).textTheme.headlineMedium, + ), + Text( + 'The cursor is here: (${x.toStringAsFixed(2)}, ${y.toStringAsFixed(2)})', + ), + ], + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/basic/mouse_region.on_exit.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/basic/mouse_region.on_exit.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..2ee0b41a1c69da66805368fd67887acf3fd976a9 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/basic/mouse_region.on_exit.0.dart @@ -0,0 +1,57 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [MouseRegion.onExit]. + +void main() => runApp(const MouseRegionApp()); + +class MouseRegionApp extends StatelessWidget { + const MouseRegionApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('MouseRegion.onExit Sample')), + body: const Center( + child: MouseRegionExample(), + ), + ), + ); + } +} + +class MouseRegionExample extends StatefulWidget { + const MouseRegionExample({super.key}); + + @override + State createState() => _MouseRegionExampleState(); +} + +class _MouseRegionExampleState extends State { + bool hovered = false; + + @override + Widget build(BuildContext context) { + return Container( + height: 100, + width: 100, + decoration: BoxDecoration(color: hovered ? Colors.yellow : Colors.blue), + child: MouseRegion( + onEnter: (_) { + setState(() { + hovered = true; + }); + }, + onExit: (_) { + setState(() { + hovered = false; + }); + }, + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/basic/mouse_region.on_exit.1.dart b/novelforge-project/flutter/examples/api/lib/widgets/basic/mouse_region.on_exit.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..4c067817ee50688a40eb435b03791ad5cb5d4d41 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/basic/mouse_region.on_exit.1.dart @@ -0,0 +1,127 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [MouseRegion.onExit]. + +void main() => runApp(const MouseRegionApp()); + +class MouseRegionApp extends StatelessWidget { + const MouseRegionApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('MouseRegion.onExit Sample')), + body: const Center( + child: MouseRegionExample(), + ), + ), + ); + } +} + +// A region that hides its content one second after being hovered. +class MyTimedButton extends StatefulWidget { + const MyTimedButton({super.key, required this.onEnterButton, required this.onExitButton}); + + final VoidCallback onEnterButton; + final VoidCallback onExitButton; + + @override + State createState() => _MyTimedButton(); +} + +class _MyTimedButton extends State { + bool regionIsHidden = false; + bool hovered = false; + + Future startCountdown() async { + await Future.delayed(const Duration(seconds: 1)); + hideButton(); + } + + void hideButton() { + setState(() { + regionIsHidden = true; + }); + // This statement is necessary. + if (hovered) { + widget.onExitButton(); + } + } + + @override + Widget build(BuildContext context) { + return SizedBox( + width: 100, + height: 100, + child: MouseRegion( + child: regionIsHidden + ? null + : MouseRegion( + onEnter: (_) { + widget.onEnterButton(); + setState(() { + hovered = true; + }); + startCountdown(); + }, + onExit: (_) { + setState(() { + hovered = false; + }); + widget.onExitButton(); + }, + child: Container(color: Colors.red), + ), + ), + ); + } +} + +class MouseRegionExample extends StatefulWidget { + const MouseRegionExample({super.key}); + + @override + State createState() => _MouseRegionExampleState(); +} + +class _MouseRegionExampleState extends State { + Key key = UniqueKey(); + bool hovering = false; + + @override + Widget build(BuildContext context) { + return Column( + children: [ + ElevatedButton( + onPressed: () { + setState(() { + key = UniqueKey(); + }); + }, + child: const Text('Refresh'), + ), + if (hovering) const Text('Hovering'), + if (!hovering) const Text('Not hovering'), + MyTimedButton( + key: key, + onEnterButton: () { + setState(() { + hovering = true; + }); + }, + onExitButton: () { + setState(() { + hovering = false; + }); + }, + ), + ], + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/basic/offstage.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/basic/offstage.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..ee9e333d4aad4289767729a2a76b3bdf990c6bd3 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/basic/offstage.0.dart @@ -0,0 +1,77 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Offstage]. + +void main() => runApp(const OffstageApp()); + +class OffstageApp extends StatelessWidget { + const OffstageApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('Offstage Sample')), + body: const Center( + child: OffstageExample(), + ), + ), + ); + } +} + +class OffstageExample extends StatefulWidget { + const OffstageExample({super.key}); + + @override + State createState() => _OffstageExampleState(); +} + +class _OffstageExampleState extends State { + final GlobalKey _key = GlobalKey(); + bool _offstage = true; + + Size _getFlutterLogoSize() { + final RenderBox renderLogo = _key.currentContext!.findRenderObject()! as RenderBox; + return renderLogo.size; + } + + @override + Widget build(BuildContext context) { + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Offstage( + offstage: _offstage, + child: FlutterLogo( + key: _key, + size: 150.0, + ), + ), + Text('Flutter logo is offstage: $_offstage'), + ElevatedButton( + child: const Text('Toggle Offstage Value'), + onPressed: () { + setState(() { + _offstage = !_offstage; + }); + }, + ), + if (_offstage) + ElevatedButton( + child: const Text('Get Flutter Logo size'), + onPressed: () { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text('Flutter Logo size is ${_getFlutterLogoSize()}'), + ), + ); + }), + ], + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/basic/overflowbox.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/basic/overflowbox.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..3d4c7bfbe4e509cf4a64427d5b62cca56cfc55bd --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/basic/overflowbox.0.dart @@ -0,0 +1,57 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [OverflowBox]. + +void main() => runApp(const OverflowBoxApp()); + +class OverflowBoxApp extends StatelessWidget { + const OverflowBoxApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('OverflowBox Sample')), + body: const Center( + child: OverflowBoxExample(), + ), + ), + ); + } +} + +class OverflowBoxExample extends StatelessWidget { + const OverflowBoxExample({super.key}); + + @override + Widget build(BuildContext context) { + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text('Cover Me'), + // This parent container has fixed width and + // height of 100 pixels. + Container( + width: 100, + height: 100, + color: Theme.of(context).colorScheme.secondaryContainer, + // This OverflowBox imposes its own constraints of maxWidth + // and maxHeight of 200 pixels on its child which allows the + // child to overflow the parent container. + child: const OverflowBox( + maxWidth: 200, + maxHeight: 200, + // Without the OverflowBox, the child widget would be + // constrained to the size of the parent container + // and would not overflow the parent container. + child: FlutterLogo(size: 200), + ), + ), + ], + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/basic/physical_shape.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/basic/physical_shape.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..e9ec1433ee3cca1435b985c1ad922186fe5a41f3 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/basic/physical_shape.0.dart @@ -0,0 +1,55 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [PhysicalShape]. + +void main() => runApp(const PhysicalShapeApp()); + +class PhysicalShapeApp extends StatelessWidget { + const PhysicalShapeApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('PhysicalShape Sample'), + ), + body: const Center(child: PhysicalShapeExample()), + ), + ); + } +} + +class PhysicalShapeExample extends StatelessWidget { + const PhysicalShapeExample({super.key}); + + @override + Widget build(BuildContext context) { + return PhysicalShape( + elevation: 5.0, + clipper: ShapeBorderClipper( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10.0), + ), + ), + color: Colors.orange, + child: const SizedBox( + height: 200.0, + width: 200.0, + child: Center( + child: Text( + 'Hello, World!', + style: TextStyle( + color: Colors.white, + fontSize: 20.0, + ), + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/binding/widget_binding_observer.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/binding/widget_binding_observer.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..e7076c22c87a454e0b0ed62ce97157dce05af65c --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/binding/widget_binding_observer.0.dart @@ -0,0 +1,71 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [WidgetBindingsObserver]. + +void main() => runApp(const WidgetBindingObserverExampleApp()); + +class WidgetBindingObserverExampleApp extends StatelessWidget { + const WidgetBindingObserverExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('WidgetBindingsObserver Sample')), + body: const WidgetBindingsObserverSample(), + ), + ); + } +} + +class WidgetBindingsObserverSample extends StatefulWidget { + const WidgetBindingsObserverSample({super.key}); + + @override + State createState() => _WidgetBindingsObserverSampleState(); +} + +class _WidgetBindingsObserverSampleState extends State with WidgetsBindingObserver { + final List _stateHistoryList = []; + + @override + void initState() { + super.initState(); + WidgetsBinding.instance.addObserver(this); + if (WidgetsBinding.instance.lifecycleState != null) { + _stateHistoryList.add(WidgetsBinding.instance.lifecycleState!); + } + } + + @override + void didChangeAppLifecycleState(AppLifecycleState state) { + setState(() { + _stateHistoryList.add(state); + }); + } + + @override + void dispose() { + WidgetsBinding.instance.removeObserver(this); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + if (_stateHistoryList.isNotEmpty) { + return ListView.builder( + key: const ValueKey('stateHistoryList'), + itemCount: _stateHistoryList.length, + itemBuilder: (BuildContext context, int index) { + return Text('state is: ${_stateHistoryList[index]}'); + }, + ); + } + + return const Center(child: Text('There are no AppLifecycleStates to show.')); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/color_filter/color_filtered.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/color_filter/color_filtered.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..59d8203d0b574a52893005c2aaed8de0c40a62db --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/color_filter/color_filtered.0.dart @@ -0,0 +1,55 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [ColorFiltered]. + +void main() => runApp(const ColorFilteredExampleApp()); + +class ColorFilteredExampleApp extends StatelessWidget { + const ColorFilteredExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('ColorFiltered Sample')), + body: const ColorFilteredExample(), + ), + ); + } +} + +class ColorFilteredExample extends StatelessWidget { + const ColorFilteredExample({super.key}); + + @override + Widget build(BuildContext context) { + return SingleChildScrollView( + child: Column( + children: [ + ColorFiltered( + colorFilter: const ColorFilter.mode( + Colors.red, + BlendMode.modulate, + ), + child: Image.network( + 'https://flutter.github.io/assets-for-api-docs/assets/widgets/owl-2.jpg', + ), + ), + ColorFiltered( + colorFilter: const ColorFilter.mode( + Colors.grey, + BlendMode.saturation, + ), + child: Image.network( + 'https://flutter.github.io/assets-for-api-docs/assets/widgets/owl.jpg', + ), + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/dismissible/dismissible.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/dismissible/dismissible.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..c148063a5435811502e58bcc88c0e5da0791c0d9 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/dismissible/dismissible.0.dart @@ -0,0 +1,60 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Dismissible]. + +void main() => runApp(const DismissibleExampleApp()); + +class DismissibleExampleApp extends StatelessWidget { + const DismissibleExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('Dismissible Sample')), + body: const DismissibleExample(), + ), + ); + } +} + +class DismissibleExample extends StatefulWidget { + const DismissibleExample({super.key}); + + @override + State createState() => _DismissibleExampleState(); +} + +class _DismissibleExampleState extends State { + List items = List.generate(100, (int index) => index); + + @override + Widget build(BuildContext context) { + return ListView.builder( + itemCount: items.length, + padding: const EdgeInsets.symmetric(vertical: 16), + itemBuilder: (BuildContext context, int index) { + return Dismissible( + background: Container( + color: Colors.green, + ), + key: ValueKey(items[index]), + onDismissed: (DismissDirection direction) { + setState(() { + items.removeAt(index); + }); + }, + child: ListTile( + title: Text( + 'Item ${items[index]}', + ), + ), + ); + }, + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/drag_target/draggable.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/drag_target/draggable.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..79192cc91762a86b8d5715236a41e804ca2f9d74 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/drag_target/draggable.0.dart @@ -0,0 +1,90 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Draggable]. + +void main() => runApp(const DraggableExampleApp()); + +class DraggableExampleApp extends StatelessWidget { + const DraggableExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('Draggable Sample')), + body: const DraggableExample(), + ), + ); + } +} + +class DraggableExample extends StatefulWidget { + const DraggableExample({super.key}); + + @override + State createState() => _DraggableExampleState(); +} + +class _DraggableExampleState extends State { + int acceptedData = 0; + + @override + Widget build(BuildContext context) { + return Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Draggable( + // Data is the value this Draggable stores. + data: 10, + feedback: Container( + color: Colors.deepOrange, + height: 100, + width: 100, + child: const Icon(Icons.directions_run), + ), + childWhenDragging: Container( + height: 100.0, + width: 100.0, + color: Colors.pinkAccent, + child: const Center( + child: Text('Child When Dragging'), + ), + ), + child: Container( + height: 100.0, + width: 100.0, + color: Colors.lightGreenAccent, + child: const Center( + child: Text('Draggable'), + ), + ), + ), + DragTarget( + builder: ( + BuildContext context, + List accepted, + List rejected, + ) { + return Container( + height: 100.0, + width: 100.0, + color: Colors.cyan, + child: Center( + child: Text('Value is updated to: $acceptedData'), + ), + ); + }, + onAcceptWithDetails: (DragTargetDetails details) { + setState(() { + acceptedData += details.data; + }); + }, + ), + ], + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/draggable_scrollable_sheet/draggable_scrollable_sheet.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/draggable_scrollable_sheet/draggable_scrollable_sheet.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..556c884ed6b9b28abe55cedeb09a6669f67905e8 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/draggable_scrollable_sheet/draggable_scrollable_sheet.0.dart @@ -0,0 +1,144 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; + +/// Flutter code sample for [DraggableScrollableSheet]. + +void main() => runApp(const DraggableScrollableSheetExampleApp()); + +class DraggableScrollableSheetExampleApp extends StatelessWidget { + const DraggableScrollableSheetExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData( + colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue.shade100), + ), + home: Scaffold( + appBar: AppBar( + title: const Text('DraggableScrollableSheet Sample'), + ), + body: const DraggableScrollableSheetExample(), + ), + ); + } +} + +class DraggableScrollableSheetExample extends StatefulWidget { + const DraggableScrollableSheetExample({super.key}); + + @override + State createState() => _DraggableScrollableSheetExampleState(); +} + +class _DraggableScrollableSheetExampleState extends State { + double _sheetPosition = 0.5; + final double _dragSensitivity = 600; + + @override + Widget build(BuildContext context) { + final ColorScheme colorScheme = Theme.of(context).colorScheme; + + return DraggableScrollableSheet( + initialChildSize: _sheetPosition, + builder: (BuildContext context, ScrollController scrollController) { + return ColoredBox( + color: colorScheme.primary, + child: Column( + children: [ + Grabber( + onVerticalDragUpdate: (DragUpdateDetails details) { + setState(() { + _sheetPosition -= details.delta.dy / _dragSensitivity; + if (_sheetPosition < 0.25) { + _sheetPosition = 0.25; + } + if (_sheetPosition > 1.0) { + _sheetPosition = 1.0; + } + }); + }, + isOnDesktopAndWeb: _isOnDesktopAndWeb, + ), + Flexible( + child: ListView.builder( + controller: _isOnDesktopAndWeb ? null : scrollController, + itemCount: 25, + itemBuilder: (BuildContext context, int index) { + return ListTile( + title: Text( + 'Item $index', + style: TextStyle(color: colorScheme.surface), + ), + ); + }, + ), + ), + ], + ), + ); + }, + ); + } + + bool get _isOnDesktopAndWeb { + if (kIsWeb) { + return true; + } + switch (defaultTargetPlatform) { + case TargetPlatform.macOS: + case TargetPlatform.linux: + case TargetPlatform.windows: + return true; + case TargetPlatform.android: + case TargetPlatform.iOS: + case TargetPlatform.fuchsia: + return false; + } + } +} + +/// A draggable widget that accepts vertical drag gestures +/// and this is only visible on desktop and web platforms. +class Grabber extends StatelessWidget { + const Grabber({ + super.key, + required this.onVerticalDragUpdate, + required this.isOnDesktopAndWeb, + }); + + final ValueChanged onVerticalDragUpdate; + final bool isOnDesktopAndWeb; + + @override + Widget build(BuildContext context) { + if (!isOnDesktopAndWeb) { + return const SizedBox.shrink(); + } + final ColorScheme colorScheme = Theme.of(context).colorScheme; + + return GestureDetector( + onVerticalDragUpdate: onVerticalDragUpdate, + child: Container( + width: double.infinity, + color: colorScheme.onSurface, + child: Align( + alignment: Alignment.topCenter, + child: Container( + margin: const EdgeInsets.symmetric(vertical: 8.0), + width: 32.0, + height: 4.0, + decoration: BoxDecoration( + color: colorScheme.surfaceVariant, + borderRadius: BorderRadius.circular(8.0), + ), + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/editable_text/editable_text.on_changed.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/editable_text/editable_text.on_changed.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..9c12a0e3d4de183ec276d396773352a5838bc502 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/editable_text/editable_text.on_changed.0.dart @@ -0,0 +1,75 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [EditableText.onChanged]. + +void main() => runApp(const OnChangedExampleApp()); + +class OnChangedExampleApp extends StatelessWidget { + const OnChangedExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: OnChangedExample(), + ); + } +} + +class OnChangedExample extends StatefulWidget { + const OnChangedExample({super.key}); + + @override + State createState() => _OnChangedExampleState(); +} + +class _OnChangedExampleState extends State { + final TextEditingController _controller = TextEditingController(); + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text('What number comes next in the sequence?'), + const Text('1, 1, 2, 3, 5, 8...?'), + TextField( + controller: _controller, + onChanged: (String value) async { + if (value != '13') { + return; + } + await showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('That is correct!'), + content: const Text('13 is the right answer.'), + actions: [ + TextButton( + onPressed: () { + Navigator.pop(context); + }, + child: const Text('OK'), + ), + ], + ); + }, + ); + }, + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/editable_text/editable_text.on_content_inserted.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/editable_text/editable_text.on_content_inserted.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..86ca154488a36782188876ac37e8b2a302c8530f --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/editable_text/editable_text.on_content_inserted.0.dart @@ -0,0 +1,68 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:typed_data'; + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [EditableText.onContentInserted]. + +void main() => runApp(const KeyboardInsertedContentApp()); + +class KeyboardInsertedContentApp extends StatelessWidget { + const KeyboardInsertedContentApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: KeyboardInsertedContentDemo(), + ); + } +} + +class KeyboardInsertedContentDemo extends StatefulWidget { + const KeyboardInsertedContentDemo({super.key}); + + @override + State createState() => _KeyboardInsertedContentDemoState(); +} + +class _KeyboardInsertedContentDemoState extends State { + final TextEditingController _controller = TextEditingController(); + Uint8List? bytes; + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: const Text('Keyboard Inserted Content Sample')), + body: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text("Here's a text field that supports inserting only png or gif content:"), + TextField( + controller: _controller, + contentInsertionConfiguration: ContentInsertionConfiguration( + allowedMimeTypes: const ['image/png', 'image/gif'], + onContentInserted: (KeyboardInsertedContent data) async { + if (data.data != null) { + setState(() { + bytes = data.data; + }); + } + }, + ), + ), + if (bytes != null) const Text("Here's the most recently inserted content:"), + if (bytes != null) Image.memory(bytes!), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/editable_text/text_editing_controller.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/editable_text/text_editing_controller.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..a9837dc3c43cfac3fa90edd714b76e58bf0373a8 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/editable_text/text_editing_controller.0.dart @@ -0,0 +1,64 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [TextEditingController]. + +void main() => runApp(const TextEditingControllerExampleApp()); + +class TextEditingControllerExampleApp extends StatelessWidget { + const TextEditingControllerExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: TextEditingControllerExample(), + ); + } +} + +class TextEditingControllerExample extends StatefulWidget { + const TextEditingControllerExample({super.key}); + + @override + State createState() => _TextEditingControllerExampleState(); +} + +class _TextEditingControllerExampleState extends State { + final TextEditingController _controller = TextEditingController(); + + @override + void initState() { + super.initState(); + _controller.addListener(() { + final String text = _controller.text.toLowerCase(); + _controller.value = _controller.value.copyWith( + text: text, + selection: TextSelection(baseOffset: text.length, extentOffset: text.length), + composing: TextRange.empty, + ); + }); + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Container( + alignment: Alignment.center, + padding: const EdgeInsets.all(6), + child: TextFormField( + controller: _controller, + decoration: const InputDecoration(border: OutlineInputBorder()), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/editable_text/text_editing_controller.1.dart b/novelforge-project/flutter/examples/api/lib/widgets/editable_text/text_editing_controller.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..46672976e1fa0f0cd9278451bf6adb0832886ede --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/editable_text/text_editing_controller.1.dart @@ -0,0 +1,61 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [TextEditingController]. + +void main() { + runApp(const TextEditingControllerExampleApp()); +} + +class TextEditingControllerExampleApp extends StatelessWidget { + const TextEditingControllerExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: TextEditingControllerExample(), + ); + } +} + +class TextEditingControllerExample extends StatefulWidget { + const TextEditingControllerExample({super.key}); + + @override + State createState() => _TextEditingControllerExampleState(); +} + +class _TextEditingControllerExampleState extends State { + // Create a controller whose initial selection is empty (collapsed) and positioned + // before the text (offset is 0). + final TextEditingController _controller = TextEditingController.fromValue( + const TextEditingValue( + text: 'Flutter', + selection: TextSelection.collapsed(offset: 0), + ), + ); + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Container( + alignment: Alignment.center, + padding: const EdgeInsets.all(16.0), + child: TextField( + controller: _controller, + autofocus: true, + decoration: const InputDecoration(filled: true), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/focus_manager/focus_node.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/focus_manager/focus_node.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..8d52b03c85f4851c051679066517e661d95a34a2 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/focus_manager/focus_node.0.dart @@ -0,0 +1,124 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +/// Flutter code sample for [FocusNode]. + +void main() => runApp(const FocusNodeExampleApp()); + +class FocusNodeExampleApp extends StatelessWidget { + const FocusNodeExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('FocusNode Sample')), + body: const FocusNodeExample(), + ), + ); + } +} + +class ColorfulButton extends StatefulWidget { + const ColorfulButton({super.key}); + + @override + State createState() => _ColorfulButtonState(); +} + +class _ColorfulButtonState extends State { + late FocusNode _node; + bool _focused = false; + late FocusAttachment _nodeAttachment; + Color _color = Colors.white; + + @override + void initState() { + super.initState(); + _node = FocusNode(debugLabel: 'Button'); + _node.addListener(_handleFocusChange); + _nodeAttachment = _node.attach(context, onKeyEvent: _handleKeyPress); + } + + void _handleFocusChange() { + if (_node.hasFocus != _focused) { + setState(() { + _focused = _node.hasFocus; + }); + } + } + + KeyEventResult _handleKeyPress(FocusNode node, KeyEvent event) { + if (event is KeyDownEvent) { + debugPrint('Focus node ${node.debugLabel} got key event: ${event.logicalKey}'); + if (event.logicalKey == LogicalKeyboardKey.keyR) { + debugPrint('Changing color to red.'); + setState(() { + _color = Colors.red; + }); + return KeyEventResult.handled; + } else if (event.logicalKey == LogicalKeyboardKey.keyG) { + debugPrint('Changing color to green.'); + setState(() { + _color = Colors.green; + }); + return KeyEventResult.handled; + } else if (event.logicalKey == LogicalKeyboardKey.keyB) { + debugPrint('Changing color to blue.'); + setState(() { + _color = Colors.blue; + }); + return KeyEventResult.handled; + } + } + return KeyEventResult.ignored; + } + + @override + void dispose() { + _node.removeListener(_handleFocusChange); + // The attachment will automatically be detached in dispose(). + _node.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + _nodeAttachment.reparent(); + return GestureDetector( + onTap: () { + if (_focused) { + _node.unfocus(); + } else { + _node.requestFocus(); + } + }, + child: Center( + child: Container( + width: 400, + height: 100, + color: _focused ? _color : Colors.white, + alignment: Alignment.center, + child: Text(_focused ? "I'm in color! Press R,G,B!" : 'Press to focus'), + ), + ), + ); + } +} + +class FocusNodeExample extends StatelessWidget { + const FocusNodeExample({super.key}); + + @override + Widget build(BuildContext context) { + final TextTheme textTheme = Theme.of(context).textTheme; + return DefaultTextStyle( + style: textTheme.headlineMedium!, + child: const ColorfulButton(), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/focus_manager/focus_node.unfocus.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/focus_manager/focus_node.unfocus.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..e568bc21015bcc0a28fb1c5e043866bd16ff71b2 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/focus_manager/focus_node.unfocus.0.dart @@ -0,0 +1,90 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [FocusNode.unfocus]. + +void main() => runApp(const UnfocusExampleApp()); + +class UnfocusExampleApp extends StatelessWidget { + const UnfocusExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: UnfocusExample(), + ); + } +} + +class UnfocusExample extends StatefulWidget { + const UnfocusExample({super.key}); + + @override + State createState() => _UnfocusExampleState(); +} + +class _UnfocusExampleState extends State { + UnfocusDisposition disposition = UnfocusDisposition.scope; + + @override + Widget build(BuildContext context) { + return Material( + child: ColoredBox( + color: Colors.white, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Wrap( + children: List.generate(4, (int index) { + return const SizedBox( + width: 200, + child: Padding( + padding: EdgeInsets.all(8.0), + child: TextField( + decoration: InputDecoration(border: OutlineInputBorder()), + ), + ), + ); + }), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + ...List.generate(UnfocusDisposition.values.length, (int index) { + return Row( + mainAxisSize: MainAxisSize.min, + children: [ + Radio( + groupValue: disposition, + onChanged: (UnfocusDisposition? value) { + setState(() { + if (value != null) { + disposition = value; + } + }); + }, + value: UnfocusDisposition.values[index], + ), + Text(UnfocusDisposition.values[index].name), + ], + ); + }), + OutlinedButton( + child: const Text('UNFOCUS'), + onPressed: () { + setState(() { + primaryFocus!.unfocus(disposition: disposition); + }); + }, + ), + ], + ), + ], + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/focus_scope/focus.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/focus_scope/focus.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..37bafe783de957d7604b9e68ef5c6084bfb7f70e --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/focus_scope/focus.0.dart @@ -0,0 +1,101 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +/// Flutter code sample for [Focus]. + +void main() => runApp(const FocusExampleApp()); + +class FocusExampleApp extends StatelessWidget { + const FocusExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('Focus Sample')), + body: const FocusExample(), + ), + ); + } +} + +class FocusExample extends StatefulWidget { + const FocusExample({super.key}); + + @override + State createState() => _FocusExampleState(); +} + +class _FocusExampleState extends State { + Color _color = Colors.white; + + KeyEventResult _handleKeyPress(FocusNode node, KeyEvent event) { + if (event is KeyDownEvent) { + debugPrint('Focus node ${node.debugLabel} got key event: ${event.logicalKey}'); + if (event.logicalKey == LogicalKeyboardKey.keyR) { + debugPrint('Changing color to red.'); + setState(() { + _color = Colors.red; + }); + return KeyEventResult.handled; + } else if (event.logicalKey == LogicalKeyboardKey.keyG) { + debugPrint('Changing color to green.'); + setState(() { + _color = Colors.green; + }); + return KeyEventResult.handled; + } else if (event.logicalKey == LogicalKeyboardKey.keyB) { + debugPrint('Changing color to blue.'); + setState(() { + _color = Colors.blue; + }); + return KeyEventResult.handled; + } + } + return KeyEventResult.ignored; + } + + @override + Widget build(BuildContext context) { + final TextTheme textTheme = Theme.of(context).textTheme; + return FocusScope( + debugLabel: 'Scope', + autofocus: true, + child: DefaultTextStyle( + style: textTheme.headlineMedium!, + child: Focus( + onKeyEvent: _handleKeyPress, + debugLabel: 'Button', + child: Builder( + builder: (BuildContext context) { + final FocusNode focusNode = Focus.of(context); + final bool hasFocus = focusNode.hasFocus; + return GestureDetector( + onTap: () { + if (hasFocus) { + focusNode.unfocus(); + } else { + focusNode.requestFocus(); + } + }, + child: Center( + child: Container( + width: 400, + height: 100, + alignment: Alignment.center, + color: hasFocus ? _color : Colors.white, + child: Text(hasFocus ? "I'm in color! Press R,G,B!" : 'Press to focus'), + ), + ), + ); + }, + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/focus_scope/focus.1.dart b/novelforge-project/flutter/examples/api/lib/widgets/focus_scope/focus.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..8bbe09092f667a8749c2161b9fa80796e5740c0c --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/focus_scope/focus.1.dart @@ -0,0 +1,73 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Focus]. + +void main() => runApp(const FocusExampleApp()); + +class FocusExampleApp extends StatelessWidget { + const FocusExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: FocusExample(), + ); + } +} + +class FocusableText extends StatelessWidget { + const FocusableText( + this.data, { + super.key, + required this.autofocus, + }); + + /// The string to display as the text for this widget. + final String data; + + /// Whether or not to focus this widget initially if nothing else is focused. + final bool autofocus; + + @override + Widget build(BuildContext context) { + return Focus( + autofocus: autofocus, + child: Builder(builder: (BuildContext context) { + // The contents of this Builder are being made focusable. It is inside + // of a Builder because the builder provides the correct context + // variable for Focus.of() to be able to find the Focus widget that is + // the Builder's parent. Without the builder, the context variable used + // would be the one given the FocusableText build function, and that + // would start looking for a Focus widget ancestor of the FocusableText + // instead of finding the one inside of its build function. + return Container( + padding: const EdgeInsets.all(8.0), + // Change the color based on whether or not this Container has focus. + color: Focus.of(context).hasPrimaryFocus ? Colors.black12 : null, + child: Text(data), + ); + }), + ); + } +} + +class FocusExample extends StatelessWidget { + const FocusExample({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: ListView.builder( + itemBuilder: (BuildContext context, int index) => FocusableText( + 'Item $index', + autofocus: index == 0, + ), + itemCount: 50, + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/focus_scope/focus.2.dart b/novelforge-project/flutter/examples/api/lib/widgets/focus_scope/focus.2.dart new file mode 100644 index 0000000000000000000000000000000000000000..4451b3db07b8cdcd032e8a0eda79db05b4f9fe7e --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/focus_scope/focus.2.dart @@ -0,0 +1,83 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Focus]. + +void main() => runApp(const FocusExampleApp()); + +class FocusExampleApp extends StatelessWidget { + const FocusExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: FocusExample(), + ); + } +} + +class FocusExample extends StatefulWidget { + const FocusExample({super.key}); + + @override + State createState() => _FocusExampleState(); +} + +class _FocusExampleState extends State { + int focusedChild = 0; + List children = []; + List childFocusNodes = []; + + @override + void initState() { + super.initState(); + // Add the first child. + _addChild(); + } + + @override + void dispose() { + for (final FocusNode node in childFocusNodes) { + node.dispose(); + } + super.dispose(); + } + + void _addChild() { + // Calling requestFocus here creates a deferred request for focus, since the + // node is not yet part of the focus tree. + childFocusNodes.add(FocusNode(debugLabel: 'Child ${children.length}')..requestFocus()); + + children.add(Padding( + padding: const EdgeInsets.all(2.0), + child: ActionChip( + focusNode: childFocusNodes.last, + label: Text('CHILD ${children.length}'), + onPressed: () {}, + ), + )); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Wrap( + children: children, + ), + ), + floatingActionButton: FloatingActionButton( + onPressed: () { + setState(() { + focusedChild = children.length; + _addChild(); + }); + }, + child: const Icon(Icons.add), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/focus_scope/focus_scope.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/focus_scope/focus_scope.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..20f4c900ae56777dee6df7e8447d856b9e0a4b14 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/focus_scope/focus_scope.0.dart @@ -0,0 +1,162 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [FocusScope]. + +void main() => runApp(const FocusScopeExampleApp()); + +class FocusScopeExampleApp extends StatelessWidget { + const FocusScopeExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: FocusScopeExample(), + ); + } +} + +/// A demonstration pane. +/// +/// This is just a separate widget to simplify the example. +class Pane extends StatelessWidget { + const Pane({ + super.key, + required this.focusNode, + this.onPressed, + required this.backgroundColor, + required this.icon, + this.child, + }); + + final FocusNode focusNode; + final VoidCallback? onPressed; + final Color backgroundColor; + final Widget icon; + final Widget? child; + + @override + Widget build(BuildContext context) { + return Material( + color: backgroundColor, + child: Stack( + fit: StackFit.expand, + children: [ + Center( + child: child, + ), + Align( + alignment: Alignment.topLeft, + child: IconButton( + autofocus: true, + focusNode: focusNode, + onPressed: onPressed, + icon: icon, + ), + ), + ], + ), + ); + } +} + +class FocusScopeExample extends StatefulWidget { + const FocusScopeExample({super.key}); + + @override + State createState() => _FocusScopeExampleState(); +} + +class _FocusScopeExampleState extends State { + bool backdropIsVisible = false; + FocusNode backdropNode = FocusNode(debugLabel: 'Close Backdrop Button'); + FocusNode foregroundNode = FocusNode(debugLabel: 'Option Button'); + + @override + void dispose() { + backdropNode.dispose(); + foregroundNode.dispose(); + super.dispose(); + } + + Widget _buildStack(BuildContext context, BoxConstraints constraints) { + final Size stackSize = constraints.biggest; + return Stack( + fit: StackFit.expand, + // The backdrop is behind the front widget in the Stack, but the widgets + // would still be active and traversable without the FocusScope. + children: [ + // TRY THIS: Try removing this FocusScope entirely to see how it affects + // the behavior. Without this FocusScope, the "ANOTHER BUTTON TO FOCUS" + // button, and the IconButton in the backdrop Pane would be focusable + // even when the backdrop wasn't visible. + FocusScope( + // TRY THIS: Try commenting out this line. Notice that the focus + // starts on the backdrop and is stuck there? It seems like the app is + // non-responsive, but it actually isn't. This line makes sure that + // this focus scope and its children can't be focused when they're not + // visible. It might help to make the background color of the + // foreground pane semi-transparent to see it clearly. + canRequestFocus: backdropIsVisible, + child: Pane( + icon: const Icon(Icons.close), + focusNode: backdropNode, + backgroundColor: Colors.lightBlue, + onPressed: () => setState(() => backdropIsVisible = false), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + // This button would be not visible, but still focusable from + // the foreground pane without the FocusScope. + ElevatedButton( + onPressed: () => debugPrint('You pressed the other button!'), + child: const Text('ANOTHER BUTTON TO FOCUS'), + ), + DefaultTextStyle( + style: Theme.of(context).textTheme.displayMedium!, + child: const Text('BACKDROP'), + ), + ], + ), + ), + ), + AnimatedPositioned( + curve: Curves.easeInOut, + duration: const Duration(milliseconds: 300), + top: backdropIsVisible ? stackSize.height * 0.9 : 0.0, + width: stackSize.width, + height: stackSize.height, + onEnd: () { + if (backdropIsVisible) { + backdropNode.requestFocus(); + } else { + foregroundNode.requestFocus(); + } + }, + child: Pane( + icon: const Icon(Icons.menu), + focusNode: foregroundNode, + // TRY THIS: Try changing this to Colors.green.withOpacity(0.8) to see for + // yourself that the hidden components do/don't get focus. + backgroundColor: Colors.green, + onPressed: backdropIsVisible ? null : () => setState(() => backdropIsVisible = true), + child: DefaultTextStyle( + style: Theme.of(context).textTheme.displayMedium!, + child: const Text('FOREGROUND'), + ), + ), + ), + ], + ); + } + + @override + Widget build(BuildContext context) { + // Use a LayoutBuilder so that we can base the size of the stack on the size + // of its parent. + return LayoutBuilder(builder: _buildStack); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/focus_traversal/focus_traversal_group.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/focus_traversal/focus_traversal_group.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..818eb2ac1f39c86c14275efc25fa1ebc9f96ed5f --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/focus_traversal/focus_traversal_group.0.dart @@ -0,0 +1,181 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [FocusTraversalGroup]. + +void main() => runApp(const FocusTraversalGroupExampleApp()); + +class FocusTraversalGroupExampleApp extends StatelessWidget { + const FocusTraversalGroupExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: FocusTraversalGroupExample(), + ); + } +} + +/// A button wrapper that adds either a numerical or lexical order, depending on +/// the type of T. +class OrderedButton extends StatefulWidget { + const OrderedButton({ + super.key, + required this.name, + this.canRequestFocus = true, + this.autofocus = false, + required this.order, + }); + + final String name; + final bool canRequestFocus; + final bool autofocus; + final T order; + + @override + State> createState() => _OrderedButtonState(); +} + +class _OrderedButtonState extends State> { + late FocusNode focusNode; + + @override + void initState() { + super.initState(); + focusNode = FocusNode( + debugLabel: widget.name, + canRequestFocus: widget.canRequestFocus, + ); + } + + @override + void dispose() { + focusNode.dispose(); + super.dispose(); + } + + @override + void didUpdateWidget(OrderedButton oldWidget) { + super.didUpdateWidget(oldWidget); + focusNode.canRequestFocus = widget.canRequestFocus; + } + + void _handleOnPressed() { + focusNode.requestFocus(); + debugPrint('Button ${widget.name} pressed.'); + debugDumpFocusTree(); + } + + @override + Widget build(BuildContext context) { + FocusOrder order; + if (widget.order is num) { + order = NumericFocusOrder((widget.order as num).toDouble()); + } else { + order = LexicalFocusOrder(widget.order.toString()); + } + + Color? overlayColor(Set states) { + if (states.contains(MaterialState.focused)) { + return Colors.red; + } + if (states.contains(MaterialState.hovered)) { + return Colors.blue; + } + return null; // defer to the default overlayColor + } + + Color? foregroundColor(Set states) { + if (states.contains(MaterialState.focused) || states.contains(MaterialState.hovered)) { + return Colors.white; + } + return null; // defer to the default foregroundColor + } + + return FocusTraversalOrder( + order: order, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: OutlinedButton( + focusNode: focusNode, + autofocus: widget.autofocus, + style: ButtonStyle( + overlayColor: MaterialStateProperty.resolveWith(overlayColor), + foregroundColor: MaterialStateProperty.resolveWith(foregroundColor), + ), + onPressed: () => _handleOnPressed(), + child: Text(widget.name), + ), + ), + ); + } +} + +class FocusTraversalGroupExample extends StatelessWidget { + const FocusTraversalGroupExample({super.key}); + + @override + Widget build(BuildContext context) { + return ColoredBox( + color: Colors.white, + child: FocusTraversalGroup( + policy: OrderedTraversalPolicy(), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + // A group that is ordered with a numerical order, from left to right. + FocusTraversalGroup( + policy: OrderedTraversalPolicy(), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: List.generate(3, (int index) { + return OrderedButton( + name: 'num: $index', + // TRY THIS: change this to "3 - index" and see how the order changes. + order: index, + ); + }), + ), + ), + // A group that is ordered with a lexical order, from right to left. + FocusTraversalGroup( + policy: OrderedTraversalPolicy(), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: List.generate(3, (int index) { + // Order as "C" "B", "A". + final String order = String.fromCharCode('A'.codeUnitAt(0) + (2 - index)); + return OrderedButton( + name: 'String: $order', + order: order, + ); + }), + ), + ), + // A group that orders in widget order, regardless of what the order is set to. + FocusTraversalGroup( + // Because this is NOT an OrderedTraversalPolicy, the + // assigned order of these OrderedButtons is ignored, and they + // are traversed in widget order. TRY THIS: change this to + // "OrderedTraversalPolicy()" and see that it now follows the + // numeric order set on them instead of the widget order. + policy: WidgetOrderTraversalPolicy(), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: List.generate(3, (int index) { + return OrderedButton( + name: 'ignored num: ${3 - index}', + order: 3 - index, + ); + }), + ), + ), + ], + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/focus_traversal/ordered_traversal_policy.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/focus_traversal/ordered_traversal_policy.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..62f14f12c087f6578807d564f4c1a203e975a131 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/focus_traversal/ordered_traversal_policy.0.dart @@ -0,0 +1,92 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [OrderedTraversalPolicy]. + +void main() => runApp(const OrderedTraversalPolicyExampleApp()); + +class OrderedTraversalPolicyExampleApp extends StatelessWidget { + const OrderedTraversalPolicyExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('OrderedTraversalPolicy Sample')), + body: const Center( + child: OrderedTraversalPolicyExample(), + ), + ), + ); + } +} + +class DemoButton extends StatelessWidget { + const DemoButton({ + super.key, + required this.name, + this.autofocus = false, + required this.order, + }); + + final String name; + final bool autofocus; + final double order; + + void _handleOnPressed() { + debugPrint('Button $name pressed.'); + debugDumpFocusTree(); + } + + @override + Widget build(BuildContext context) { + return FocusTraversalOrder( + order: NumericFocusOrder(order), + child: TextButton( + autofocus: autofocus, + onPressed: () => _handleOnPressed(), + child: Text(name), + ), + ); + } +} + +class OrderedTraversalPolicyExample extends StatelessWidget { + const OrderedTraversalPolicyExample({super.key}); + + @override + Widget build(BuildContext context) { + return FocusTraversalGroup( + policy: OrderedTraversalPolicy(), + child: const Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + DemoButton(name: 'Six', order: 6), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + DemoButton(name: 'Five', order: 5), + DemoButton(name: 'Four', order: 4), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + DemoButton(name: 'Three', order: 3), + DemoButton(name: 'Two', order: 2), + DemoButton(name: 'One', order: 1, autofocus: true), + ], + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/form/form.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/form/form.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..18b50c94b7fc453c57edabb0b0d250ba233605a3 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/form/form.0.dart @@ -0,0 +1,70 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Form]. + +void main() => runApp(const FormExampleApp()); + +class FormExampleApp extends StatelessWidget { + const FormExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('Form Sample')), + body: const FormExample(), + ), + ); + } +} + +class FormExample extends StatefulWidget { + const FormExample({super.key}); + + @override + State createState() => _FormExampleState(); +} + +class _FormExampleState extends State { + final GlobalKey _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return Form( + key: _formKey, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextFormField( + decoration: const InputDecoration( + hintText: 'Enter your email', + ), + validator: (String? value) { + if (value == null || value.isEmpty) { + return 'Please enter some text'; + } + return null; + }, + ), + Padding( + padding: const EdgeInsets.symmetric(vertical: 16.0), + child: ElevatedButton( + onPressed: () { + // Validate will return true if the form is valid, or false if + // the form is invalid. + if (_formKey.currentState!.validate()) { + // Process data. + } + }, + child: const Text('Submit'), + ), + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/form/form.1.dart b/novelforge-project/flutter/examples/api/lib/widgets/form/form.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..b5e8b6e09ca1f25a90338595421c01e0c4f9f11b --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/form/form.1.dart @@ -0,0 +1,166 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +/// This sample demonstrates showing a confirmation dialog when the user +/// attempts to navigate away from a page with unsaved [Form] data. + +void main() => runApp(const FormApp()); + +class FormApp extends StatelessWidget { + const FormApp({ + super.key, + }); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Confirmation Dialog Example'), + ), + body: Center( + child: _SaveableForm(), + ), + ), + ); + } +} + +class _SaveableForm extends StatefulWidget { + @override + State<_SaveableForm> createState() => _SaveableFormState(); +} + +class _SaveableFormState extends State<_SaveableForm> { + final TextEditingController _controller = TextEditingController(); + String _savedValue = ''; + bool _isDirty = false; + + @override + void initState() { + super.initState(); + _controller.addListener(_onChanged); + } + + @override + void dispose() { + _controller.removeListener(_onChanged); + super.dispose(); + } + + void _onChanged() { + final bool nextIsDirty = _savedValue != _controller.text; + if (nextIsDirty == _isDirty) { + return; + } + setState(() { + _isDirty = nextIsDirty; + }); + } + + Future _showDialog() async { + final bool? shouldDiscard = await showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Are you sure?'), + content: const Text('Any unsaved changes will be lost!'), + actions: [ + TextButton( + child: const Text('Yes, discard my changes'), + onPressed: () { + Navigator.pop(context, true); + }, + ), + TextButton( + child: const Text('No, continue editing'), + onPressed: () { + Navigator.pop(context, false); + }, + ), + ], + ); + }, + ); + + if (shouldDiscard ?? false) { + // Since this is the root route, quit the app where possible by invoking + // the SystemNavigator. If this wasn't the root route, then + // Navigator.maybePop could be used instead. + // See https://github.com/flutter/flutter/issues/11490 + SystemNavigator.pop(); + } + } + + void _save(String? value) { + setState(() { + _savedValue = value ?? ''; + }); + } + + @override + Widget build(BuildContext context) { + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text('If the field below is unsaved, a confirmation dialog will be shown on back.'), + const SizedBox(height: 20.0), + Form( + canPop: !_isDirty, + onPopInvoked: (bool didPop) { + if (didPop) { + return; + } + _showDialog(); + }, + autovalidateMode: AutovalidateMode.always, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + TextFormField( + controller: _controller, + onFieldSubmitted: (String? value) { + _save(value); + }, + ), + TextButton( + onPressed: () { + _save(_controller.text); + }, + child: Row( + children: [ + const Text('Save'), + if (_controller.text.isNotEmpty) + Icon( + _isDirty ? Icons.warning : Icons.check, + ), + ], + ), + ), + ], + ), + ), + TextButton( + onPressed: () { + if (_isDirty) { + _showDialog(); + return; + } + // Since this is the root route, quit the app where possible by + // invoking the SystemNavigator. If this wasn't the root route, + // then Navigator.maybePop could be used instead. + // See https://github.com/flutter/flutter/issues/11490 + SystemNavigator.pop(); + }, + child: const Text('Go back'), + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/framework/build_owner.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/framework/build_owner.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..ab173907c3ae25e69f301b619aa23baa7fb5c376 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/framework/build_owner.0.dart @@ -0,0 +1,60 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; + +/// Flutter code sample for [BuildOwner]. + +void main() { + WidgetsFlutterBinding.ensureInitialized(); + final Size size = measureWidget(const SizedBox(width: 640, height: 480)); + + // Just displays the size calculated above. + runApp( + WidgetsApp( + title: 'BuildOwner Sample', + color: const Color(0xff000000), + builder: (BuildContext context, Widget? child) { + return Scaffold( + body: Center( + child: Text(size.toString()), + ), + ); + }, + ), + ); +} + +Size measureWidget(Widget widget) { + final PipelineOwner pipelineOwner = PipelineOwner(); + final MeasurementView rootView = pipelineOwner.rootNode = MeasurementView(); + final BuildOwner buildOwner = BuildOwner(focusManager: FocusManager()); + final RenderObjectToWidgetElement element = RenderObjectToWidgetAdapter( + container: rootView, + debugShortDescription: '[root]', + child: widget, + ).attachToRenderTree(buildOwner); + try { + rootView.scheduleInitialLayout(); + pipelineOwner.flushLayout(); + return rootView.size; + } finally { + // Clean up. + element.update(RenderObjectToWidgetAdapter(container: rootView)); + buildOwner.finalizeTree(); + } +} + +class MeasurementView extends RenderBox with RenderObjectWithChildMixin { + @override + void performLayout() { + assert(child != null); + child!.layout(const BoxConstraints(), parentUsesSize: true); + size = child!.size; + } + + @override + void debugAssertDoesMeetConstraints() => true; +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/framework/error_widget.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/framework/error_widget.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..3be9ff88cb3f7a90381ff2258965a39d820e020e --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/framework/error_widget.0.dart @@ -0,0 +1,71 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; + +/// Flutter code sample for [ErrorWidget]. + +void main() { + // Set the ErrorWidget's builder before the app is started. + ErrorWidget.builder = (FlutterErrorDetails details) { + // If we're in debug mode, use the normal error widget which shows the error + // message: + if (kDebugMode) { + return ErrorWidget(details.exception); + } + // In release builds, show a yellow-on-blue message instead: + return Container( + alignment: Alignment.center, + child: Text( + 'Error!\n${details.exception}', + style: const TextStyle(color: Colors.yellow), + textAlign: TextAlign.center, + textDirection: TextDirection.ltr, + ), + ); + }; + + // Start the app. + runApp(const ErrorWidgetExampleApp()); +} + +class ErrorWidgetExampleApp extends StatefulWidget { + const ErrorWidgetExampleApp({super.key}); + + @override + State createState() => _ErrorWidgetExampleAppState(); +} + +class _ErrorWidgetExampleAppState extends State { + bool throwError = false; + + @override + Widget build(BuildContext context) { + if (throwError) { + // Since the error widget is only used during a build, in this contrived example, + // we purposely throw an exception in a build function. + return Builder( + builder: (BuildContext context) { + throw Exception('oh no, an error'); + }, + ); + } else { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('ErrorWidget Sample')), + body: Center( + child: TextButton( + onPressed: () { + setState(() { + throwError = true; + }); + }, + child: const Text('Error Prone')), + ), + ), + ); + } + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/gesture_detector/gesture_detector.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/gesture_detector/gesture_detector.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..21b1ff98d5277d29eda05224102e74064c940ae4 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/gesture_detector/gesture_detector.0.dart @@ -0,0 +1,67 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [GestureDetector]. + +void main() => runApp(const GestureDetectorExampleApp()); + +class GestureDetectorExampleApp extends StatelessWidget { + const GestureDetectorExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: GestureDetectorExample(), + ); + } +} + +class GestureDetectorExample extends StatefulWidget { + const GestureDetectorExample({super.key}); + + @override + State createState() => _GestureDetectorExampleState(); +} + +class _GestureDetectorExampleState extends State { + bool _lightIsOn = false; + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Container( + alignment: FractionalOffset.center, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Icon( + Icons.lightbulb_outline, + color: _lightIsOn ? Colors.yellow.shade600 : Colors.black, + size: 60, + ), + ), + GestureDetector( + onTap: () { + setState(() { + // Toggle light when tapped. + _lightIsOn = !_lightIsOn; + }); + }, + child: Container( + color: Colors.yellow.shade600, + padding: const EdgeInsets.all(8), + // Change button text when light changes state. + child: Text(_lightIsOn ? 'TURN LIGHT OFF' : 'TURN LIGHT ON'), + ), + ), + ], + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/gesture_detector/gesture_detector.1.dart b/novelforge-project/flutter/examples/api/lib/widgets/gesture_detector/gesture_detector.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..11212d14238fcf01a6291370ec5d221bb13a84b7 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/gesture_detector/gesture_detector.1.dart @@ -0,0 +1,47 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [GestureDetector]. + +void main() => runApp(const GestureDetectorExampleApp()); + +class GestureDetectorExampleApp extends StatelessWidget { + const GestureDetectorExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: GestureDetectorExample(), + ); + } +} + +class GestureDetectorExample extends StatefulWidget { + const GestureDetectorExample({super.key}); + + @override + State createState() => _GestureDetectorExampleState(); +} + +class _GestureDetectorExampleState extends State { + Color _color = Colors.white; + + @override + Widget build(BuildContext context) { + return Container( + color: _color, + height: 200.0, + width: 200.0, + child: GestureDetector( + onTap: () { + setState(() { + _color == Colors.yellow ? _color = Colors.white : _color = Colors.yellow; + }); + }, + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/gesture_detector/gesture_detector.2.dart b/novelforge-project/flutter/examples/api/lib/widgets/gesture_detector/gesture_detector.2.dart new file mode 100644 index 0000000000000000000000000000000000000000..594545301cf42f0e900845bd4aaab7a59d08a6da --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/gesture_detector/gesture_detector.2.dart @@ -0,0 +1,126 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; + +/// Flutter code sample for [GestureDetector]. + +void main() { + debugPrintGestureArenaDiagnostics = true; + runApp(const NestedGestureDetectorsApp()); +} + +enum _OnTapWinner { none, yellow, green } + +class NestedGestureDetectorsApp extends StatelessWidget { + const NestedGestureDetectorsApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('Nested GestureDetectors')), + body: const NestedGestureDetectorsExample(), + ), + ); + } +} + +class NestedGestureDetectorsExample extends StatefulWidget { + const NestedGestureDetectorsExample({super.key}); + + @override + State createState() => _NestedGestureDetectorsExampleState(); +} + +class _NestedGestureDetectorsExampleState extends State { + bool _isYellowTranslucent = false; + _OnTapWinner _winner = _OnTapWinner.none; + final Border highlightBorder = Border.all(color: Colors.red, width: 5); + + @override + Widget build(BuildContext context) { + return Column( + children: [ + Expanded( + child: GestureDetector( + onTap: () { + debugPrint('Green onTap'); + setState(() { + _winner = _OnTapWinner.green; + }); + }, + onTapDown: (_) => debugPrint('Green onTapDown'), + onTapCancel: () => debugPrint('Green onTapCancel'), + child: Container( + alignment: Alignment.center, + decoration: BoxDecoration( + border: _winner == _OnTapWinner.green ? highlightBorder : null, + color: Colors.green, + ), + child: GestureDetector( + // Setting behavior to transparent or opaque as no impact on + // parent-child hit testing. A tap on 'Yellow' is also in + // 'Green' bounds. Both enter the gesture arena, 'Yellow' wins + // because it is in front. + behavior: _isYellowTranslucent ? HitTestBehavior.translucent : HitTestBehavior.opaque, + onTap: () { + debugPrint('Yellow onTap'); + setState(() { + _winner = _OnTapWinner.yellow; + }); + }, + child: Container( + alignment: Alignment.center, + decoration: BoxDecoration( + border: _winner == _OnTapWinner.yellow ? highlightBorder : null, + color: Colors.amber, + ), + width: 200, + height: 200, + child: Text( + 'HitTextBehavior.${_isYellowTranslucent ? 'translucent' : 'opaque'}', + textAlign: TextAlign.center, + ), + ), + ), + ), + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + children: [ + ElevatedButton( + child: const Text('Reset'), + onPressed: () { + setState(() { + _isYellowTranslucent = false; + _winner = _OnTapWinner.none; + }); + }, + ), + const SizedBox(width: 8), + ElevatedButton( + child: Text( + 'Set Yellow behavior to ${_isYellowTranslucent ? 'opaque' : 'translucent'}', + ), + onPressed: () { + setState(() => _isYellowTranslucent = !_isYellowTranslucent); + }, + ), + ], + ), + ), + ], + ); + } + + @override + void dispose() { + debugPrintGestureArenaDiagnostics = false; + super.dispose(); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/hardware_keyboard/key_event_manager.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/hardware_keyboard/key_event_manager.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..dcafc6bf92d13ec60dbfbfedf24adf85e7b3f9fd --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/hardware_keyboard/key_event_manager.0.dart @@ -0,0 +1,190 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +// TODO(gspencergoog): Delete this example when deprecated RawKeyEvent API is +// removed. +// ignore_for_file: deprecated_member_use + +/// Flutter code sample for [KeyEventManager.keyMessageHandler]. + +void main() { + runApp( + const MaterialApp( + home: Scaffold( + body: Center( + child: FallbackDemo(), + ), + ), + ), + ); +} + +class FallbackDemo extends StatefulWidget { + const FallbackDemo({super.key}); + + @override + State createState() => FallbackDemoState(); +} + +class FallbackDemoState extends State { + String? _capture; + late final FallbackFocusNode _node = FallbackFocusNode( + onKeyEvent: (KeyEvent event) { + if (event is! KeyDownEvent) { + return false; + } + setState(() { + _capture = event.logicalKey.keyLabel; + }); + // TRY THIS: Change the return value to true. You will no longer be able + // to type text, because these key events will no longer be sent to the + // text input system. + return false; + }, + ); + + @override + Widget build(BuildContext context) { + return FallbackFocus( + node: _node, + child: Container( + decoration: BoxDecoration(border: Border.all(color: Colors.red)), + padding: const EdgeInsets.all(10), + constraints: const BoxConstraints(maxWidth: 500, maxHeight: 400), + child: Column( + children: [ + const Text('This area handles key presses that are unhandled by any shortcuts, by ' + 'displaying them below. Try text shortcuts such as Ctrl-A!'), + Text(_capture == null ? '' : '$_capture is not handled by shortcuts.'), + const TextField(decoration: InputDecoration(label: Text('Text field 1'))), + Shortcuts( + shortcuts: { + const SingleActivator(LogicalKeyboardKey.keyQ): VoidCallbackIntent(() {}), + }, + child: const TextField( + decoration: InputDecoration( + label: Text('This field also considers key Q as a shortcut (that does nothing).'), + ), + ), + ), + ], + ), + ), + ); + } +} + +/// A node used by [FallbackKeyEventRegistrar] to register fallback key handlers. +/// +/// This class must not be replaced by bare [KeyEventCallback] because Dart +/// does not allow comparing with `==` on anonymous functions (always returns +/// false.) +class FallbackFocusNode { + FallbackFocusNode({required this.onKeyEvent}); + + final KeyEventCallback onKeyEvent; +} + +/// A singleton class that allows [FallbackFocus] to register fallback key +/// event handlers. +/// +/// This class is initialized when [instance] is first called, at which time it +/// patches [KeyEventManager.keyMessageHandler] with its own handler. +/// +/// A global registrar like [FallbackKeyEventRegistrar] is almost always needed +/// when patching [KeyEventManager.keyMessageHandler]. This is because +/// [FallbackFocus] will add and remove callbacks constantly, but +/// [KeyEventManager.keyMessageHandler] can only be patched once, and can not +/// be unpatched. Therefore [FallbackFocus] must not directly interact with +/// [KeyEventManager.keyMessageHandler], but through a separate registrar that +/// handles listening reversibly. +class FallbackKeyEventRegistrar { + FallbackKeyEventRegistrar._(); + static FallbackKeyEventRegistrar get instance { + if (!_initialized) { + // Get the global handler. + final KeyMessageHandler? existing = ServicesBinding.instance.keyEventManager.keyMessageHandler; + // The handler is guaranteed non-null since + // `FallbackKeyEventRegistrar.instance` is only called during + // `Focus.onFocusChange`, at which time `ServicesBinding.instance` must + // have been called somewhere. + assert(existing != null); + // Assign the global handler with a patched handler. + ServicesBinding.instance.keyEventManager.keyMessageHandler = _instance._buildHandler(existing!); + _initialized = true; + } + return _instance; + } + + static bool _initialized = false; + static final FallbackKeyEventRegistrar _instance = FallbackKeyEventRegistrar._(); + + final List _fallbackNodes = []; + + // Returns a handler that patches the existing `KeyEventManager.keyMessageHandler`. + // + // The existing `KeyEventManager.keyMessageHandler` is typically the one + // assigned by the shortcut system, but it can be anything. The returned + // handler calls that handler first, and if the event is not handled at all + // by the framework, invokes the innermost `FallbackNode`'s handler. + KeyMessageHandler _buildHandler(KeyMessageHandler existing) { + return (KeyMessage message) { + if (existing(message)) { + return true; + } + if (_fallbackNodes.isNotEmpty) { + for (final KeyEvent event in message.events) { + if (_fallbackNodes.last.onKeyEvent(event)) { + return true; + } + } + } + return false; + }; + } +} + +/// A widget that, when focused, handles key events only if no other handlers +/// do. +/// +/// If a [FallbackFocus] is being focused on, then key events that are not +/// handled by other handlers will be dispatched to the `onKeyEvent` of [node]. +/// If `onKeyEvent` returns true, this event is considered "handled" and will +/// not move forward with the text input system. +/// +/// If multiple [FallbackFocus] nest, then only the innermost takes effect. +/// +/// Internally, this class registers its node to the singleton +/// [FallbackKeyEventRegistrar]. The inner this widget is, the later its node +/// will be added to the registrar's list when focused on. +class FallbackFocus extends StatelessWidget { + const FallbackFocus({ + super.key, + required this.node, + required this.child, + }); + + final Widget child; + final FallbackFocusNode node; + + void _onFocusChange(bool focused) { + if (focused) { + FallbackKeyEventRegistrar.instance._fallbackNodes.add(node); + } else { + assert(FallbackKeyEventRegistrar.instance._fallbackNodes.last == node); + FallbackKeyEventRegistrar.instance._fallbackNodes.removeLast(); + } + } + + @override + Widget build(BuildContext context) { + return Focus( + onFocusChange: _onFocusChange, + child: child, + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/heroes/hero.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/heroes/hero.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..2c6772ee288d102cd886cca103ed7c96b856754e --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/heroes/hero.0.dart @@ -0,0 +1,78 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Hero]. + +void main() => runApp(const HeroApp()); + +class HeroApp extends StatelessWidget { + const HeroApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: HeroExample(), + ); + } +} + +class HeroExample extends StatelessWidget { + const HeroExample({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: const Text('Hero Sample')), + body: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const SizedBox(height: 20.0), + ListTile( + leading: const Hero( + tag: 'hero-rectangle', + child: BoxWidget(size: Size(50.0, 50.0)), + ), + onTap: () => _gotoDetailsPage(context), + title: const Text( + 'Tap on the icon to view hero animation transition.', + ), + ), + ], + ), + ); + } + + void _gotoDetailsPage(BuildContext context) { + Navigator.of(context).push(MaterialPageRoute( + builder: (BuildContext context) => Scaffold( + appBar: AppBar( + title: const Text('Second Page'), + ), + body: const Center( + child: Hero( + tag: 'hero-rectangle', + child: BoxWidget(size: Size(200.0, 200.0)), + ), + ), + ), + )); + } +} + +class BoxWidget extends StatelessWidget { + const BoxWidget({super.key, required this.size}); + + final Size size; + + @override + Widget build(BuildContext context) { + return Container( + width: size.width, + height: size.height, + color: Colors.blue, + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/heroes/hero.1.dart b/novelforge-project/flutter/examples/api/lib/widgets/heroes/hero.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..63d6931c38c3653d02df20450a24840ac01c5dd0 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/heroes/hero.1.dart @@ -0,0 +1,128 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/scheduler.dart'; + +/// Flutter code sample for [Hero]. + +void main() { + // Slow down time to see Hero flight animation. + timeDilation = 15.0; + runApp(const HeroApp()); +} + +class HeroApp extends StatelessWidget { + const HeroApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData(useMaterial3: true), + home: const HeroExample(), + ); + } +} + +class HeroExample extends StatelessWidget { + const HeroExample({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: const Text('Hero Sample')), + body: Column( + children: [ + ListTile( + leading: Hero( + tag: 'hero-default-tween', + child: BoxWidget( + size: const Size(50.0, 50.0), + color: Colors.red[700]!.withOpacity(0.5), + ), + ), + title: const Text( + 'This red icon will use a default rect tween during the hero flight.', + ), + ), + const SizedBox(height: 10.0), + ListTile( + leading: Hero( + tag: 'hero-custom-tween', + createRectTween: (Rect? begin, Rect? end) { + return MaterialRectCenterArcTween(begin: begin, end: end); + }, + child: BoxWidget( + size: const Size(50.0, 50.0), + color: Colors.blue[700]!.withOpacity(0.5), + ), + ), + title: const Text( + 'This blue icon will use a custom rect tween during the hero flight.', + ), + ), + const SizedBox(height: 10), + ElevatedButton( + onPressed: () => _gotoDetailsPage(context), + child: const Text('Tap to trigger hero flight'), + ), + ], + ), + ); + } + + void _gotoDetailsPage(BuildContext context) { + Navigator.of(context).push(MaterialPageRoute( + builder: (BuildContext context) => Scaffold( + appBar: AppBar( + title: const Text('Second Page'), + ), + body: Align( + alignment: Alignment.bottomRight, + child: Stack( + children: [ + Hero( + tag: 'hero-custom-tween', + createRectTween: (Rect? begin, Rect? end) { + return MaterialRectCenterArcTween(begin: begin, end: end); + }, + child: BoxWidget( + size: const Size(400.0, 400.0), + color: Colors.blue[700]!.withOpacity(0.5), + ), + ), + Hero( + tag: 'hero-default-tween', + child: BoxWidget( + size: const Size(400.0, 400.0), + color: Colors.red[700]!.withOpacity(0.5), + ), + ), + ], + ), + ), + ), + )); + } +} + +class BoxWidget extends StatelessWidget { + const BoxWidget({ + super.key, + required this.size, + required this.color, + }); + + final Size size; + final Color color; + + @override + Widget build(BuildContext context) { + return Container( + width: size.width, + height: size.height, + color: color, + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/image/image.error_builder.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/image/image.error_builder.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..e076c45b8f6a28e8d24424eea8cefa7776d2a1c2 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/image/image.error_builder.0.dart @@ -0,0 +1,51 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Image.errorBuilder]. + +void main() => runApp(const ErrorBuilderExampleApp()); + +class ErrorBuilderExampleApp extends StatelessWidget { + const ErrorBuilderExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: Scaffold( + body: Center( + child: ErrorBuilderExample(), + ), + ), + ); + } +} + +class ErrorBuilderExample extends StatelessWidget { + const ErrorBuilderExample({super.key}); + + @override + Widget build(BuildContext context) { + return DecoratedBox( + decoration: BoxDecoration( + color: Colors.white, + border: Border.all(), + borderRadius: BorderRadius.circular(20), + ), + child: Image.network( + 'https://example.does.not.exist/image.jpg', + errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) { + // Appropriate logging or analytics, e.g. + // myAnalytics.recordError( + // 'An error occurred loading "https://example.does.not.exist/image.jpg"', + // exception, + // stackTrace, + // ); + return const Text('😢'); + }, + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/image/image.frame_builder.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/image/image.frame_builder.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..809fd6319e1ef6273d281b8f6fba77fbf2d59d02 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/image/image.frame_builder.0.dart @@ -0,0 +1,50 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Image.frameBuilder]. + +void main() => runApp(const FrameBuilderExampleApp()); + +class FrameBuilderExampleApp extends StatelessWidget { + const FrameBuilderExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: FrameBuilderExample(), + ); + } +} + +class FrameBuilderExample extends StatelessWidget { + const FrameBuilderExample({super.key}); + + @override + @override + Widget build(BuildContext context) { + return DecoratedBox( + decoration: BoxDecoration( + color: Colors.white, + border: Border.all(), + borderRadius: BorderRadius.circular(20), + ), + child: Image.network( + 'https://flutter.github.io/assets-for-api-docs/assets/widgets/puffin.jpg', + frameBuilder: (BuildContext context, Widget child, int? frame, bool wasSynchronouslyLoaded) { + if (wasSynchronouslyLoaded) { + return child; + } + return AnimatedOpacity( + opacity: frame == null ? 0 : 1, + duration: const Duration(seconds: 1), + curve: Curves.easeOut, + child: child, + ); + }, + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/image/image.loading_builder.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/image/image.loading_builder.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..3005bf0c0a8d737c6b7fa322db1cfa4e86ff3373 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/image/image.loading_builder.0.dart @@ -0,0 +1,50 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Image.loadingBuilder]. + +void main() => runApp(const LoadingBuilderExampleApp()); + +class LoadingBuilderExampleApp extends StatelessWidget { + const LoadingBuilderExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: LoadingBuilderExample(), + ); + } +} + +class LoadingBuilderExample extends StatelessWidget { + const LoadingBuilderExample({super.key}); + + @override + Widget build(BuildContext context) { + return DecoratedBox( + decoration: BoxDecoration( + color: Colors.white, + border: Border.all(), + borderRadius: BorderRadius.circular(20), + ), + child: Image.network( + 'https://flutter.github.io/assets-for-api-docs/assets/widgets/falcon.jpg', + loadingBuilder: (BuildContext context, Widget child, ImageChunkEvent? loadingProgress) { + if (loadingProgress == null) { + return child; + } + return Center( + child: CircularProgressIndicator( + value: loadingProgress.expectedTotalBytes != null + ? loadingProgress.cumulativeBytesLoaded / loadingProgress.expectedTotalBytes! + : null, + ), + ); + }, + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/implicit_animations/animated_align.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/implicit_animations/animated_align.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..6f73cf704bd37157a6c972568ca85d7bb350e4b0 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/implicit_animations/animated_align.0.dart @@ -0,0 +1,58 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [AnimatedAlign]. + +void main() => runApp(const AnimatedAlignExampleApp()); + +class AnimatedAlignExampleApp extends StatelessWidget { + const AnimatedAlignExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('AnimatedAlign Sample')), + body: const AnimatedAlignExample(), + ), + ); + } +} + +class AnimatedAlignExample extends StatefulWidget { + const AnimatedAlignExample({super.key}); + + @override + State createState() => _AnimatedAlignExampleState(); +} + +class _AnimatedAlignExampleState extends State { + bool selected = false; + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: () { + setState(() { + selected = !selected; + }); + }, + child: Center( + child: Container( + width: 250.0, + height: 250.0, + color: Colors.red, + child: AnimatedAlign( + alignment: selected ? Alignment.topRight : Alignment.bottomLeft, + duration: const Duration(seconds: 1), + curve: Curves.fastOutSlowIn, + child: const FlutterLogo(size: 50.0), + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/implicit_animations/animated_container.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/implicit_animations/animated_container.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..a9706e56e24c6a94404c16446fb41190da56c8a2 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/implicit_animations/animated_container.0.dart @@ -0,0 +1,56 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [AnimatedContainer]. + +void main() => runApp(const AnimatedContainerExampleApp()); + +class AnimatedContainerExampleApp extends StatelessWidget { + const AnimatedContainerExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('AnimatedContainer Sample')), + body: const AnimatedContainerExample(), + ), + ); + } +} + +class AnimatedContainerExample extends StatefulWidget { + const AnimatedContainerExample({super.key}); + + @override + State createState() => _AnimatedContainerExampleState(); +} + +class _AnimatedContainerExampleState extends State { + bool selected = false; + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: () { + setState(() { + selected = !selected; + }); + }, + child: Center( + child: AnimatedContainer( + width: selected ? 200.0 : 100.0, + height: selected ? 100.0 : 200.0, + color: selected ? Colors.red : Colors.blue, + alignment: selected ? Alignment.center : AlignmentDirectional.topCenter, + duration: const Duration(seconds: 2), + curve: Curves.fastOutSlowIn, + child: const FlutterLogo(size: 75), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/implicit_animations/animated_fractionally_sized_box.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/implicit_animations/animated_fractionally_sized_box.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..8efa5163188b87ecfe72662ac795f68b40df45e8 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/implicit_animations/animated_fractionally_sized_box.0.dart @@ -0,0 +1,65 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [AnimatedFractionallySizedBox]. + +void main() => runApp(const AnimatedFractionallySizedBoxExampleApp()); + +class AnimatedFractionallySizedBoxExampleApp extends StatelessWidget { + const AnimatedFractionallySizedBoxExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('AnimatedFractionallySizedBox Sample')), + body: const AnimatedFractionallySizedBoxExample(), + ), + ); + } +} + +class AnimatedFractionallySizedBoxExample extends StatefulWidget { + const AnimatedFractionallySizedBoxExample({super.key}); + + @override + State createState() => _AnimatedFractionallySizedBoxExampleState(); +} + +class _AnimatedFractionallySizedBoxExampleState extends State { + bool selected = false; + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: () { + setState(() { + selected = !selected; + }); + }, + child: Center( + child: SizedBox( + width: 200, + height: 200, + child: ColoredBox( + color: Colors.red, + child: AnimatedFractionallySizedBox( + widthFactor: selected ? 0.25 : 0.75, + heightFactor: selected ? 0.75 : 0.25, + alignment: selected ? Alignment.topLeft : Alignment.bottomRight, + duration: const Duration(seconds: 1), + curve: Curves.fastOutSlowIn, + child: const ColoredBox( + color: Colors.blue, + child: FlutterLogo(size: 75), + ), + ), + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/implicit_animations/animated_padding.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/implicit_animations/animated_padding.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..eebf76e0650bd45dfe4587173eff2136e7d92c2f --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/implicit_animations/animated_padding.0.dart @@ -0,0 +1,64 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [AnimatedPadding]. + +void main() => runApp(const AnimatedPaddingExampleApp()); + +class AnimatedPaddingExampleApp extends StatelessWidget { + const AnimatedPaddingExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('AnimatedPadding Sample')), + body: const AnimatedPaddingExample(), + ), + ); + } +} + +class AnimatedPaddingExample extends StatefulWidget { + const AnimatedPaddingExample({super.key}); + + @override + State createState() => _AnimatedPaddingExampleState(); +} + +class _AnimatedPaddingExampleState extends State { + double padValue = 0.0; + void _updatePadding(double value) { + setState(() { + padValue = value; + }); + } + + @override + Widget build(BuildContext context) { + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + AnimatedPadding( + padding: EdgeInsets.all(padValue), + duration: const Duration(seconds: 2), + curve: Curves.easeInOut, + child: Container( + width: MediaQuery.of(context).size.width, + height: MediaQuery.of(context).size.height / 5, + color: Colors.blue, + ), + ), + Text('Padding: $padValue'), + ElevatedButton( + child: const Text('Change padding'), + onPressed: () { + _updatePadding(padValue == 0.0 ? 100.0 : 0.0); + }), + ], + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/implicit_animations/animated_positioned.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/implicit_animations/animated_positioned.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..bc0a2948cb3c69841d8c5b16ec5297b80aaa5f18 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/implicit_animations/animated_positioned.0.dart @@ -0,0 +1,66 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [AnimatedPositioned]. + +void main() => runApp(const AnimatedPositionedExampleApp()); + +class AnimatedPositionedExampleApp extends StatelessWidget { + const AnimatedPositionedExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('AnimatedPositioned Sample')), + body: const Center( + child: AnimatedPositionedExample(), + ), + ), + ); + } +} + +class AnimatedPositionedExample extends StatefulWidget { + const AnimatedPositionedExample({super.key}); + + @override + State createState() => _AnimatedPositionedExampleState(); +} + +class _AnimatedPositionedExampleState extends State { + bool selected = false; + + @override + Widget build(BuildContext context) { + return SizedBox( + width: 200, + height: 350, + child: Stack( + children: [ + AnimatedPositioned( + width: selected ? 200.0 : 50.0, + height: selected ? 50.0 : 200.0, + top: selected ? 50.0 : 150.0, + duration: const Duration(seconds: 2), + curve: Curves.fastOutSlowIn, + child: GestureDetector( + onTap: () { + setState(() { + selected = !selected; + }); + }, + child: const ColoredBox( + color: Colors.blue, + child: Center(child: Text('Tap me')), + ), + ), + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/implicit_animations/animated_slide.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/implicit_animations/animated_slide.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..968955d154c9cd95bd4c0d7b44a0b9f6c8c89ca0 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/implicit_animations/animated_slide.0.dart @@ -0,0 +1,106 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [AnimatedSlide]. + +void main() => runApp(const AnimatedSlideApp()); + +class AnimatedSlideApp extends StatelessWidget { + const AnimatedSlideApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData(useMaterial3: true), + home: const AnimatedSlideExample(), + ); + } +} + +class AnimatedSlideExample extends StatefulWidget { + const AnimatedSlideExample({super.key}); + + @override + State createState() => _AnimatedSlideExampleState(); +} + +class _AnimatedSlideExampleState extends State { + Offset offset = Offset.zero; + + @override + Widget build(BuildContext context) { + final TextTheme textTheme = Theme.of(context).textTheme; + + return Scaffold( + appBar: AppBar(title: const Text('AnimatedSlide Sample')), + body: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Expanded( + child: Row( + children: [ + Expanded( + child: Container( + alignment: Alignment.center, + padding: const EdgeInsets.all(50.0), + child: AnimatedSlide( + offset: offset, + duration: const Duration(milliseconds: 500), + curve: Curves.easeInOut, + child: const FlutterLogo(size: 50.0), + ), + ), + ), + Column( + children: [ + Text('Y', style: textTheme.bodyMedium), + Expanded( + child: RotatedBox( + quarterTurns: 1, + child: Slider( + min: -5.0, + max: 5.0, + value: offset.dy, + onChanged: (double value) { + setState(() { + offset = Offset(offset.dx, value); + }); + }, + ), + ), + ), + ], + ), + ], + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Text('X', style: textTheme.bodyMedium), + Expanded( + child: Slider( + min: -5.0, + max: 5.0, + value: offset.dx, + onChanged: (double value) { + setState(() { + offset = Offset(value, offset.dy); + }); + }, + ), + ), + const SizedBox(width: 48.0), + ], + ), + ], + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/implicit_animations/sliver_animated_opacity.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/implicit_animations/sliver_animated_opacity.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..35df561f66284dd93f309cf8abe3c45586cf54a2 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/implicit_animations/sliver_animated_opacity.0.dart @@ -0,0 +1,68 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [SliverAnimatedOpacity]. + +void main() => runApp(const SliverAnimatedOpacityExampleApp()); + +class SliverAnimatedOpacityExampleApp extends StatelessWidget { + const SliverAnimatedOpacityExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('SliverAnimatedOpacity Sample')), + body: const Center( + child: SliverAnimatedOpacityExample(), + ), + ), + ); + } +} + +class SliverAnimatedOpacityExample extends StatefulWidget { + const SliverAnimatedOpacityExample({super.key}); + + @override + State createState() => _SliverAnimatedOpacityExampleState(); +} + +class _SliverAnimatedOpacityExampleState extends State + with SingleTickerProviderStateMixin { + bool _visible = true; + + @override + Widget build(BuildContext context) { + return CustomScrollView(slivers: [ + SliverAnimatedOpacity( + opacity: _visible ? 1.0 : 0.0, + duration: const Duration(milliseconds: 500), + sliver: SliverFixedExtentList( + itemExtent: 100.0, + delegate: SliverChildBuilderDelegate( + (BuildContext context, int index) { + return Container( + color: index.isEven ? Colors.indigo[200] : Colors.orange[200], + ); + }, + childCount: 5, + ), + ), + ), + SliverToBoxAdapter( + child: FloatingActionButton( + onPressed: () { + setState(() { + _visible = !_visible; + }); + }, + tooltip: 'Toggle opacity', + child: const Icon(Icons.flip), + )), + ]); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/inherited_model/inherited_model.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/inherited_model/inherited_model.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..dcc92ae477360fb41a3a597c81532ba277a8ea1a --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/inherited_model/inherited_model.0.dart @@ -0,0 +1,164 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [InheritedModel]. + +enum LogoAspect { backgroundColor, large } + +void main() => runApp(const InheritedModelApp()); + +class InheritedModelApp extends StatelessWidget { + const InheritedModelApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: InheritedModelExample(), + ); + } +} + +class LogoModel extends InheritedModel { + const LogoModel({ + super.key, + this.backgroundColor, + this.large, + required super.child, + }); + + final Color? backgroundColor; + final bool? large; + + static Color? backgroundColorOf(BuildContext context) { + return InheritedModel.inheritFrom(context, aspect: LogoAspect.backgroundColor)?.backgroundColor; + } + + static bool sizeOf(BuildContext context) { + return InheritedModel.inheritFrom(context, aspect: LogoAspect.large)?.large ?? false; + } + + @override + bool updateShouldNotify(LogoModel oldWidget) { + return backgroundColor != oldWidget.backgroundColor || large != oldWidget.large; + } + + @override + bool updateShouldNotifyDependent(LogoModel oldWidget, Set dependencies) { + if (backgroundColor != oldWidget.backgroundColor && dependencies.contains(LogoAspect.backgroundColor)) { + return true; + } + if (large != oldWidget.large && dependencies.contains(LogoAspect.large)) { + return true; + } + return false; + } +} + +class InheritedModelExample extends StatefulWidget { + const InheritedModelExample({super.key}); + + @override + State createState() => _InheritedModelExampleState(); +} + +class _InheritedModelExampleState extends State { + bool large = false; + Color color = Colors.blue; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: const Text('InheritedModel Sample')), + body: Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Center( + child: LogoModel( + backgroundColor: color, + large: large, + child: const BackgroundWidget( + child: LogoWidget(), + ), + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + ElevatedButton( + onPressed: () { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text('Rebuilt Background'), + duration: Duration(milliseconds: 500), + ), + ); + setState(() { + if (color == Colors.blue) { + color = Colors.red; + } else { + color = Colors.blue; + } + }); + }, + child: const Text('Update background'), + ), + ElevatedButton( + onPressed: () { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text('Rebuilt LogoWidget'), + duration: Duration(milliseconds: 500), + ), + ); + setState(() { + large = !large; + }); + }, + child: const Text('Resize Logo'), + ), + ], + ) + ], + ), + ); + } +} + +class BackgroundWidget extends StatelessWidget { + const BackgroundWidget({super.key, required this.child}); + + final Widget child; + + @override + Widget build(BuildContext context) { + final Color color = LogoModel.backgroundColorOf(context)!; + + return AnimatedContainer( + padding: const EdgeInsets.all(12.0), + color: color, + duration: const Duration(seconds: 2), + curve: Curves.fastOutSlowIn, + child: child, + ); + } +} + +class LogoWidget extends StatelessWidget { + const LogoWidget({super.key}); + + @override + Widget build(BuildContext context) { + final bool largeLogo = LogoModel.sizeOf(context); + + return AnimatedContainer( + padding: const EdgeInsets.all(20.0), + duration: const Duration(seconds: 2), + curve: Curves.fastLinearToSlowEaseIn, + alignment: Alignment.center, + child: FlutterLogo(size: largeLogo ? 200.0 : 100.0), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/inherited_notifier/inherited_notifier.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/inherited_notifier/inherited_notifier.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..938ac06dc2c8260345a96ed3c81fbe2ee5aeb381 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/inherited_notifier/inherited_notifier.0.dart @@ -0,0 +1,96 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:math' as math; + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [InheritedNotifier]. + +void main() => runApp(const InheritedNotifierExampleApp()); + +class InheritedNotifierExampleApp extends StatelessWidget { + const InheritedNotifierExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: InheritedNotifierExample(), + ); + } +} + +class SpinModel extends InheritedNotifier { + const SpinModel({ + super.key, + super.notifier, + required super.child, + }); + + static double of(BuildContext context) { + return context.dependOnInheritedWidgetOfExactType()!.notifier!.value; + } +} + +class Spinner extends StatelessWidget { + const Spinner({super.key}); + + @override + Widget build(BuildContext context) { + return Transform.rotate( + angle: SpinModel.of(context) * 2.0 * math.pi, + child: Container( + width: 100, + height: 100, + color: Colors.green, + child: const Center( + child: Text('Whee!'), + ), + ), + ); + } +} + +class InheritedNotifierExample extends StatefulWidget { + const InheritedNotifierExample({super.key}); + + @override + State createState() => _InheritedNotifierExampleState(); +} + +/// [AnimationController]s can be created with `vsync: this` because of +/// [TickerProviderStateMixin]. +class _InheritedNotifierExampleState extends State with TickerProviderStateMixin { + late AnimationController _controller; + + @override + void initState() { + super.initState(); + _controller = AnimationController( + duration: const Duration(seconds: 10), + vsync: this, + )..repeat(); + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return SpinModel( + notifier: _controller, + child: const Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Spinner(), + Spinner(), + Spinner(), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/inherited_theme/inherited_theme.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/inherited_theme/inherited_theme.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..6786db11b70d840c9b20fe9614bd1ce88c4f3de9 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/inherited_theme/inherited_theme.0.dart @@ -0,0 +1,66 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [InheritedTheme]. + +void main() { + runApp(const InheritedThemeExampleApp()); +} + +class MyAppBody extends StatelessWidget { + const MyAppBody({super.key}); + + @override + Widget build(BuildContext context) { + final NavigatorState navigator = Navigator.of(context); + // This InheritedTheme.capture() saves references to themes that are + // found above the context provided to this widget's build method + // excluding themes are found above the navigator. Those themes do + // not have to be captured, because they will already be visible from + // the new route pushed onto said navigator. + // Themes are captured outside of the route's builder because when the + // builder executes, the context may not be valid anymore. + final CapturedThemes themes = InheritedTheme.capture(from: context, to: navigator.context); + return GestureDetector( + onTap: () { + Navigator.of(context).push( + MaterialPageRoute( + builder: (BuildContext _) { + // Wrap the actual child of the route in the previously + // captured themes. + return themes.wrap( + Container( + alignment: Alignment.center, + color: Colors.white, + child: const Text('Hello World'), + ), + ); + }, + ), + ); + }, + child: const Center(child: Text('Tap Here')), + ); + } +} + +class InheritedThemeExampleApp extends StatelessWidget { + const InheritedThemeExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: Scaffold( + // Override the DefaultTextStyle defined by the Scaffold. + // Descendant widgets will inherit this big blue text style. + body: DefaultTextStyle( + style: TextStyle(fontSize: 48, color: Colors.blue), + child: MyAppBody(), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/interactive_viewer/interactive_viewer.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/interactive_viewer/interactive_viewer.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..eaae7baa4eeffd935fd8b31aa5083a748debe359 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/interactive_viewer/interactive_viewer.0.dart @@ -0,0 +1,48 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [InteractiveViewer]. + +void main() => runApp(const InteractiveViewerExampleApp()); + +class InteractiveViewerExampleApp extends StatelessWidget { + const InteractiveViewerExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('InteractiveViewer Sample')), + body: const InteractiveViewerExample(), + ), + ); + } +} + +class InteractiveViewerExample extends StatelessWidget { + const InteractiveViewerExample({super.key}); + + @override + Widget build(BuildContext context) { + return Center( + child: InteractiveViewer( + boundaryMargin: const EdgeInsets.all(20.0), + minScale: 0.1, + maxScale: 1.6, + child: Container( + decoration: const BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [Colors.orange, Colors.red], + stops: [0.0, 1.0], + ), + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/interactive_viewer/interactive_viewer.builder.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/interactive_viewer/interactive_viewer.builder.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..b2f05d9c90852f58969c2b2574ac784f10bdd8c7 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/interactive_viewer/interactive_viewer.builder.0.dart @@ -0,0 +1,142 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:vector_math/vector_math_64.dart' show Quad, Vector3; + +/// Flutter code sample for [InteractiveViewer.builder]. + +void main() => runApp(const IVBuilderExampleApp()); + +class IVBuilderExampleApp extends StatelessWidget { + const IVBuilderExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('IV Builder Example'), + ), + body: const _IVBuilderExample(), + ), + ); + } +} + +class _IVBuilderExample extends StatefulWidget { + const _IVBuilderExample(); + + @override + State<_IVBuilderExample> createState() => _IVBuilderExampleState(); +} + +class _IVBuilderExampleState extends State<_IVBuilderExample> { + static const double _cellWidth = 160.0; + static const double _cellHeight = 80.0; + + // Returns the axis aligned bounding box for the given Quad, which might not + // be axis aligned. + Rect axisAlignedBoundingBox(Quad quad) { + double xMin = quad.point0.x; + double xMax = quad.point0.x; + double yMin = quad.point0.y; + double yMax = quad.point0.y; + for (final Vector3 point in [ + quad.point1, + quad.point2, + quad.point3, + ]) { + if (point.x < xMin) { + xMin = point.x; + } else if (point.x > xMax) { + xMax = point.x; + } + + if (point.y < yMin) { + yMin = point.y; + } else if (point.y > yMax) { + yMax = point.y; + } + } + + return Rect.fromLTRB(xMin, yMin, xMax, yMax); + } + + @override + Widget build(BuildContext context) { + return Center( + child: LayoutBuilder( + builder: (BuildContext context, BoxConstraints constraints) { + return InteractiveViewer.builder( + boundaryMargin: const EdgeInsets.all(double.infinity), + builder: (BuildContext context, Quad viewport) { + return _TableBuilder( + cellWidth: _cellWidth, + cellHeight: _cellHeight, + viewport: axisAlignedBoundingBox(viewport), + builder: (BuildContext context, int row, int column) { + return Container( + height: _cellHeight, + width: _cellWidth, + color: row % 2 + column % 2 == 1 ? Colors.white : Colors.grey.withOpacity(0.1), + child: Align( + child: Text('$row x $column'), + ), + ); + }, + ); + }, + ); + }, + ), + ); + } +} + +typedef _CellBuilder = Widget Function(BuildContext context, int row, int column); + +class _TableBuilder extends StatelessWidget { + const _TableBuilder({ + required this.cellWidth, + required this.cellHeight, + required this.viewport, + required this.builder, + }); + + final double cellWidth; + final double cellHeight; + final Rect viewport; + final _CellBuilder builder; + + @override + Widget build(BuildContext context) { + final int firstRow = (viewport.top / cellHeight).floor(); + final int lastRow = (viewport.bottom / cellHeight).ceil(); + final int firstCol = (viewport.left / cellWidth).floor(); + final int lastCol = (viewport.right / cellWidth).ceil(); + + // This will create and render exactly (lastRow - firstRow) * (lastCol - firstCol) cells + + return SizedBox( + // Stack needs constraints, even though we then Clip.none outside of them. + // InteractiveViewer.builder always sets constrained to false, giving infinite constraints to the child. + // See: https://api.flutter.dev/flutter/widgets/InteractiveViewer/constrained.html + width: 1, + height: 1, + child: Stack( + clipBehavior: Clip.none, + children: [ + for (int row = firstRow; row < lastRow; row++) + for (int col = firstCol; col < lastCol; col++) + Positioned( + left: col * cellWidth, + top: row * cellHeight, + child: builder(context, row, col), + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/interactive_viewer/interactive_viewer.constrained.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/interactive_viewer/interactive_viewer.constrained.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..be4aa440872522e6234a17cbef94549ca0e34219 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/interactive_viewer/interactive_viewer.constrained.0.dart @@ -0,0 +1,60 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [InteractiveViewer.constrained]. + +void main() => runApp(const ConstrainedExampleApp()); + +class ConstrainedExampleApp extends StatelessWidget { + const ConstrainedExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('Constrained Sample')), + body: const ConstrainedExample(), + ), + ); + } +} + +class ConstrainedExample extends StatelessWidget { + const ConstrainedExample({super.key}); + + @override + Widget build(BuildContext context) { + const int rowCount = 48; + const int columnCount = 6; + + return InteractiveViewer( + panAxis: PanAxis.aligned, + constrained: false, + scaleEnabled: false, + child: Table( + columnWidths: { + for (int column = 0; column < columnCount; column += 1) column: const FixedColumnWidth(200.0), + }, + children: [ + for (int row = 0; row < rowCount; row += 1) + TableRow( + children: [ + for (int column = 0; column < columnCount; column += 1) + Container( + height: 26, + color: row % 2 + column % 2 == 1 ? Colors.white : Colors.grey.withOpacity(0.1), + child: Align( + alignment: Alignment.centerLeft, + child: Text('$row x $column'), + ), + ), + ], + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/interactive_viewer/interactive_viewer.transformation_controller.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/interactive_viewer/interactive_viewer.transformation_controller.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..135f72e46ab1fa06ff68530e6b0e27d4aa489bcf --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/interactive_viewer/interactive_viewer.transformation_controller.0.dart @@ -0,0 +1,124 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [InteractiveViewer.transformationController]. + +void main() => runApp(const TransformationControllerExampleApp()); + +class TransformationControllerExampleApp extends StatelessWidget { + const TransformationControllerExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: TransformationControllerExample(), + ); + } +} + +class TransformationControllerExample extends StatefulWidget { + const TransformationControllerExample({super.key}); + + @override + State createState() => _TransformationControllerExampleState(); +} + +/// [AnimationController]s can be created with `vsync: this` because of +/// [TickerProviderStateMixin]. +class _TransformationControllerExampleState extends State + with TickerProviderStateMixin { + final TransformationController _transformationController = TransformationController(); + Animation? _animationReset; + late final AnimationController _controllerReset; + + void _onAnimateReset() { + _transformationController.value = _animationReset!.value; + if (!_controllerReset.isAnimating) { + _animationReset!.removeListener(_onAnimateReset); + _animationReset = null; + _controllerReset.reset(); + } + } + + void _animateResetInitialize() { + _controllerReset.reset(); + _animationReset = Matrix4Tween( + begin: _transformationController.value, + end: Matrix4.identity(), + ).animate(_controllerReset); + _animationReset!.addListener(_onAnimateReset); + _controllerReset.forward(); + } + +// Stop a running reset to home transform animation. + void _animateResetStop() { + _controllerReset.stop(); + _animationReset?.removeListener(_onAnimateReset); + _animationReset = null; + _controllerReset.reset(); + } + + void _onInteractionStart(ScaleStartDetails details) { + // If the user tries to cause a transformation while the reset animation is + // running, cancel the reset animation. + if (_controllerReset.status == AnimationStatus.forward) { + _animateResetStop(); + } + } + + @override + void initState() { + super.initState(); + _controllerReset = AnimationController( + vsync: this, + duration: const Duration(milliseconds: 400), + ); + } + + @override + void dispose() { + _controllerReset.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Theme.of(context).colorScheme.primary, + appBar: AppBar( + automaticallyImplyLeading: false, + title: const Text('Controller demo'), + ), + body: Center( + child: InteractiveViewer( + boundaryMargin: const EdgeInsets.all(double.infinity), + transformationController: _transformationController, + minScale: 0.1, + maxScale: 1.0, + onInteractionStart: _onInteractionStart, + child: Container( + decoration: const BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [Colors.orange, Colors.red], + stops: [0.0, 1.0], + ), + ), + ), + ), + ), + persistentFooterButtons: [ + IconButton( + onPressed: _animateResetInitialize, + tooltip: 'Reset', + color: Theme.of(context).colorScheme.surface, + icon: const Icon(Icons.replay), + ), + ], + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/layout_builder/layout_builder.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/layout_builder/layout_builder.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..b0254f7ed18bbf3d209127ac89402d3da8e54863 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/layout_builder/layout_builder.0.dart @@ -0,0 +1,70 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [LayoutBuilder]. + +void main() => runApp(const LayoutBuilderExampleApp()); + +class LayoutBuilderExampleApp extends StatelessWidget { + const LayoutBuilderExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: LayoutBuilderExample(), + ); + } +} + +class LayoutBuilderExample extends StatelessWidget { + const LayoutBuilderExample({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: const Text('LayoutBuilder Example')), + body: LayoutBuilder( + builder: (BuildContext context, BoxConstraints constraints) { + if (constraints.maxWidth > 600) { + return _buildWideContainers(); + } else { + return _buildNormalContainer(); + } + }, + ), + ); + } + + Widget _buildNormalContainer() { + return Center( + child: Container( + height: 100.0, + width: 100.0, + color: Colors.red, + ), + ); + } + + Widget _buildWideContainers() { + return Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Container( + height: 100.0, + width: 100.0, + color: Colors.red, + ), + Container( + height: 100.0, + width: 100.0, + color: Colors.yellow, + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/magnifier/magnifier.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/magnifier/magnifier.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..323cca9fb377a1de4098ec374f42fcf90e62b892 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/magnifier/magnifier.0.dart @@ -0,0 +1,61 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +void main() => runApp(const MagnifierExampleApp()); + +class MagnifierExampleApp extends StatefulWidget { + const MagnifierExampleApp({super.key}); + + @override + State createState() => _MagnifierExampleAppState(); +} + +class _MagnifierExampleAppState extends State { + Offset dragGesturePosition = Offset.zero; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text('Drag on the logo!'), + RepaintBoundary( + child: Stack( + children: [ + GestureDetector( + onPanUpdate: (DragUpdateDetails details) => setState( + () { + dragGesturePosition = details.localPosition; + }, + ), + child: const FlutterLogo(size: 200), + ), + Positioned( + left: dragGesturePosition.dx, + top: dragGesturePosition.dy, + child: const RawMagnifier( + decoration: MagnifierDecoration( + shape: CircleBorder( + side: BorderSide(color: Colors.pink, width: 3), + ), + ), + size: Size(100, 100), + magnificationScale: 2, + ), + ) + ], + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/media_query/media_query_data.system_gesture_insets.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/media_query/media_query_data.system_gesture_insets.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..d41df331a9703a0c86499f1c05a36d89a028fc62 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/media_query/media_query_data.system_gesture_insets.0.dart @@ -0,0 +1,54 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [MediaQueryData.systemGestureInsets]. + +void main() => runApp(const SystemGestureInsetsExampleApp()); + +class SystemGestureInsetsExampleApp extends StatelessWidget { + const SystemGestureInsetsExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: SystemGestureInsetsExample(), + ); + } +} + +class SystemGestureInsetsExample extends StatefulWidget { + const SystemGestureInsetsExample({super.key}); + + @override + State createState() => _SystemGestureInsetsExampleState(); +} + +class _SystemGestureInsetsExampleState extends State { + double _currentValue = 0.2; + + @override + Widget build(BuildContext context) { + final EdgeInsets systemGestureInsets = MediaQuery.of(context).systemGestureInsets; + return Scaffold( + appBar: AppBar(title: const Text('Pad Slider to avoid systemGestureInsets')), + body: Padding( + padding: EdgeInsets.only( + // only left and right padding are needed here + left: systemGestureInsets.left, + right: systemGestureInsets.right, + ), + child: Slider( + value: _currentValue, + onChanged: (double newValue) { + setState(() { + _currentValue = newValue; + }); + }, + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/navigator/navigator.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/navigator/navigator.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..0f19ecb92e56bcccbc468b38d7dec3b0f6e03895 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/navigator/navigator.0.dart @@ -0,0 +1,126 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Navigator]. + +void main() => runApp(const NavigatorExampleApp()); + +class NavigatorExampleApp extends StatelessWidget { + const NavigatorExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + // MaterialApp contains our top-level Navigator + initialRoute: '/', + routes: { + '/': (BuildContext context) => const HomePage(), + '/signup': (BuildContext context) => const SignUpPage(), + }, + ); + } +} + +class HomePage extends StatelessWidget { + const HomePage({super.key}); + + @override + Widget build(BuildContext context) { + return DefaultTextStyle( + style: Theme.of(context).textTheme.headlineMedium!, + child: Container( + color: Colors.white, + alignment: Alignment.center, + child: const Text('Home Page'), + ), + ); + } +} + +class CollectPersonalInfoPage extends StatelessWidget { + const CollectPersonalInfoPage({super.key}); + + @override + Widget build(BuildContext context) { + return DefaultTextStyle( + style: Theme.of(context).textTheme.headlineMedium!, + child: GestureDetector( + onTap: () { + // This moves from the personal info page to the credentials page, + // replacing this page with that one. + Navigator.of(context).pushReplacementNamed('signup/choose_credentials'); + }, + child: Container( + color: Colors.lightBlue, + alignment: Alignment.center, + child: const Text('Collect Personal Info Page'), + ), + ), + ); + } +} + +class ChooseCredentialsPage extends StatelessWidget { + const ChooseCredentialsPage({ + super.key, + required this.onSignupComplete, + }); + + final VoidCallback onSignupComplete; + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: onSignupComplete, + child: DefaultTextStyle( + style: Theme.of(context).textTheme.headlineMedium!, + child: Container( + color: Colors.pinkAccent, + alignment: Alignment.center, + child: const Text('Choose Credentials Page'), + ), + ), + ); + } +} + +class SignUpPage extends StatelessWidget { + const SignUpPage({super.key}); + + @override + Widget build(BuildContext context) { + // SignUpPage builds its own Navigator which ends up being a nested + // Navigator in our app. + return Navigator( + initialRoute: 'signup/personal_info', + onGenerateRoute: (RouteSettings settings) { + WidgetBuilder builder; + switch (settings.name) { + case 'signup/personal_info': + // Assume CollectPersonalInfoPage collects personal info and then + // navigates to 'signup/choose_credentials'. + builder = (BuildContext context) => const CollectPersonalInfoPage(); + case 'signup/choose_credentials': + // Assume ChooseCredentialsPage collects new credentials and then + // invokes 'onSignupComplete()'. + builder = (BuildContext _) => ChooseCredentialsPage( + onSignupComplete: () { + // Referencing Navigator.of(context) from here refers to the + // top level Navigator because SignUpPage is above the + // nested Navigator that it created. Therefore, this pop() + // will pop the entire "sign up" journey and return to the + // "/" route, AKA HomePage. + Navigator.of(context).pop(); + }, + ); + default: + throw Exception('Invalid route: ${settings.name}'); + } + return MaterialPageRoute(builder: builder, settings: settings); + }, + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/navigator/navigator.restorable_push.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/navigator/navigator.restorable_push.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..1e292f58b646f0af35652686fa7b2f31dbb1b361 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/navigator/navigator.restorable_push.0.dart @@ -0,0 +1,50 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Navigator.restorablePush]. + +void main() => runApp(const RestorablePushExampleApp()); + +class RestorablePushExampleApp extends StatelessWidget { + const RestorablePushExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: RestorablePushExample(), + ); + } +} + +class RestorablePushExample extends StatefulWidget { + const RestorablePushExample({super.key}); + + @override + State createState() => _RestorablePushExampleState(); +} + +class _RestorablePushExampleState extends State { + @pragma('vm:entry-point') + static Route _myRouteBuilder(BuildContext context, Object? arguments) { + return MaterialPageRoute( + builder: (BuildContext context) => const RestorablePushExample(), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Sample Code'), + ), + floatingActionButton: FloatingActionButton( + onPressed: () => Navigator.restorablePush(context, _myRouteBuilder), + tooltip: 'Increment Counter', + child: const Icon(Icons.add), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/navigator/navigator.restorable_push_and_remove_until.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/navigator/navigator.restorable_push_and_remove_until.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..eaf34b3e19891d1d537ccfcdc8cf533edcd3fb3d --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/navigator/navigator.restorable_push_and_remove_until.0.dart @@ -0,0 +1,54 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Navigator.restorablePushAndRemoveUntil]. + +void main() => runApp(const RestorablePushAndRemoveUntilExampleApp()); + +class RestorablePushAndRemoveUntilExampleApp extends StatelessWidget { + const RestorablePushAndRemoveUntilExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: RestorablePushAndRemoveUntilExample(), + ); + } +} + +class RestorablePushAndRemoveUntilExample extends StatefulWidget { + const RestorablePushAndRemoveUntilExample({super.key}); + + @override + State createState() => _RestorablePushAndRemoveUntilExampleState(); +} + +class _RestorablePushAndRemoveUntilExampleState extends State { + @pragma('vm:entry-point') + static Route _myRouteBuilder(BuildContext context, Object? arguments) { + return MaterialPageRoute( + builder: (BuildContext context) => const RestorablePushAndRemoveUntilExample(), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Sample Code'), + ), + floatingActionButton: FloatingActionButton( + onPressed: () => Navigator.restorablePushAndRemoveUntil( + context, + _myRouteBuilder, + ModalRoute.withName('/'), + ), + tooltip: 'Increment Counter', + child: const Icon(Icons.add), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/navigator/navigator.restorable_push_replacement.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/navigator/navigator.restorable_push_replacement.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..7d5df6079583675b6ed413c3bd60aed1ccd6b7b2 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/navigator/navigator.restorable_push_replacement.0.dart @@ -0,0 +1,50 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Navigator.restorablePushReplacement]. + +void main() => runApp(const RestorablePushReplacementExampleApp()); + +class RestorablePushReplacementExampleApp extends StatelessWidget { + const RestorablePushReplacementExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: RestorablePushReplacementExample(), + ); + } +} + +class RestorablePushReplacementExample extends StatefulWidget { + const RestorablePushReplacementExample({super.key}); + + @override + State createState() => _RestorablePushReplacementExampleState(); +} + +class _RestorablePushReplacementExampleState extends State { + @pragma('vm:entry-point') + static Route _myRouteBuilder(BuildContext context, Object? arguments) { + return MaterialPageRoute( + builder: (BuildContext context) => const RestorablePushReplacementExample(), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Sample Code'), + ), + floatingActionButton: FloatingActionButton( + onPressed: () => Navigator.restorablePushReplacement(context, _myRouteBuilder), + tooltip: 'Increment Counter', + child: const Icon(Icons.add), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/navigator/navigator_state.restorable_push.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/navigator/navigator_state.restorable_push.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..cb45abe8ba65e234cf1155f337a7097cf7b96e35 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/navigator/navigator_state.restorable_push.0.dart @@ -0,0 +1,50 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [NavigatorState.restorablePush]. + +void main() => runApp(const RestorablePushExampleApp()); + +class RestorablePushExampleApp extends StatelessWidget { + const RestorablePushExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: RestorablePushExample(), + ); + } +} + +class RestorablePushExample extends StatefulWidget { + const RestorablePushExample({super.key}); + + @override + State createState() => _RestorablePushExampleState(); +} + +class _RestorablePushExampleState extends State { + @pragma('vm:entry-point') + static Route _myRouteBuilder(BuildContext context, Object? arguments) { + return MaterialPageRoute( + builder: (BuildContext context) => const RestorablePushExample(), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Sample Code'), + ), + floatingActionButton: FloatingActionButton( + onPressed: () => Navigator.of(context).restorablePush(_myRouteBuilder), + tooltip: 'Increment Counter', + child: const Icon(Icons.add), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/navigator/navigator_state.restorable_push_and_remove_until.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/navigator/navigator_state.restorable_push_and_remove_until.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..0567ad4ac21e34437e8ccfcec3f622eb24b5cde5 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/navigator/navigator_state.restorable_push_and_remove_until.0.dart @@ -0,0 +1,53 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [NavigatorState.restorablePushAndRemoveUntil]. + +void main() => runApp(const RestorablePushAndRemoveUntilExampleApp()); + +class RestorablePushAndRemoveUntilExampleApp extends StatelessWidget { + const RestorablePushAndRemoveUntilExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: RestorablePushAndRemoveUntilExample(), + ); + } +} + +class RestorablePushAndRemoveUntilExample extends StatefulWidget { + const RestorablePushAndRemoveUntilExample({super.key}); + + @override + State createState() => _RestorablePushAndRemoveUntilExampleState(); +} + +class _RestorablePushAndRemoveUntilExampleState extends State { + @pragma('vm:entry-point') + static Route _myRouteBuilder(BuildContext context, Object? arguments) { + return MaterialPageRoute( + builder: (BuildContext context) => const RestorablePushAndRemoveUntilExample(), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Sample Code'), + ), + floatingActionButton: FloatingActionButton( + onPressed: () => Navigator.of(context).restorablePushAndRemoveUntil( + _myRouteBuilder, + ModalRoute.withName('/'), + ), + tooltip: 'Increment Counter', + child: const Icon(Icons.add), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/navigator/navigator_state.restorable_push_replacement.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/navigator/navigator_state.restorable_push_replacement.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..b22315a2f5b91372da9e53c76fad39039d5d4289 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/navigator/navigator_state.restorable_push_replacement.0.dart @@ -0,0 +1,52 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [NavigatorState.restorablePushReplacement]. + +void main() => runApp(const RestorablePushReplacementExampleApp()); + +class RestorablePushReplacementExampleApp extends StatelessWidget { + const RestorablePushReplacementExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: RestorablePushReplacementExample(), + ); + } +} + +class RestorablePushReplacementExample extends StatefulWidget { + const RestorablePushReplacementExample({super.key}); + + @override + State createState() => _RestorablePushReplacementExampleState(); +} + +class _RestorablePushReplacementExampleState extends State { + @pragma('vm:entry-point') + static Route _myRouteBuilder(BuildContext context, Object? arguments) { + return MaterialPageRoute( + builder: (BuildContext context) => const RestorablePushReplacementExample(), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Sample Code'), + ), + floatingActionButton: FloatingActionButton( + onPressed: () => Navigator.of(context).restorablePushReplacement( + _myRouteBuilder, + ), + tooltip: 'Increment Counter', + child: const Icon(Icons.add), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/navigator/restorable_route_future.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/navigator/restorable_route_future.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..ddf8efc6ac25945d3c61ba97efacfdc61ad9d0ee --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/navigator/restorable_route_future.0.dart @@ -0,0 +1,156 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [RestorableRouteFuture]. + +void main() => runApp(const RestorableRouteFutureExampleApp()); + +class RestorableRouteFutureExampleApp extends StatelessWidget { + const RestorableRouteFutureExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + restorationScopeId: 'app', + home: Scaffold( + appBar: AppBar(title: const Text('RestorableRouteFuture Example')), + body: const MyHome(), + ), + ); + } +} + +class MyHome extends StatefulWidget { + const MyHome({super.key}); + + @override + State createState() => _MyHomeState(); +} + +class _MyHomeState extends State with RestorationMixin { + final RestorableInt _lastCount = RestorableInt(0); + late RestorableRouteFuture _counterRoute; + + @override + String get restorationId => 'home'; + + @override + void initState() { + super.initState(); + _counterRoute = RestorableRouteFuture(onPresent: (NavigatorState navigator, Object? arguments) { + // Defines what route should be shown (and how it should be added + // to the navigator) when `RestorableRouteFuture.present` is called. + return navigator.restorablePush( + _counterRouteBuilder, + arguments: arguments, + ); + }, onComplete: (int count) { + // Defines what should happen with the return value when the route + // completes. + setState(() { + _lastCount.value = count; + }); + }); + } + + @override + void restoreState(RestorationBucket? oldBucket, bool initialRestore) { + // Register the `RestorableRouteFuture` with the state restoration framework. + registerForRestoration(_counterRoute, 'route'); + registerForRestoration(_lastCount, 'count'); + } + + @override + void dispose() { + super.dispose(); + _lastCount.dispose(); + _counterRoute.dispose(); + } + + // A static `RestorableRouteBuilder` that can re-create the route during + // state restoration. + @pragma('vm:entry-point') + static Route _counterRouteBuilder(BuildContext context, Object? arguments) { + return MaterialPageRoute( + builder: (BuildContext context) => MyCounter( + title: arguments!.toString(), + ), + ); + } + + @override + Widget build(BuildContext context) { + return Center( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text('Last count: ${_lastCount.value}'), + ElevatedButton( + onPressed: () { + // Show the route defined by the `RestorableRouteFuture`. + _counterRoute.present('Awesome Counter'); + }, + child: const Text('Open Counter'), + ), + ], + ), + ); + } +} + +// Widget for the route pushed by the `RestorableRouteFuture`. +class MyCounter extends StatefulWidget { + const MyCounter({super.key, required this.title}); + + final String title; + + @override + State createState() => _MyCounterState(); +} + +class _MyCounterState extends State with RestorationMixin { + final RestorableInt _count = RestorableInt(0); + + @override + String get restorationId => 'counter'; + + @override + void restoreState(RestorationBucket? oldBucket, bool initialRestore) { + registerForRestoration(_count, 'count'); + } + + @override + void dispose() { + super.dispose(); + _count.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text(widget.title), + leading: BackButton( + onPressed: () { + // Return the current count of the counter from this route. + Navigator.of(context).pop(_count.value); + }, + ), + ), + body: Center( + child: Text('Count: ${_count.value}'), + ), + floatingActionButton: FloatingActionButton( + child: const Icon(Icons.add), + onPressed: () { + setState(() { + _count.value++; + }); + }, + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/navigator_pop_handler/navigator_pop_handler.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/navigator_pop_handler/navigator_pop_handler.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..d81b74f65f71484121204a6e3c415eb00de70525 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/navigator_pop_handler/navigator_pop_handler.0.dart @@ -0,0 +1,164 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// This sample demonstrates using [NavigatorPopHandler] to handle system back +/// gestures when there are nested [Navigator] widgets by delegating to the +/// current [Navigator]. + +void main() => runApp(const NavigatorPopHandlerApp()); + +class NavigatorPopHandlerApp extends StatelessWidget { + const NavigatorPopHandlerApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + initialRoute: '/', + routes: { + '/': (BuildContext context) => _HomePage(), + '/nested_navigators': (BuildContext context) => const NestedNavigatorsPage(), + }, + ); + } +} + +class _HomePage extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Nested Navigators Example'), + ), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text('Home Page'), + const Text('A system back gesture here will exit the app.'), + const SizedBox(height: 20.0), + ListTile( + title: const Text('Nested Navigator route'), + subtitle: const Text('This route has another Navigator widget in addition to the one inside MaterialApp above.'), + onTap: () { + Navigator.of(context).pushNamed('/nested_navigators'); + }, + ), + ], + ), + ), + ); + } +} + +class NestedNavigatorsPage extends StatefulWidget { + const NestedNavigatorsPage({super.key}); + + @override + State createState() => _NestedNavigatorsPageState(); +} + +class _NestedNavigatorsPageState extends State { + final GlobalKey _nestedNavigatorKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return NavigatorPopHandler( + onPop: () { + _nestedNavigatorKey.currentState!.maybePop(); + }, + child: Navigator( + key: _nestedNavigatorKey, + initialRoute: 'nested_navigators/one', + onGenerateRoute: (RouteSettings settings) { + switch (settings.name) { + case 'nested_navigators/one': + final BuildContext rootContext = context; + return MaterialPageRoute( + builder: (BuildContext context) => NestedNavigatorsPageOne( + onBack: () { + Navigator.of(rootContext).pop(); + }, + ), + ); + case 'nested_navigators/one/another_one': + return MaterialPageRoute( + builder: (BuildContext context) => const NestedNavigatorsPageTwo( + ), + ); + default: + throw Exception('Invalid route: ${settings.name}'); + } + }, + ), + ); + } +} + +class NestedNavigatorsPageOne extends StatelessWidget { + const NestedNavigatorsPageOne({ + required this.onBack, + super.key, + }); + + final VoidCallback onBack; + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.grey, + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text('Nested Navigators Page One'), + const Text('A system back here returns to the home page.'), + TextButton( + onPressed: () { + Navigator.of(context).pushNamed('nested_navigators/one/another_one'); + }, + child: const Text('Go to another route in this nested Navigator'), + ), + TextButton( + // Can't use Navigator.of(context).pop() because this is the root + // route, so it can't be popped. The Navigator above this needs to + // be popped. + onPressed: onBack, + child: const Text('Go back'), + ), + ], + ), + ), + ); + } +} + +class NestedNavigatorsPageTwo extends StatelessWidget { + const NestedNavigatorsPageTwo({ + super.key, + }); + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.grey.withBlue(180), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text('Nested Navigators Page Two'), + const Text('A system back here will go back to Nested Navigators Page One'), + TextButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: const Text('Go back'), + ), + ], + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/navigator_pop_handler/navigator_pop_handler.1.dart b/novelforge-project/flutter/examples/api/lib/widgets/navigator_pop_handler/navigator_pop_handler.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..04fbdedd34e56ca68b919748757b75724e294eea --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/navigator_pop_handler/navigator_pop_handler.1.dart @@ -0,0 +1,250 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This sample demonstrates nested navigation in a bottom navigation bar. + +import 'package:flutter/material.dart'; + +// There are three possible tabs. +enum _Tab { + home, + one, + two, +} + +// Each tab has two possible pages. +enum _TabPage { + home, + one, +} + +typedef _TabPageCallback = void Function(List<_TabPage> pages); + +void main() => runApp(const NavigatorPopHandlerApp()); + +class NavigatorPopHandlerApp extends StatelessWidget { + const NavigatorPopHandlerApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + initialRoute: '/home', + routes: { + '/home': (BuildContext context) => const _BottomNavPage( + ), + }, + ); + } +} + +class _BottomNavPage extends StatefulWidget { + const _BottomNavPage(); + + @override + State<_BottomNavPage> createState() => _BottomNavPageState(); +} + +class _BottomNavPageState extends State<_BottomNavPage> { + _Tab _tab = _Tab.home; + + final GlobalKey _tabHomeKey = GlobalKey(); + final GlobalKey _tabOneKey = GlobalKey(); + final GlobalKey _tabTwoKey = GlobalKey(); + + List<_TabPage> _tabHomePages = <_TabPage>[_TabPage.home]; + List<_TabPage> _tabOnePages = <_TabPage>[_TabPage.home]; + List<_TabPage> _tabTwoPages = <_TabPage>[_TabPage.home]; + + BottomNavigationBarItem _itemForPage(_Tab page) { + switch (page) { + case _Tab.home: + return const BottomNavigationBarItem( + icon: Icon(Icons.home), + label: 'Go to Home', + ); + case _Tab.one: + return const BottomNavigationBarItem( + icon: Icon(Icons.one_k), + label: 'Go to One', + ); + case _Tab.two: + return const BottomNavigationBarItem( + icon: Icon(Icons.two_k), + label: 'Go to Two', + ); + } + } + + Widget _getPage(_Tab page) { + switch (page) { + case _Tab.home: + return _BottomNavTab( + key: _tabHomeKey, + title: 'Home Tab', + color: Colors.grey, + pages: _tabHomePages, + onChangedPages: (List<_TabPage> pages) { + setState(() { + _tabHomePages = pages; + }); + }, + ); + case _Tab.one: + return _BottomNavTab( + key: _tabOneKey, + title: 'Tab One', + color: Colors.amber, + pages: _tabOnePages, + onChangedPages: (List<_TabPage> pages) { + setState(() { + _tabOnePages = pages; + }); + }, + ); + case _Tab.two: + return _BottomNavTab( + key: _tabTwoKey, + title: 'Tab Two', + color: Colors.blueGrey, + pages: _tabTwoPages, + onChangedPages: (List<_TabPage> pages) { + setState(() { + _tabTwoPages = pages; + }); + }, + ); + } + } + + void _onItemTapped(int index) { + setState(() { + _tab = _Tab.values.elementAt(index); + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: _getPage(_tab), + ), + bottomNavigationBar: BottomNavigationBar( + items: _Tab.values.map(_itemForPage).toList(), + currentIndex: _Tab.values.indexOf(_tab), + selectedItemColor: Colors.amber[800], + onTap: _onItemTapped, + ), + ); + } +} + +class _BottomNavTab extends StatefulWidget { + const _BottomNavTab({ + super.key, + required this.color, + required this.onChangedPages, + required this.pages, + required this.title, + }); + + final Color color; + final _TabPageCallback onChangedPages; + final List<_TabPage> pages; + final String title; + + @override + State<_BottomNavTab> createState() => _BottomNavTabState(); +} + +class _BottomNavTabState extends State<_BottomNavTab> { + final GlobalKey _navigatorKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return NavigatorPopHandler( + onPop: () { + _navigatorKey.currentState?.maybePop(); + }, + child: Navigator( + key: _navigatorKey, + onPopPage: (Route route, void result) { + if (!route.didPop(null)) { + return false; + } + widget.onChangedPages(<_TabPage>[ + ...widget.pages, + ]..removeLast()); + return true; + }, + pages: widget.pages.map((_TabPage page) { + switch (page) { + case _TabPage.home: + return MaterialPage( + child: _LinksPage( + title: 'Bottom nav - tab ${widget.title} - route $page', + backgroundColor: widget.color, + buttons: [ + TextButton( + onPressed: () { + widget.onChangedPages(<_TabPage>[ + ...widget.pages, + _TabPage.one, + ]); + }, + child: const Text('Go to another route in this nested Navigator'), + ), + ], + ), + ); + case _TabPage.one: + return MaterialPage( + child: _LinksPage( + backgroundColor: widget.color, + title: 'Bottom nav - tab ${widget.title} - route $page', + buttons: [ + TextButton( + onPressed: () { + widget.onChangedPages(<_TabPage>[ + ...widget.pages, + ]..removeLast()); + }, + child: const Text('Go back'), + ), + ], + ), + ); + } + }).toList(), + ), + ); + } +} + +class _LinksPage extends StatelessWidget { + const _LinksPage ({ + required this.backgroundColor, + this.buttons = const [], + required this.title, + }); + + final Color backgroundColor; + final List buttons; + final String title; + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: backgroundColor, + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text(title), + ...buttons, + ], + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/nested_scroll_view/nested_scroll_view.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/nested_scroll_view/nested_scroll_view.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..1d49cb67bce57cde81625f23c8cbdf1b2c02acbf --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/nested_scroll_view/nested_scroll_view.0.dart @@ -0,0 +1,131 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [NestedScrollView]. + +void main() => runApp(const NestedScrollViewExampleApp()); + +class NestedScrollViewExampleApp extends StatelessWidget { + const NestedScrollViewExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: NestedScrollViewExample(), + ); + } +} + +class NestedScrollViewExample extends StatelessWidget { + const NestedScrollViewExample({super.key}); + + @override + Widget build(BuildContext context) { + final List tabs = ['Tab 1', 'Tab 2']; + return DefaultTabController( + length: tabs.length, // This is the number of tabs. + child: Scaffold( + body: NestedScrollView( + headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { + // These are the slivers that show up in the "outer" scroll view. + return [ + SliverOverlapAbsorber( + // This widget takes the overlapping behavior of the SliverAppBar, + // and redirects it to the SliverOverlapInjector below. If it is + // missing, then it is possible for the nested "inner" scroll view + // below to end up under the SliverAppBar even when the inner + // scroll view thinks it has not been scrolled. + // This is not necessary if the "headerSliverBuilder" only builds + // widgets that do not overlap the next sliver. + handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context), + sliver: SliverAppBar( + title: const Text('Books'), // This is the title in the app bar. + pinned: true, + expandedHeight: 150.0, + // The "forceElevated" property causes the SliverAppBar to show + // a shadow. The "innerBoxIsScrolled" parameter is true when the + // inner scroll view is scrolled beyond its "zero" point, i.e. + // when it appears to be scrolled below the SliverAppBar. + // Without this, there are cases where the shadow would appear + // or not appear inappropriately, because the SliverAppBar is + // not actually aware of the precise position of the inner + // scroll views. + forceElevated: innerBoxIsScrolled, + bottom: TabBar( + // These are the widgets to put in each tab in the tab bar. + tabs: tabs.map((String name) => Tab(text: name)).toList(), + ), + ), + ), + ]; + }, + body: TabBarView( + // These are the contents of the tab views, below the tabs. + children: tabs.map((String name) { + return SafeArea( + top: false, + bottom: false, + child: Builder( + // This Builder is needed to provide a BuildContext that is + // "inside" the NestedScrollView, so that + // sliverOverlapAbsorberHandleFor() can find the + // NestedScrollView. + builder: (BuildContext context) { + return CustomScrollView( + // The "controller" and "primary" members should be left + // unset, so that the NestedScrollView can control this + // inner scroll view. + // If the "controller" property is set, then this scroll + // view will not be associated with the NestedScrollView. + // The PageStorageKey should be unique to this ScrollView; + // it allows the list to remember its scroll position when + // the tab view is not on the screen. + key: PageStorageKey(name), + slivers: [ + SliverOverlapInjector( + // This is the flip side of the SliverOverlapAbsorber + // above. + handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context), + ), + SliverPadding( + padding: const EdgeInsets.all(8.0), + // In this example, the inner scroll view has + // fixed-height list items, hence the use of + // SliverFixedExtentList. However, one could use any + // sliver widget here, e.g. SliverList or SliverGrid. + sliver: SliverFixedExtentList( + // The items in this example are fixed to 48 pixels + // high. This matches the Material Design spec for + // ListTile widgets. + itemExtent: 48.0, + delegate: SliverChildBuilderDelegate( + (BuildContext context, int index) { + // This builder is called for each child. + // In this example, we just number each list item. + return ListTile( + title: Text('Item $index'), + ); + }, + // The childCount of the SliverChildBuilderDelegate + // specifies how many children this inner list + // has. In this example, each tab has a list of + // exactly 30 items, but this is arbitrary. + childCount: 30, + ), + ), + ), + ], + ); + }, + ), + ); + }).toList(), + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/nested_scroll_view/nested_scroll_view.1.dart b/novelforge-project/flutter/examples/api/lib/widgets/nested_scroll_view/nested_scroll_view.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..560f18c51306b7c895231dd78a938b1266c14129 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/nested_scroll_view/nested_scroll_view.1.dart @@ -0,0 +1,52 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [NestedScrollView]. + +void main() => runApp(const NestedScrollViewExampleApp()); + +class NestedScrollViewExampleApp extends StatelessWidget { + const NestedScrollViewExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: NestedScrollViewExample(), + ); + } +} + +class NestedScrollViewExample extends StatelessWidget { + const NestedScrollViewExample({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: NestedScrollView( + // Setting floatHeaderSlivers to true is required in order to float + // the outer slivers over the inner scrollable. + floatHeaderSlivers: true, + headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { + return [ + SliverAppBar( + title: const Text('Floating Nested SliverAppBar'), + floating: true, + expandedHeight: 200.0, + forceElevated: innerBoxIsScrolled, + ), + ]; + }, + body: ListView.builder( + padding: const EdgeInsets.all(8), + itemCount: 30, + itemBuilder: (BuildContext context, int index) { + return SizedBox( + height: 50, + child: Center(child: Text('Item $index')), + ); + }))); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/nested_scroll_view/nested_scroll_view.2.dart b/novelforge-project/flutter/examples/api/lib/widgets/nested_scroll_view/nested_scroll_view.2.dart new file mode 100644 index 0000000000000000000000000000000000000000..9ed8aae49b7c39f8d2841c1c30a3de4ef611cc17 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/nested_scroll_view/nested_scroll_view.2.dart @@ -0,0 +1,60 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [NestedScrollView]. + +void main() => runApp(const NestedScrollViewExampleApp()); + +class NestedScrollViewExampleApp extends StatelessWidget { + const NestedScrollViewExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: NestedScrollViewExample(), + ); + } +} + +class NestedScrollViewExample extends StatelessWidget { + const NestedScrollViewExample({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: NestedScrollView(headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { + return [ + SliverOverlapAbsorber( + handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context), + sliver: SliverAppBar( + title: const Text('Snapping Nested SliverAppBar'), + floating: true, + snap: true, + expandedHeight: 200.0, + forceElevated: innerBoxIsScrolled, + ), + ), + ]; + }, body: Builder(builder: (BuildContext context) { + return CustomScrollView( + // The "controller" and "primary" members should be left unset, so that + // the NestedScrollView can control this inner scroll view. + // If the "controller" property is set, then this scroll view will not + // be associated with the NestedScrollView. + slivers: [ + SliverOverlapInjector(handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context)), + SliverFixedExtentList( + itemExtent: 48.0, + delegate: SliverChildBuilderDelegate( + (BuildContext context, int index) => ListTile(title: Text('Item $index')), + childCount: 30, + ), + ), + ], + ); + }))); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/nested_scroll_view/nested_scroll_view_state.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/nested_scroll_view/nested_scroll_view_state.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..6de7899b7b156566c4d3cb895562efdec9917157 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/nested_scroll_view/nested_scroll_view_state.0.dart @@ -0,0 +1,48 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [NestedScrollViewState]. + +void main() => runApp(const NestedScrollViewStateExampleApp()); + +class NestedScrollViewStateExampleApp extends StatelessWidget { + const NestedScrollViewStateExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: NestedScrollViewStateExample(), + ); + } +} + +final GlobalKey globalKey = GlobalKey(); + +class NestedScrollViewStateExample extends StatelessWidget { + const NestedScrollViewStateExample({super.key}); + + @override + @override + Widget build(BuildContext context) { + return NestedScrollView( + key: globalKey, + headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { + return const [ + SliverAppBar( + title: Text('NestedScrollViewState Demo!'), + ), + ]; + }, + body: const CustomScrollView( + // Body slivers go here! + ), + ); + } + + ScrollController get innerController { + return globalKey.currentState!.innerController; + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/notification_listener/notification.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/notification_listener/notification.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..40f7040b76160b26d421f1a147919e8f3e7077c1 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/notification_listener/notification.0.dart @@ -0,0 +1,87 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Notification]. + +void main() => runApp(const NotificationExampleApp()); + +class NotificationExampleApp extends StatelessWidget { + const NotificationExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: NotificationExample(), + ); + } +} + +class NotificationExample extends StatelessWidget { + const NotificationExample({super.key}); + + static const List _tabs = ['Months', 'Days']; + static const List _months = [ + 'January', + 'February', + 'March', + ]; + static const List _days = [ + 'Sunday', + 'Monday', + 'Tuesday', + ]; + + @override + Widget build(BuildContext context) { + return DefaultTabController( + length: _tabs.length, + child: Scaffold( + // Listens to the scroll events and returns the current position. + body: NotificationListener( + onNotification: (ScrollNotification scrollNotification) { + if (scrollNotification is ScrollStartNotification) { + debugPrint('Scrolling has started'); + } else if (scrollNotification is ScrollEndNotification) { + debugPrint('Scrolling has ended'); + } + // Return true to cancel the notification bubbling. + return true; + }, + child: NestedScrollView( + headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { + return [ + SliverAppBar( + title: const Text('Notification Sample'), + pinned: true, + floating: true, + bottom: TabBar( + tabs: _tabs.map((String name) => Tab(text: name)).toList(), + ), + ), + ]; + }, + body: TabBarView( + children: [ + ListView.builder( + itemCount: _months.length, + itemBuilder: (BuildContext context, int index) { + return ListTile(title: Text(_months[index])); + }, + ), + ListView.builder( + itemCount: _days.length, + itemBuilder: (BuildContext context, int index) { + return ListTile(title: Text(_days[index])); + }, + ), + ], + ), + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/overflow_bar/overflow_bar.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/overflow_bar/overflow_bar.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..e870d72ec30cf37ad750627c3413f8c595f5fb17 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/overflow_bar/overflow_bar.0.dart @@ -0,0 +1,67 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [OverflowBar]. + +void main() => runApp(const OverflowBarExampleApp()); + +class OverflowBarExampleApp extends StatelessWidget { + const OverflowBarExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('OverflowBar Sample')), + body: const Center( + child: OverflowBarExample(), + ), + ), + ); + } +} + +class OverflowBarExample extends StatelessWidget { + const OverflowBarExample({super.key}); + + @override + Widget build(BuildContext context) { + return Container( + alignment: Alignment.center, + padding: const EdgeInsets.all(16), + color: Colors.black.withOpacity(0.15), + child: Material( + color: Colors.white, + elevation: 24, + shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(4))), + child: Padding( + padding: const EdgeInsets.all(8), + child: SingleChildScrollView( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + const SizedBox(height: 128, child: Placeholder()), + Align( + alignment: AlignmentDirectional.centerEnd, + child: OverflowBar( + spacing: 8, + overflowAlignment: OverflowBarAlignment.end, + children: [ + TextButton(child: const Text('Cancel'), onPressed: () {}), + TextButton(child: const Text('Really Really Cancel'), onPressed: () {}), + OutlinedButton(child: const Text('OK'), onPressed: () {}), + ], + ), + ), + ], + ), + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/overlay/overlay.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/overlay/overlay.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..2a69e58f3d8a95f6788676821c099b5a0bc42c87 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/overlay/overlay.0.dart @@ -0,0 +1,244 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Overlay]. + +void main() => runApp(const OverlayApp()); + +class OverlayApp extends StatelessWidget { + const OverlayApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: OverlayExample(), + ); + } +} + +class OverlayExample extends StatefulWidget { + const OverlayExample({super.key}); + + @override + State createState() => _OverlayExampleState(); +} + +class _OverlayExampleState extends State { + OverlayEntry? overlayEntry; + int currentPageIndex = 0; + + void createHighlightOverlay({ + required AlignmentDirectional alignment, + required Color borderColor, + }) { + // Remove the existing OverlayEntry. + removeHighlightOverlay(); + + assert(overlayEntry == null); + + overlayEntry = OverlayEntry( + // Create a new OverlayEntry. + builder: (BuildContext context) { + // Align is used to position the highlight overlay + // relative to the NavigationBar destination. + return SafeArea( + child: Align( + alignment: alignment, + heightFactor: 1.0, + child: DefaultTextStyle( + style: const TextStyle( + color: Colors.blue, + fontWeight: FontWeight.bold, + fontSize: 14.0, + ), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Text('Tap here for'), + Builder(builder: (BuildContext context) { + switch (currentPageIndex) { + case 0: + return const Column( + children: [ + Text( + 'Explore page', + style: TextStyle( + color: Colors.red, + ), + ), + Icon( + Icons.arrow_downward, + color: Colors.red, + ), + ], + ); + case 1: + return const Column( + children: [ + Text( + 'Commute page', + style: TextStyle( + color: Colors.green, + ), + ), + Icon( + Icons.arrow_downward, + color: Colors.green, + ), + ], + ); + case 2: + return const Column( + children: [ + Text( + 'Saved page', + style: TextStyle( + color: Colors.orange, + ), + ), + Icon( + Icons.arrow_downward, + color: Colors.orange, + ), + ], + ); + default: + return const Text('No page selected.'); + } + }), + SizedBox( + width: MediaQuery.of(context).size.width / 3, + height: 80.0, + child: Center( + child: Container( + decoration: BoxDecoration( + border: Border.all( + color: borderColor, + width: 4.0, + ), + ), + ), + ), + ), + ], + ), + ), + ), + ); + }, + ); + + // Add the OverlayEntry to the Overlay. + Overlay.of(context, debugRequiredFor: widget).insert(overlayEntry!); + } + + // Remove the OverlayEntry. + void removeHighlightOverlay() { + overlayEntry?.remove(); + overlayEntry?.dispose(); + overlayEntry = null; + } + + @override + void dispose() { + // Make sure to remove OverlayEntry when the widget is disposed. + removeHighlightOverlay(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Overlay Sample'), + ), + bottomNavigationBar: NavigationBar( + selectedIndex: currentPageIndex, + destinations: const [ + NavigationDestination( + icon: Icon(Icons.explore), + label: 'Explore', + ), + NavigationDestination( + icon: Icon(Icons.commute), + label: 'Commute', + ), + NavigationDestination( + selectedIcon: Icon(Icons.bookmark), + icon: Icon(Icons.bookmark_border), + label: 'Saved', + ), + ], + ), + body: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + 'Use Overlay to highlight a NavigationBar destination', + style: Theme.of(context).textTheme.bodyMedium, + ), + const SizedBox(height: 20.0), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + // This creates a highlight Overlay for + // the Explore item. + ElevatedButton( + onPressed: () { + setState(() { + currentPageIndex = 0; + }); + createHighlightOverlay( + alignment: AlignmentDirectional.bottomStart, + borderColor: Colors.red, + ); + }, + child: const Text('Explore'), + ), + const SizedBox(width: 20.0), + // This creates a highlight Overlay for + // the Commute item. + ElevatedButton( + onPressed: () { + setState(() { + currentPageIndex = 1; + }); + createHighlightOverlay( + alignment: AlignmentDirectional.bottomCenter, + borderColor: Colors.green, + ); + }, + child: const Text('Commute'), + ), + const SizedBox(width: 20.0), + // This creates a highlight Overlay for + // the Saved item. + ElevatedButton( + onPressed: () { + setState(() { + currentPageIndex = 2; + }); + createHighlightOverlay( + alignment: AlignmentDirectional.bottomEnd, + borderColor: Colors.orange, + ); + }, + child: const Text('Saved'), + ), + ], + ), + const SizedBox(height: 10.0), + ElevatedButton( + onPressed: () { + removeHighlightOverlay(); + }, + child: const Text('Remove Overlay'), + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/overlay/overlay_portal.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/overlay/overlay_portal.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..a3fcead6626c75c1067f8b03ab2b4a19696dcb2e --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/overlay/overlay_portal.0.dart @@ -0,0 +1,58 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [OverlayPortal]. + +void main() => runApp(const OverlayPortalExampleApp()); + +class OverlayPortalExampleApp extends StatelessWidget { + const OverlayPortalExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('OverlayPortal Example')), + body: const Center(child: ClickableTooltipWidget()), + ), + ); + } +} + +class ClickableTooltipWidget extends StatefulWidget { + const ClickableTooltipWidget({super.key}); + + @override + State createState() => ClickableTooltipWidgetState(); +} + +class ClickableTooltipWidgetState extends State { + final OverlayPortalController _tooltipController = OverlayPortalController(); + + @override + Widget build(BuildContext context) { + return TextButton( + onPressed: _tooltipController.toggle, + child: DefaultTextStyle( + style: DefaultTextStyle.of(context).style.copyWith(fontSize: 50), + child: OverlayPortal( + controller: _tooltipController, + overlayChildBuilder: (BuildContext context) { + return const Positioned( + right: 50, + bottom: 50, + child: ColoredBox( + color: Colors.amberAccent, + child: Text('tooltip'), + ), + ); + }, + child: const Text('Press to show/hide tooltip'), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/overscroll_indicator/glowing_overscroll_indicator.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/overscroll_indicator/glowing_overscroll_indicator.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..fc695e47e5693dfb91f539ce6a40f515f75f3777 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/overscroll_indicator/glowing_overscroll_indicator.0.dart @@ -0,0 +1,53 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [GlowingOverscrollIndicator]. + +void main() => runApp(const GlowingOverscrollIndicatorExampleApp()); + +class GlowingOverscrollIndicatorExampleApp extends StatelessWidget { + const GlowingOverscrollIndicatorExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('GlowingOverscrollIndicator Sample')), + body: const GlowingOverscrollIndicatorExample(), + ), + ); + } +} + +class GlowingOverscrollIndicatorExample extends StatelessWidget { + const GlowingOverscrollIndicatorExample({super.key}); + + @override + Widget build(BuildContext context) { + final double leadingPaintOffset = MediaQuery.of(context).padding.top + AppBar().preferredSize.height; + return NotificationListener( + onNotification: (OverscrollIndicatorNotification notification) { + if (notification.leading) { + notification.paintOffset = leadingPaintOffset; + } + return false; + }, + child: CustomScrollView( + slivers: [ + const SliverAppBar(title: Text('Custom PaintOffset')), + SliverToBoxAdapter( + child: Container( + color: Colors.amberAccent, + height: 100, + child: const Center(child: Text('Glow all day!')), + ), + ), + const SliverFillRemaining(child: FlutterLogo()), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/overscroll_indicator/glowing_overscroll_indicator.1.dart b/novelforge-project/flutter/examples/api/lib/widgets/overscroll_indicator/glowing_overscroll_indicator.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..a9a5532bf9c2a752f00df13f4c7dd0684e4adfb8 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/overscroll_indicator/glowing_overscroll_indicator.1.dart @@ -0,0 +1,50 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [GlowingOverscrollIndicator]. + +void main() => runApp(const GlowingOverscrollIndicatorExampleApp()); + +class GlowingOverscrollIndicatorExampleApp extends StatelessWidget { + const GlowingOverscrollIndicatorExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('GlowingOverscrollIndicator Sample')), + body: const GlowingOverscrollIndicatorExample(), + ), + ); + } +} + +class GlowingOverscrollIndicatorExample extends StatelessWidget { + const GlowingOverscrollIndicatorExample({super.key}); + + @override + Widget build(BuildContext context) { + return NestedScrollView( + headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { + return const [ + SliverAppBar(title: Text('Custom NestedScrollViews')), + ]; + }, + body: CustomScrollView( + slivers: [ + SliverToBoxAdapter( + child: Container( + color: Colors.amberAccent, + height: 100, + child: const Center(child: Text('Glow all day!')), + ), + ), + const SliverFillRemaining(child: FlutterLogo()), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/page/page_can_pop.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/page/page_can_pop.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..b100069070d1c2726405a6347df7570f7c8b8ed9 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/page/page_can_pop.0.dart @@ -0,0 +1,160 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This sample demonstrates showing a confirmation dialog before navigating +// away from a page. + +import 'package:flutter/material.dart'; + +void main() => runApp(const PageApiExampleApp()); + +class PageApiExampleApp extends StatefulWidget { + const PageApiExampleApp({super.key}); + + @override + State createState() => _PageApiExampleAppState(); +} + +class _PageApiExampleAppState extends State { + final RouterDelegate delegate = MyRouterDelegate(); + + @override + Widget build(BuildContext context) { + return MaterialApp.router( + routerDelegate: delegate, + ); + } +} + +class MyRouterDelegate extends RouterDelegate with PopNavigatorRouterDelegateMixin, ChangeNotifier { + // This example doesn't use RouteInformationProvider. + @override + Future setNewRoutePath(Object configuration) async => throw UnimplementedError(); + + @override + final GlobalKey navigatorKey = GlobalKey(); + + static MyRouterDelegate of(BuildContext context) => Router.of(context).routerDelegate as MyRouterDelegate; + + bool get showDetailPage => _showDetailPage; + bool _showDetailPage = false; + set showDetailPage(bool value) { + if (_showDetailPage == value) { + return; + } + _showDetailPage = value; + notifyListeners(); + } + + Future _showConfirmDialog() async { + return await showDialog( + context: navigatorKey.currentContext!, + barrierDismissible: false, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Are you sure?'), + actions: [ + TextButton( + child: const Text('Cancel'), + onPressed: () { + Navigator.of(context).pop(false); + }, + ), + TextButton( + child: const Text('Confirm'), + onPressed: () { + Navigator.of(context).pop(true); + }, + ), + ], + ); + }, + ) ?? false; + } + + Future _handlePopDetails(bool didPop, void result) async { + if (didPop) { + showDetailPage = false; + return; + } + final bool confirmed = await _showConfirmDialog(); + if (confirmed) { + showDetailPage = false; + } + } + + List> _getPages() { + return >[ + const MaterialPage(key: ValueKey('home'), child: _HomePage()), + if (showDetailPage) + MaterialPage( + key: const ValueKey('details'), + child: const _DetailsPage(), + canPop: false, + onPopInvoked: _handlePopDetails, + ), + ]; + } + + @override + Widget build(BuildContext context) { + return Navigator( + key: navigatorKey, + pages: _getPages(), + onDidRemovePage: (Page page) { + assert(page.key == const ValueKey('details')); + showDetailPage = false; + }, + ); + } +} + +class _HomePage extends StatefulWidget { + const _HomePage(); + + @override + State<_HomePage> createState() => _HomePageState(); +} + +class _HomePageState extends State<_HomePage> { + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: const Text('Home')), + body: Center( + child: TextButton( + onPressed: () { + MyRouterDelegate.of(context).showDetailPage = true; + }, + child: const Text('Go to details'), + ), + ), + ); + } +} + +class _DetailsPage extends StatefulWidget { + const _DetailsPage(); + + @override + State<_DetailsPage> createState() => _DetailsPageState(); +} + +class _DetailsPageState extends State<_DetailsPage> { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: const Text('Details')), + body: Center( + child: TextButton( + onPressed: () { + Navigator.of(context).maybePop(); + }, + child: const Text('Go back'), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/page_storage/page_storage.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/page_storage/page_storage.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..78c731981c99f21cbbab31b02dab5d6379492243 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/page_storage/page_storage.0.dart @@ -0,0 +1,91 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [PageStorage]. + +void main() => runApp(const PageStorageExampleApp()); + +class PageStorageExampleApp extends StatelessWidget { + const PageStorageExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: MyHomePage(), + ); + } +} + +class MyHomePage extends StatefulWidget { + const MyHomePage({super.key}); + + @override + State createState() => _MyHomePageState(); +} + +class _MyHomePageState extends State { + final List pages = const [ + ColorBoxPage( + key: PageStorageKey('pageOne'), + ), + ColorBoxPage( + key: PageStorageKey('pageTwo'), + ), + ]; + int currentTab = 0; + final PageStorageBucket _bucket = PageStorageBucket(); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Persistence Example'), + ), + body: PageStorage( + bucket: _bucket, + child: pages[currentTab], + ), + bottomNavigationBar: BottomNavigationBar( + currentIndex: currentTab, + onTap: (int index) { + setState(() { + currentTab = index; + }); + }, + items: const [ + BottomNavigationBarItem( + icon: Icon(Icons.home), + label: 'page 1', + ), + BottomNavigationBarItem( + icon: Icon(Icons.settings), + label: 'page2', + ), + ], + ), + ); + } +} + +class ColorBoxPage extends StatelessWidget { + const ColorBoxPage({super.key}); + + @override + Widget build(BuildContext context) { + return ListView.builder( + itemExtent: 250.0, + itemBuilder: (BuildContext context, int index) => Container( + padding: const EdgeInsets.all(10.0), + child: Material( + color: index.isEven ? Colors.cyan : Colors.deepOrange, + child: Center( + child: Text(index.toString()), + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/page_view/page_view.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/page_view/page_view.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..4bf358123b8dcdc5bfdacc0fe581d3d13b0b6ddf --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/page_view/page_view.0.dart @@ -0,0 +1,193 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; + +/// Flutter code sample for [PageView]. + +void main() => runApp(const PageViewExampleApp()); + +class PageViewExampleApp extends StatelessWidget { + const PageViewExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('PageView Sample')), + body: const PageViewExample(), + ), + ); + } +} + +class PageViewExample extends StatefulWidget { + const PageViewExample({super.key}); + + @override + State createState() => _PageViewExampleState(); +} + +class _PageViewExampleState extends State with TickerProviderStateMixin { + late PageController _pageViewController; + late TabController _tabController; + int _currentPageIndex = 0; + + @override + void initState() { + super.initState(); + _pageViewController = PageController(); + _tabController = TabController(length: 3, vsync: this); + } + + @override + void dispose() { + super.dispose(); + _pageViewController.dispose(); + _tabController.dispose(); + } + + @override + Widget build(BuildContext context) { + final TextTheme textTheme = Theme.of(context).textTheme; + + return Stack( + alignment: Alignment.bottomCenter, + children: [ + PageView( + /// [PageView.scrollDirection] defaults to [Axis.horizontal]. + /// Use [Axis.vertical] to scroll vertically. + controller: _pageViewController, + onPageChanged: _handlePageViewChanged, + children: [ + Center( + child: Text('First Page', style: textTheme.titleLarge), + ), + Center( + child: Text('Second Page', style: textTheme.titleLarge), + ), + Center( + child: Text('Third Page', style: textTheme.titleLarge), + ), + ], + ), + PageIndicator( + tabController: _tabController, + currentPageIndex: _currentPageIndex, + onUpdateCurrentPageIndex: _updateCurrentPageIndex, + isOnDesktopAndWeb: _isOnDesktopAndWeb, + ), + ], + ); + } + + void _handlePageViewChanged(int currentPageIndex) { + if (!_isOnDesktopAndWeb) { + return; + } + _tabController.index = currentPageIndex; + setState(() { + _currentPageIndex = currentPageIndex; + }); + } + + void _updateCurrentPageIndex(int index) { + _tabController.index = index; + _pageViewController.animateToPage( + index, + duration: const Duration(milliseconds: 400), + curve: Curves.easeInOut, + ); + } + + bool get _isOnDesktopAndWeb { + if (kIsWeb) { + return true; + } + switch (defaultTargetPlatform) { + case TargetPlatform.macOS: + case TargetPlatform.linux: + case TargetPlatform.windows: + return true; + case TargetPlatform.android: + case TargetPlatform.iOS: + case TargetPlatform.fuchsia: + return false; + } + } +} + +/// Page indicator for desktop and web platforms. +/// +/// On Desktop and Web, drag gesture for horizontal scrolling in a PageView is disabled by default. +/// You can defined a custom scroll behavior to activate drag gestures, +/// see https://docs.flutter.dev/release/breaking-changes/default-scroll-behavior-drag. +/// +/// In this sample, we use a TabPageSelector to navigate between pages, +/// in order to build natural behavior similar to other desktop applications. +class PageIndicator extends StatelessWidget { + const PageIndicator({ + super.key, + required this.tabController, + required this.currentPageIndex, + required this.onUpdateCurrentPageIndex, + required this.isOnDesktopAndWeb, + }); + + final int currentPageIndex; + final TabController tabController; + final void Function(int) onUpdateCurrentPageIndex; + final bool isOnDesktopAndWeb; + + @override + Widget build(BuildContext context) { + if (!isOnDesktopAndWeb) { + return const SizedBox.shrink(); + } + final ColorScheme colorScheme = Theme.of(context).colorScheme; + + return Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + IconButton( + splashRadius: 16.0, + padding: EdgeInsets.zero, + onPressed: () { + if (currentPageIndex == 0) { + return; + } + onUpdateCurrentPageIndex(currentPageIndex - 1); + }, + icon: const Icon( + Icons.arrow_left_rounded, + size: 32.0, + ), + ), + TabPageSelector( + controller: tabController, + color: colorScheme.background, + selectedColor: colorScheme.primary, + ), + IconButton( + splashRadius: 16.0, + padding: EdgeInsets.zero, + onPressed: () { + if (currentPageIndex == 2) { + return; + } + onUpdateCurrentPageIndex(currentPageIndex + 1); + }, + icon: const Icon( + Icons.arrow_right_rounded, + size: 32.0, + ), + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/page_view/page_view.1.dart b/novelforge-project/flutter/examples/api/lib/widgets/page_view/page_view.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..56aef059a3d97fa115cb90cea49e32ee26fe5778 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/page_view/page_view.1.dart @@ -0,0 +1,95 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for a [PageView] using the `findChildIndexCallback` argument. +void main() => runApp(const PageViewExampleApp()); + +class PageViewExampleApp extends StatelessWidget { + const PageViewExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp(home: PageViewExample()); + } +} + +class PageViewExample extends StatefulWidget { + const PageViewExample({super.key}); + + @override + State createState() => _PageViewExampleState(); +} + +class _PageViewExampleState extends State { + List items = ['1', '2', '3', '4', '5']; + + void _reverse() { + setState(() { + items = items.reversed.toList(); + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: const Text('PageView Sample')), + body: SafeArea( + child: PageView.custom( + childrenDelegate: SliverChildBuilderDelegate( + (BuildContext context, int index) { + return KeepAliveItem( + data: items[index], + key: ValueKey(items[index]), + ); + }, + childCount: items.length, + findChildIndexCallback: (Key key) { + final ValueKey valueKey = key as ValueKey; + final String data = valueKey.value; + final int index = items.indexOf(data); + if (index >= 0) { + return index; + } + return null; + }, + ), + ), + ), + bottomNavigationBar: BottomAppBar( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + TextButton( + onPressed: () => _reverse(), + child: const Text('Reverse items'), + ), + ], + ), + ), + ); + } +} + +class KeepAliveItem extends StatefulWidget { + const KeepAliveItem({super.key, required this.data}); + + final String data; + + @override + State createState() => _KeepAliveItemState(); +} + +class _KeepAliveItemState extends State + with AutomaticKeepAliveClientMixin { + @override + bool get wantKeepAlive => true; + + @override + Widget build(BuildContext context) { + super.build(context); + return Text(widget.data); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/pop_scope/pop_scope.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/pop_scope/pop_scope.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..6d144bd088de1d5a8f5a7c75cc24838962841a61 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/pop_scope/pop_scope.0.dart @@ -0,0 +1,128 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This sample demonstrates showing a confirmation dialog before navigating +// away from a page. + +import 'package:flutter/material.dart'; + +void main() => runApp(const NavigatorPopHandlerApp()); + +class NavigatorPopHandlerApp extends StatelessWidget { + const NavigatorPopHandlerApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + initialRoute: '/home', + routes: { + '/home': (BuildContext context) => const _HomePage(), + '/two': (BuildContext context) => const _PageTwo(), + }, + ); + } +} + +class _HomePage extends StatefulWidget { + const _HomePage(); + + @override + State<_HomePage> createState() => _HomePageState(); +} + +class _HomePageState extends State<_HomePage> { + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text('Page One'), + TextButton( + onPressed: () { + Navigator.of(context).pushNamed('/two'); + }, + child: const Text('Next page'), + ), + ], + ), + ), + ); + } +} + +class _PageTwo extends StatefulWidget { + const _PageTwo(); + + @override + State<_PageTwo> createState() => _PageTwoState(); +} + +class _PageTwoState extends State<_PageTwo> { + void _showBackDialog() { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Are you sure?'), + content: const Text( + 'Are you sure you want to leave this page?', + ), + actions: [ + TextButton( + style: TextButton.styleFrom( + textStyle: Theme.of(context).textTheme.labelLarge, + ), + child: const Text('Nevermind'), + onPressed: () { + Navigator.pop(context); + }, + ), + TextButton( + style: TextButton.styleFrom( + textStyle: Theme.of(context).textTheme.labelLarge, + ), + child: const Text('Leave'), + onPressed: () { + Navigator.pop(context); + Navigator.pop(context); + }, + ), + ], + ); + }, + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text('Page Two'), + PopScope( + canPop: false, + onPopInvoked: (bool didPop) { + if (didPop) { + return; + } + _showBackDialog(); + }, + child: TextButton( + onPressed: () { + _showBackDialog(); + }, + child: const Text('Go back'), + ), + ), + ], + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/pop_scope/pop_scope.1.dart b/novelforge-project/flutter/examples/api/lib/widgets/pop_scope/pop_scope.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..7a058837a548151dae966691a4017f7ac06baaa8 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/pop_scope/pop_scope.1.dart @@ -0,0 +1,233 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This sample demonstrates how to use a PopScope to wrap a widget that +// may pop the page with a result. + +import 'package:flutter/material.dart'; + +void main() => runApp(const NavigatorPopHandlerApp()); + +class NavigatorPopHandlerApp extends StatelessWidget { + const NavigatorPopHandlerApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + initialRoute: '/home', + onGenerateRoute: (RouteSettings settings) { + return switch (settings.name) { + '/two' => MaterialPageRoute( + builder: (BuildContext context) => const _PageTwo(), + ), + _ => MaterialPageRoute( + builder: (BuildContext context) => const _HomePage(), + ), + }; + }, + ); + } +} + +class _HomePage extends StatefulWidget { + const _HomePage(); + + @override + State<_HomePage> createState() => _HomePageState(); +} + +class _HomePageState extends State<_HomePage> { + FormData? _formData; + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text('Page One'), + if (_formData != null) + Text('Hello ${_formData!.name}, whose favorite food is ${_formData!.favoriteFood}.'), + TextButton( + onPressed: () async { + final FormData formData = + await Navigator.of(context).pushNamed('/two') + ?? const FormData(); + if (formData != _formData) { + setState(() { + _formData = formData; + }); + } + }, + child: const Text('Next page'), + ), + ], + ), + ), + ); + } +} + +class _PopScopeWrapper extends StatelessWidget { + const _PopScopeWrapper({required this.child}); + + final Widget child; + + Future _showBackDialog(BuildContext context) { + return showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Are you sure?'), + content: const Text( + 'Are you sure you want to leave this page?', + ), + actions: [ + TextButton( + style: TextButton.styleFrom( + textStyle: Theme.of(context).textTheme.labelLarge, + ), + child: const Text('Never mind'), + onPressed: () { + Navigator.pop(context, false); + }, + ), + TextButton( + style: TextButton.styleFrom( + textStyle: Theme.of(context).textTheme.labelLarge, + ), + child: const Text('Leave'), + onPressed: () { + Navigator.pop(context, true); + }, + ), + ], + ); + }, + ); + } + + @override + Widget build(BuildContext context) { + return PopScope( + canPop: false, + // The result argument contains the pop result that is defined in `_PageTwo`. + onPopInvokedWithResult: (bool didPop, FormData? result) async { + if (didPop) { + return; + } + final bool shouldPop = await _showBackDialog(context) ?? false; + if (context.mounted && shouldPop) { + Navigator.pop(context, result); + } + }, + child: child, + ); + } +} + +// This is a PopScope wrapper over _PageTwoBody +class _PageTwo extends StatelessWidget { + const _PageTwo(); + + @override + Widget build(BuildContext context) { + return const _PopScopeWrapper( + child: _PageTwoBody(), + ); + } + +} + +class _PageTwoBody extends StatefulWidget { + const _PageTwoBody(); + + @override + State<_PageTwoBody> createState() => _PageTwoBodyState(); +} + +class _PageTwoBodyState extends State<_PageTwoBody> { + FormData _formData = const FormData(); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text('Page Two'), + Form( + child: Column( + children: [ + TextFormField( + decoration: const InputDecoration( + hintText: 'Enter your name.', + ), + onChanged: (String value) { + _formData = _formData.copyWith( + name: value, + ); + }, + ), + TextFormField( + decoration: const InputDecoration( + hintText: 'Enter your favorite food.', + ), + onChanged: (String value) { + _formData = _formData.copyWith( + favoriteFood: value, + ); + }, + ), + ], + ), + ), + TextButton( + onPressed: () async { + Navigator.maybePop(context, _formData); + }, + child: const Text('Go back'), + ), + ], + ), + ), + ); + } +} + +@immutable +class FormData { + const FormData({ + this.name = '', + this.favoriteFood = '', + }); + + final String name; + final String favoriteFood; + + FormData copyWith({String? name, String? favoriteFood}) { + return FormData( + name: name ?? this.name, + favoriteFood: favoriteFood ?? this.favoriteFood, + ); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (other.runtimeType != runtimeType) { + return false; + } + return other is FormData + && other.name == name + && other.favoriteFood == favoriteFood; + } + + @override + int get hashCode => Object.hash(name, favoriteFood); +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/preferred_size/preferred_size.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/preferred_size/preferred_size.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..8ea542f0929f98c41f5b023cffd38a07d4b555b6 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/preferred_size/preferred_size.0.dart @@ -0,0 +1,85 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [PreferredSize]. + +void main() => runApp(const PreferredSizeExampleApp()); + +class PreferredSizeExampleApp extends StatelessWidget { + const PreferredSizeExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: PreferredSizeExample(), + ); + } +} + +class AppBarContent extends StatelessWidget { + const AppBarContent({super.key}); + + @override + Widget build(BuildContext context) { + return Column( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Padding( + padding: const EdgeInsets.symmetric(horizontal: 10), + child: Row( + children: [ + const Text( + 'PreferredSize Sample', + style: TextStyle(color: Colors.white), + ), + const Spacer(), + IconButton( + icon: const Icon( + Icons.search, + size: 20, + ), + color: Colors.white, + onPressed: () {}, + ), + IconButton( + icon: const Icon( + Icons.more_vert, + size: 20, + ), + color: Colors.white, + onPressed: () {}, + ), + ], + ), + ), + ], + ); + } +} + +class PreferredSizeExample extends StatelessWidget { + const PreferredSizeExample({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: PreferredSize( + preferredSize: const Size.fromHeight(80.0), + child: Container( + decoration: const BoxDecoration( + gradient: LinearGradient( + colors: [Colors.blue, Colors.pink], + ), + ), + child: const AppBarContent(), + ), + ), + body: const Center( + child: Text('Content'), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/restoration/restoration_mixin.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/restoration/restoration_mixin.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..5f401a2dbd19668bf5a38fd4dc330eff4ff11bc3 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/restoration/restoration_mixin.0.dart @@ -0,0 +1,96 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [RestorationMixin]. + +void main() => runApp(const RestorationExampleApp()); + +class RestorationExampleApp extends StatelessWidget { + const RestorationExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + restorationScopeId: 'app', + title: 'Restorable Counter', + home: RestorableCounter(restorationId: 'counter'), + ); + } +} + +class RestorableCounter extends StatefulWidget { + const RestorableCounter({super.key, this.restorationId}); + + final String? restorationId; + + @override + State createState() => _RestorableCounterState(); +} + +// The [State] object uses the [RestorationMixin] to make the current value +// of the counter restorable. +class _RestorableCounterState extends State with RestorationMixin { + // The current value of the counter is stored in a [RestorableProperty]. + // During state restoration it is automatically restored to its old value. + // If no restoration data is available to restore the counter from, it is + // initialized to the specified default value of zero. + final RestorableInt _counter = RestorableInt(0); + + // In this example, the restoration ID for the mixin is passed in through + // the [StatefulWidget]'s constructor. + @override + String? get restorationId => widget.restorationId; + + @override + void restoreState(RestorationBucket? oldBucket, bool initialRestore) { + // All restorable properties must be registered with the mixin. After + // registration, the counter either has its old value restored or is + // initialized to its default value. + registerForRestoration(_counter, 'count'); + } + + void _incrementCounter() { + setState(() { + // The current value of the property can be accessed and modified via + // the value getter and setter. + _counter.value++; + }); + } + + @override + void dispose() { + _counter.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Restorable Counter'), + ), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text( + 'You have pushed the button this many times:', + ), + Text( + '${_counter.value}', + style: Theme.of(context).textTheme.headlineMedium, + ), + ], + ), + ), + floatingActionButton: FloatingActionButton( + onPressed: _incrementCounter, + tooltip: 'Increment', + child: const Icon(Icons.add), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/restoration_properties/restorable_value.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/restoration_properties/restorable_value.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..f16a6994f92813a2a94ed56b0e86da494a7dbba2 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/restoration_properties/restorable_value.0.dart @@ -0,0 +1,80 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [RestorableValue]. + +void main() => runApp(const RestorableValueExampleApp()); + +class RestorableValueExampleApp extends StatelessWidget { + const RestorableValueExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return WidgetsApp( + title: 'RestorableValue Sample', + color: const Color(0xffffffff), + builder: (BuildContext context, Widget? child) { + return const Center( + child: RestorableValueExample(restorationId: 'main'), + ); + }, + ); + } +} + +class RestorableValueExample extends StatefulWidget { + const RestorableValueExample({super.key, this.restorationId}); + + final String? restorationId; + + @override + State createState() => _RestorableValueExampleState(); +} + +/// RestorationProperty objects can be used because of RestorationMixin. +class _RestorableValueExampleState extends State with RestorationMixin { + // In this example, the restoration ID for the mixin is passed in through + // the [StatefulWidget]'s constructor. + @override + String? get restorationId => widget.restorationId; + + // The current value of the answer is stored in a [RestorableProperty]. + // During state restoration it is automatically restored to its old value. + // If no restoration data is available to restore the answer from, it is + // initialized to the specified default value, in this case 42. + final RestorableInt _answer = RestorableInt(42); + + @override + void restoreState(RestorationBucket? oldBucket, bool initialRestore) { + // All restorable properties must be registered with the mixin. After + // registration, the answer either has its old value restored or is + // initialized to its default value. + registerForRestoration(_answer, 'answer'); + } + + void _incrementAnswer() { + setState(() { + // The current value of the property can be accessed and modified via + // the value getter and setter. + _answer.value += 1; + }); + } + + @override + void dispose() { + // Properties must be disposed when no longer used. + _answer.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return OutlinedButton( + onPressed: _incrementAnswer, + child: Text('${_answer.value}'), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/routes/popup_route.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/routes/popup_route.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..ea1384e72939a4d135c4b1bd3f75fbda4accf723 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/routes/popup_route.0.dart @@ -0,0 +1,84 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [PopupRoute]. + +void main() => runApp(const PopupRouteApp()); + +class PopupRouteApp extends StatelessWidget { + const PopupRouteApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: PopupRouteExample(), + ); + } +} + +class PopupRouteExample extends StatelessWidget { + const PopupRouteExample({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: OutlinedButton( + onPressed: () { + // This shows a dismissible dialog. + Navigator.of(context).push(DismissibleDialog()); + }, + child: const Text('Open DismissibleDialog'), + ), + ), + ); + } +} + +class DismissibleDialog extends PopupRoute { + @override + Color? get barrierColor => Colors.black.withAlpha(0x50); + + // This allows the popup to be dismissed by tapping the scrim or by pressing + // the escape key on the keyboard. + @override + bool get barrierDismissible => true; + + @override + String? get barrierLabel => 'Dismissible Dialog'; + + @override + Duration get transitionDuration => const Duration(milliseconds: 300); + + @override + Widget buildPage(BuildContext context, Animation animation, Animation secondaryAnimation) { + return Center( + // Provide DefaultTextStyle to ensure that the dialog's text style + // matches the rest of the text in the app. + child: DefaultTextStyle( + style: Theme.of(context).textTheme.bodyMedium!, + // UnconstrainedBox is used to make the dialog size itself + // to fit to the size of the content. + child: UnconstrainedBox( + child: Container( + padding: const EdgeInsets.all(20.0), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.white, + ), + child: Column( + children: [ + Text('Dismissible Dialog', style: Theme.of(context).textTheme.headlineSmall), + const SizedBox(height: 20), + const Text('Tap in the scrim or press escape key to dismiss.'), + ], + ), + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/routes/route_observer.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/routes/route_observer.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..f022e308238bfcef939ec59f3d8879d978c2f684 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/routes/route_observer.0.dart @@ -0,0 +1,120 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [RouteObserver]. + +final RouteObserver> routeObserver = RouteObserver>(); + +void main() { + runApp(const RouteObserverApp()); +} + +class RouteObserverApp extends StatelessWidget { + const RouteObserverApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + navigatorObservers: [ routeObserver ], + home: const RouteObserverExample(), + ); + } +} + +class RouteObserverExample extends StatefulWidget { + const RouteObserverExample({super.key}); + + @override + State createState() => _RouteObserverExampleState(); +} + +class _RouteObserverExampleState extends State with RouteAware { + List log = []; + + @override + void didChangeDependencies() { + super.didChangeDependencies(); + routeObserver.subscribe(this, ModalRoute.of(context)!); + } + + @override + void dispose() { + routeObserver.unsubscribe(this); + super.dispose(); + } + + @override + void didPush() { + // Route was pushed onto navigator and is now the topmost route. + log.add('didPush'); + } + + @override + void didPopNext() { + // Covering route was popped off the navigator. + log.add('didPopNext'); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + 'RouteObserver log:', + style: Theme.of(context).textTheme.headlineSmall, + ), + ConstrainedBox( + constraints: const BoxConstraints(maxHeight: 300.0), + child: ListView.builder( + itemCount: log.length, + itemBuilder: (BuildContext context, int index) { + if (log.isEmpty) { + return const SizedBox.shrink(); + } + return Text( + log[index], + textAlign: TextAlign.center, + ); + }, + ), + ), + OutlinedButton( + onPressed: () { + Navigator.of(context).push( + MaterialPageRoute( + builder: (BuildContext context) => const NextPage(), + ), + ); + }, + child: const Text('Go to next page'), + ), + ], + ), + ), + ); + } +} + +class NextPage extends StatelessWidget { + const NextPage({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: FilledButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: const Text('Go back to RouteAware page'), + ) + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/routes/show_general_dialog.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/routes/show_general_dialog.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..339a2ce61d1c5744abe707531bb16179cdefd8fb --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/routes/show_general_dialog.0.dart @@ -0,0 +1,53 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [showGeneralDialog]. + +void main() => runApp(const GeneralDialogApp()); + +class GeneralDialogApp extends StatelessWidget { + const GeneralDialogApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + restorationScopeId: 'app', + home: GeneralDialogExample(), + ); + } +} + +class GeneralDialogExample extends StatelessWidget { + const GeneralDialogExample({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: OutlinedButton( + onPressed: () { + /// This shows an alert dialog. + Navigator.of(context).restorablePush(_dialogBuilder); + }, + child: const Text('Open Dialog'), + ), + ), + ); + } + + @pragma('vm:entry-point') + static Route _dialogBuilder(BuildContext context, Object? arguments) { + return RawDialogRoute( + pageBuilder: ( + BuildContext context, + Animation animation, + Animation secondaryAnimation, + ) { + return const AlertDialog(title: Text('Alert!')); + }, + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/scroll_end_notification/scroll_end_notification.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/scroll_end_notification/scroll_end_notification.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..f1f0b67011015560979d289a0455d07bdef528bb --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/scroll_end_notification/scroll_end_notification.0.dart @@ -0,0 +1,131 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/scheduler.dart'; + +/// Flutter code sample for [ScrollEndNotification]. + +void main() { + runApp(const ScrollEndNotificationApp()); +} + +class ScrollEndNotificationApp extends StatelessWidget { + const ScrollEndNotificationApp({ super.key }); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: ScrollEndNotificationExample(), + ); + } +} + +class ScrollEndNotificationExample extends StatefulWidget { + const ScrollEndNotificationExample({ super.key }); + + @override + State createState() => _ScrollEndNotificationExampleState(); +} + +class _ScrollEndNotificationExampleState extends State { + static const int itemCount = 25; + static const double itemExtent = 100; + + late final ScrollController scrollController; + late double lastScrollOffset; + + @override + void initState() { + scrollController = ScrollController(); + super.initState(); + } + + @override + void dispose() { + super.dispose(); + scrollController.dispose(); + } + + // After an interactive scroll "ends", auto-scroll so that last item in the + // viewport is completely visible. To accomodate mouse-wheel scrolls, other small + // adjustments, and scrolling to the top, scrolls that put the scroll offset at + // zero or change the scroll offset by less than itemExtent don't trigger + // an auto-scroll. This also prevents the auto-scroll from triggering itself, + // since the alignedScrollOffset is guaranteed to be less than itemExtent. + bool handleScrollNotification(ScrollNotification notification) { + if (notification is ScrollStartNotification) { + lastScrollOffset = scrollController.position.pixels; + } + if (notification is ScrollEndNotification) { + final ScrollMetrics m = notification.metrics; + final int lastIndex = ((m.extentBefore + m.extentInside) ~/ itemExtent).clamp(0, itemCount - 1); + final double alignedScrollOffset = itemExtent * (lastIndex + 1) - m.extentInside; + final double scrollOffset = scrollController.position.pixels; + if (scrollOffset > 0 && (scrollOffset - lastScrollOffset).abs() > itemExtent) { + SchedulerBinding.instance.addPostFrameCallback((Duration duration) { + scrollController.animateTo( + alignedScrollOffset, + duration: const Duration(milliseconds: 400), + curve: Curves.fastOutSlowIn, + ); + }); + } + } + return true; + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SafeArea( + child: Scrollbar( + controller: scrollController, + thumbVisibility: true, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 8), + child: NotificationListener( + onNotification: handleScrollNotification, + child: CustomScrollView( + controller: scrollController, + slivers: [ + SliverFixedExtentList( + itemExtent: itemExtent, + delegate: SliverChildBuilderDelegate( + (BuildContext context, int index) { + return Item( + title: 'Item $index', + color: Color.lerp(Colors.red, Colors.blue, index / itemCount)! + ); + }, + childCount: itemCount, + ), + ), + ], + ), + ), + ), + ), + ), + ); + } +} + +class Item extends StatelessWidget { + const Item({ super.key, required this.title, required this.color }); + + final String title; + final Color color; + + @override + Widget build(BuildContext context) { + return Card( + color: color, + child: ListTile( + textColor: Colors.white, + title: Text(title), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/scroll_end_notification/scroll_end_notification.1.dart b/novelforge-project/flutter/examples/api/lib/widgets/scroll_end_notification/scroll_end_notification.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..450e062b08db69d757a262b18fc8c23ed5ada00f --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/scroll_end_notification/scroll_end_notification.1.dart @@ -0,0 +1,188 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; +import 'package:flutter/scheduler.dart'; + +void main() { + runApp(const SliverAutoScrollExampleApp()); +} + +class SliverAutoScrollExampleApp extends StatelessWidget { + const SliverAutoScrollExampleApp({ super.key }); + + @override + Widget build(BuildContext context) { + return const MaterialApp(home: SliverAutoScrollExample()); + } +} + +class SliverAutoScrollExample extends StatefulWidget { + const SliverAutoScrollExample({ super.key }); + + @override + State createState() => _SliverAutoScrollExampleState(); +} + +class _SliverAutoScrollExampleState extends State { + final GlobalKey alignedItemKey = GlobalKey(); + late final ScrollController scrollController; + late double lastScrollOffset; + + @override + void initState() { + super.initState(); + scrollController = ScrollController(); + } + + @override + void dispose() { + scrollController.dispose(); + super.dispose(); + } + + void autoScrollTo(double offset) { + scrollController.position.animateTo( + offset, + duration: const Duration(milliseconds: 300), + curve: Curves.easeInOut, + ); + } + + // After an interactive scroll ends, if the alignedItem is partially visible + // at the top or bottom of the viewport, then auto-scroll so that it's + // completely visible. To accomodate mouse-wheel scrolls and other small + // adjustments, scrolls that change the scroll offset by less than + // the alignedItem's extent don't trigger an auto-scroll. + void maybeAutoScrollAlignedItem(RenderSliver alignedItem) { + final SliverConstraints constraints = alignedItem.constraints; + final SliverGeometry geometry = alignedItem.geometry!; + final double sliverOffset = constraints.scrollOffset; + + if ((scrollController.offset - lastScrollOffset).abs() <= geometry.maxPaintExtent) { + // Ignore scrolls that are smaller than the aligned item's extent. + return; + } + final double overflow = geometry.maxPaintExtent - geometry.paintExtent; + if (overflow > 0 && overflow < geometry.scrollExtent) { // indicates partial visibility + if (sliverOffset > 0) { + autoScrollTo(constraints.precedingScrollExtent); // top + } else if (sliverOffset == 0) { + autoScrollTo(scrollController.offset + overflow); // bottom + } + } + } + + // Calls maybeAutoScrollAlignedItem in a post-frame callback so that + // auto-scrolls are triggered _after_ the current scroll activity + // has completed. Otherwise auto-scrolling would be a no-op. + bool handleScrollNotification(ScrollNotification notification) { + if (notification is ScrollStartNotification) { + lastScrollOffset = scrollController.offset; + } + if (notification is ScrollEndNotification) { + SchedulerBinding.instance.addPostFrameCallback((Duration duration) { + final RenderSliver? sliver = + alignedItemKey.currentContext?.findAncestorRenderObjectOfType(); + if (sliver != null && sliver.geometry != null) { + maybeAutoScrollAlignedItem(sliver); + } + }); + } + return false; + } + + @override + Widget build(BuildContext context) { + const EdgeInsets horizontalPadding = EdgeInsets.symmetric(horizontal: 8); + + return Scaffold( + body: SafeArea( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 4), + child: NotificationListener( + onNotification: handleScrollNotification, + child: Scrollbar( + controller: scrollController, + thumbVisibility: true, + child: CustomScrollView( + controller: scrollController, + slivers: [ + const SliverPadding( + padding: horizontalPadding, + sliver: ItemList(itemCount: 15), + ), + SliverPadding( + padding: horizontalPadding, + sliver: BigOrangeSliver(sliverChildKey: alignedItemKey), + ), + const SliverPadding( + padding: horizontalPadding, + sliver: ItemList(itemCount: 25), + ), + ], + ), + ), + ), + ), + ), + ); + } +} + +// A big list item that's easy to spot. The provided key is assigned to +// the aligned sliver's child so that we can find the this item's RenderSliver +// later with BuildContext.findAncestorRenderObjectOfType. +class BigOrangeSliver extends StatelessWidget { + const BigOrangeSliver({ super.key, required this.sliverChildKey }); + + final Key sliverChildKey; + + @override + Widget build(BuildContext context) { + return SliverToBoxAdapter( + child: Card( + key: sliverChildKey, + color: Colors.orange, + child: const SizedBox( + width: 300, + child: ListTile( + textColor: Colors.white, + title: Padding( + padding: EdgeInsets.symmetric(vertical: 32), + child: Text('Aligned Item'), + ), + ) + ), + ), + ); + } +} + +// A placeholder SliverList of 50 items. +class ItemList extends StatelessWidget { + const ItemList({ super.key, this.itemCount = 50 }); + + final int itemCount; + + @override + Widget build(BuildContext context) { + final ColorScheme colorScheme = Theme.of(context).colorScheme; + return SliverList( + delegate: SliverChildBuilderDelegate( + (BuildContext context, int index) { + return Card( + color: colorScheme.onSecondary, + child: SizedBox(width: 100, child: ListTile( + textColor: colorScheme.secondary, + title: Text('Item $index.$itemCount'), + )), + ); + }, + childCount: itemCount, + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/scroll_notification_observer/scroll_notification_observer.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/scroll_notification_observer/scroll_notification_observer.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..78459bc59c1e61272264270d8ad7460773d6f59f --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/scroll_notification_observer/scroll_notification_observer.0.dart @@ -0,0 +1,135 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [ScrollNotificationObserver]. + +void main() => runApp(const ScrollNotificationObserverApp()); + +class ScrollNotificationObserverApp extends StatelessWidget { + const ScrollNotificationObserverApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData(useMaterial3: true), + // The Scaffold widget contains a [ScrollNotificationObserver]. + // This is used by [AppBar] for its scrolled under behavior. + // + // We can use [ScrollNotificationObserver.maybeOf] to get the + // state of this [ScrollNotificationObserver] from descendants + // of the Scaffold widget. + // + // If you're not using a [Scaffold] widget, you can create a [ScrollNotificationObserver] + // to notify its descendants of scroll notifications by adding it to the subtree. + home: Scaffold( + appBar: AppBar( + title: const Text('ScrollNotificationObserver Sample'), + ), + body: const ScrollNotificationObserverExample(), + ), + ); + } +} + +class ScrollNotificationObserverExample extends StatefulWidget { + const ScrollNotificationObserverExample({super.key}); + + @override + State createState() => _ScrollNotificationObserverExampleState(); +} + +class _ScrollNotificationObserverExampleState extends State { + ScrollNotificationObserverState? _scrollNotificationObserver; + ScrollController controller = ScrollController(); + bool _scrolledDown = false; + + @override + void didChangeDependencies() { + super.didChangeDependencies(); + // Remove any previous listener. + _scrollNotificationObserver?.removeListener(_handleScrollNotification); + // Get the ScrollNotificationObserverState from the Scaffold widget. + _scrollNotificationObserver = ScrollNotificationObserver.maybeOf(context); + // Add a new listener. + _scrollNotificationObserver?.addListener(_handleScrollNotification); + } + + @override + void dispose() { + if (_scrollNotificationObserver != null) { + _scrollNotificationObserver!.removeListener(_handleScrollNotification); + _scrollNotificationObserver = null; + } + controller.dispose(); + super.dispose(); + } + + void _handleScrollNotification(ScrollNotification notification) { + // Check if the notification is a scroll update notification and if the + // `notification.depth` is 0. This way we only listen to the scroll + // notifications from the closest scrollable, instead of those that may be nested. + if (notification is ScrollUpdateNotification && defaultScrollNotificationPredicate(notification)) { + final ScrollMetrics metrics = notification.metrics; + // Check if the user scrolled down. + if (_scrolledDown != metrics.extentBefore > 0) { + setState(() { + _scrolledDown = metrics.extentBefore > 0; + }); + } + } + } + + @override + Widget build(BuildContext context) { + return Stack( + children: [ + SampleList(controller: controller), + // Show the button only if the user scrolled down. + if (_scrolledDown) + Positioned( + right: 25, + bottom: 20, + child: Center( + child: GestureDetector( + onTap: () { + // Scroll to the top when the user taps the button. + controller.animateTo(0, duration: const Duration(milliseconds: 200), curve:Curves.fastOutSlowIn); + }, + child: const Card( + child: Padding( + padding: EdgeInsets.all(8.0), + child: Column( + children: [ + Icon(Icons.arrow_upward_rounded), + Text('Scroll to top') + ], + ), + ), + ), + ), + ), + ), + ], + ); + } +} + +class SampleList extends StatelessWidget { + const SampleList({super.key, required this.controller}); + + final ScrollController controller; + + @override + Widget build(BuildContext context) { + return ListView.builder( + controller: controller, + itemCount: 30, + itemBuilder: (BuildContext context, int index) { + return ListTile(title: Text('Item $index')); + }, + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/scroll_position/is_scrolling_listener.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/scroll_position/is_scrolling_listener.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..26f59f81c261e98808e0cb94c8364c2e5e0212fb --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/scroll_position/is_scrolling_listener.0.dart @@ -0,0 +1,139 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/scheduler.dart'; + +/// Flutter code sample for [IsScrollingListener]. +void main() { + runApp(const IsScrollingListenerApp()); +} + +class IsScrollingListenerApp extends StatelessWidget { + const IsScrollingListenerApp({ super.key }); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: IsScrollingListenerExample(), + ); + } +} + +class IsScrollingListenerExample extends StatefulWidget { + const IsScrollingListenerExample({ super.key }); + + @override + State createState() => _IsScrollingListenerExampleState(); +} + +class _IsScrollingListenerExampleState extends State { + static const int itemCount = 25; + static const double itemExtent = 100; + + late final ScrollController scrollController; + late double lastScrollOffset; + bool isScrolling = false; + + @override + void initState() { + scrollController = ScrollController( + onAttach: (ScrollPosition position) { + position.isScrollingNotifier.addListener(handleScrollChange); + }, + onDetach: (ScrollPosition position) { + position.isScrollingNotifier.removeListener(handleScrollChange); + }, + ); + super.initState(); + } + + @override + void dispose() { + scrollController.dispose(); + super.dispose(); + } + + // After an interactive scroll "ends", auto-scroll so that last item in the + // viewport is completely visible. To accomodate mouse-wheel scrolls, other small + // adjustments, and scrolling to the top, scrolls that put the scroll offset at + // zero or change the scroll offset by less than itemExtent don't trigger + // an auto-scroll. + void handleScrollChange() { + final bool isScrollingNow = scrollController.position.isScrollingNotifier.value; + if (isScrolling == isScrollingNow) { + return; + } + isScrolling = isScrollingNow; + if (isScrolling) { + // scroll-start + lastScrollOffset = scrollController.position.pixels; + } else { + // scroll-end + final ScrollPosition p = scrollController.position; + final int lastIndex = ((p.extentBefore + p.extentInside) ~/ itemExtent).clamp(0, itemCount - 1); + final double alignedScrollOffset = itemExtent * (lastIndex + 1) - p.extentInside; + final double scrollOffset = scrollController.position.pixels; + if (scrollOffset > 0 && (scrollOffset - lastScrollOffset).abs() > itemExtent) { + SchedulerBinding.instance.addPostFrameCallback((Duration duration) { + scrollController.animateTo( + alignedScrollOffset, + duration: const Duration(milliseconds: 400), + curve: Curves.fastOutSlowIn, + ); + }); + } + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SafeArea( + child: Scrollbar( + controller: scrollController, + thumbVisibility: true, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 8), + child: CustomScrollView( + controller: scrollController, + slivers: [ + SliverFixedExtentList( + itemExtent: itemExtent, + delegate: SliverChildBuilderDelegate( + (BuildContext context, int index) { + return Item( + title: 'Item $index', + color: Color.lerp(Colors.red, Colors.blue, index / itemCount)! + ); + }, + childCount: itemCount, + ), + ), + ], + ), + ), + ), + ), + ); + } +} + +class Item extends StatelessWidget { + const Item({ super.key, required this.title, required this.color }); + + final String title; + final Color color; + + @override + Widget build(BuildContext context) { + return Card( + color: color, + child: ListTile( + textColor: Colors.white, + title: Text(title), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/scroll_position/scroll_controller_notification.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/scroll_position/scroll_controller_notification.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..0d8d66082e2c93316f6a67b8e871356664104ec6 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/scroll_position/scroll_controller_notification.0.dart @@ -0,0 +1,163 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [ScrollController] & [ScrollNotification]. + +void main() => runApp(const ScrollNotificationDemo()); + +class ScrollNotificationDemo extends StatefulWidget { + const ScrollNotificationDemo({super.key}); + + @override + State createState() => _ScrollNotificationDemoState(); +} + +class _ScrollNotificationDemoState extends State { + ScrollNotification? _lastNotification; + late final ScrollController _controller; + bool _useController = true; + + // This method handles the notification from the ScrollController. + void _handleControllerNotification() { + print('Notified through the scroll controller.'); + // Access the position directly through the controller for details on the + // scroll position. + } + + // This method handles the notification from the NotificationListener. + bool _handleScrollNotification(ScrollNotification notification) { + print('Notified through scroll notification.'); + // The position can still be accessed through the scroll controller, but + // the notification object provides more details about the activity that is + // occurring. + if (_lastNotification.runtimeType != notification.runtimeType) { + setState(() { + // Call set state to respond to a change in the scroll notification. + _lastNotification = notification; + }); + } + + // Returning false allows the notification to continue bubbling up to + // ancestor listeners. If we wanted the notification to stop bubbling, + // return true. + return false; + } + + @override + void initState() { + _controller = ScrollController(); + if (_useController) { + // When listening to scrolling via the ScrollController, call + // `addListener` on the controller. + _controller.addListener(_handleControllerNotification); + } + super.initState(); + } + + @override + Widget build(BuildContext context) { + // ListView.separated works very similarly to this example with + // CustomScrollView & SliverList. + Widget body = CustomScrollView( + // Provide the scroll controller to the scroll view. + controller: _controller, + slivers: [ + SliverList.separated( + itemCount: 50, + itemBuilder: (_,int index) { + return Padding( + padding: const EdgeInsets.symmetric( + vertical: 8.0, + horizontal: 20.0, + ), + child: Text('Item $index'), + ); + }, + separatorBuilder: (_, __) => const Divider( + indent: 20, + endIndent: 20, + thickness: 2, + ), + ), + ], + ); + + if (!_useController) { + // If we are not using a ScrollController to listen to scrolling, + // let's use a NotificationListener. Similar, but with a different + // handler that provides information on what scrolling is occurring. + body = NotificationListener( + onNotification: _handleScrollNotification, + child: body, + ); + } + + return MaterialApp( + theme: ThemeData.from( + useMaterial3: true, + colorScheme: ColorScheme.fromSeed(seedColor: Colors.blueGrey), + ), + home: Scaffold( + appBar: AppBar( + title: const Text('Listening to a ScrollPosition'), + bottom: PreferredSize( + preferredSize: const Size.fromHeight(70), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + if (!_useController) Text('Last notification: ${_lastNotification.runtimeType}'), + if (!_useController) const SizedBox.square(dimension: 10), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text('with:'), + Radio( + value: true, + groupValue: _useController, + onChanged: _handleRadioChange, + ), + const Text('ScrollController'), + Radio( + value: false, + groupValue: _useController, + onChanged: _handleRadioChange, + ), + const Text('NotificationListener'), + ], + ), + ], + ), + ), + ), + body: body, + ), + ); + } + + void _handleRadioChange(bool? value) { + if (value == null) { + return; + } + if (value != _useController) { + setState(() { + // Respond to a change in selected radio button, and add/remove the + // listener to the scroll controller. + _useController = value; + if (_useController) { + _controller.addListener(_handleControllerNotification); + } else { + _controller.removeListener(_handleControllerNotification); + } + }); + } + } + + @override + void dispose() { + _controller.removeListener(_handleControllerNotification); + super.dispose(); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/scroll_position/scroll_controller_on_attach.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/scroll_position/scroll_controller_on_attach.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..d8902d271da38419ad9f74d185b6bd4c0fbdec3f --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/scroll_position/scroll_controller_on_attach.0.dart @@ -0,0 +1,107 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [ScrollController]. + +void main() => runApp(const ScrollControllerDemo()); + +class ScrollControllerDemo extends StatefulWidget { + const ScrollControllerDemo({super.key}); + + @override + State createState() => _ScrollControllerDemoState(); +} + +class _ScrollControllerDemoState extends State { + late final ScrollController _controller; + bool isScrolling = false; + + void _handleScrollChange() { + if (isScrolling != _controller.position.isScrollingNotifier.value) { + setState((){ + isScrolling = _controller.position.isScrollingNotifier.value; + }); + } + } + + void _handlePositionAttach(ScrollPosition position) { + // From here, add a listener to the given ScrollPosition. + // Here the isScrollingNotifier will be used to inform when scrolling starts + // and stops and change the AppBar's color in response. + position.isScrollingNotifier.addListener(_handleScrollChange); + } + + void _handlePositionDetach(ScrollPosition position) { + // From here, add a listener to the given ScrollPosition. + // Here the isScrollingNotifier will be used to inform when scrolling starts + // and stops and change the AppBar's color in response. + position.isScrollingNotifier.removeListener(_handleScrollChange); + } + + @override + void initState() { + _controller = ScrollController( + // These methods will be called in response to a scroll position + // being attached to or detached from this ScrollController. This happens + // when the Scrollable is built. + onAttach: _handlePositionAttach, + onDetach: _handlePositionDetach, + ); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: Text(isScrolling ? 'Scrolling' : 'Not Scrolling'), + backgroundColor: isScrolling + ? Colors.green[800]!.withOpacity(.85) + : Colors.redAccent[700]!.withOpacity(.85), + ), + // ListView.builder works very similarly to this example with + // CustomScrollView & SliverList. + body: CustomScrollView( + // Provide the scroll controller to the scroll view. + controller: _controller, + slivers: [ + SliverList.builder( + itemCount: 50, + itemBuilder: (_, int index) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: DecoratedBox( + decoration: BoxDecoration( + color: Colors.blueGrey[50], + boxShadow: const [ + BoxShadow( + color: Colors.black12, + offset: Offset(5, 5), + blurRadius: 5, + ), + ], + borderRadius: const BorderRadius.all(Radius.circular(10)) + ), + child: Padding( + padding: const EdgeInsets.symmetric( + vertical: 12.0, + horizontal: 20.0, + ), + child: Text('Item $index'), + ), + ), + ), + ); + }, + ), + ], + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/scroll_position/scroll_metrics_notification.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/scroll_position/scroll_metrics_notification.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..cd53ffc13ef0552aaf85a4725874413325c47854 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/scroll_position/scroll_metrics_notification.0.dart @@ -0,0 +1,60 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [ScrollMetricsNotification]. + +void main() => runApp(const ScrollMetricsDemo()); + +class ScrollMetricsDemo extends StatefulWidget { + const ScrollMetricsDemo({super.key}); + + @override + State createState() => ScrollMetricsDemoState(); +} + +class ScrollMetricsDemoState extends State { + double windowSize = 200.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('ScrollMetrics Demo'), + ), + floatingActionButton: FloatingActionButton( + child: const Icon(Icons.add), + onPressed: () => setState(() { + windowSize += 10.0; + }), + ), + body: NotificationListener( + onNotification: (ScrollMetricsNotification notification) { + ScaffoldMessenger.of(notification.context).showSnackBar( + const SnackBar( + content: Text('Scroll metrics changed!'), + ), + ); + return false; + }, + child: Scrollbar( + thumbVisibility: true, + child: SizedBox( + height: windowSize, + width: double.infinity, + child: const SingleChildScrollView( + primary: true, + child: FlutterLogo( + size: 300.0, + ), + ), + ), + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/scroll_view/custom_scroll_view.1.dart b/novelforge-project/flutter/examples/api/lib/widgets/scroll_view/custom_scroll_view.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..213175d744b24de1b70378afd3f257cdb8dede0d --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/scroll_view/custom_scroll_view.1.dart @@ -0,0 +1,83 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [CustomScrollView]. + +void main() => runApp(const CustomScrollViewExampleApp()); + +class CustomScrollViewExampleApp extends StatelessWidget { + const CustomScrollViewExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: CustomScrollViewExample(), + ); + } +} + +class CustomScrollViewExample extends StatefulWidget { + const CustomScrollViewExample({super.key}); + + @override + State createState() => _CustomScrollViewExampleState(); +} + +class _CustomScrollViewExampleState extends State { + List top = []; + List bottom = [0]; + + @override + Widget build(BuildContext context) { + const Key centerKey = ValueKey('bottom-sliver-list'); + return Scaffold( + appBar: AppBar( + title: const Text('Press on the plus to add items above and below'), + leading: IconButton( + icon: const Icon(Icons.add), + onPressed: () { + setState(() { + top.add(-top.length - 1); + bottom.add(bottom.length); + }); + }, + ), + ), + body: CustomScrollView( + center: centerKey, + slivers: [ + SliverList( + delegate: SliverChildBuilderDelegate( + (BuildContext context, int index) { + return Container( + alignment: Alignment.center, + color: Colors.blue[200 + top[index] % 4 * 100], + height: 100 + top[index] % 4 * 20.0, + child: Text('Item: ${top[index]}'), + ); + }, + childCount: top.length, + ), + ), + SliverList( + key: centerKey, + delegate: SliverChildBuilderDelegate( + (BuildContext context, int index) { + return Container( + alignment: Alignment.center, + color: Colors.blue[200 + bottom[index] % 4 * 100], + height: 100 + bottom[index] % 4 * 20.0, + child: Text('Item: ${bottom[index]}'), + ); + }, + childCount: bottom.length, + ), + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/scroll_view/grid_view.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/scroll_view/grid_view.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..218429fde5ef219df379952130afbbed5dfbabf8 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/scroll_view/grid_view.0.dart @@ -0,0 +1,190 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:math' as math; + +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; + +void main() => runApp(const GridViewExampleApp()); + +class GridViewExampleApp extends StatelessWidget { + const GridViewExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Padding( + padding: const EdgeInsets.all(20.0), + child: Card( + elevation: 8.0, + child: GridView.builder( + padding: const EdgeInsets.all(12.0), + gridDelegate: CustomGridDelegate(dimension: 240.0), + // Try uncommenting some of these properties to see the effect on the grid: + // itemCount: 20, // The default is that the number of grid tiles is infinite. + // scrollDirection: Axis.horizontal, // The default is vertical. + // reverse: true, // The default is false, going down (or left to right). + itemBuilder: (BuildContext context, int index) { + final math.Random random = math.Random(index); + return GridTile( + header: GridTileBar( + title: Text('$index', style: const TextStyle(color: Colors.black)), + ), + child: Container( + margin: const EdgeInsets.all(12.0), + decoration: ShapeDecoration( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12.0), + ), + gradient: const RadialGradient( + colors: [ Color(0x0F88EEFF), Color(0x2F0099BB) ], + ), + ), + child: FlutterLogo( + style: FlutterLogoStyle.values[random.nextInt(FlutterLogoStyle.values.length)], + ), + ), + ); + }, + ), + ), + ), + ); + } +} + +class CustomGridDelegate extends SliverGridDelegate { + CustomGridDelegate({ required this.dimension }); + + // This is the desired height of each row (and width of each square). + // When there is not enough room, we shrink this to the width of the scroll view. + final double dimension; + + // The layout is two rows of squares, then one very wide cell, repeat. + + @override + SliverGridLayout getLayout(SliverConstraints constraints) { + // Determine how many squares we can fit per row. + int count = constraints.crossAxisExtent ~/ dimension; + if (count < 1) { + count = 1; // Always fit at least one regardless. + } + final double squareDimension = constraints.crossAxisExtent / count; + return CustomGridLayout( + crossAxisCount: count, + fullRowPeriod: 3, // Number of rows per block (one of which is the full row). + dimension: squareDimension, + ); + } + + @override + bool shouldRelayout(CustomGridDelegate oldDelegate) { + return dimension != oldDelegate.dimension; + } +} + +class CustomGridLayout extends SliverGridLayout { + const CustomGridLayout({ + required this.crossAxisCount, + required this.dimension, + required this.fullRowPeriod, + }) : assert(crossAxisCount > 0), + assert(fullRowPeriod > 1), + loopLength = crossAxisCount * (fullRowPeriod - 1) + 1, + loopHeight = fullRowPeriod * dimension; + + final int crossAxisCount; + final double dimension; + final int fullRowPeriod; + + // Computed values. + final int loopLength; + final double loopHeight; + + @override + double computeMaxScrollOffset(int childCount) { + // This returns the scroll offset of the end side of the childCount'th child. + // In the case of this example, this method is not used, since the grid is + // infinite. However, if one set an itemCount on the GridView above, this + // function would be used to determine how far to allow the user to scroll. + if (childCount == 0 || dimension == 0) { + return 0; + } + return (childCount ~/ loopLength) * loopHeight + + ((childCount % loopLength) ~/ crossAxisCount) * dimension; + } + + @override + SliverGridGeometry getGeometryForChildIndex(int index) { + // This returns the position of the index'th tile. + // + // The SliverGridGeometry object returned from this method has four + // properties. For a grid that scrolls down, as in this example, the four + // properties are equivalent to x,y,width,height. However, since the + // GridView is direction agnostic, the names used for SliverGridGeometry are + // also direction-agnostic. + // + // Try changing the scrollDirection and reverse properties on the GridView + // to see how this algorithm works in any direction (and why, therefore, the + // names are direction-agnostic). + final int loop = index ~/ loopLength; + final int loopIndex = index % loopLength; + if (loopIndex == loopLength - 1) { + // Full width case. + return SliverGridGeometry( + scrollOffset: (loop + 1) * loopHeight - dimension, // "y" + crossAxisOffset: 0, // "x" + mainAxisExtent: dimension, // "height" + crossAxisExtent: crossAxisCount * dimension, // "width" + ); + } + // Square case. + final int rowIndex = loopIndex ~/ crossAxisCount; + final int columnIndex = loopIndex % crossAxisCount; + return SliverGridGeometry( + scrollOffset: (loop * loopHeight) + (rowIndex * dimension), // "y" + crossAxisOffset: columnIndex * dimension, // "x" + mainAxisExtent: dimension, // "height" + crossAxisExtent: dimension, // "width" + ); + } + + @override + int getMinChildIndexForScrollOffset(double scrollOffset) { + // This returns the first index that is visible for a given scrollOffset. + // + // The GridView only asks for the geometry of children that are visible + // between the scroll offset passed to getMinChildIndexForScrollOffset and + // the scroll offset passed to getMaxChildIndexForScrollOffset. + // + // It is the responsibility of the SliverGridLayout to ensure that + // getGeometryForChildIndex is consistent with getMinChildIndexForScrollOffset + // and getMaxChildIndexForScrollOffset. + // + // Not every child between the minimum child index and the maximum child + // index need be visible (some may have scroll offsets that are outside the + // view; this happens commonly when the grid view places tiles out of + // order). However, doing this means the grid view is less efficient, as it + // will do work for children that are not visible. It is preferred that the + // children are returned in the order that they are laid out. + final int rows = scrollOffset ~/ dimension; + final int loops = rows ~/ fullRowPeriod; + final int extra = rows % fullRowPeriod; + return loops * loopLength + extra * crossAxisCount; + } + + @override + int getMaxChildIndexForScrollOffset(double scrollOffset) { + // (See commentary above.) + final int rows = scrollOffset ~/ dimension; + final int loops = rows ~/ fullRowPeriod; + final int extra = rows % fullRowPeriod; + final int count = loops * loopLength + extra * crossAxisCount; + if (extra == fullRowPeriod - 1) { + return count; + } + return count + crossAxisCount - 1; + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/scroll_view/list_view.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/scroll_view/list_view.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..870420fdfd8f1292053f165dab899aa945c0ca8f --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/scroll_view/list_view.0.dart @@ -0,0 +1,231 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [ListTile] selection in a [ListView] or [GridView]. + +void main() => runApp(const ListViewExampleApp()); + +class ListViewExampleApp extends StatelessWidget { + const ListViewExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: ListTileSelectExample(), + ); + } +} + +class ListTileSelectExample extends StatefulWidget { + const ListTileSelectExample({super.key}); + + @override + ListTileSelectExampleState createState() => ListTileSelectExampleState(); +} + +class ListTileSelectExampleState extends State { + bool isSelectionMode = false; + final int listLength = 30; + late List _selected; + bool _selectAll = false; + bool _isGridMode = false; + + @override + void initState() { + super.initState(); + initializeSelection(); + } + + void initializeSelection() { + _selected = List.generate(listLength, (_) => false); + } + + @override + void dispose() { + _selected.clear(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text( + 'ListTile selection', + ), + leading: isSelectionMode + ? IconButton( + icon: const Icon(Icons.close), + onPressed: () { + setState(() { + isSelectionMode = false; + }); + initializeSelection(); + }, + ) + : const SizedBox(), + actions: [ + if (_isGridMode) + IconButton( + icon: const Icon(Icons.grid_on), + onPressed: () { + setState(() { + _isGridMode = false; + }); + }, + ) + else + IconButton( + icon: const Icon(Icons.list), + onPressed: () { + setState(() { + _isGridMode = true; + }); + }, + ), + if (isSelectionMode) + TextButton( + child: !_selectAll + ? const Text( + 'select all', + style: TextStyle(color: Colors.white), + ) + : const Text( + 'unselect all', + style: TextStyle(color: Colors.white), + ), + onPressed: () { + _selectAll = !_selectAll; + setState(() { + _selected = List.generate(listLength, (_) => _selectAll); + }); + }), + ], + ), + body: _isGridMode + ? GridBuilder( + isSelectionMode: isSelectionMode, + selectedList: _selected, + onSelectionChange: (bool x) { + setState(() { + isSelectionMode = x; + }); + }, + ) + : ListBuilder( + isSelectionMode: isSelectionMode, + selectedList: _selected, + onSelectionChange: (bool x) { + setState(() { + isSelectionMode = x; + }); + }, + )); + } +} + +class GridBuilder extends StatefulWidget { + const GridBuilder({ + super.key, + required this.selectedList, + required this.isSelectionMode, + required this.onSelectionChange, + }); + + final bool isSelectionMode; + final ValueChanged? onSelectionChange; + final List selectedList; + + @override + GridBuilderState createState() => GridBuilderState(); +} + +class GridBuilderState extends State { + void _toggle(int index) { + if (widget.isSelectionMode) { + setState(() { + widget.selectedList[index] = !widget.selectedList[index]; + }); + } + } + + @override + Widget build(BuildContext context) { + return GridView.builder( + itemCount: widget.selectedList.length, + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2), + itemBuilder: (_, int index) { + return InkWell( + onTap: () => _toggle(index), + onLongPress: () { + if (!widget.isSelectionMode) { + setState(() { + widget.selectedList[index] = true; + }); + widget.onSelectionChange!(true); + } + }, + child: GridTile( + child: Container( + child: widget.isSelectionMode + ? Checkbox(onChanged: (bool? x) => _toggle(index), value: widget.selectedList[index]) + : const Icon(Icons.image), + )), + ); + }); + } +} + +class ListBuilder extends StatefulWidget { + const ListBuilder({ + super.key, + required this.selectedList, + required this.isSelectionMode, + required this.onSelectionChange, + }); + + final bool isSelectionMode; + final List selectedList; + final ValueChanged? onSelectionChange; + + @override + State createState() => _ListBuilderState(); +} + +class _ListBuilderState extends State { + void _toggle(int index) { + if (widget.isSelectionMode) { + setState(() { + widget.selectedList[index] = !widget.selectedList[index]; + }); + } + } + + @override + Widget build(BuildContext context) { + return ListView.builder( + itemCount: widget.selectedList.length, + itemBuilder: (_, int index) { + return ListTile( + onTap: () => _toggle(index), + onLongPress: () { + if (!widget.isSelectionMode) { + setState(() { + widget.selectedList[index] = true; + }); + widget.onSelectionChange!(true); + } + }, + trailing: widget.isSelectionMode + ? Checkbox( + value: widget.selectedList[index], + onChanged: (bool? x) => _toggle(index), + ) + : const SizedBox.shrink(), + title: Text('item $index')); + }); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/scroll_view/list_view.1.dart b/novelforge-project/flutter/examples/api/lib/widgets/scroll_view/list_view.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..46adcd3c67cf836c01ef1ad9dcb580bb43d6778d --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/scroll_view/list_view.1.dart @@ -0,0 +1,97 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for a [ListView.custom] using the `findChildIndexCallback` argument. +void main() => runApp(const ListViewExampleApp()); + +class ListViewExampleApp extends StatelessWidget { + const ListViewExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp(home: ListViewExample()); + } +} + +class ListViewExample extends StatefulWidget { + const ListViewExample({super.key}); + + @override + State createState() => _ListViewExampleState(); +} + +class _ListViewExampleState extends State { + List items = ['1', '2', '3', '4', '5']; + + void _reverse() { + setState(() { + items = items.reversed.toList(); + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SafeArea( + child: ListView.custom( + childrenDelegate: SliverChildBuilderDelegate( + (BuildContext context, int index) { + return KeepAliveItem( + data: items[index], + key: ValueKey(items[index]), + ); + }, + childCount: items.length, + findChildIndexCallback: (Key key) { + final ValueKey valueKey = key as ValueKey; + final String data = valueKey.value; + final int index = items.indexOf(data); + if (index >= 0) { + return index; + } + return null; + }, + ), + ), + ), + bottomNavigationBar: BottomAppBar( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + TextButton( + onPressed: () => _reverse(), + child: const Text('Reverse items'), + ), + ], + ), + ), + ); + } +} + +class KeepAliveItem extends StatefulWidget { + const KeepAliveItem({ + required Key key, + required this.data, + }) : super(key: key); + + final String data; + + @override + State createState() => _KeepAliveItemState(); +} + +class _KeepAliveItemState extends State + with AutomaticKeepAliveClientMixin { + @override + bool get wantKeepAlive => true; + + @override + Widget build(BuildContext context) { + super.build(context); + return Text(widget.data); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/scrollbar/raw_scrollbar.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/scrollbar/raw_scrollbar.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..c707aa13f1f65c0ecd8e0e70aa1b7d530846b387 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/scrollbar/raw_scrollbar.0.dart @@ -0,0 +1,88 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [RawScrollbar]. + +void main() => runApp(const RawScrollbarExampleApp()); + +class RawScrollbarExampleApp extends StatelessWidget { + const RawScrollbarExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('RawScrollbar Sample')), + body: const Center( + child: RawScrollbarExample(), + ), + ), + ); + } +} + +class RawScrollbarExample extends StatefulWidget { + const RawScrollbarExample({super.key}); + + @override + State createState() => _RawScrollbarExampleState(); +} + +class _RawScrollbarExampleState extends State { + final ScrollController _firstController = ScrollController(); + + @override + Widget build(BuildContext context) { + return LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) { + return Row( + children: [ + SizedBox( + width: constraints.maxWidth / 2, + // When using the PrimaryScrollController and a Scrollbar + // together, only one ScrollPosition can be attached to the + // PrimaryScrollController at a time. Providing a + // unique scroll controller to this scroll view prevents it + // from attaching to the PrimaryScrollController. + child: Scrollbar( + thumbVisibility: true, + controller: _firstController, + child: ListView.builder( + controller: _firstController, + itemCount: 100, + itemBuilder: (BuildContext context, int index) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Text('Scrollable 1 : Index $index'), + ); + }), + )), + SizedBox( + width: constraints.maxWidth / 2, + // This vertical scroll view has primary set to true, so it is + // using the PrimaryScrollController. On mobile platforms, the + // PrimaryScrollController automatically attaches to vertical + // ScrollViews, unlike on Desktop platforms, where the primary + // parameter is required. + child: Scrollbar( + thumbVisibility: true, + child: ListView.builder( + primary: true, + itemCount: 100, + itemBuilder: (BuildContext context, int index) { + return Container( + height: 50, + color: index.isEven ? Colors.amberAccent : Colors.blueAccent, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Text('Scrollable 2 : Index $index'), + )); + }), + )), + ], + ); + }); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/scrollbar/raw_scrollbar.1.dart b/novelforge-project/flutter/examples/api/lib/widgets/scrollbar/raw_scrollbar.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..2ff22cf071f239df912528076e0f4f91b0b94ba4 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/scrollbar/raw_scrollbar.1.dart @@ -0,0 +1,42 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [RawScrollbar]. + +void main() => runApp(const RawScrollbarExampleApp()); + +class RawScrollbarExampleApp extends StatelessWidget { + const RawScrollbarExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('RawScrollbar Sample')), + body: const RawScrollbarExample(), + ), + ); + } +} + +class RawScrollbarExample extends StatelessWidget { + const RawScrollbarExample({super.key}); + + @override + Widget build(BuildContext context) { + return RawScrollbar( + child: GridView.builder( + itemCount: 120, + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3), + itemBuilder: (BuildContext context, int index) { + return Center( + child: Text('item $index'), + ); + }, + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/scrollbar/raw_scrollbar.2.dart b/novelforge-project/flutter/examples/api/lib/widgets/scrollbar/raw_scrollbar.2.dart new file mode 100644 index 0000000000000000000000000000000000000000..f8aeb105ef02862486ef8277c051d813da80731b --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/scrollbar/raw_scrollbar.2.dart @@ -0,0 +1,52 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [RawScrollbar]. + +void main() => runApp(const RawScrollbarExampleApp()); + +class RawScrollbarExampleApp extends StatelessWidget { + const RawScrollbarExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('RawScrollbar Sample')), + body: const RawScrollbarExample(), + ), + ); + } +} + +class RawScrollbarExample extends StatefulWidget { + const RawScrollbarExample({super.key}); + + @override + State createState() => _RawScrollbarExampleState(); +} + +class _RawScrollbarExampleState extends State { + final ScrollController _controllerOne = ScrollController(); + + @override + Widget build(BuildContext context) { + return RawScrollbar( + controller: _controllerOne, + thumbVisibility: true, + child: GridView.builder( + controller: _controllerOne, + itemCount: 120, + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3), + itemBuilder: (BuildContext context, int index) { + return Center( + child: Text('item $index'), + ); + }, + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/scrollbar/raw_scrollbar.desktop.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/scrollbar/raw_scrollbar.desktop.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..b917dace70e4e159892626bb87e9bdf4c39dd636 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/scrollbar/raw_scrollbar.desktop.0.dart @@ -0,0 +1,95 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Scrollbar]. + +void main() => runApp(const ScrollbarApp()); + +class ScrollbarApp extends StatelessWidget { + const ScrollbarApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('Scrollbar Sample')), + body: const Center( + child: DesktopExample(), + ), + ), + ); + } +} + +class DesktopExample extends StatefulWidget { + const DesktopExample({super.key}); + + @override + State createState() => _DesktopExampleState(); +} + +class _DesktopExampleState extends State { + final ScrollController controller = ScrollController(); + + @override + Widget build(BuildContext context) { + return LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) { + return Row( + children: [ + SizedBox( + width: constraints.maxWidth / 2, + // When running this sample on desktop, two scrollbars will be + // visible here. One is the default scrollbar and the other is the + // Scrollbar widget with custom thickness. + child: Scrollbar( + thickness: 20.0, + thumbVisibility: true, + controller: controller, + child: ListView.builder( + controller: controller, + itemCount: 100, + itemBuilder: (BuildContext context, int index) { + return SizedBox( + height: 50, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Text('Scrollable 1 : Index $index'), + ), + ); + }, + ), + )), + SizedBox( + width: constraints.maxWidth / 2, + // When running this sample on desktop, one scrollbar will be + // visible here. The default scrollbar is hidden by setting the + // ScrollConfiguration's scrollbars to false. The Scrollbar widget + // with custom thickness is visible. + child: Scrollbar( + thickness: 20.0, + thumbVisibility: true, + child: ScrollConfiguration( + behavior: ScrollConfiguration.of(context).copyWith(scrollbars: false), + child: ListView.builder( + primary: true, + itemCount: 100, + itemBuilder: (BuildContext context, int index) { + return SizedBox( + height: 50, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Text('Scrollable 2 : Index $index'), + ), + ); + }, + ), + ), + )), + ], + ); + }); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/scrollbar/raw_scrollbar.shape.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/scrollbar/raw_scrollbar.shape.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..1993cc59b6f98ca15a82f06ef87c4cd30d10513d --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/scrollbar/raw_scrollbar.shape.0.dart @@ -0,0 +1,45 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [RawScrollbar.shape]. + +void main() => runApp(const ShapeExampleApp()); + +class ShapeExampleApp extends StatelessWidget { + const ShapeExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: ShapeExample(), + ); + } +} + +class ShapeExample extends StatelessWidget { + const ShapeExample({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: RawScrollbar( + shape: const StadiumBorder(side: BorderSide(color: Colors.brown, width: 3.0)), + thickness: 15.0, + thumbColor: Colors.blue, + thumbVisibility: true, + child: ListView( + // On mobile platforms, setting primary to true is not required, as + // the PrimaryScrollController automatically attaches to vertical + // ScrollPositions. On desktop platforms however, using the + // PrimaryScrollController requires ScrollView.primary be set. + primary: true, + physics: const BouncingScrollPhysics(), + children: List.generate(100, (int index) => Text((index * index).toString())), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/shared_app_data/shared_app_data.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/shared_app_data/shared_app_data.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..2a2c698e50e98d722859f359ba13e6ad3f7a325c --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/shared_app_data/shared_app_data.0.dart @@ -0,0 +1,77 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [SharedAppData]. + +class ShowSharedValue extends StatelessWidget { + const ShowSharedValue({super.key, required this.appDataKey}); + + final String appDataKey; + + @override + Widget build(BuildContext context) { + // The SharedAppData.getValue() call causes this widget to depend on the + // value of the SharedAppData's 'foo' key. If it's changed, with + // SharedAppData.setValue(), then this widget will be rebuilt. + final String value = SharedAppData.getValue(context, appDataKey, () => 'initial'); + return Text('$appDataKey: $value'); + } +} + +// Demonstrates that changes to the SharedAppData _only_ cause the dependent +// widgets to be rebuilt. In this case that's the ShowSharedValue widget that's +// displaying the value of a key whose value has been updated. +class Home extends StatefulWidget { + const Home({super.key}); + + @override + State createState() => _HomeState(); +} + +class _HomeState extends State { + int _fooVersion = 0; + int _barVersion = 0; + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const ShowSharedValue(appDataKey: 'foo'), + const SizedBox(height: 16), + const ShowSharedValue(appDataKey: 'bar'), + const SizedBox(height: 16), + ElevatedButton( + child: const Text('change foo'), + onPressed: () { + _fooVersion += 1; + // Changing the SharedAppData's value for 'foo' causes the + // widgets that depend on 'foo' to be rebuilt. + SharedAppData.setValue( + context, 'foo', 'FOO $_fooVersion'); // no need to call setState() + }, + ), + const SizedBox(height: 16), + ElevatedButton( + child: const Text('change bar'), + onPressed: () { + _barVersion += 1; + SharedAppData.setValue( + context, 'bar', 'BAR $_barVersion'); // no need to call setState() + }, + ), + ], + ), + ), + ); + } +} + +void main() { + runApp(const MaterialApp(home: Home())); +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/shared_app_data/shared_app_data.1.dart b/novelforge-project/flutter/examples/api/lib/widgets/shared_app_data/shared_app_data.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..76b081e895a9fcf27ff5be0a33ab38f0ac7ec987 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/shared_app_data/shared_app_data.1.dart @@ -0,0 +1,64 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; + +/// Flutter code sample for [SharedAppData]. + +// A single lazily-constructed object that's shared with the entire application +// via `SharedObject.of(context)`. The value of the object can be changed with +// `SharedObject.reset(context)`. Resetting the value will cause all of the +// widgets that depend on it to be rebuilt. +class SharedObject { + SharedObject._(); + + static final Object _sharedObjectKey = Object(); + + @override + String toString() => describeIdentity(this); + + static void reset(BuildContext context) { + // Calling SharedAppData.setValue() causes dependent widgets to be rebuilt. + SharedAppData.setValue(context, _sharedObjectKey, SharedObject._()); + } + + static SharedObject of(BuildContext context) { + // If a value for _sharedObjectKey has never been set then the third + // callback parameter is used to generate an initial value. + return SharedAppData.getValue(context, _sharedObjectKey, () => SharedObject._()); + } +} + +// An example of a widget which depends on the SharedObject's value, which might +// be provided - along with SharedObject - in a Dart package. +class CustomWidget extends StatelessWidget { + const CustomWidget({super.key}); + + @override + Widget build(BuildContext context) { + // Will be rebuilt if the shared object's value is changed. + return ElevatedButton( + child: Text('Replace ${SharedObject.of(context)}'), + onPressed: () { + SharedObject.reset(context); + }, + ); + } +} + +class Home extends StatelessWidget { + const Home({super.key}); + + @override + Widget build(BuildContext context) { + return const Scaffold( + body: Center(child: CustomWidget()), + ); + } +} + +void main() { + runApp(const MaterialApp(home: Home())); +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/shortcuts/callback_shortcuts.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/shortcuts/callback_shortcuts.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..f4297c310c2c62ce1743577b5959e02c032da5d8 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/shortcuts/callback_shortcuts.0.dart @@ -0,0 +1,61 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +/// Flutter code sample for [CallbackShortcuts]. + +void main() => runApp(const CallbackShortcutsApp()); + +class CallbackShortcutsApp extends StatelessWidget { + const CallbackShortcutsApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('CallbackShortcuts Sample')), + body: const Center( + child: CallbackShortcutsExample(), + ), + ), + ); + } +} + +class CallbackShortcutsExample extends StatefulWidget { + const CallbackShortcutsExample({super.key}); + + @override + State createState() => _CallbackShortcutsExampleState(); +} + +class _CallbackShortcutsExampleState extends State { + int count = 0; + + @override + Widget build(BuildContext context) { + return CallbackShortcuts( + bindings: { + const SingleActivator(LogicalKeyboardKey.arrowUp): () { + setState(() => count = count + 1); + }, + const SingleActivator(LogicalKeyboardKey.arrowDown): () { + setState(() => count = count - 1); + }, + }, + child: Focus( + autofocus: true, + child: Column( + children: [ + const Text('Press the up arrow key to add to the counter'), + const Text('Press the down arrow key to subtract from the counter'), + Text('count: $count'), + ], + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/shortcuts/character_activator.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/shortcuts/character_activator.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..08e703c3980f1f58857962d22d57d0de07f080ee --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/shortcuts/character_activator.0.dart @@ -0,0 +1,67 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [CharacterActivator]. + +void main() => runApp(const CharacterActivatorExampleApp()); + +class CharacterActivatorExampleApp extends StatelessWidget { + const CharacterActivatorExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('CharacterActivator Sample')), + body: const Center( + child: CharacterActivatorExample(), + ), + ), + ); + } +} + +class HelpMenuIntent extends Intent { + const HelpMenuIntent(); +} + +class CharacterActivatorExample extends StatefulWidget { + const CharacterActivatorExample({super.key}); + + @override + State createState() => _CharacterActivatorExampleState(); +} + +class _CharacterActivatorExampleState extends State { + @override + Widget build(BuildContext context) { + return Shortcuts( + shortcuts: const { + CharacterActivator('?'): HelpMenuIntent(), + }, + child: Actions( + actions: >{ + HelpMenuIntent: CallbackAction( + onInvoke: (HelpMenuIntent intent) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Keep calm and carry on!')), + ); + return null; + }, + ), + }, + child: const Focus( + autofocus: true, + child: Column( + children: [ + Text('Press question mark for help'), + ], + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/shortcuts/logical_key_set.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/shortcuts/logical_key_set.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..e784c72a8cb9ab5ec7b9529b9f0dec354ff30518 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/shortcuts/logical_key_set.0.dart @@ -0,0 +1,68 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +/// Flutter code sample for [LogicalKeySet]. + +void main() => runApp(const LogicalKeySetExampleApp()); + +class LogicalKeySetExampleApp extends StatelessWidget { + const LogicalKeySetExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('LogicalKeySet Sample')), + body: const Center( + child: LogicalKeySetExample(), + ), + ), + ); + } +} + +class IncrementIntent extends Intent { + const IncrementIntent(); +} + +class LogicalKeySetExample extends StatefulWidget { + const LogicalKeySetExample({super.key}); + + @override + State createState() => _LogicalKeySetExampleState(); +} + +class _LogicalKeySetExampleState extends State { + int count = 0; + + @override + Widget build(BuildContext context) { + return Shortcuts( + shortcuts: { + LogicalKeySet(LogicalKeyboardKey.keyC, LogicalKeyboardKey.controlLeft): const IncrementIntent(), + }, + child: Actions( + actions: >{ + IncrementIntent: CallbackAction( + onInvoke: (IncrementIntent intent) => setState(() { + count = count + 1; + }), + ), + }, + child: Focus( + autofocus: true, + child: Column( + children: [ + const Text('Add to the counter by pressing Ctrl+C'), + Text('count: $count'), + ], + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/shortcuts/shortcuts.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/shortcuts/shortcuts.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..d88825cb2740efd41a42c23f6665bca6fcb83678 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/shortcuts/shortcuts.0.dart @@ -0,0 +1,79 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +/// Flutter code sample for [Shortcuts]. + +void main() => runApp(const ShortcutsExampleApp()); + +class ShortcutsExampleApp extends StatelessWidget { + const ShortcutsExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('Shortcuts Sample')), + body: const Center( + child: ShortcutsExample(), + ), + ), + ); + } +} + +class IncrementIntent extends Intent { + const IncrementIntent(); +} + +class DecrementIntent extends Intent { + const DecrementIntent(); +} + +class ShortcutsExample extends StatefulWidget { + const ShortcutsExample({super.key}); + + @override + State createState() => _ShortcutsExampleState(); +} + +class _ShortcutsExampleState extends State { + int count = 0; + + @override + Widget build(BuildContext context) { + return Shortcuts( + shortcuts: const { + SingleActivator(LogicalKeyboardKey.arrowUp): IncrementIntent(), + SingleActivator(LogicalKeyboardKey.arrowDown): DecrementIntent(), + }, + child: Actions( + actions: >{ + IncrementIntent: CallbackAction( + onInvoke: (IncrementIntent intent) => setState(() { + count = count + 1; + }), + ), + DecrementIntent: CallbackAction( + onInvoke: (DecrementIntent intent) => setState(() { + count = count - 1; + }), + ), + }, + child: Focus( + autofocus: true, + child: Column( + children: [ + const Text('Add to the counter by pressing the up arrow key'), + const Text('Subtract from the counter by pressing the down arrow key'), + Text('count: $count'), + ], + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/shortcuts/shortcuts.1.dart b/novelforge-project/flutter/examples/api/lib/widgets/shortcuts/shortcuts.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..8d59f00601fcd2141ac80f1829c7472634980ef0 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/shortcuts/shortcuts.1.dart @@ -0,0 +1,115 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +/// Flutter code sample for [Shortcuts]. + +void main() => runApp(const ShortcutsExampleApp()); + +class ShortcutsExampleApp extends StatelessWidget { + const ShortcutsExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('Shortcuts Sample')), + body: const Center( + child: ShortcutsExample(), + ), + ), + ); + } +} + +class Model with ChangeNotifier { + int count = 0; + void incrementBy(int amount) { + count += amount; + notifyListeners(); + } + + void decrementBy(int amount) { + count -= amount; + notifyListeners(); + } +} + +class IncrementIntent extends Intent { + const IncrementIntent(this.amount); + + final int amount; +} + +class DecrementIntent extends Intent { + const DecrementIntent(this.amount); + + final int amount; +} + +class IncrementAction extends Action { + IncrementAction(this.model); + + final Model model; + + @override + void invoke(covariant IncrementIntent intent) { + model.incrementBy(intent.amount); + } +} + +class DecrementAction extends Action { + DecrementAction(this.model); + + final Model model; + + @override + void invoke(covariant DecrementIntent intent) { + model.decrementBy(intent.amount); + } +} + +class ShortcutsExample extends StatefulWidget { + const ShortcutsExample({super.key}); + + @override + State createState() => _ShortcutsExampleState(); +} + +class _ShortcutsExampleState extends State { + Model model = Model(); + + @override + Widget build(BuildContext context) { + return Shortcuts( + shortcuts: { + LogicalKeySet(LogicalKeyboardKey.arrowUp): const IncrementIntent(2), + LogicalKeySet(LogicalKeyboardKey.arrowDown): const DecrementIntent(2), + }, + child: Actions( + actions: >{ + IncrementIntent: IncrementAction(model), + DecrementIntent: DecrementAction(model), + }, + child: Focus( + autofocus: true, + child: Column( + children: [ + const Text('Add to the counter by pressing the up arrow key'), + const Text('Subtract from the counter by pressing the down arrow key'), + ListenableBuilder( + listenable: model, + builder: (BuildContext context, Widget? child) { + return Text('count: ${model.count}'); + }, + ), + ], + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/shortcuts/single_activator.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/shortcuts/single_activator.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..4552c96a832488813f976058dcf1d4a25557ecb6 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/shortcuts/single_activator.0.dart @@ -0,0 +1,68 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +/// Flutter code sample for [SingleActivator]. + +void main() => runApp(const SingleActivatorExampleApp()); + +class SingleActivatorExampleApp extends StatelessWidget { + const SingleActivatorExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('SingleActivator Sample')), + body: const Center( + child: SingleActivatorExample(), + ), + ), + ); + } +} + +class IncrementIntent extends Intent { + const IncrementIntent(); +} + +class SingleActivatorExample extends StatefulWidget { + const SingleActivatorExample({super.key}); + + @override + State createState() => _SingleActivatorExampleState(); +} + +class _SingleActivatorExampleState extends State { + int count = 0; + + @override + Widget build(BuildContext context) { + return Shortcuts( + shortcuts: const { + SingleActivator(LogicalKeyboardKey.keyC, control: true): IncrementIntent(), + }, + child: Actions( + actions: >{ + IncrementIntent: CallbackAction( + onInvoke: (IncrementIntent intent) => setState(() { + count = count + 1; + }), + ), + }, + child: Focus( + autofocus: true, + child: Column( + children: [ + const Text('Add to the counter by pressing Ctrl+C'), + Text('count: $count'), + ], + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/shortcuts/single_activator.single_activator.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/shortcuts/single_activator.single_activator.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..5cb5eb8b688dbafe6250a17620bc542fbf678afe --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/shortcuts/single_activator.single_activator.0.dart @@ -0,0 +1,68 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +/// Flutter code sample for [SingleActivator.SingleActivator]. + +void main() => runApp(const SingleActivatorExampleApp()); + +class SingleActivatorExampleApp extends StatelessWidget { + const SingleActivatorExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('SingleActivator Sample')), + body: const Center( + child: SingleActivatorExample(), + ), + ), + ); + } +} + +class IncrementIntent extends Intent { + const IncrementIntent(); +} + +class SingleActivatorExample extends StatefulWidget { + const SingleActivatorExample({super.key}); + + @override + State createState() => _SingleActivatorExampleState(); +} + +class _SingleActivatorExampleState extends State { + int count = 0; + + @override + Widget build(BuildContext context) { + return Shortcuts( + shortcuts: const { + SingleActivator(LogicalKeyboardKey.keyC, control: true): IncrementIntent(), + }, + child: Actions( + actions: >{ + IncrementIntent: CallbackAction( + onInvoke: (IncrementIntent intent) => setState(() { + count = count + 1; + }), + ), + }, + child: Focus( + autofocus: true, + child: Column( + children: [ + const Text('Add to the counter by pressing Ctrl+C'), + Text('count: $count'), + ], + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/single_child_scroll_view/single_child_scroll_view.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/single_child_scroll_view/single_child_scroll_view.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..c0be195c30fc6fca5ec81ce29644c962b8cb3ddf --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/single_child_scroll_view/single_child_scroll_view.0.dart @@ -0,0 +1,62 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [SingleChildScrollView]. + +void main() => runApp(const SingleChildScrollViewExampleApp()); + +class SingleChildScrollViewExampleApp extends StatelessWidget { + const SingleChildScrollViewExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: SingleChildScrollViewExample(), + ); + } +} + +class SingleChildScrollViewExample extends StatelessWidget { + const SingleChildScrollViewExample({super.key}); + + @override + Widget build(BuildContext context) { + return DefaultTextStyle( + style: Theme.of(context).textTheme.bodyMedium!, + child: LayoutBuilder( + builder: (BuildContext context, BoxConstraints viewportConstraints) { + return SingleChildScrollView( + child: ConstrainedBox( + constraints: BoxConstraints( + minHeight: viewportConstraints.maxHeight, + ), + child: Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Container( + // A fixed-height child. + color: const Color(0xffeeee00), // Yellow + height: 120.0, + alignment: Alignment.center, + child: const Text('Fixed Height Content'), + ), + Container( + // Another fixed-height child. + color: const Color(0xff008000), // Green + height: 120.0, + alignment: Alignment.center, + child: const Text('Fixed Height Content'), + ), + ], + ), + ), + ); + }, + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/single_child_scroll_view/single_child_scroll_view.1.dart b/novelforge-project/flutter/examples/api/lib/widgets/single_child_scroll_view/single_child_scroll_view.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..9a21cb2caeb7b02071f78b316cf438cbda5d2747 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/single_child_scroll_view/single_child_scroll_view.1.dart @@ -0,0 +1,65 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [SingleChildScrollView]. + +void main() => runApp(const SingleChildScrollViewExampleApp()); + +class SingleChildScrollViewExampleApp extends StatelessWidget { + const SingleChildScrollViewExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: SingleChildScrollViewExample(), + ); + } +} + +class SingleChildScrollViewExample extends StatelessWidget { + const SingleChildScrollViewExample({super.key}); + + @override + Widget build(BuildContext context) { + return DefaultTextStyle( + style: Theme.of(context).textTheme.bodyMedium!, + child: LayoutBuilder( + builder: (BuildContext context, BoxConstraints viewportConstraints) { + return SingleChildScrollView( + child: ConstrainedBox( + constraints: BoxConstraints( + minHeight: viewportConstraints.maxHeight, + ), + child: IntrinsicHeight( + child: Column( + children: [ + Container( + // A fixed-height child. + color: const Color(0xffeeee00), // Yellow + height: 120.0, + alignment: Alignment.center, + child: const Text('Fixed Height Content'), + ), + Expanded( + // A flexible child that will grow to fit the viewport but + // still be at least as big as necessary to fit its contents. + child: Container( + color: const Color(0xffee0000), // Red + height: 120.0, + alignment: Alignment.center, + child: const Text('Flexible Content'), + ), + ), + ], + ), + ), + ), + ); + }, + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/sliver/decorated_sliver.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/sliver/decorated_sliver.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..5ccd9b93cfb053b737387eba2a83971b9b1e0a87 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/sliver/decorated_sliver.0.dart @@ -0,0 +1,58 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +void main() => runApp(const SliverDecorationExampleApp()); + +class SliverDecorationExampleApp extends StatelessWidget { + const SliverDecorationExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('SliverDecoration Sample')), + body: const SliverDecorationExample(), + ), + ); + } +} + +class SliverDecorationExample extends StatelessWidget { + const SliverDecorationExample({super.key}); + + @override + Widget build(BuildContext context) { + return CustomScrollView( + slivers: [ + DecoratedSliver( + decoration: const BoxDecoration( + gradient: RadialGradient( + center: Alignment(-0.5, -0.6), + radius: 0.15, + colors: [ + Color(0xFFEEEEEE), + Color(0xFF111133), + ], + stops: [0.9, 1.0], + ), + ), + sliver: SliverList( + delegate: SliverChildListDelegate([ + const Text('Goodnight Moon'), + ]), + ), + ), + const DecoratedSliver( + decoration: BoxDecoration( + color: Colors.amber, + borderRadius: BorderRadius.all(Radius.circular(50)) + ), + sliver: SliverToBoxAdapter(child: SizedBox(height: 300)), + ), + ], + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/sliver/pinned_header_sliver.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/sliver/pinned_header_sliver.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..5eacfca82a65c2e63ce8e883581b65c061f1fd18 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/sliver/pinned_header_sliver.0.dart @@ -0,0 +1,129 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [PinnedHeaderSliver]. + +void main() { + runApp(const PinnedHeaderSliverApp()); +} + +class PinnedHeaderSliverApp extends StatelessWidget { + const PinnedHeaderSliverApp({ super.key }); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: PinnedHeaderSliverExample(), + ); + } +} + +class PinnedHeaderSliverExample extends StatefulWidget { + const PinnedHeaderSliverExample({ super.key }); + + @override + State createState() => _PinnedHeaderSliverExampleState(); +} + +class _PinnedHeaderSliverExampleState extends State { + int count = 0; + late final ScrollController scrollController; + + @override + void initState() { + super.initState(); + scrollController = ScrollController(); + } + + @override + void dispose() { + scrollController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + final ThemeData theme = Theme.of(context); + final ColorScheme colorScheme = theme.colorScheme; + + final Widget header = Container( + color: colorScheme.background, + padding: const EdgeInsets.all(4), + child: Material( + color: colorScheme.primaryContainer, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + side: BorderSide( + width: 7, + color: colorScheme.outline, + ), + ), + child: Container( + alignment: Alignment.center, + padding: const EdgeInsets.symmetric(vertical: 48), + child: Text( + count.isOdd ? 'Alternative Title\nWith Two Lines' : 'PinnedHeaderSliver', + style: theme.textTheme.headlineMedium!.copyWith( + color: colorScheme.onPrimaryContainer, + ), + ), + ), + ), + ); + + return Scaffold( + body: SafeArea( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 4), + child: CustomScrollView( + controller: scrollController, + slivers: [ + PinnedHeaderSliver(child: header), + const ItemList(), + ], + ), + ), + ), + floatingActionButton: FloatingActionButton( + onPressed: () { + setState(() { + count += 1; + }); + }, + child: const Icon(Icons.add), + ), + ); + } +} + +// A placeholder SliverList of 25 items. +class ItemList extends StatelessWidget { + const ItemList({ + super.key, + this.itemCount = 25, + }); + + final int itemCount; + + @override + Widget build(BuildContext context) { + final ColorScheme colorScheme = Theme.of(context).colorScheme; + return SliverList( + delegate: SliverChildBuilderDelegate( + (BuildContext context, int index) { + return Card( + color: colorScheme.onSecondary, + child: ListTile( + textColor: colorScheme.secondary, + title: Text('Item $index'), + ), + ); + }, + childCount: itemCount, + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/sliver/sliver_constrained_cross_axis.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/sliver/sliver_constrained_cross_axis.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..78f877aa16a2f5fe3d58f6dd7b4096d105b99b8a --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/sliver/sliver_constrained_cross_axis.0.dart @@ -0,0 +1,51 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +void main() => runApp(const SliverConstrainedCrossAxisExampleApp()); + +class SliverConstrainedCrossAxisExampleApp extends StatelessWidget { + const SliverConstrainedCrossAxisExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('SliverConstrainedCrossAxis Sample')), + body: const SliverConstrainedCrossAxisExample(), + ), + ); + } +} + +class SliverConstrainedCrossAxisExample extends StatelessWidget { + const SliverConstrainedCrossAxisExample({super.key}); + + @override + Widget build(BuildContext context) { + return CustomScrollView( + slivers: [ + SliverConstrainedCrossAxis( + maxExtent: 200, + sliver: SliverList.builder( + itemBuilder: (BuildContext context, int index) { + return Container( + color: index.isEven ? Colors.amber[300] : Colors.blue[300], + height: 100.0, + child: Center( + child: Text( + 'Item $index', + style: const TextStyle(fontSize: 24), + ), + ), + ); + }, + itemCount: 10, + ), + ), + ], + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/sliver/sliver_cross_axis_group.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/sliver/sliver_cross_axis_group.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..fefbb4767e6d93a0fe307228d16cd5e189e67b94 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/sliver/sliver_cross_axis_group.0.dart @@ -0,0 +1,88 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +void main() => runApp(const SliverCrossAxisGroupExampleApp()); + +class SliverCrossAxisGroupExampleApp extends StatelessWidget { + const SliverCrossAxisGroupExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('SliverCrossAxisGroup Sample')), + body: const SliverCrossAxisGroupExample(), + ), + ); + } +} + +class SliverCrossAxisGroupExample extends StatelessWidget { + const SliverCrossAxisGroupExample({super.key}); + + @override + Widget build(BuildContext context) { + return CustomScrollView( + slivers: [ + SliverCrossAxisGroup( + slivers: [ + SliverList.builder( + itemBuilder: (BuildContext context, int index) { + return Container( + color: index.isEven ? Colors.amber[300] : Colors.blue[300], + height: 100.0, + child: Center( + child: Text( + 'Item $index', + style: const TextStyle(fontSize: 24), + ), + ), + ); + }, + itemCount: 5, + ), + SliverConstrainedCrossAxis( + maxExtent: 200, + sliver: SliverList.builder( + itemBuilder: (BuildContext context, int index) { + return Container( + color: index.isEven ? Colors.green[300] : Colors.red[300], + height: 100.0, + child: Center( + child: Text( + 'Item ${index + 5}', + style: const TextStyle(fontSize: 24), + ), + ), + ); + }, + itemCount: 5, + ), + ), + SliverCrossAxisExpanded( + flex: 2, + sliver: SliverList.builder( + itemBuilder: (BuildContext context, int index) { + return Container( + color: index.isEven ? Colors.purple[300] : Colors.orange[300], + height: 100.0, + child: Center( + child: Text( + 'Item ${index + 10}', + style: const TextStyle(fontSize: 24), + ), + ), + ); + }, + itemCount: 5, + ), + ), + ], + ), + ], + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/sliver/sliver_main_axis_group.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/sliver/sliver_main_axis_group.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..14fdb3ac4200a53ea21ee1ee15022d6be94fcb59 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/sliver/sliver_main_axis_group.0.dart @@ -0,0 +1,75 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +void main() => runApp(const SliverMainAxisGroupExampleApp()); + +class SliverMainAxisGroupExampleApp extends StatelessWidget { + const SliverMainAxisGroupExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('SliverMainAxisGroup Sample')), + body: const SliverMainAxisGroupExample(), + ), + ); + } +} + +class SliverMainAxisGroupExample extends StatelessWidget { + const SliverMainAxisGroupExample({super.key}); + + @override + Widget build(BuildContext context) { + return CustomScrollView( + slivers: [ + SliverMainAxisGroup( + slivers: [ + const SliverAppBar( + title: Text('Section Title'), + expandedHeight: 70.0, + pinned: true, + ), + SliverList.builder( + itemBuilder: (BuildContext context, int index) { + return Container( + color: index.isEven ? Colors.amber[300] : Colors.blue[300], + height: 100.0, + child: Center( + child: Text( + 'Item $index', + style: const TextStyle(fontSize: 24), + ), + ), + ); + }, + itemCount: 5, + ), + SliverToBoxAdapter( + child: Container( + color: Colors.cyan, + height: 100, + child: const Center( + child: Text('Another sliver child', style: TextStyle(fontSize: 24)), + ), + ), + ) + ], + ), + SliverToBoxAdapter( + child: Container( + height: 1000, + decoration: const BoxDecoration(color: Colors.greenAccent), + child: const Center( + child: Text('Hello World!', style: TextStyle(fontSize: 24)), + ), + ), + ), + ], + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/sliver/sliver_opacity.1.dart b/novelforge-project/flutter/examples/api/lib/widgets/sliver/sliver_opacity.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..e2ea3492c38c2b473547838147e7a5d0f6e8a036 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/sliver/sliver_opacity.1.dart @@ -0,0 +1,72 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [SliverOpacity]. + +void main() => runApp(const SliverOpacityExampleApp()); + +class SliverOpacityExampleApp extends StatelessWidget { + const SliverOpacityExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: SliverOpacityExample(), + ); + } +} + +class SliverOpacityExample extends StatefulWidget { + const SliverOpacityExample({super.key}); + + @override + State createState() => _SliverOpacityExampleState(); +} + +class _SliverOpacityExampleState extends State { + static const List _listItems = [ + ListTile(title: Text('Now you see me,')), + ListTile(title: Text("Now you don't!")), + ]; + + bool _visible = true; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('SliverOpacity demo'), + ), + body: CustomScrollView( + slivers: [ + const SliverToBoxAdapter( + child: ListTile(title: Text('Press on the button to toggle the list visibility.')), + ), + const SliverToBoxAdapter( + child: ListTile(title: Text('Before the list...')), + ), + SliverOpacity( + opacity: _visible ? 1.0 : 0.0, + sliver: SliverList( + delegate: SliverChildListDelegate(_listItems), + ), + ), + const SliverToBoxAdapter( + child: ListTile(title: Text('Before the list...')), + ), + ], + ), + floatingActionButton: FloatingActionButton( + child: const Icon(Icons.disabled_visible), + onPressed: () { + setState(() { + _visible = !_visible; + }); + }, + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/sliver/sliver_resizing_header.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/sliver/sliver_resizing_header.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..347a433d43e034fd9eccd6dadf66df7d6ed507a0 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/sliver/sliver_resizing_header.0.dart @@ -0,0 +1,145 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +void main() { + runApp(const SliverResizingHeaderApp()); +} + +class SliverResizingHeaderApp extends StatelessWidget { + const SliverResizingHeaderApp({ super.key }); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: ResizingHeaderExample(), + ); + } +} + +class ResizingHeaderExample extends StatefulWidget { + const ResizingHeaderExample({ super.key }); + + @override + State createState() => _ResizingHeaderExampleState(); +} + +class _ResizingHeaderExampleState extends State { + late final ScrollController scrollController; + + @override + void initState() { + super.initState(); + scrollController = ScrollController(); + } + + @override + void dispose() { + scrollController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SafeArea( + child: Padding( + padding: const EdgeInsets.all(4), + child: Scrollbar( + controller: scrollController, + child: CustomScrollView( + controller: scrollController, + slivers: const [ + SliverResizingHeader( + minExtentPrototype: ListHeader( + text: 'One', + ), + maxExtentPrototype: ListHeader( + text: 'One\nTwo\nThree' + ), + child: ListHeader( + text: 'SliverResizingHeader\nWith Two Optional\nLines of Text', + ), + ), + ItemList(), + ], + ), + ), + ), + ), + ); + } +} + +// A widget that displays its text within a thick rounded rectangle border +class ListHeader extends StatelessWidget { + const ListHeader({ + super.key, + required this.text, + }); + + final String text; + + @override + Widget build(BuildContext context) { + final ThemeData theme = Theme.of(context); + final ColorScheme colorScheme = theme.colorScheme; + + return Container( + color: colorScheme.background, + padding: const EdgeInsets.symmetric(horizontal: 4), + child: Material( + color: colorScheme.primaryContainer, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + side: BorderSide( + width: 7, + color: colorScheme.outline, + ), + ), + child: Container( + alignment: Alignment.center, + padding: const EdgeInsets.symmetric(vertical: 16), + child: Text( + text, + textAlign: TextAlign.center, + style: theme.textTheme.headlineMedium!.copyWith( + color: colorScheme.onPrimaryContainer, + ), + ), + ), + ), + ); + } +} + +// A placeholder SliverList of 50 items. +class ItemList extends StatelessWidget { + const ItemList({ + super.key, + this.itemCount = 50, + }); + + final int itemCount; + + @override + Widget build(BuildContext context) { + final ColorScheme colorScheme = Theme.of(context).colorScheme; + return SliverList( + delegate: SliverChildBuilderDelegate( + (BuildContext context, int index) { + return Card( + color: colorScheme.onSecondary, + child: ListTile( + textColor: colorScheme.secondary, + title: Text('Item $index'), + ), + ); + }, + childCount: itemCount, + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/sliver/sliver_tree.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/sliver/sliver_tree.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..914815752df76c97e4181884a4c5ec10f4727976 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/sliver/sliver_tree.0.dart @@ -0,0 +1,104 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [TreeSliver]. + +void main() => runApp(const TreeSliverExampleApp()); + +class TreeSliverExampleApp extends StatelessWidget { + const TreeSliverExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: TreeSliverExample(), + ); + } +} + +class TreeSliverExample extends StatefulWidget { + const TreeSliverExample({super.key}); + + @override + State createState() => _TreeSliverExampleState(); +} + +class _TreeSliverExampleState extends State { + TreeSliverNode? _selectedNode; + final TreeSliverController controller = TreeSliverController(); + final List> _tree = >[ + TreeSliverNode('First'), + TreeSliverNode( + 'Second', + children: >[ + TreeSliverNode( + 'alpha', + children: >[ + TreeSliverNode('uno'), + TreeSliverNode('dos'), + TreeSliverNode('tres'), + ], + ), + TreeSliverNode('beta'), + TreeSliverNode('kappa'), + ], + ), + TreeSliverNode( + 'Third', + expanded: true, + children: >[ + TreeSliverNode('gamma'), + TreeSliverNode('delta'), + TreeSliverNode('epsilon'), + ], + ), + TreeSliverNode('Fourth'), + ]; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('TreeSliver Demo'), + ), + body: CustomScrollView( + slivers: [ + TreeSliver( + tree: _tree, + controller: controller, + treeNodeBuilder: ( + BuildContext context, + TreeSliverNode node, + AnimationStyle animationStyle, + ) { + Widget child = GestureDetector( + behavior: HitTestBehavior.translucent, + onTap: () { + setState(() { + controller.toggleNode(node); + _selectedNode = node as TreeSliverNode; + }); + }, + child: TreeSliver.defaultTreeNodeBuilder( + context, + node, + animationStyle, + ), + ); + if (_selectedNode == node as TreeSliverNode) { + child = ColoredBox( + color: Colors.purple[100]!, + child: child, + ); + } + return child; + }, + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/sliver/sliver_tree.1.dart b/novelforge-project/flutter/examples/api/lib/widgets/sliver/sliver_tree.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..b5d8b783f35136dc1a677ca5e208dc6253e18ec3 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/sliver/sliver_tree.1.dart @@ -0,0 +1,189 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; + +/// Flutter code sample for [TreeSliver]. + +void main() => runApp(const TreeSliverExampleApp()); + +class TreeSliverExampleApp extends StatelessWidget { + const TreeSliverExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: TreeSliverExample(), + ); + } +} + +class TreeSliverExample extends StatefulWidget { + const TreeSliverExample({super.key}); + + @override + State createState() => _TreeSliverExampleState(); +} + +class _TreeSliverExampleState extends State { + TreeSliverNode? _selectedNode; + final List> tree = >[ + TreeSliverNode('README.md'), + TreeSliverNode('analysis_options.yaml'), + TreeSliverNode( + 'lib', + children: >[ + TreeSliverNode( + 'src', + children: >[ + TreeSliverNode( + 'widgets', + children: >[ + TreeSliverNode('about.dart.dart'), + TreeSliverNode('app.dart'), + TreeSliverNode('basic.dart'), + TreeSliverNode('constants.dart'), + ], + ), + ], + ), + TreeSliverNode('widgets.dart'), + ], + ), + TreeSliverNode('pubspec.lock'), + TreeSliverNode('pubspec.yaml'), + TreeSliverNode( + 'test', + children: >[ + TreeSliverNode( + 'widgets', + children: >[ + TreeSliverNode('about_test.dart'), + TreeSliverNode('app_test.dart'), + TreeSliverNode('basic_test.dart'), + TreeSliverNode('constants_test.dart'), + ], + ), + ], + ), + ]; + + Widget _treeNodeBuilder( + BuildContext context, + TreeSliverNode node, + AnimationStyle toggleAnimationStyle, + ) { + final bool isParentNode = node.children.isNotEmpty; + final BorderSide border = BorderSide( + width: 2, + color: Colors.purple[300]!, + ); + return TreeSliver.wrapChildToToggleNode( + node: node, + child: Row( + children: [ + // Custom indentation + SizedBox(width: 10.0 * node.depth! + 8.0), + DecoratedBox( + decoration: BoxDecoration( + border: node.parent != null + ? Border(left: border, bottom: border) + : null, + ), + child: const SizedBox(height: 50.0, width: 20.0), + ), + // Leading icon for parent nodes + if (isParentNode) + DecoratedBox( + decoration: BoxDecoration(border: Border.all()), + child: SizedBox.square( + dimension: 20.0, + child: Icon( + node.isExpanded ? Icons.remove : Icons.add, + size: 14, + ), + ), + ), + // Spacer + const SizedBox(width: 8.0), + // Content + Text(node.content.toString()), + ], + ), + ); + } + + Widget _getTree() { + return DecoratedSliver( + decoration: BoxDecoration( border: Border.all()), + sliver: TreeSliver( + tree: tree, + onNodeToggle: (TreeSliverNode node) { + setState(() { + _selectedNode = node as TreeSliverNode; + }); + }, + treeNodeBuilder: _treeNodeBuilder, + treeRowExtentBuilder: ( + TreeSliverNode node, + SliverLayoutDimensions layoutDimensions, + ) { + // This gives more space to parent nodes. + return node.children.isNotEmpty ? 60.0 : 50.0; + }, + // No internal indentation, the custom treeNodeBuilder applies its + // own indentation to decorate in the indented space. + indentation: TreeSliverIndentationType.none, + ), + ); + } + + @override + Widget build(BuildContext context) { + // This example is assumes the full screen is available. + final Size screenSize = MediaQuery.sizeOf(context); + final List selectedChildren = []; + if (_selectedNode != null) { + selectedChildren.addAll([ + const Spacer(), + Icon( + _selectedNode!.children.isEmpty + ? Icons.file_open_outlined + : Icons.folder_outlined, + ), + const SizedBox(height: 16.0), + Text(_selectedNode!.content), + const Spacer(), + ]); + } + return Scaffold( + body: Row(children: [ + SizedBox( + width: screenSize.width / 2, + height: double.infinity, + child: CustomScrollView( + slivers: [ + _getTree(), + ], + ), + ), + DecoratedBox( + decoration: BoxDecoration( + border: Border.all(), + ), + child: SizedBox( + width: screenSize.width / 2, + height: double.infinity, + child: Center( + child: Column( + children: selectedChildren, + ), + ), + ), + ), + ]), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/sliver_fill/sliver_fill_remaining.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/sliver_fill/sliver_fill_remaining.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..fe5c7453304d360bf890c672c26230c60eb1c42c --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/sliver_fill/sliver_fill_remaining.0.dart @@ -0,0 +1,52 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [SliverFillRemaining]. + +void main() => runApp(const SliverFillRemainingExampleApp()); + +class SliverFillRemainingExampleApp extends StatelessWidget { + const SliverFillRemainingExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('SliverFillRemaining Sample')), + body: const SliverFillRemainingExample(), + ), + ); + } +} + +class SliverFillRemainingExample extends StatelessWidget { + const SliverFillRemainingExample({super.key}); + + @override + Widget build(BuildContext context) { + return CustomScrollView( + slivers: [ + SliverToBoxAdapter( + child: Container( + color: Colors.amber[300], + height: 150.0, + ), + ), + SliverFillRemaining( + hasScrollBody: false, + child: Container( + color: Colors.blue[100], + child: Icon( + Icons.sentiment_very_satisfied, + size: 75, + color: Colors.blue[900], + ), + ), + ), + ], + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/sliver_fill/sliver_fill_remaining.1.dart b/novelforge-project/flutter/examples/api/lib/widgets/sliver_fill/sliver_fill_remaining.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..5d0f4c89dd10da8fab932f5d3e8a478da319c1e1 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/sliver_fill/sliver_fill_remaining.1.dart @@ -0,0 +1,56 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [SliverFillRemaining]. + +void main() => runApp(const SliverFillRemainingExampleApp()); + +class SliverFillRemainingExampleApp extends StatelessWidget { + const SliverFillRemainingExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('SliverFillRemaining Sample')), + body: const SliverFillRemainingExample(), + ), + ); + } +} + +class SliverFillRemainingExample extends StatelessWidget { + const SliverFillRemainingExample({super.key}); + + @override + Widget build(BuildContext context) { + return CustomScrollView( + slivers: [ + SliverFixedExtentList( + itemExtent: 100.0, + delegate: SliverChildBuilderDelegate( + (BuildContext context, int index) { + return Container( + color: index.isEven ? Colors.amber[200] : Colors.blue[200], + ); + }, + childCount: 3, + ), + ), + SliverFillRemaining( + hasScrollBody: false, + child: Container( + color: Colors.orange[300], + child: const Padding( + padding: EdgeInsets.all(50.0), + child: FlutterLogo(size: 100), + ), + ), + ), + ], + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/sliver_fill/sliver_fill_remaining.2.dart b/novelforge-project/flutter/examples/api/lib/widgets/sliver_fill/sliver_fill_remaining.2.dart new file mode 100644 index 0000000000000000000000000000000000000000..5f3fff43d1ae6cae0bc906f64ffea7e39f95c65b --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/sliver_fill/sliver_fill_remaining.2.dart @@ -0,0 +1,57 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [SliverFillRemaining]. + +void main() => runApp(const SliverFillRemainingExampleApp()); + +class SliverFillRemainingExampleApp extends StatelessWidget { + const SliverFillRemainingExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('SliverFillRemaining Sample')), + body: const SliverFillRemainingExample(), + ), + ); + } +} + +class SliverFillRemainingExample extends StatelessWidget { + const SliverFillRemainingExample({super.key}); + + @override + Widget build(BuildContext context) { + return CustomScrollView( + slivers: [ + SliverFixedExtentList( + itemExtent: 130.0, + delegate: SliverChildBuilderDelegate( + (BuildContext context, int index) { + return Container( + color: index.isEven ? Colors.indigo[200] : Colors.orange[200], + ); + }, + childCount: 5, + ), + ), + const SliverFillRemaining( + hasScrollBody: false, + child: Padding( + padding: EdgeInsets.all(50.0), + child: Icon( + Icons.pan_tool, + size: 60, + color: Colors.blueGrey, + ), + ), + ), + ], + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/sliver_fill/sliver_fill_remaining.3.dart b/novelforge-project/flutter/examples/api/lib/widgets/sliver_fill/sliver_fill_remaining.3.dart new file mode 100644 index 0000000000000000000000000000000000000000..45d8626c1a28e5ca4aa0fbfc2163229fb6cb7131 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/sliver_fill/sliver_fill_remaining.3.dart @@ -0,0 +1,71 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [SliverFillRemaining]. + +void main() => runApp(const SliverFillRemainingExampleApp()); + +class SliverFillRemainingExampleApp extends StatelessWidget { + const SliverFillRemainingExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('SliverFillRemaining Sample')), + body: const SliverFillRemainingExample(), + ), + ); + } +} + +class SliverFillRemainingExample extends StatelessWidget { + const SliverFillRemainingExample({super.key}); + + @override + Widget build(BuildContext context) { + return CustomScrollView( + // The ScrollPhysics are overridden here to illustrate the functionality + // of fillOverscroll on all devices this sample may be run on. + // fillOverscroll only changes the behavior of your layout when applied to + // Scrollables that allow for overscroll. BouncingScrollPhysics are one + // example, which are provided by default on the iOS platform. + // BouncingScrollPhysics is combined with AlwaysScrollableScrollPhysics to + // allow for the overscroll, regardless of the depth of the scrollable. + physics: const BouncingScrollPhysics(parent: AlwaysScrollableScrollPhysics()), + slivers: [ + SliverToBoxAdapter( + child: Container( + color: Colors.tealAccent[700], + height: 150.0, + ), + ), + SliverFillRemaining( + hasScrollBody: false, + // Switch for different overscroll behavior in your layout. If your + // ScrollPhysics do not allow for overscroll, setting fillOverscroll + // to true will have no effect. + fillOverscroll: true, + child: Container( + color: Colors.teal[100], + child: Align( + alignment: Alignment.bottomCenter, + child: Padding( + padding: const EdgeInsets.all(16.0), + child: ElevatedButton( + onPressed: () { + /* Place your onPressed code here! */ + }, + child: const Text('Bottom Pinned Button!'), + ), + ), + ), + ), + ), + ], + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/slotted_render_object_widget/slotted_multi_child_render_object_widget_mixin.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/slotted_render_object_widget/slotted_multi_child_render_object_widget_mixin.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..1d0525e9a82f6af366637dc6d47c0b98a79132f6 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/slotted_render_object_widget/slotted_multi_child_render_object_widget_mixin.0.dart @@ -0,0 +1,290 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; + +/// Flutter code sample for [SlottedMultiChildRenderObjectWidget]. + +/// Slots used for the children of [Diagonal] and [RenderDiagonal]. +enum DiagonalSlot { + topLeft, + bottomRight, +} + +/// A widget that demonstrates the usage of +/// [SlottedMultiChildRenderObjectWidget] by providing slots for two +/// children that will be arranged diagonally. +class Diagonal extends SlottedMultiChildRenderObjectWidget { + const Diagonal({ + super.key, + this.topLeft, + this.bottomRight, + this.backgroundColor, + }); + + final Widget? topLeft; + final Widget? bottomRight; + final Color? backgroundColor; + + @override + Iterable get slots => DiagonalSlot.values; + + @override + Widget? childForSlot(DiagonalSlot slot) { + return switch (slot) { + DiagonalSlot.topLeft => topLeft, + DiagonalSlot.bottomRight => bottomRight, + }; + } + + // The [createRenderObject] and [updateRenderObject] methods configure the + // [RenderObject] backing this widget with the configuration of the widget. + // They do not need to do anything with the children of the widget, though. + // The children of the widget are automatically configured on the + // [RenderObject] by [SlottedRenderObjectElement.mount] and + // [SlottedRenderObjectElement.update]. + + @override + SlottedContainerRenderObjectMixin createRenderObject( + BuildContext context, + ) { + return RenderDiagonal( + backgroundColor: backgroundColor, + ); + } + + @override + void updateRenderObject( + BuildContext context, + SlottedContainerRenderObjectMixin renderObject, + ) { + (renderObject as RenderDiagonal).backgroundColor = backgroundColor; + } +} + +/// A render object that demonstrates the usage of +/// [SlottedContainerRenderObjectMixin] by providing slots for two children that +/// will be arranged diagonally. +class RenderDiagonal extends RenderBox + with SlottedContainerRenderObjectMixin, DebugOverflowIndicatorMixin { + RenderDiagonal({Color? backgroundColor}) : _backgroundColor = backgroundColor; + + // Getters and setters to configure the [RenderObject] with the configuration + // of the [Widget]. These mostly contain boilerplate code, but depending on + // where the configuration value is used, the setter has to call + // [markNeedsLayout], [markNeedsPaint], or [markNeedsSemanticsUpdate]. + Color? get backgroundColor => _backgroundColor; + Color? _backgroundColor; + set backgroundColor(Color? value) { + assert(value != null); + if (_backgroundColor == value) { + return; + } + _backgroundColor = value; + markNeedsPaint(); + } + + // Getters to simplify accessing the slotted children. + RenderBox? get _topLeft => childForSlot(DiagonalSlot.topLeft); + RenderBox? get _bottomRight => childForSlot(DiagonalSlot.bottomRight); + + // The size this render object would have if the incoming constraints were + // unconstrained; calculated during performLayout used during paint for an + // assertion that checks for unintended overflow. + late Size _childrenSize; + + // Returns children in hit test order. + @override + Iterable get children { + return [ + if (_topLeft != null) _topLeft!, + if (_bottomRight != null) _bottomRight!, + ]; + } + + // LAYOUT + + @override + void performLayout() { + // Children are allowed to be as big as they want (= unconstrained). + const BoxConstraints childConstraints = BoxConstraints(); + + // Lay out the top left child and position it at offset zero. + Size topLeftSize = Size.zero; + final RenderBox? topLeft = _topLeft; + if (topLeft != null) { + topLeft.layout(childConstraints, parentUsesSize: true); + _positionChild(topLeft, Offset.zero); + topLeftSize = topLeft.size; + } + + // Lay out the bottom right child and position it at the bottom right corner + // of the top left child. + Size bottomRightSize = Size.zero; + final RenderBox? bottomRight = _bottomRight; + if (bottomRight != null) { + bottomRight.layout(childConstraints, parentUsesSize: true); + _positionChild( + bottomRight, + Offset(topLeftSize.width, topLeftSize.height), + ); + bottomRightSize = bottomRight.size; + } + + // Calculate the overall size and constrain it to the given constraints. + // Any overflow is marked (in debug mode) during paint. + _childrenSize = Size( + topLeftSize.width + bottomRightSize.width, + topLeftSize.height + bottomRightSize.height, + ); + size = constraints.constrain(_childrenSize); + } + + void _positionChild(RenderBox child, Offset offset) { + (child.parentData! as BoxParentData).offset = offset; + } + + // PAINT + + @override + void paint(PaintingContext context, Offset offset) { + // Paint the background. + if (backgroundColor != null) { + context.canvas.drawRect( + offset & size, + Paint()..color = backgroundColor!, + ); + } + + void paintChild(RenderBox child, PaintingContext context, Offset offset) { + final BoxParentData childParentData = child.parentData! as BoxParentData; + context.paintChild(child, childParentData.offset + offset); + } + + // Paint the children at the offset calculated during layout. + final RenderBox? topLeft = _topLeft; + if (topLeft != null) { + paintChild(topLeft, context, offset); + } + final RenderBox? bottomRight = _bottomRight; + if (bottomRight != null) { + paintChild(bottomRight, context, offset); + } + + // Paint an overflow indicator in debug mode if the children want to be + // larger than the incoming constraints allow. + assert(() { + paintOverflowIndicator( + context, + offset, + Offset.zero & size, + Offset.zero & _childrenSize, + ); + return true; + }()); + } + + // HIT TEST + + @override + bool hitTestChildren(BoxHitTestResult result, {required Offset position}) { + for (final RenderBox child in children) { + final BoxParentData parentData = child.parentData! as BoxParentData; + final bool isHit = result.addWithPaintOffset( + offset: parentData.offset, + position: position, + hitTest: (BoxHitTestResult result, Offset transformed) { + assert(transformed == position - parentData.offset); + return child.hitTest(result, position: transformed); + }, + ); + if (isHit) { + return true; + } + } + return false; + } + + // INTRINSICS + + // Incoming height/width are ignored as children are always laid out unconstrained. + + @override + double computeMinIntrinsicWidth(double height) { + final double topLeftWidth = _topLeft?.getMinIntrinsicWidth(double.infinity) ?? 0; + final double bottomRightWith = _bottomRight?.getMinIntrinsicWidth(double.infinity) ?? 0; + return topLeftWidth + bottomRightWith; + } + + @override + double computeMaxIntrinsicWidth(double height) { + final double topLeftWidth = _topLeft?.getMaxIntrinsicWidth(double.infinity) ?? 0; + final double bottomRightWith = _bottomRight?.getMaxIntrinsicWidth(double.infinity) ?? 0; + return topLeftWidth + bottomRightWith; + } + + @override + double computeMinIntrinsicHeight(double width) { + final double topLeftHeight = _topLeft?.getMinIntrinsicHeight(double.infinity) ?? 0; + final double bottomRightHeight = _bottomRight?.getMinIntrinsicHeight(double.infinity) ?? 0; + return topLeftHeight + bottomRightHeight; + } + + @override + double computeMaxIntrinsicHeight(double width) { + final double topLeftHeight = _topLeft?.getMaxIntrinsicHeight(double.infinity) ?? 0; + final double bottomRightHeight = _bottomRight?.getMaxIntrinsicHeight(double.infinity) ?? 0; + return topLeftHeight + bottomRightHeight; + } + + @override + Size computeDryLayout(BoxConstraints constraints) { + const BoxConstraints childConstraints = BoxConstraints(); + final Size topLeftSize = _topLeft?.computeDryLayout(childConstraints) ?? Size.zero; + final Size bottomRightSize = _bottomRight?.computeDryLayout(childConstraints) ?? Size.zero; + return constraints.constrain(Size( + topLeftSize.width + bottomRightSize.width, + topLeftSize.height + bottomRightSize.height, + )); + } +} + +class ExampleWidget extends StatelessWidget { + const ExampleWidget({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('Slotted RenderObject Example')), + body: Center( + child: Diagonal( + topLeft: Container( + color: Colors.green, + height: 100, + width: 200, + child: const Center( + child: Text('topLeft'), + ), + ), + bottomRight: Container( + color: Colors.yellow, + height: 60, + width: 30, + child: const Center( + child: Text('bottomRight'), + ), + ), + backgroundColor: Colors.blue, + ), + ), + ), + ); + } +} + +void main() { + runApp(const ExampleWidget()); +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/system_context_menu/system_context_menu.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/system_context_menu/system_context_menu.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..b648c116b00e34171f60b13c46e3cfb5fbe6f9cc --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/system_context_menu/system_context_menu.0.dart @@ -0,0 +1,41 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [SystemContextMenu]. + +void main() => runApp(const SystemContextMenuExampleApp()); + +class SystemContextMenuExampleApp extends StatelessWidget { + const SystemContextMenuExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('SystemContextMenu Basic Example'), + ), + body: Center( + child: TextField( + contextMenuBuilder: (BuildContext context, EditableTextState editableTextState) { + // If supported, show the system context menu. + if (SystemContextMenu.isSupported(context)) { + return SystemContextMenu.editableText( + editableTextState: editableTextState, + ); + } + // Otherwise, show the flutter-rendered context menu for the current + // platform. + return AdaptiveTextSelectionToolbar.editableText( + editableTextState: editableTextState, + ); + }, + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/table/table.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/table/table.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..531b6e95db2ac7c069a2d2119ee467ad6e8b15c5 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/table/table.0.dart @@ -0,0 +1,85 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [Table]. + +void main() => runApp(const TableExampleApp()); + +class TableExampleApp extends StatelessWidget { + const TableExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('Table Sample')), + body: const TableExample(), + ), + ); + } +} + +class TableExample extends StatelessWidget { + const TableExample({super.key}); + + @override + Widget build(BuildContext context) { + return Table( + border: TableBorder.all(), + columnWidths: const { + 0: IntrinsicColumnWidth(), + 1: FlexColumnWidth(), + 2: FixedColumnWidth(64), + }, + defaultVerticalAlignment: TableCellVerticalAlignment.middle, + children: [ + TableRow( + children: [ + Container( + height: 32, + color: Colors.green, + ), + TableCell( + verticalAlignment: TableCellVerticalAlignment.top, + child: Container( + height: 32, + width: 32, + color: Colors.red, + ), + ), + Container( + height: 64, + color: Colors.blue, + ), + ], + ), + TableRow( + decoration: const BoxDecoration( + color: Colors.grey, + ), + children: [ + Container( + height: 64, + width: 128, + color: Colors.purple, + ), + Container( + height: 32, + color: Colors.yellow, + ), + Center( + child: Container( + height: 32, + width: 32, + color: Colors.orange, + ), + ), + ], + ), + ], + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/tap_region/text_field_tap_region.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/tap_region/text_field_tap_region.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..e4e08a4ace93cbce66b85157a0eb2e83dda06a76 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/tap_region/text_field_tap_region.0.dart @@ -0,0 +1,250 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +/// Flutter code sample for [TextFieldTapRegion]. + +void main() => runApp(const TapRegionApp()); + +class TapRegionApp extends StatelessWidget { + const TapRegionApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('TextFieldTapRegion Example')), + body: const TextFieldTapRegionExample(), + ), + ); + } +} + +class TextFieldTapRegionExample extends StatefulWidget { + const TextFieldTapRegionExample({super.key}); + + @override + State createState() => _TextFieldTapRegionExampleState(); +} + +class _TextFieldTapRegionExampleState extends State { + int value = 0; + + @override + Widget build(BuildContext context) { + return ListView( + children: [ + Center( + child: Padding( + padding: const EdgeInsets.all(20.0), + child: SizedBox( + width: 150, + height: 80, + child: IntegerSpinnerField( + value: value, + autofocus: true, + onChanged: (int newValue) { + if (value == newValue) { + // Avoid unnecessary redraws. + return; + } + setState(() { + // Update the value and redraw. + value = newValue; + }); + }, + ), + ), + ), + ), + ], + ); + } +} + +/// An integer example of the generic [SpinnerField] that validates input and +/// increments by a delta. +class IntegerSpinnerField extends StatelessWidget { + const IntegerSpinnerField({ + super.key, + required this.value, + this.autofocus = false, + this.delta = 1, + this.onChanged, + }); + + final int value; + final bool autofocus; + final int delta; + final ValueChanged? onChanged; + + @override + Widget build(BuildContext context) { + return SpinnerField( + value: value, + onChanged: onChanged, + autofocus: autofocus, + fromString: (String stringValue) => int.tryParse(stringValue) ?? value, + increment: (int i) => i + delta, + decrement: (int i) => i - delta, + // Add a text formatter that only allows integer values and a leading + // minus sign. + inputFormatters: [ + TextInputFormatter.withFunction( + (TextEditingValue oldValue, TextEditingValue newValue) { + String newString; + if (newValue.text.startsWith('-')) { + newString = '-${newValue.text.replaceAll(RegExp(r'\D'), '')}'; + } else { + newString = newValue.text.replaceAll(RegExp(r'\D'), ''); + } + return newValue.copyWith( + text: newString, + selection: newValue.selection.copyWith( + baseOffset: newValue.selection.baseOffset.clamp(0, newString.length), + extentOffset: newValue.selection.extentOffset.clamp(0, newString.length), + ), + ); + }, + ) + ], + ); + } +} + +/// A generic "spinner" field example which adds extra buttons next to a +/// [TextField] to increment and decrement the value. +/// +/// This widget uses [TextFieldTapRegion] to indicate that tapping on the +/// spinner buttons should not cause the text field to lose focus. +class SpinnerField extends StatefulWidget { + SpinnerField({ + super.key, + required this.value, + required this.fromString, + this.autofocus = false, + String Function(T value)? asString, + this.increment, + this.decrement, + this.onChanged, + this.inputFormatters = const [], + }) : asString = asString ?? ((T value) => value.toString()); + + final T value; + final T Function(T value)? increment; + final T Function(T value)? decrement; + final String Function(T value) asString; + final T Function(String value) fromString; + final ValueChanged? onChanged; + final List inputFormatters; + final bool autofocus; + + @override + State> createState() => _SpinnerFieldState(); +} + +class _SpinnerFieldState extends State> { + TextEditingController controller = TextEditingController(); + + @override + void initState() { + super.initState(); + _updateText(widget.asString(widget.value)); + } + + @override + void dispose() { + controller.dispose(); + super.dispose(); + } + + @override + void didUpdateWidget(covariant SpinnerField oldWidget) { + super.didUpdateWidget(oldWidget); + if (oldWidget.asString != widget.asString || oldWidget.value != widget.value) { + final String newText = widget.asString(widget.value); + _updateText(newText); + } + } + + void _updateText(String text, {bool collapsed = true}) { + if (text != controller.text) { + controller.value = TextEditingValue( + text: text, + selection: collapsed + ? TextSelection.collapsed(offset: text.length) + : TextSelection(baseOffset: 0, extentOffset: text.length), + ); + } + } + + void _spin(T Function(T value)? spinFunction) { + if (spinFunction == null) { + return; + } + final T newValue = spinFunction(widget.value); + widget.onChanged?.call(newValue); + _updateText(widget.asString(newValue), collapsed: false); + } + + void _increment() { + _spin(widget.increment); + } + + void _decrement() { + _spin(widget.decrement); + } + + @override + Widget build(BuildContext context) { + return CallbackShortcuts( + bindings: { + const SingleActivator(LogicalKeyboardKey.arrowUp): _increment, + const SingleActivator(LogicalKeyboardKey.arrowDown): _decrement, + }, + child: Row( + children: [ + Expanded( + child: TextField( + autofocus: widget.autofocus, + inputFormatters: widget.inputFormatters, + decoration: const InputDecoration( + border: OutlineInputBorder(), + ), + onChanged: (String value) => widget.onChanged?.call(widget.fromString(value)), + controller: controller, + textAlign: TextAlign.center, + ), + ), + const SizedBox(width: 12), + // Without this TextFieldTapRegion, tapping on the buttons below would + // increment the value, but it would cause the text field to be + // unfocused, since tapping outside of a text field should unfocus it + // on non-mobile platforms. + TextFieldTapRegion( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Expanded( + child: OutlinedButton( + onPressed: _increment, + child: const Icon(Icons.add), + ), + ), + Expanded( + child: OutlinedButton( + onPressed: _decrement, + child: const Icon(Icons.remove), + ), + ), + ], + ), + ) + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/text/text.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/text/text.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..26ea189955994a5048e05ad5980b5b55d26524f7 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/text/text.0.dart @@ -0,0 +1,46 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [DefaultTextStyle]. + +void main() => runApp(const DefaultTextStyleApp()); + +class DefaultTextStyleApp extends StatelessWidget { + const DefaultTextStyleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData( + useMaterial3: true, + brightness: Brightness.light, + colorSchemeSeed: Colors.purple, + ), + home: const DefaultTextStyleExample(), + ); + } +} + +class DefaultTextStyleExample extends StatelessWidget { + const DefaultTextStyleExample({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: const Text('DefaultTextStyle.merge Sample')), + // Inherit MaterialApp text theme and override font size and font weight. + body: DefaultTextStyle.merge( + style: const TextStyle( + fontSize: 24, + fontWeight: FontWeight.bold, + ), + child: const Center( + child: Text('Flutter'), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/text_magnifier/text_magnifier.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/text_magnifier/text_magnifier.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..03daf7e8f0e29b121fe2af1247289d8afbc8ab97 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/text_magnifier/text_magnifier.0.dart @@ -0,0 +1,110 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; + +void main() => runApp(const TextMagnifierExampleApp(text: 'Hello world!')); + +class TextMagnifierExampleApp extends StatelessWidget { + const TextMagnifierExampleApp({ + super.key, + this.textDirection = TextDirection.ltr, + required this.text, + }); + + final TextDirection textDirection; + final String text; + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData(useMaterial3: true), + home: Scaffold( + body: Padding( + padding: const EdgeInsets.symmetric(horizontal: 48.0), + child: Center( + child: TextField( + textDirection: textDirection, + // Create a custom magnifier configuration that + // this `TextField` will use to build a magnifier with. + magnifierConfiguration: TextMagnifierConfiguration( + magnifierBuilder: (_, __, ValueNotifier magnifierInfo) => CustomMagnifier( + magnifierInfo: magnifierInfo, + ), + ), + controller: TextEditingController(text: text), + ), + ), + ), + ), + ); + } +} + +class CustomMagnifier extends StatelessWidget { + const CustomMagnifier({super.key, required this.magnifierInfo}); + + static const Size magnifierSize = Size(200, 200); + + // This magnifier will consume some text data and position itself + // based on the info in the magnifier. + final ValueNotifier magnifierInfo; + + @override + Widget build(BuildContext context) { + // Use a value listenable builder because we want to rebuild + // every time the text selection info changes. + // `CustomMagnifier` could also be a `StatefulWidget` and call `setState` + // when `magnifierInfo` updates. This would be useful for more complex + // positioning cases. + return ValueListenableBuilder( + valueListenable: magnifierInfo, + builder: (BuildContext context, MagnifierInfo currentMagnifierInfo, _) { + // We want to position the magnifier at the global position of the gesture. + Offset magnifierPosition = currentMagnifierInfo.globalGesturePosition; + + // You may use the `MagnifierInfo` however you'd like: + // In this case, we make sure the magnifier never goes out of the current line bounds. + magnifierPosition = Offset( + clampDouble( + magnifierPosition.dx, + currentMagnifierInfo.currentLineBoundaries.left, + currentMagnifierInfo.currentLineBoundaries.right, + ), + clampDouble( + magnifierPosition.dy, + currentMagnifierInfo.currentLineBoundaries.top, + currentMagnifierInfo.currentLineBoundaries.bottom, + ), + ); + + // Finally, align the magnifier to the bottom center. The initial anchor is + // the top left, so subtract bottom center alignment. + magnifierPosition -= Alignment.bottomCenter.alongSize(magnifierSize); + + return Positioned( + left: magnifierPosition.dx, + top: magnifierPosition.dy, + child: RawMagnifier( + magnificationScale: 2, + // The focal point starts at the center of the magnifier. + // We probably want to point below the magnifier, so + // offset the focal point by half the magnifier height. + focalPointOffset: Offset(0, magnifierSize.height / 2), + // Decorate it however we'd like! + decoration: const MagnifierDecoration( + shape: StarBorder( + side: BorderSide( + color: Colors.green, + width: 2, + ), + ), + ), + size: magnifierSize, + ), + ); + }); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/transitions/align_transition.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/transitions/align_transition.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..fa7118c82a7eaee5aa4efdf68e8e2875fc6e9cd5 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/transitions/align_transition.0.dart @@ -0,0 +1,67 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [AlignTransition]. + +void main() => runApp(const AlignTransitionExampleApp()); + +class AlignTransitionExampleApp extends StatelessWidget { + const AlignTransitionExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: AlignTransitionExample(), + ); + } +} + +class AlignTransitionExample extends StatefulWidget { + const AlignTransitionExample({super.key}); + + @override + State createState() => _AlignTransitionExampleState(); +} + +/// [AnimationController]s can be created with `vsync: this` because of +/// [TickerProviderStateMixin]. +class _AlignTransitionExampleState extends State with TickerProviderStateMixin { + // Using `late final` for lazy initialization. See + // https://dart.dev/null-safety/understanding-null-safety#lazy-initialization. + late final AnimationController _controller = AnimationController( + duration: const Duration(seconds: 2), + vsync: this, + )..repeat(reverse: true); + late final Animation _animation = Tween( + begin: Alignment.bottomLeft, + end: Alignment.center, + ).animate( + CurvedAnimation( + parent: _controller, + curve: Curves.decelerate, + ), + ); + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return ColoredBox( + color: Colors.white, + child: AlignTransition( + alignment: _animation, + child: const Padding( + padding: EdgeInsets.all(8), + child: FlutterLogo(size: 150.0), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/transitions/animated_builder.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/transitions/animated_builder.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..89abd212925bc05fce2a4f912d68f9cc3baa90fe --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/transitions/animated_builder.0.dart @@ -0,0 +1,65 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:math' as math; + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [AnimatedBuilder]. + +void main() => runApp(const AnimatedBuilderExampleApp()); + +class AnimatedBuilderExampleApp extends StatelessWidget { + const AnimatedBuilderExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: AnimatedBuilderExample(), + ); + } +} + +class AnimatedBuilderExample extends StatefulWidget { + const AnimatedBuilderExample({super.key}); + + @override + State createState() => _AnimatedBuilderExampleState(); +} + +/// AnimationControllers can be created with `vsync: this` because of +/// TickerProviderStateMixin. +class _AnimatedBuilderExampleState extends State with TickerProviderStateMixin { + late final AnimationController _controller = AnimationController( + duration: const Duration(seconds: 10), + vsync: this, + )..repeat(); + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return AnimatedBuilder( + animation: _controller, + child: Container( + width: 200.0, + height: 200.0, + color: Colors.green, + child: const Center( + child: Text('Whee!'), + ), + ), + builder: (BuildContext context, Widget? child) { + return Transform.rotate( + angle: _controller.value * 2.0 * math.pi, + child: child, + ); + }, + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/transitions/animated_widget.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/transitions/animated_widget.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..93c98bc43f88f33e6ab1ad4572c9cb42631ef1be --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/transitions/animated_widget.0.dart @@ -0,0 +1,66 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:math' as math; + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [AnimatedWidget]. + +void main() => runApp(const AnimatedWidgetExampleApp()); + +class AnimatedWidgetExampleApp extends StatelessWidget { + const AnimatedWidgetExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: AnimatedWidgetExample(), + ); + } +} + +class SpinningContainer extends AnimatedWidget { + const SpinningContainer({ + super.key, + required AnimationController controller, + }) : super(listenable: controller); + + Animation get _progress => listenable as Animation; + + @override + Widget build(BuildContext context) { + return Transform.rotate( + angle: _progress.value * 2.0 * math.pi, + child: Container(width: 200.0, height: 200.0, color: Colors.green), + ); + } +} + +class AnimatedWidgetExample extends StatefulWidget { + const AnimatedWidgetExample({super.key}); + + @override + State createState() => _AnimatedWidgetExampleState(); +} + +/// [AnimationController]s can be created with `vsync: this` because of +/// [TickerProviderStateMixin]. +class _AnimatedWidgetExampleState extends State with TickerProviderStateMixin { + late final AnimationController _controller = AnimationController( + duration: const Duration(seconds: 10), + vsync: this, + )..repeat(); + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return SpinningContainer(controller: _controller); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/transitions/decorated_box_transition.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/transitions/decorated_box_transition.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..2ff7ef3ea5c4d976b74eaa6383fca4cc1cc641c5 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/transitions/decorated_box_transition.0.dart @@ -0,0 +1,84 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [DecoratedBoxTransition]. + +void main() => runApp(const DecoratedBoxTransitionExampleApp()); + +class DecoratedBoxTransitionExampleApp extends StatelessWidget { + const DecoratedBoxTransitionExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: DecoratedBoxTransitionExample(), + ); + } +} + +class DecoratedBoxTransitionExample extends StatefulWidget { + const DecoratedBoxTransitionExample({super.key}); + + @override + State createState() => _DecoratedBoxTransitionExampleState(); +} + +/// [AnimationController]s can be created with `vsync: this` because of +/// [TickerProviderStateMixin]. +class _DecoratedBoxTransitionExampleState extends State with TickerProviderStateMixin { + final DecorationTween decorationTween = DecorationTween( + begin: BoxDecoration( + color: const Color(0xFFFFFFFF), + border: Border.all(style: BorderStyle.none), + borderRadius: BorderRadius.circular(60.0), + boxShadow: const [ + BoxShadow( + color: Color(0x66666666), + blurRadius: 10.0, + spreadRadius: 3.0, + offset: Offset(0, 6.0), + ), + ], + ), + end: BoxDecoration( + color: const Color(0xFFFFFFFF), + border: Border.all( + style: BorderStyle.none, + ), + borderRadius: BorderRadius.zero, + // No shadow. + ), + ); + + late final AnimationController _controller = AnimationController( + vsync: this, + duration: const Duration(seconds: 3), + )..repeat(reverse: true); + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return ColoredBox( + color: Colors.white, + child: Center( + child: DecoratedBoxTransition( + decoration: decorationTween.animate(_controller), + child: Container( + width: 200, + height: 200, + padding: const EdgeInsets.all(10), + child: const FlutterLogo(), + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/transitions/default_text_style_transition.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/transitions/default_text_style_transition.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..bd62f97dc3bafeb329ec488b316082c84f2e1561 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/transitions/default_text_style_transition.0.dart @@ -0,0 +1,69 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [DefaultTextStyleTransition]. + +void main() => runApp(const DefaultTextStyleTransitionExampleApp()); + +class DefaultTextStyleTransitionExampleApp extends StatelessWidget { + const DefaultTextStyleTransitionExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: DefaultTextStyleTransitionExample(), + ); + } +} + +class DefaultTextStyleTransitionExample extends StatefulWidget { + const DefaultTextStyleTransitionExample({super.key}); + + @override + State createState() => _DefaultTextStyleTransitionExampleState(); +} + +/// [AnimationController]s can be created with `vsync: this` because of +/// [TickerProviderStateMixin]. +class _DefaultTextStyleTransitionExampleState extends State + with TickerProviderStateMixin { + late AnimationController _controller; + late TextStyleTween _styleTween; + late CurvedAnimation _curvedAnimation; + + @override + void initState() { + super.initState(); + _controller = AnimationController( + duration: const Duration(seconds: 2), + vsync: this, + )..repeat(reverse: true); + _styleTween = TextStyleTween( + begin: const TextStyle(fontSize: 50, color: Colors.blue, fontWeight: FontWeight.w900), + end: const TextStyle(fontSize: 50, color: Colors.red, fontWeight: FontWeight.w100), + ); + _curvedAnimation = CurvedAnimation( + parent: _controller, + curve: Curves.elasticInOut, + ); + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Center( + child: DefaultTextStyleTransition( + style: _styleTween.animate(_curvedAnimation), + child: const Text('Flutter'), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/transitions/fade_transition.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/transitions/fade_transition.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..a6dd3246412913aff104d750062c4a0e525aa721 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/transitions/fade_transition.0.dart @@ -0,0 +1,57 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [FadeTransition]. + +void main() => runApp(const FadeTransitionExampleApp()); + +class FadeTransitionExampleApp extends StatelessWidget { + const FadeTransitionExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: FadeTransitionExample(), + ); + } +} + +class FadeTransitionExample extends StatefulWidget { + const FadeTransitionExample({super.key}); + + @override + State createState() => _FadeTransitionExampleState(); +} + +/// [AnimationController]s can be created with `vsync: this` because of +/// [TickerProviderStateMixin]. +class _FadeTransitionExampleState extends State with TickerProviderStateMixin { + late final AnimationController _controller = AnimationController( + duration: const Duration(seconds: 2), + vsync: this, + )..repeat(reverse: true); + late final Animation _animation = CurvedAnimation( + parent: _controller, + curve: Curves.easeIn, + ); + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return ColoredBox( + color: Colors.white, + child: FadeTransition( + opacity: _animation, + child: const Padding(padding: EdgeInsets.all(8), child: FlutterLogo()), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/transitions/listenable_builder.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/transitions/listenable_builder.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..e0cd2eff3feb30bc2859fc6db5afbf1542e1abd0 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/transitions/listenable_builder.0.dart @@ -0,0 +1,172 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [ListenableBuilder]. + +void main() => runApp(const ListenableBuilderExample()); + +/// This widget listens for changes in the focus state of the subtree defined by +/// its [child] widget, changing the border and color of the container it is in +/// when it has focus. +/// +/// A [FocusListenerContainer] swaps out the [BorderSide] of a border around the +/// child widget with [focusedSide], and the background color with +/// [focusedColor], when a widget that is a descendant of this widget has focus. +class FocusListenerContainer extends StatefulWidget { + const FocusListenerContainer({ + super.key, + this.border, + this.padding, + this.focusedSide, + this.focusedColor = Colors.black12, + required this.child, + }); + + /// This is the border that will be used when not focused, and which defines + /// all the attributes except for the [OutlinedBorder.side] when focused. + final OutlinedBorder? border; + + /// This is the [BorderSide] that will be used for [border] when the [child] + /// subtree is focused. + final BorderSide? focusedSide; + + /// This is the [Color] that will be used as the fill color for the background + /// of the [child] when a descendant widget is focused. + final Color? focusedColor; + + /// The padding around the inside of the container. + final EdgeInsetsGeometry? padding; + + /// This is defines the subtree to listen to for focus changes. + final Widget child; + + @override + State createState() => _FocusListenerContainerState(); +} + +class _FocusListenerContainerState extends State { + final FocusNode _focusNode = FocusNode(); + + @override + void dispose() { + _focusNode.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + final OutlinedBorder effectiveBorder = widget.border ?? const RoundedRectangleBorder(); + return ListenableBuilder( + listenable: _focusNode, + child: Focus( + focusNode: _focusNode, + skipTraversal: true, + canRequestFocus: false, + child: widget.child, + ), + builder: (BuildContext context, Widget? child) { + return Container( + padding: widget.padding, + decoration: ShapeDecoration( + color: _focusNode.hasFocus ? widget.focusedColor : null, + shape: effectiveBorder.copyWith( + side: _focusNode.hasFocus ? widget.focusedSide : null, + ), + ), + child: child, + ); + }, + ); + } +} + +class MyField extends StatefulWidget { + const MyField({super.key, required this.label}); + + final String label; + + @override + State createState() => _MyFieldState(); +} + +class _MyFieldState extends State { + final TextEditingController controller = TextEditingController(); + + @override + Widget build(BuildContext context) { + return Row( + children: [ + Expanded(child: Text(widget.label)), + Expanded( + flex: 2, + child: TextField( + controller: controller, + onEditingComplete: () { + debugPrint('Field ${widget.label} changed to ${controller.value}'); + }, + ), + ), + ], + ); + } +} + +class ListenableBuilderExample extends StatelessWidget { + const ListenableBuilderExample({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('ListenableBuilder Example')), + body: Center( + child: SizedBox( + width: 300, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Padding( + padding: EdgeInsets.only(bottom: 8), + child: MyField(label: 'Company'), + ), + FocusListenerContainer( + padding: const EdgeInsets.all(8), + border: const RoundedRectangleBorder( + side: BorderSide( + strokeAlign: BorderSide.strokeAlignOutside, + ), + borderRadius: BorderRadius.all( + Radius.circular(5), + ), + ), + // The border side will get wider when the subtree has focus. + focusedSide: const BorderSide( + width: 4, + strokeAlign: BorderSide.strokeAlignOutside, + ), + // The container background will change color to this when + // the subtree has focus. + focusedColor: Colors.blue.shade50, + child: const Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('Owner:'), + MyField(label: 'First Name'), + MyField(label: 'Last Name'), + ], + ), + ), + ], + ), + ), + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/transitions/listenable_builder.1.dart b/novelforge-project/flutter/examples/api/lib/widgets/transitions/listenable_builder.1.dart new file mode 100644 index 0000000000000000000000000000000000000000..4d83badcdb18dd01a76e877a55ca60ca46bb212d --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/transitions/listenable_builder.1.dart @@ -0,0 +1,64 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for a [ValueNotifier] with a [ListenableBuilder]. + +void main() { + runApp(const ListenableBuilderExample()); +} + +class ListenableBuilderExample extends StatefulWidget { + const ListenableBuilderExample({super.key}); + + @override + State createState() => _ListenableBuilderExampleState(); +} + +class _ListenableBuilderExampleState extends State { + final ValueNotifier _counter = ValueNotifier(0); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('ListenableBuilder Example')), + body: CounterBody(counterValueNotifier: _counter), + floatingActionButton: FloatingActionButton( + onPressed: () => _counter.value++, + child: const Icon(Icons.add), + ), + ), + ); + } +} + +class CounterBody extends StatelessWidget { + const CounterBody({super.key, required this.counterValueNotifier}); + + final ValueNotifier counterValueNotifier; + + @override + Widget build(BuildContext context) { + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text('Current counter value:'), + // Thanks to the ListenableBuilder, only the widget displaying the + // current count is rebuilt when counterValueNotifier notifies its + // listeners. The Text widget above and CounterBody itself aren't + // rebuilt. + ListenableBuilder( + listenable: counterValueNotifier, + builder: (BuildContext context, Widget? child) { + return Text('${counterValueNotifier.value}'); + }, + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/transitions/listenable_builder.2.dart b/novelforge-project/flutter/examples/api/lib/widgets/transitions/listenable_builder.2.dart new file mode 100644 index 0000000000000000000000000000000000000000..f417bfc46f4cf0749b45f7ba9325f99fef11a37b --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/transitions/listenable_builder.2.dart @@ -0,0 +1,74 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for a [ChangeNotifier] with a [ListenableBuilder]. + +void main() { + runApp(const ListenableBuilderExample()); +} + +class CounterModel with ChangeNotifier { + int _count = 0; + int get count => _count; + + void increment() { + _count += 1; + notifyListeners(); + } +} + +class ListenableBuilderExample extends StatefulWidget { + const ListenableBuilderExample({super.key}); + + @override + State createState() => _ListenableBuilderExampleState(); +} + +class _ListenableBuilderExampleState extends State { + final CounterModel _counter = CounterModel(); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('ListenableBuilder Example')), + body: CounterBody(counterNotifier: _counter), + floatingActionButton: FloatingActionButton( + onPressed: _counter.increment, + child: const Icon(Icons.add), + ), + ), + ); + } +} + +class CounterBody extends StatelessWidget { + const CounterBody({super.key, required this.counterNotifier}); + + final CounterModel counterNotifier; + + @override + Widget build(BuildContext context) { + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text('Current counter value:'), + // Thanks to the ListenableBuilder, only the widget displaying the + // current count is rebuilt when counterValueNotifier notifies its + // listeners. The Text widget above and CounterBody itself aren't + // rebuilt. + ListenableBuilder( + listenable: counterNotifier, + builder: (BuildContext context, Widget? child) { + return Text('${counterNotifier.count}'); + }, + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/transitions/listenable_builder.3.dart b/novelforge-project/flutter/examples/api/lib/widgets/transitions/listenable_builder.3.dart new file mode 100644 index 0000000000000000000000000000000000000000..8bc7ae1ed454c7826f83b7534ee1bda3aef176a1 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/transitions/listenable_builder.3.dart @@ -0,0 +1,82 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:math' as math; +import 'package:flutter/material.dart'; + +/// Flutter code sample for a [ChangeNotifier] with a [ListenableBuilder]. + +void main() { + runApp(const ListenableBuilderExample()); +} + +class ListModel with ChangeNotifier { + final List _values = []; + List get values => _values.toList(); // O(N), makes a new copy each time. + + void add(int value) { + _values.add(value); + notifyListeners(); + } +} + +class ListenableBuilderExample extends StatefulWidget { + const ListenableBuilderExample({super.key}); + + @override + State createState() => _ListenableBuilderExampleState(); +} + +class _ListenableBuilderExampleState extends State { + final ListModel _listNotifier = ListModel(); + final math.Random _random = math.Random(0); // fixed seed for reproducability + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('ListenableBuilder Example')), + body: ListBody(listNotifier: _listNotifier), + floatingActionButton: FloatingActionButton( + onPressed: () => _listNotifier.add(_random.nextInt(1 << 31)), // 1 << 31 is the maximum supported value + child: const Icon(Icons.add), + ), + ), + ); + } +} + +class ListBody extends StatelessWidget { + const ListBody({super.key, required this.listNotifier}); + + final ListModel listNotifier; + + @override + Widget build(BuildContext context) { + return Center( + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + const Text('Current values:'), + Expanded( + child: ListenableBuilder( + listenable: listNotifier, + builder: (BuildContext context, Widget? child) { + // We rebuild the ListView each time the list changes, + // so that the framework knows to update the rendering. + final List values = listNotifier.values; // copy the list + return ListView.builder( + itemBuilder: (BuildContext context, int index) => ListTile( + title: Text('${values[index]}'), + ), + itemCount: values.length, + ); + }, + ), + ), + ], + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/transitions/matrix_transition.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/transitions/matrix_transition.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..2d687a31e7a70b5158810ba7bb8932749d1e1197 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/transitions/matrix_transition.0.dart @@ -0,0 +1,75 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:math'; + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [MatrixTransition]. + +void main() => runApp(const MatrixTransitionExampleApp()); + +class MatrixTransitionExampleApp extends StatelessWidget { + const MatrixTransitionExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: MatrixTransitionExample(), + ); + } +} + +class MatrixTransitionExample extends StatefulWidget { + const MatrixTransitionExample({super.key}); + + @override + State createState() => _MatrixTransitionExampleState(); +} + +/// [AnimationController]s can be created with `vsync: this` because of +/// [TickerProviderStateMixin]. +class _MatrixTransitionExampleState extends State with TickerProviderStateMixin { + late AnimationController _controller; + late Animation _animation; + + @override + void initState() { + super.initState(); + _controller = AnimationController( + duration: const Duration(seconds: 2), + vsync: this, + )..repeat(); + _animation = CurvedAnimation( + parent: _controller, + curve: Curves.linear, + ); + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: MatrixTransition( + animation: _animation, + child: const Padding( + padding: EdgeInsets.all(8.0), + child: FlutterLogo(size: 150.0), + ), + onTransform: (double value) { + return Matrix4.identity() + ..setEntry(3, 2, 0.004) + ..rotateY(pi * 2.0 * value); + }, + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/transitions/positioned_transition.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/transitions/positioned_transition.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..5adf8b161f1290d61204ec7e6c3678391af681e1 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/transitions/positioned_transition.0.dart @@ -0,0 +1,77 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [PositionedTransition]. + +void main() => runApp(const PositionedTransitionExampleApp()); + +class PositionedTransitionExampleApp extends StatelessWidget { + const PositionedTransitionExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: PositionedTransitionExample(), + ); + } +} + +class PositionedTransitionExample extends StatefulWidget { + const PositionedTransitionExample({super.key}); + + @override + State createState() => _PositionedTransitionExampleState(); +} + +/// [AnimationController]s can be created with `vsync: this` because of +/// [TickerProviderStateMixin]. +class _PositionedTransitionExampleState extends State with TickerProviderStateMixin { + late final AnimationController _controller = AnimationController( + duration: const Duration(seconds: 2), + vsync: this, + )..repeat(reverse: true); + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + const double smallLogo = 100; + const double bigLogo = 200; + + return LayoutBuilder( + builder: (BuildContext context, BoxConstraints constraints) { + final Size biggest = constraints.biggest; + return Stack( + children: [ + PositionedTransition( + rect: RelativeRectTween( + begin: RelativeRect.fromSize( + const Rect.fromLTWH(0, 0, smallLogo, smallLogo), + biggest, + ), + end: RelativeRect.fromSize( + Rect.fromLTWH(biggest.width - bigLogo, biggest.height - bigLogo, bigLogo, bigLogo), + biggest, + ), + ).animate(CurvedAnimation( + parent: _controller, + curve: Curves.elasticInOut, + )), + child: const Padding( + padding: EdgeInsets.all(8), + child: FlutterLogo(), + ), + ), + ], + ); + }, + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/transitions/relative_positioned_transition.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/transitions/relative_positioned_transition.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..3b5f57c0530849412e9823eebad98571a6e70696 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/transitions/relative_positioned_transition.0.dart @@ -0,0 +1,78 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [RelativePositionedTransition]. + +void main() => runApp(const RelativePositionedTransitionExampleApp()); + +class RelativePositionedTransitionExampleApp extends StatelessWidget { + const RelativePositionedTransitionExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: RelativePositionedTransitionExample(), + ); + } +} + +class RelativePositionedTransitionExample extends StatefulWidget { + const RelativePositionedTransitionExample({super.key}); + + @override + State createState() => _RelativePositionedTransitionExampleState(); +} + +/// [AnimationController]s can be created with `vsync: this` because of +/// [TickerProviderStateMixin]. +class _RelativePositionedTransitionExampleState extends State + with TickerProviderStateMixin { + late final AnimationController _controller = AnimationController( + duration: const Duration(seconds: 2), + vsync: this, + )..repeat(reverse: true); + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + const double smallLogo = 100; + const double bigLogo = 200; + + return LayoutBuilder( + builder: (BuildContext context, BoxConstraints constraints) { + final Size biggest = constraints.biggest; + return Stack( + children: [ + RelativePositionedTransition( + size: biggest, + rect: RectTween( + begin: const Rect.fromLTWH(0, 0, bigLogo, bigLogo), + end: Rect.fromLTWH( + biggest.width - smallLogo, + biggest.height - smallLogo, + smallLogo, + smallLogo, + ), + ).animate(CurvedAnimation( + parent: _controller, + curve: Curves.elasticInOut, + )), + child: const Padding( + padding: EdgeInsets.all(8), + child: FlutterLogo(), + ), + ), + ], + ); + }, + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/transitions/rotation_transition.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/transitions/rotation_transition.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..58001daf30f24fae49d4e308f4f4e5d6b4a26826 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/transitions/rotation_transition.0.dart @@ -0,0 +1,61 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [RotationTransition]. + +void main() => runApp(const RotationTransitionExampleApp()); + +class RotationTransitionExampleApp extends StatelessWidget { + const RotationTransitionExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: RotationTransitionExample(), + ); + } +} + +class RotationTransitionExample extends StatefulWidget { + const RotationTransitionExample({super.key}); + + @override + State createState() => _RotationTransitionExampleState(); +} + +/// [AnimationController]s can be created with `vsync: this` because of +/// [TickerProviderStateMixin]. +class _RotationTransitionExampleState extends State with TickerProviderStateMixin { + late final AnimationController _controller = AnimationController( + duration: const Duration(seconds: 2), + vsync: this, + )..repeat(reverse: true); + late final Animation _animation = CurvedAnimation( + parent: _controller, + curve: Curves.elasticOut, + ); + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: RotationTransition( + turns: _animation, + child: const Padding( + padding: EdgeInsets.all(8.0), + child: FlutterLogo(size: 150.0), + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/transitions/scale_transition.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/transitions/scale_transition.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..34b3527354e410dbbea9c8e081051eb9fc18209f --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/transitions/scale_transition.0.dart @@ -0,0 +1,61 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [ScaleTransition]. + +void main() => runApp(const ScaleTransitionExampleApp()); + +class ScaleTransitionExampleApp extends StatelessWidget { + const ScaleTransitionExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: ScaleTransitionExample(), + ); + } +} + +class ScaleTransitionExample extends StatefulWidget { + const ScaleTransitionExample({super.key}); + + @override + State createState() => _ScaleTransitionExampleState(); +} + +/// [AnimationController]s can be created with `vsync: this` because of +/// [TickerProviderStateMixin]. +class _ScaleTransitionExampleState extends State with TickerProviderStateMixin { + late final AnimationController _controller = AnimationController( + duration: const Duration(seconds: 2), + vsync: this, + )..repeat(reverse: true); + late final Animation _animation = CurvedAnimation( + parent: _controller, + curve: Curves.fastOutSlowIn, + ); + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: ScaleTransition( + scale: _animation, + child: const Padding( + padding: EdgeInsets.all(8.0), + child: FlutterLogo(size: 150.0), + ), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/transitions/size_transition.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/transitions/size_transition.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..cfd9525c7834d88db46c63c50f40a4f58a475c56 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/transitions/size_transition.0.dart @@ -0,0 +1,60 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [SizeTransition]. + +void main() => runApp(const SizeTransitionExampleApp()); + +class SizeTransitionExampleApp extends StatelessWidget { + const SizeTransitionExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: SizeTransitionExample(), + ); + } +} + +class SizeTransitionExample extends StatefulWidget { + const SizeTransitionExample({super.key}); + + @override + State createState() => _SizeTransitionExampleState(); +} + +/// [AnimationController]s can be created with `vsync: this` because of +/// [TickerProviderStateMixin]. +class _SizeTransitionExampleState extends State with TickerProviderStateMixin { + late final AnimationController _controller = AnimationController( + duration: const Duration(seconds: 3), + vsync: this, + )..repeat(); + late final Animation _animation = CurvedAnimation( + parent: _controller, + curve: Curves.fastOutSlowIn, + ); + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SizeTransition( + sizeFactor: _animation, + axis: Axis.horizontal, + axisAlignment: -1, + child: const Center( + child: FlutterLogo(size: 200.0), + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/transitions/slide_transition.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/transitions/slide_transition.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..861dc7f5d4934d1331f23ecc02b1861166e07e47 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/transitions/slide_transition.0.dart @@ -0,0 +1,63 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [SlideTransition]. + +void main() => runApp(const SlideTransitionExampleApp()); + +class SlideTransitionExampleApp extends StatelessWidget { + const SlideTransitionExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('SlideTransition Sample')), + body: const Center( + child: SlideTransitionExample(), + ), + ), + ); + } +} + +class SlideTransitionExample extends StatefulWidget { + const SlideTransitionExample({super.key}); + + @override + State createState() => _SlideTransitionExampleState(); +} + +class _SlideTransitionExampleState extends State with SingleTickerProviderStateMixin { + late final AnimationController _controller = AnimationController( + duration: const Duration(seconds: 2), + vsync: this, + )..repeat(reverse: true); + late final Animation _offsetAnimation = Tween( + begin: Offset.zero, + end: const Offset(1.5, 0.0), + ).animate(CurvedAnimation( + parent: _controller, + curve: Curves.elasticIn, + )); + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return SlideTransition( + position: _offsetAnimation, + child: const Padding( + padding: EdgeInsets.all(8.0), + child: FlutterLogo(size: 150.0), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/transitions/sliver_fade_transition.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/transitions/sliver_fade_transition.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..bdd364b859a63be28093fa656fb8e91a69bee1b6 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/transitions/sliver_fade_transition.0.dart @@ -0,0 +1,82 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [SliverFadeTransition]. + +void main() => runApp(const SliverFadeTransitionExampleApp()); + +class SliverFadeTransitionExampleApp extends StatelessWidget { + const SliverFadeTransitionExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('SliverFadeTransition Sample')), + body: const Center( + child: SliverFadeTransitionExample(), + ), + ), + ); + } +} + +class SliverFadeTransitionExample extends StatefulWidget { + const SliverFadeTransitionExample({super.key}); + + @override + State createState() => _SliverFadeTransitionExampleState(); +} + +class _SliverFadeTransitionExampleState extends State with SingleTickerProviderStateMixin { + late final AnimationController controller = AnimationController( + duration: const Duration(milliseconds: 1000), + vsync: this, + ); + late final Animation animation = CurvedAnimation( + parent: controller, + curve: Curves.easeIn, + ); + + @override + void initState() { + super.initState(); + animation.addStatusListener((AnimationStatus status) { + if (status == AnimationStatus.completed) { + controller.reverse(); + } else if (status == AnimationStatus.dismissed) { + controller.forward(); + } + }); + controller.forward(); + } + + @override + void dispose() { + controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return CustomScrollView(slivers: [ + SliverFadeTransition( + opacity: animation, + sliver: SliverFixedExtentList( + itemExtent: 100.0, + delegate: SliverChildBuilderDelegate( + (BuildContext context, int index) { + return Container( + color: index.isEven ? Colors.indigo[200] : Colors.orange[200], + ); + }, + childCount: 5, + ), + ), + ), + ]); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/tween_animation_builder/tween_animation_builder.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/tween_animation_builder/tween_animation_builder.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..65d9587818acbaae0f3b285addef39c75126ba94 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/tween_animation_builder/tween_animation_builder.0.dart @@ -0,0 +1,57 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [TweenAnimationBuilder]. + +void main() => runApp(const TweenAnimationBuilderExampleApp()); + +class TweenAnimationBuilderExampleApp extends StatelessWidget { + const TweenAnimationBuilderExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('TweenAnimationBuilder Sample')), + body: const Center( + child: TweenAnimationBuilderExample(), + ), + ), + ); + } +} + +class TweenAnimationBuilderExample extends StatefulWidget { + const TweenAnimationBuilderExample({super.key}); + + @override + State createState() => _TweenAnimationBuilderExampleState(); +} + +class _TweenAnimationBuilderExampleState extends State { + double targetValue = 24.0; + + @override + Widget build(BuildContext context) { + return TweenAnimationBuilder( + tween: Tween(begin: 0, end: targetValue), + duration: const Duration(seconds: 1), + builder: (BuildContext context, double size, Widget? child) { + return IconButton( + iconSize: size, + color: Colors.blue, + icon: child!, + onPressed: () { + setState(() { + targetValue = targetValue == 24.0 ? 48.0 : 24.0; + }); + }, + ); + }, + child: const Icon(Icons.aspect_ratio), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/undo_history/undo_history_controller.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/undo_history/undo_history_controller.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..33a0dfec052eb6d70c65ae29fbef691a6e2a4fec --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/undo_history/undo_history_controller.0.dart @@ -0,0 +1,78 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [UndoHistoryController]. + +void main() { + runApp(const UndoHistoryControllerExampleApp()); +} + +class UndoHistoryControllerExampleApp extends StatelessWidget { + const UndoHistoryControllerExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: MyHomePage(), + ); + } +} + +class MyHomePage extends StatefulWidget { + const MyHomePage({super.key}); + + @override + State createState() => _MyHomePageState(); +} + +class _MyHomePageState extends State { + final TextEditingController _controller = TextEditingController(); + final FocusNode _focusNode = FocusNode(); + final UndoHistoryController _undoController = UndoHistoryController(); + + TextStyle? get enabledStyle => Theme.of(context).textTheme.bodyMedium; + TextStyle? get disabledStyle => Theme.of(context).textTheme.bodyMedium?.copyWith(color: Colors.grey); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + TextField( + maxLines: 4, + controller: _controller, + focusNode: _focusNode, + undoController: _undoController, + ), + ValueListenableBuilder( + valueListenable: _undoController, + builder: (BuildContext context, UndoHistoryValue value, Widget? child) { + return Row( + children: [ + TextButton( + child: Text('Undo', style: value.canUndo ? enabledStyle : disabledStyle), + onPressed: () { + _undoController.undo(); + }, + ), + TextButton( + child: Text('Redo', style: value.canRedo ? enabledStyle : disabledStyle), + onPressed: () { + _undoController.redo(); + }, + ), + ], + ); + }, + ), + ], + ), + ), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/lib/widgets/value_listenable_builder/value_listenable_builder.0.dart b/novelforge-project/flutter/examples/api/lib/widgets/value_listenable_builder/value_listenable_builder.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..07b91848a3448db82258f15a6abb067cac561259 --- /dev/null +++ b/novelforge-project/flutter/examples/api/lib/widgets/value_listenable_builder/value_listenable_builder.0.dart @@ -0,0 +1,94 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +/// Flutter code sample for [ValueListenableBuilder]. + +void main() => runApp(const ValueListenableBuilderExampleApp()); + +class ValueListenableBuilderExampleApp extends StatelessWidget { + const ValueListenableBuilderExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: ValueListenableBuilderExample(), + ); + } +} + +class ValueListenableBuilderExample extends StatefulWidget { + const ValueListenableBuilderExample({super.key}); + + @override + State createState() => _ValueListenableBuilderExampleState(); +} + +class _ValueListenableBuilderExampleState extends State { + final ValueNotifier _counter = ValueNotifier(0); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('ValueListenableBuilder Sample'), + ), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text('You have pushed the button this many times:'), + ValueListenableBuilder( + builder: (BuildContext context, int value, Widget? child) { + // This builder will only get called when the _counter + // is updated. + return Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CountDisplay(count: value), + child!, + ], + ); + }, + valueListenable: _counter, + // The child parameter is most helpful if the child is + // expensive to build and does not depend on the value from + // the notifier. + child: const Padding( + padding: EdgeInsets.all(10.0), + child: SizedBox( + width: 40, + height: 40, + child: FlutterLogo(size: 40), + ), + ), + ), + ], + ), + ), + floatingActionButton: FloatingActionButton( + child: const Icon(Icons.plus_one), + onPressed: () => _counter.value += 1, + ), + ); + } +} + +class CountDisplay extends StatelessWidget { + const CountDisplay({super.key, required this.count}); + + final int count; + + @override + Widget build(BuildContext context) { + return Container( + width: 100, + height: 100, + padding: const EdgeInsetsDirectional.all(10), + child: Text('$count', style: Theme.of(context).textTheme.headlineMedium), + ); + } +} diff --git a/novelforge-project/flutter/examples/api/linux/CMakeLists.txt b/novelforge-project/flutter/examples/api/linux/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..6c1592115d6232c4097f8621713101b34f051308 --- /dev/null +++ b/novelforge-project/flutter/examples/api/linux/CMakeLists.txt @@ -0,0 +1,116 @@ +cmake_minimum_required(VERSION 3.10) +project(runner LANGUAGES CXX) + +set(BINARY_NAME "flutter_api_samples") +set(APPLICATION_ID "dev.flutter.flutter_api_samples") + +cmake_policy(SET CMP0063 NEW) + +set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") + +# Root filesystem for cross-building. +if(FLUTTER_TARGET_PLATFORM_SYSROOT) + set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif() + +# Configure build options. +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") +endif() + +# Compilation settings that should be applied to most targets. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_14) + target_compile_options(${TARGET} PRIVATE -Wall -Werror) + target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") + target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") +endfunction() + +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") + +# Flutter library and tool build rules. +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) + +add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") + +# Application build +add_executable(${BINARY_NAME} + "main.cc" + "my_application.cc" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" +) +apply_standard_settings(${BINARY_NAME}) +target_link_libraries(${BINARY_NAME} PRIVATE flutter) +target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) +add_dependencies(${BINARY_NAME} flutter_assemble) +# Only the install-generated bundle's copy of the executable will launch +# correctly, since the resources must in the right relative locations. To avoid +# people trying to run the unbundled copy, put it in a subdirectory instead of +# the default top-level location. +set_target_properties(${BINARY_NAME} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" +) + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# By default, "installing" just makes a relocatable bundle in the build +# directory. +set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +# Start with a clean build bundle directory every time. +install(CODE " + file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") + " COMPONENT Runtime) + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +if(PLUGIN_BUNDLED_LIBRARIES) + install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() diff --git a/novelforge-project/flutter/examples/api/linux/flutter/CMakeLists.txt b/novelforge-project/flutter/examples/api/linux/flutter/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..33fd5801e7134249aa03257b3190f0e700055870 --- /dev/null +++ b/novelforge-project/flutter/examples/api/linux/flutter/CMakeLists.txt @@ -0,0 +1,87 @@ +cmake_minimum_required(VERSION 3.10) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. + +# Serves the same purpose as list(TRANSFORM ... PREPEND ...), +# which isn't available in 3.10. +function(list_prepend LIST_NAME PREFIX) + set(NEW_LIST "") + foreach(element ${${LIST_NAME}}) + list(APPEND NEW_LIST "${PREFIX}${element}") + endforeach(element) + set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) +endfunction() + +# === Flutter Library === +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) +pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) +pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) + +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "fl_basic_message_channel.h" + "fl_binary_codec.h" + "fl_binary_messenger.h" + "fl_dart_project.h" + "fl_engine.h" + "fl_json_message_codec.h" + "fl_json_method_codec.h" + "fl_message_codec.h" + "fl_method_call.h" + "fl_method_channel.h" + "fl_method_codec.h" + "fl_method_response.h" + "fl_plugin_registrar.h" + "fl_plugin_registry.h" + "fl_standard_message_codec.h" + "fl_standard_method_codec.h" + "fl_string_codec.h" + "fl_value.h" + "fl_view.h" + "flutter_linux.h" +) +list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") +target_link_libraries(flutter INTERFACE + PkgConfig::GTK + PkgConfig::GLIB + PkgConfig::GIO +) +add_dependencies(flutter flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CMAKE_CURRENT_BINARY_DIR}/_phony_ + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" + ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} +) diff --git a/novelforge-project/flutter/examples/api/linux/main.cc b/novelforge-project/flutter/examples/api/linux/main.cc new file mode 100644 index 0000000000000000000000000000000000000000..281a29e16b599a95421e7a35112eda77900ff549 --- /dev/null +++ b/novelforge-project/flutter/examples/api/linux/main.cc @@ -0,0 +1,10 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "my_application.h" + +int main(int argc, char** argv) { + g_autoptr(MyApplication) app = my_application_new(); + return g_application_run(G_APPLICATION(app), argc, argv); +} diff --git a/novelforge-project/flutter/examples/api/linux/my_application.cc b/novelforge-project/flutter/examples/api/linux/my_application.cc new file mode 100644 index 0000000000000000000000000000000000000000..654c0788bbde460e6860c1cf83a57dcf51838d93 --- /dev/null +++ b/novelforge-project/flutter/examples/api/linux/my_application.cc @@ -0,0 +1,108 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "my_application.h" + +#include +#ifdef GDK_WINDOWING_X11 +#include +#endif + +#include "flutter/generated_plugin_registrant.h" + +struct _MyApplication { + GtkApplication parent_instance; + char** dart_entrypoint_arguments; +}; + +G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) + +// Implements GApplication::activate. +static void my_application_activate(GApplication* application) { + MyApplication* self = MY_APPLICATION(application); + GtkWindow* window = + GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); + + // Use a header bar when running in GNOME as this is the common style used + // by applications and is the setup most users will be using (e.g. Ubuntu + // desktop). + // If running on X and not using GNOME then just use a traditional title bar + // in case the window manager does more exotic layout, e.g. tiling. + // If running on Wayland assume the header bar will work (may need changing + // if future cases occur). + gboolean use_header_bar = TRUE; +#ifdef GDK_WINDOWING_X11 + GdkScreen* screen = gtk_window_get_screen(window); + if (GDK_IS_X11_SCREEN(screen)) { + const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); + if (g_strcmp0(wm_name, "GNOME Shell") != 0) { + use_header_bar = FALSE; + } + } +#endif + if (use_header_bar) { + GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); + gtk_widget_show(GTK_WIDGET(header_bar)); + gtk_header_bar_set_title(header_bar, "flutter_api_samples"); + gtk_header_bar_set_show_close_button(header_bar, TRUE); + gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); + } else { + gtk_window_set_title(window, "flutter_api_samples"); + } + + gtk_window_set_default_size(window, 1280, 720); + gtk_widget_show(GTK_WIDGET(window)); + + g_autoptr(FlDartProject) project = fl_dart_project_new(); + fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); + + FlView* view = fl_view_new(project); + gtk_widget_show(GTK_WIDGET(view)); + gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); + + fl_register_plugins(FL_PLUGIN_REGISTRY(view)); + + gtk_widget_grab_focus(GTK_WIDGET(view)); +} + +// Implements GApplication::local_command_line. +static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { + MyApplication* self = MY_APPLICATION(application); + // Strip out the first argument as it is the binary name. + self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); + + g_autoptr(GError) error = nullptr; + if (!g_application_register(application, nullptr, &error)) { + g_warning("Failed to register: %s", error->message); + *exit_status = 1; + return TRUE; + } + + g_application_activate(application); + *exit_status = 0; + + return TRUE; +} + +// Implements GObject::dispose. +static void my_application_dispose(GObject* object) { + MyApplication* self = MY_APPLICATION(object); + g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); + G_OBJECT_CLASS(my_application_parent_class)->dispose(object); +} + +static void my_application_class_init(MyApplicationClass* klass) { + G_APPLICATION_CLASS(klass)->activate = my_application_activate; + G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; + G_OBJECT_CLASS(klass)->dispose = my_application_dispose; +} + +static void my_application_init(MyApplication* self) {} + +MyApplication* my_application_new() { + return MY_APPLICATION(g_object_new(my_application_get_type(), + "application-id", APPLICATION_ID, + "flags", G_APPLICATION_NON_UNIQUE, + nullptr)); +} diff --git a/novelforge-project/flutter/examples/api/linux/my_application.h b/novelforge-project/flutter/examples/api/linux/my_application.h new file mode 100644 index 0000000000000000000000000000000000000000..8c66ec485434d1f922c9915bdaefcb8969cdfec9 --- /dev/null +++ b/novelforge-project/flutter/examples/api/linux/my_application.h @@ -0,0 +1,22 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef FLUTTER_MY_APPLICATION_H_ +#define FLUTTER_MY_APPLICATION_H_ + +#include + +G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, + GtkApplication) + +/** + * my_application_new: + * + * Creates a new Flutter-based application. + * + * Returns: a new #MyApplication. + */ +MyApplication* my_application_new(); + +#endif // FLUTTER_MY_APPLICATION_H_ diff --git a/novelforge-project/flutter/examples/api/macos/Flutter/Flutter-Debug.xcconfig b/novelforge-project/flutter/examples/api/macos/Flutter/Flutter-Debug.xcconfig new file mode 100644 index 0000000000000000000000000000000000000000..4b81f9b2d200fc807eed25bca04dff9ee9dcc45f --- /dev/null +++ b/novelforge-project/flutter/examples/api/macos/Flutter/Flutter-Debug.xcconfig @@ -0,0 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/novelforge-project/flutter/examples/api/macos/Flutter/Flutter-Release.xcconfig b/novelforge-project/flutter/examples/api/macos/Flutter/Flutter-Release.xcconfig new file mode 100644 index 0000000000000000000000000000000000000000..5caa9d1579e481a5894c37e2e56b0da062e95b35 --- /dev/null +++ b/novelforge-project/flutter/examples/api/macos/Flutter/Flutter-Release.xcconfig @@ -0,0 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/novelforge-project/flutter/examples/api/macos/Podfile b/novelforge-project/flutter/examples/api/macos/Podfile new file mode 100644 index 0000000000000000000000000000000000000000..049abe2954279f0ed15c66d4c858fa4ae2a590bf --- /dev/null +++ b/novelforge-project/flutter/examples/api/macos/Podfile @@ -0,0 +1,40 @@ +platform :osx, '10.14' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_macos_build_settings(target) + end +end diff --git a/novelforge-project/flutter/examples/api/macos/Runner.xcodeproj/project.pbxproj b/novelforge-project/flutter/examples/api/macos/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000000000000000000000000000000000000..82887b9e11118c5fabe643666b93e0ebe243b637 --- /dev/null +++ b/novelforge-project/flutter/examples/api/macos/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,615 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXAggregateTarget section */ + 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = { + isa = PBXAggregateTarget; + buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */; + buildPhases = ( + 33CC111E2044C6BF0003C045 /* ShellScript */, + ); + dependencies = ( + ); + name = "Flutter Assemble"; + productName = FLX; + }; +/* End PBXAggregateTarget section */ + +/* Begin PBXBuildFile section */ + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; + 950C239DEA05231F26974A10 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 639541EE500E1E798CB69526 /* Pods_Runner.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC111A2044C6BA0003C045; + remoteInfo = FLX; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 33CC110E2044A8840003C045 /* Bundle Framework */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Bundle Framework"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 277104DEA919A7BC0A865477 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; + 29AD1BE7CDBB31470316D7C5 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; + 33CC10ED2044A3C60003C045 /* flutter_api_samples.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = flutter_api_samples.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; + 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; + 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; }; + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; }; + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; + 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; + 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; + 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; + 639541EE500E1E798CB69526 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; + E2F543B6F3F601B2108EAB46 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 33CC10EA2044A3C60003C045 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 950C239DEA05231F26974A10 /* Pods_Runner.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 02C0718F439899652B288987 /* Pods */ = { + isa = PBXGroup; + children = ( + 29AD1BE7CDBB31470316D7C5 /* Pods-Runner.debug.xcconfig */, + 277104DEA919A7BC0A865477 /* Pods-Runner.release.xcconfig */, + E2F543B6F3F601B2108EAB46 /* Pods-Runner.profile.xcconfig */, + ); + name = Pods; + path = Pods; + sourceTree = ""; + }; + 33BA886A226E78AF003329D5 /* Configs */ = { + isa = PBXGroup; + children = ( + 33E5194F232828860026EE4D /* AppInfo.xcconfig */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */, + ); + path = Configs; + sourceTree = ""; + }; + 33CC10E42044A3C60003C045 = { + isa = PBXGroup; + children = ( + 33FAB671232836740065AC1E /* Runner */, + 33CEB47122A05771004F2AC0 /* Flutter */, + 33CC10EE2044A3C60003C045 /* Products */, + D73912EC22F37F3D000D13A0 /* Frameworks */, + 02C0718F439899652B288987 /* Pods */, + ); + sourceTree = ""; + }; + 33CC10EE2044A3C60003C045 /* Products */ = { + isa = PBXGroup; + children = ( + 33CC10ED2044A3C60003C045 /* flutter_api_samples.app */, + ); + name = Products; + sourceTree = ""; + }; + 33CC11242044D66E0003C045 /* Resources */ = { + isa = PBXGroup; + children = ( + 33CC10F22044A3C60003C045 /* Assets.xcassets */, + 33CC10F42044A3C60003C045 /* MainMenu.xib */, + 33CC10F72044A3C60003C045 /* Info.plist */, + ); + name = Resources; + path = ..; + sourceTree = ""; + }; + 33CEB47122A05771004F2AC0 /* Flutter */ = { + isa = PBXGroup; + children = ( + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */, + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, + ); + path = Flutter; + sourceTree = ""; + }; + 33FAB671232836740065AC1E /* Runner */ = { + isa = PBXGroup; + children = ( + 33CC10F02044A3C60003C045 /* AppDelegate.swift */, + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */, + 33E51913231747F40026EE4D /* DebugProfile.entitlements */, + 33E51914231749380026EE4D /* Release.entitlements */, + 33CC11242044D66E0003C045 /* Resources */, + 33BA886A226E78AF003329D5 /* Configs */, + ); + path = Runner; + sourceTree = ""; + }; + D73912EC22F37F3D000D13A0 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 639541EE500E1E798CB69526 /* Pods_Runner.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 33CC10EC2044A3C60003C045 /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 6365747C9AFB9FD3319FF0D0 /* [CP] Check Pods Manifest.lock */, + 33CC10E92044A3C60003C045 /* Sources */, + 33CC10EA2044A3C60003C045 /* Frameworks */, + 33CC10EB2044A3C60003C045 /* Resources */, + 33CC110E2044A8840003C045 /* Bundle Framework */, + 3399D490228B24CF009A79C7 /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + 33CC11202044C79F0003C045 /* PBXTargetDependency */, + ); + name = Runner; + productName = Runner; + productReference = 33CC10ED2044A3C60003C045 /* flutter_api_samples.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 33CC10E52044A3C60003C045 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0920; + LastUpgradeCheck = 1510; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 33CC10EC2044A3C60003C045 = { + CreatedOnToolsVersion = 9.2; + LastSwiftMigration = 1100; + ProvisioningStyle = Automatic; + SystemCapabilities = { + com.apple.Sandbox = { + enabled = 1; + }; + }; + }; + 33CC111A2044C6BA0003C045 = { + CreatedOnToolsVersion = 9.2; + ProvisioningStyle = Manual; + }; + }; + }; + buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 33CC10E42044A3C60003C045; + productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 33CC10EC2044A3C60003C045 /* Runner */, + 33CC111A2044C6BA0003C045 /* Flutter Assemble */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 33CC10EB2044A3C60003C045 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3399D490228B24CF009A79C7 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; + }; + 33CC111E2044C6BF0003C045 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + Flutter/ephemeral/FlutterInputs.xcfilelist, + ); + inputPaths = ( + Flutter/ephemeral/tripwire, + ); + outputFileListPaths = ( + Flutter/ephemeral/FlutterOutputs.xcfilelist, + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; + }; + 6365747C9AFB9FD3319FF0D0 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 33CC10E92044A3C60003C045 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */, + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */, + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 33CC11202044C79F0003C045 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */; + targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 33CC10F42044A3C60003C045 /* MainMenu.xib */ = { + isa = PBXVariantGroup; + children = ( + 33CC10F52044A3C60003C045 /* Base */, + ); + name = MainMenu.xib; + path = Runner; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 338D0CE9231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Profile; + }; + 338D0CEA231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Profile; + }; + 338D0CEB231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Profile; + }; + 33CC10F92044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 33CC10FA2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + 33CC10FC2044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 33CC10FD2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 33CC111C2044C6BA0003C045 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 33CC111D2044C6BA0003C045 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10F92044A3C60003C045 /* Debug */, + 33CC10FA2044A3C60003C045 /* Release */, + 338D0CE9231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10FC2044A3C60003C045 /* Debug */, + 33CC10FD2044A3C60003C045 /* Release */, + 338D0CEA231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC111C2044C6BA0003C045 /* Debug */, + 33CC111D2044C6BA0003C045 /* Release */, + 338D0CEB231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 33CC10E52044A3C60003C045 /* Project object */; +} diff --git a/novelforge-project/flutter/examples/api/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/novelforge-project/flutter/examples/api/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000000000000000000000000000000000000..18d981003d68d0546c4804ac2ff47dd97c6e7921 --- /dev/null +++ b/novelforge-project/flutter/examples/api/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/novelforge-project/flutter/examples/api/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/novelforge-project/flutter/examples/api/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000000000000000000000000000000000000..0650630cd8f0604c52a627796f6620e927a9c38d --- /dev/null +++ b/novelforge-project/flutter/examples/api/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/novelforge-project/flutter/examples/api/macos/Runner.xcworkspace/contents.xcworkspacedata b/novelforge-project/flutter/examples/api/macos/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000000000000000000000000000000000000..21a3cc14c74e969ab1548274a8512ebfecc40f78 --- /dev/null +++ b/novelforge-project/flutter/examples/api/macos/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/novelforge-project/flutter/examples/api/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/novelforge-project/flutter/examples/api/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000000000000000000000000000000000000..18d981003d68d0546c4804ac2ff47dd97c6e7921 --- /dev/null +++ b/novelforge-project/flutter/examples/api/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/novelforge-project/flutter/examples/api/macos/Runner/AppDelegate.swift b/novelforge-project/flutter/examples/api/macos/Runner/AppDelegate.swift new file mode 100644 index 0000000000000000000000000000000000000000..d080d41951d3506a861ceadcf4354bbbb609a562 --- /dev/null +++ b/novelforge-project/flutter/examples/api/macos/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import Cocoa +import FlutterMacOS + +@NSApplicationMain +class AppDelegate: FlutterAppDelegate { + override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { + return true + } +} diff --git a/novelforge-project/flutter/examples/api/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/novelforge-project/flutter/examples/api/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000000000000000000000000000000000000..a2ec33f19f110ebff51a23342d7bc29ec9a1aaa6 --- /dev/null +++ b/novelforge-project/flutter/examples/api/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images" : [ + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_16.png", + "scale" : "1x" + }, + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "2x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "1x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_64.png", + "scale" : "2x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_128.png", + "scale" : "1x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "2x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "1x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "2x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "1x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_1024.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/novelforge-project/flutter/examples/api/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png b/novelforge-project/flutter/examples/api/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png new file mode 100644 index 0000000000000000000000000000000000000000..3c4935a7ca84f0976aca34b7f2895d65fb94d1ea Binary files /dev/null and b/novelforge-project/flutter/examples/api/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png differ diff --git a/novelforge-project/flutter/examples/api/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png b/novelforge-project/flutter/examples/api/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png new file mode 100644 index 0000000000000000000000000000000000000000..ed4cc16421680a50164ba74381b4b35ceaa0ccfc Binary files /dev/null and b/novelforge-project/flutter/examples/api/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png differ diff --git a/novelforge-project/flutter/examples/api/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png b/novelforge-project/flutter/examples/api/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png new file mode 100644 index 0000000000000000000000000000000000000000..483be61389733f2e5331c08db8ca245268610ccb Binary files /dev/null and b/novelforge-project/flutter/examples/api/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png differ diff --git a/novelforge-project/flutter/examples/api/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png b/novelforge-project/flutter/examples/api/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png new file mode 100644 index 0000000000000000000000000000000000000000..bcbf36df2f2aaaa0a63c7dabc94e600184229d0d Binary files /dev/null and b/novelforge-project/flutter/examples/api/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png differ diff --git a/novelforge-project/flutter/examples/api/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png b/novelforge-project/flutter/examples/api/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png new file mode 100644 index 0000000000000000000000000000000000000000..9c0a652864769b250ed58097f2f6270b393f751f Binary files /dev/null and b/novelforge-project/flutter/examples/api/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png differ diff --git a/novelforge-project/flutter/examples/api/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png b/novelforge-project/flutter/examples/api/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png new file mode 100644 index 0000000000000000000000000000000000000000..e71a726136a47ed24125c7efc79d68a4a01961b4 Binary files /dev/null and b/novelforge-project/flutter/examples/api/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png differ diff --git a/novelforge-project/flutter/examples/api/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png b/novelforge-project/flutter/examples/api/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png new file mode 100644 index 0000000000000000000000000000000000000000..8a31fe2dd3f91d79cab6e0390356bb3c1a355f94 Binary files /dev/null and b/novelforge-project/flutter/examples/api/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png differ diff --git a/novelforge-project/flutter/examples/api/macos/Runner/Base.lproj/MainMenu.xib b/novelforge-project/flutter/examples/api/macos/Runner/Base.lproj/MainMenu.xib new file mode 100644 index 0000000000000000000000000000000000000000..537341abf994b3b9c5fd0a42fa6ffe6b5ed01aae --- /dev/null +++ b/novelforge-project/flutter/examples/api/macos/Runner/Base.lproj/MainMenu.xib @@ -0,0 +1,339 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/novelforge-project/flutter/examples/api/macos/Runner/Configs/AppInfo.xcconfig b/novelforge-project/flutter/examples/api/macos/Runner/Configs/AppInfo.xcconfig new file mode 100644 index 0000000000000000000000000000000000000000..e4d293cfc9e23f76e216ff6e03890598e988cb2d --- /dev/null +++ b/novelforge-project/flutter/examples/api/macos/Runner/Configs/AppInfo.xcconfig @@ -0,0 +1,14 @@ +// Application-level settings for the Runner target. +// +// This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the +// future. If not, the values below would default to using the project name when this becomes a +// 'flutter create' template. + +// The application's name. By default this is also the title of the Flutter window. +PRODUCT_NAME = Flutter API Sample + +// The application's bundle identifier +PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.flutter-api-samples + +// The copyright displayed in application information +PRODUCT_COPYRIGHT = Copyright 2014 The Flutter Authors. All rights reserved. diff --git a/novelforge-project/flutter/examples/api/macos/Runner/Configs/Debug.xcconfig b/novelforge-project/flutter/examples/api/macos/Runner/Configs/Debug.xcconfig new file mode 100644 index 0000000000000000000000000000000000000000..36b0fd9464f45b33f482e64bea579787e142affa --- /dev/null +++ b/novelforge-project/flutter/examples/api/macos/Runner/Configs/Debug.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Debug.xcconfig" +#include "Warnings.xcconfig" diff --git a/novelforge-project/flutter/examples/api/macos/Runner/Configs/Release.xcconfig b/novelforge-project/flutter/examples/api/macos/Runner/Configs/Release.xcconfig new file mode 100644 index 0000000000000000000000000000000000000000..dff4f49561c816f70eaea557d889d31cf63447ac --- /dev/null +++ b/novelforge-project/flutter/examples/api/macos/Runner/Configs/Release.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Release.xcconfig" +#include "Warnings.xcconfig" diff --git a/novelforge-project/flutter/examples/api/macos/Runner/Configs/Warnings.xcconfig b/novelforge-project/flutter/examples/api/macos/Runner/Configs/Warnings.xcconfig new file mode 100644 index 0000000000000000000000000000000000000000..42bcbf4780b187e80025b7917058bcb882012aa1 --- /dev/null +++ b/novelforge-project/flutter/examples/api/macos/Runner/Configs/Warnings.xcconfig @@ -0,0 +1,13 @@ +WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings +GCC_WARN_UNDECLARED_SELECTOR = YES +CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES +CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE +CLANG_WARN__DUPLICATE_METHOD_MATCH = YES +CLANG_WARN_PRAGMA_PACK = YES +CLANG_WARN_STRICT_PROTOTYPES = YES +CLANG_WARN_COMMA = YES +GCC_WARN_STRICT_SELECTOR_MATCH = YES +CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES +CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES +GCC_WARN_SHADOW = YES +CLANG_WARN_UNREACHABLE_CODE = YES diff --git a/novelforge-project/flutter/examples/api/macos/Runner/DebugProfile.entitlements b/novelforge-project/flutter/examples/api/macos/Runner/DebugProfile.entitlements new file mode 100644 index 0000000000000000000000000000000000000000..9f56413f3814e40c7b9307f3f9b5f027f0d0d556 --- /dev/null +++ b/novelforge-project/flutter/examples/api/macos/Runner/DebugProfile.entitlements @@ -0,0 +1,12 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.cs.allow-jit + + com.apple.security.network.server + + + diff --git a/novelforge-project/flutter/examples/api/macos/Runner/Info.plist b/novelforge-project/flutter/examples/api/macos/Runner/Info.plist new file mode 100644 index 0000000000000000000000000000000000000000..4789daa6a443eefa7f3f729164a18351e06e9800 --- /dev/null +++ b/novelforge-project/flutter/examples/api/macos/Runner/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + $(PRODUCT_COPYRIGHT) + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/novelforge-project/flutter/examples/api/macos/Runner/MainFlutterWindow.swift b/novelforge-project/flutter/examples/api/macos/Runner/MainFlutterWindow.swift new file mode 100644 index 0000000000000000000000000000000000000000..a6a6b9af83072d4765fb492f05ebc05671f9924e --- /dev/null +++ b/novelforge-project/flutter/examples/api/macos/Runner/MainFlutterWindow.swift @@ -0,0 +1,19 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import Cocoa +import FlutterMacOS + +class MainFlutterWindow: NSWindow { + override func awakeFromNib() { + let flutterViewController = FlutterViewController() + let windowFrame = self.frame + self.contentViewController = flutterViewController + self.setFrame(windowFrame, display: true) + + RegisterGeneratedPlugins(registry: flutterViewController) + + super.awakeFromNib() + } +} diff --git a/novelforge-project/flutter/examples/api/macos/Runner/Release.entitlements b/novelforge-project/flutter/examples/api/macos/Runner/Release.entitlements new file mode 100644 index 0000000000000000000000000000000000000000..e89b7f323cf06c0f693e45a878b20d54db92e85c --- /dev/null +++ b/novelforge-project/flutter/examples/api/macos/Runner/Release.entitlements @@ -0,0 +1,8 @@ + + + + + com.apple.security.app-sandbox + + + diff --git a/novelforge-project/flutter/examples/api/test/animation/animation_controller/animated_digit.0_test.dart b/novelforge-project/flutter/examples/api/test/animation/animation_controller/animated_digit.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..cbdad2b5222b452e9ef4031cf0d9320b1f5c664c --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/animation/animation_controller/animated_digit.0_test.dart @@ -0,0 +1,39 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/animation/animation_controller/animated_digit.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('animated digit example', (WidgetTester tester) async { + await tester.pumpWidget( + const example.AnimatedDigitApp(), + ); + + Finder findVisibleDigit(int digit) { + return find.descendant( + of: find.byType(SlideTransition).last, + matching: find.text('$digit'), + ); + } + + expect(findVisibleDigit(0), findsOneWidget); + + await tester.tap(find.byType(FloatingActionButton)); + await tester.pumpAndSettle(); + expect(findVisibleDigit(1), findsOneWidget); + + await tester.tap(find.byType(FloatingActionButton)); + await tester.pumpAndSettle(); + expect(findVisibleDigit(2), findsOneWidget); + + await tester.tap(find.byType(FloatingActionButton)); + await tester.pump(const Duration(milliseconds: 100)); // Animation duration is 300ms + await tester.tap(find.byType(FloatingActionButton)); + await tester.pumpAndSettle(); + expect(findVisibleDigit(4), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/activity_indicator/cupertino_activity_indicator.0_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/activity_indicator/cupertino_activity_indicator.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..d842ff1e04790641b5997e118a3d63d220e96986 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/activity_indicator/cupertino_activity_indicator.0_test.dart @@ -0,0 +1,31 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter_api_samples/cupertino/activity_indicator/cupertino_activity_indicator.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Default and customized cupertino activity indicators', (WidgetTester tester) async { + await tester.pumpWidget( + const example.CupertinoIndicatorApp(), + ); + + // Cupertino activity indicator with default properties. + final Finder firstIndicator = find.byType(CupertinoActivityIndicator).at(0); + expect(tester.widget(firstIndicator).animating, true); + expect(tester.widget(firstIndicator).radius, 10.0); + + // Cupertino activity indicator with custom radius and color. + final Finder secondIndicator = find.byType(CupertinoActivityIndicator).at(1); + expect(tester.widget(secondIndicator).animating, true); + expect(tester.widget(secondIndicator).radius, 20.0); + expect(tester.widget(secondIndicator).color, CupertinoColors.activeBlue); + + // Cupertino activity indicator with custom radius and disabled animation. + final Finder thirdIndicator = find.byType(CupertinoActivityIndicator).at(2); + expect(tester.widget(thirdIndicator).animating, false); + expect(tester.widget(thirdIndicator).radius, 20.0); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/bottom_tab_bar/cupertino_tab_bar.0_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/bottom_tab_bar/cupertino_tab_bar.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..906aeb576a954f91973411be449eda3cc6094bd6 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/bottom_tab_bar/cupertino_tab_bar.0_test.dart @@ -0,0 +1,23 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter_api_samples/cupertino/bottom_tab_bar/cupertino_tab_bar.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can switch between tabs', (WidgetTester tester) async { + await tester.pumpWidget( + const example.CupertinoTabBarApp(), + ); + + expect(find.byType(CupertinoTabBar), findsOneWidget); + expect(find.text('Content of tab 0'), findsOneWidget); + + await tester.tap(find.text('Contacts')); + await tester.pump(); + + expect(find.text('Content of tab 2'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/button/cupertino_button.0_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/button/cupertino_button.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..cdccda93856221695a8b8fdd8cdcff8411483ed8 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/button/cupertino_button.0_test.dart @@ -0,0 +1,19 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter_api_samples/cupertino/button/cupertino_button.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Has 4 CupertinoButton variants', (WidgetTester tester) async { + await tester.pumpWidget( + const example.CupertinoButtonApp(), + ); + + expect(find.byType(CupertinoButton), findsNWidgets(4)); + expect(find.ancestor(of: find.text('Enabled'), matching: find.byType(CupertinoButton)), findsNWidgets(2)); + expect(find.ancestor(of: find.text('Disabled'), matching: find.byType(CupertinoButton)), findsNWidgets(2)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/context_menu/cupertino_context_menu.0_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/context_menu/cupertino_context_menu.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..e0dbd0e0895e27ca91e3cfd2d03f519f982187aa --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/context_menu/cupertino_context_menu.0_test.dart @@ -0,0 +1,26 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/cupertino/context_menu/cupertino_context_menu.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can open cupertino context menu', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ContextMenuApp(), + ); + + final Offset logo = tester.getCenter(find.byType(FlutterLogo)); + expect(find.text('Favorite'), findsNothing); + + await tester.startGesture(logo); + await tester.pumpAndSettle(); + expect(find.text('Favorite'), findsOneWidget); + + await tester.tap(find.text('Favorite')); + await tester.pumpAndSettle(); + expect(find.text('Favorite'), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/context_menu/cupertino_context_menu.1_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/context_menu/cupertino_context_menu.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..540656c28aa9bfbc4afcde477b5c405db5feac4a --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/context_menu/cupertino_context_menu.1_test.dart @@ -0,0 +1,26 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/cupertino/context_menu/cupertino_context_menu.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can open cupertino context menu', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ContextMenuApp(), + ); + + final Offset logo = tester.getCenter(find.byType(FlutterLogo)); + expect(find.text('Favorite'), findsNothing); + + await tester.startGesture(logo); + await tester.pumpAndSettle(); + expect(find.text('Favorite'), findsOneWidget); + + await tester.tap(find.text('Favorite')); + await tester.pumpAndSettle(); + expect(find.text('Favorite'), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/date_picker/cupertino_date_picker.0_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/date_picker/cupertino_date_picker.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..04b4bf2af921f418436389bd22666ce3dac667df --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/date_picker/cupertino_date_picker.0_test.dart @@ -0,0 +1,67 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_api_samples/cupertino/date_picker/cupertino_date_picker.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +const Offset _kRowOffset = Offset(0.0, -50.0); + +void main() { + testWidgets('Can change date, time and dateTime using CupertinoDatePicker', (WidgetTester tester) async { + await tester.pumpWidget( + const example.DatePickerApp(), + ); + // Open the date picker. + await tester.tap(find.text('10-26-2016')); + await tester.pumpAndSettle(); + + // Drag month, day and year wheels to change the picked date. + await tester.drag(find.text('October'), _kRowOffset, touchSlopY: 0, warnIfMissed: false); // see top of file + await tester.drag(find.textContaining('26').last, _kRowOffset, touchSlopY: 0, warnIfMissed: false); // see top of file + await tester.drag(find.text('2016'), _kRowOffset, touchSlopY: 0, warnIfMissed: false); // see top of file + + await tester.pump(); + await tester.pump(const Duration(milliseconds: 500)); + + // Close the date picker. + await tester.tapAt(const Offset(1.0, 1.0)); + await tester.pumpAndSettle(); + + expect(find.text('12-28-2018'), findsOneWidget); + + // Open the time picker. + await tester.tap(find.text('22:35')); + await tester.pumpAndSettle(); + + // Drag hour and minute wheels to change the picked time. + await tester.drag(find.text('22'), const Offset(0.0, 50.0), touchSlopY: 0, warnIfMissed: false); // see top of file + await tester.drag(find.text('35'), const Offset(0.0, 50.0), touchSlopY: 0, warnIfMissed: false); // see top of file + + await tester.pump(); + await tester.pump(const Duration(milliseconds: 500)); + + // Close the time picker. + await tester.tapAt(const Offset(1.0, 1.0)); + await tester.pumpAndSettle(); + + expect(find.text('20:33'), findsOneWidget); + + // Open the dateTime picker. + await tester.tap(find.text('8-3-2016 17:45')); + await tester.pumpAndSettle(); + + // Drag hour and minute wheels to change the picked time. + await tester.drag(find.text('17'), const Offset(0.0, 50.0), touchSlopY: 0, warnIfMissed: false); // see top of file + await tester.drag(find.text('45'), const Offset(0.0, 50.0), touchSlopY: 0, warnIfMissed: false); // see top of file + + await tester.pump(); + await tester.pump(const Duration(milliseconds: 500)); + + // Close the dateTime picker. + await tester.tapAt(const Offset(1.0, 1.0)); + await tester.pumpAndSettle(); + + expect(find.text('8-3-2016 15:43'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/date_picker/cupertino_timer_picker.0_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/date_picker/cupertino_timer_picker.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..8631467172d87141ee1744778d73e4fec005e2a9 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/date_picker/cupertino_timer_picker.0_test.dart @@ -0,0 +1,33 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_api_samples/cupertino/date_picker/cupertino_timer_picker.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +const Offset _kRowOffset = Offset(0.0, -50.0); + +void main() { + testWidgets('Can pick a duration from CupertinoTimerPicker', (WidgetTester tester) async { + await tester.pumpWidget( + const example.TimerPickerApp(), + ); + + // Launch the timer picker. + await tester.tap(find.text('1:23:00.000000')); + await tester.pumpAndSettle(); + + // Drag hour, minute to change the time. + await tester.drag(find.text('1'), _kRowOffset, touchSlopY: 0, warnIfMissed: false); // see top of file + await tester.drag(find.text('23'), _kRowOffset, touchSlopY: 0, warnIfMissed: false); // see top of file + + await tester.pump(); + await tester.pump(const Duration(milliseconds: 500)); + + // Close the timer picker. + await tester.tapAt(const Offset(1.0, 1.0)); + await tester.pumpAndSettle(); + + expect(find.text('3:25:00.000000'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/dialog/cupertino_action_sheet.0_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/dialog/cupertino_action_sheet.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..28162b9ad45424dcabb2ae0aab28ca648e6f7c05 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/dialog/cupertino_action_sheet.0_test.dart @@ -0,0 +1,27 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter_api_samples/cupertino/dialog/cupertino_action_sheet.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Perform an action on CupertinoActionSheet', (WidgetTester tester) async { + const String actionText = 'Destructive Action'; + await tester.pumpWidget( + const example.ActionSheetApp(), + ); + + // Launch the CupertinoActionSheet. + await tester.tap(find.byType(CupertinoButton)); + await tester.pump(); + await tester.pumpAndSettle(); + expect(find.text(actionText), findsOneWidget); + + // Tap on an action to close the CupertinoActionSheet. + await tester.tap(find.text(actionText)); + await tester.pumpAndSettle(); + expect(find.text(actionText), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/dialog/cupertino_alert_dialog.0_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/dialog/cupertino_alert_dialog.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..d9f554da45c75c67fdf12683323e7e36c6fa4fa7 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/dialog/cupertino_alert_dialog.0_test.dart @@ -0,0 +1,27 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter_api_samples/cupertino/dialog/cupertino_alert_dialog.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Perform an action on CupertinoAlertDialog', (WidgetTester tester) async { + const String actionText = 'Yes'; + await tester.pumpWidget( + const example.AlertDialogApp(), + ); + + // Launch the CupertinoAlertDialog. + await tester.tap(find.byType(CupertinoButton)); + await tester.pump(); + await tester.pumpAndSettle(); + expect(find.text(actionText), findsOneWidget); + + // Tap on an action to close the CupertinoAlertDialog. + await tester.tap(find.text(actionText)); + await tester.pumpAndSettle(); + expect(find.text(actionText), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/dialog/cupertino_popup_surface.0_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/dialog/cupertino_popup_surface.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..37b30f796ab56e919ee8acc3aa8ca32d5fb1cefe --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/dialog/cupertino_popup_surface.0_test.dart @@ -0,0 +1,70 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter_api_samples/cupertino/dialog/cupertino_popup_surface.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('CupertinoPopupSurface displays expected widgets in init state', + (WidgetTester tester) async { + await tester.pumpWidget(const example.PopupSurfaceApp()); + + final Finder cupertinoButton = find.byType(CupertinoButton); + expect(cupertinoButton, findsOneWidget); + + final Finder cupertinoSwitch = find.byType(CupertinoSwitch); + expect(cupertinoSwitch, findsOneWidget); + }); + + testWidgets('CupertinoPopupSurface is displayed with painted surface', + (WidgetTester tester) async { + await tester.pumpWidget(const example.PopupSurfaceApp()); + + // CupertinoSwitch is toggled on by default. + expect(tester.widget(find.byType(CupertinoSwitch)).value, isTrue); + + // Tap on the CupertinoButton to show the CupertinoPopupSurface. + await tester.tap(find.byType(CupertinoButton)); + await tester.pumpAndSettle(); + + // Make sure CupertinoPopupSurface is showing. + final Finder cupertinoPopupSurface = find.byType(CupertinoPopupSurface); + expect(cupertinoPopupSurface, findsOneWidget); + + // Confirm that CupertinoPopupSurface is painted with a ColoredBox. + final Finder coloredBox = find.descendant( + of: cupertinoPopupSurface, + matching: find.byType(ColoredBox), + ); + expect(coloredBox, findsOneWidget); + }); + + testWidgets('CupertinoPopupSurface is displayed without painted surface', + (WidgetTester tester) async { + await tester.pumpWidget(const example.PopupSurfaceApp()); + + // Toggling off CupertinoSwitch and confirm its state. + final Finder cupertinoSwitch = find.byType(CupertinoSwitch); + await tester.tap(cupertinoSwitch); + await tester.pumpAndSettle(); + expect(tester.widget(cupertinoSwitch).value, isFalse); + + // Tap on the CupertinoButton to show the CupertinoPopupSurface. + await tester.tap(find.byType(CupertinoButton)); + await tester.pumpAndSettle(); + + // Make sure CupertinoPopupSurface is showing. + final Finder cupertinoPopupSurface = find.byType(CupertinoPopupSurface); + expect(cupertinoPopupSurface, findsOneWidget); + + // Confirm that CupertinoPopupSurface is not painted with a ColoredBox. + final Finder coloredBox = find.descendant( + of: cupertinoPopupSurface, + matching: find.byType(ColoredBox), + ); + expect(coloredBox, findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/form_row/cupertino_form_row.0_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/form_row/cupertino_form_row.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..47bc894d4a3ade4a3243a7b982b04fb6bf043edc --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/form_row/cupertino_form_row.0_test.dart @@ -0,0 +1,23 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter_api_samples/cupertino/form_row/cupertino_form_row.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Cupertino form section displays cupertino form rows', (WidgetTester tester) async { + await tester.pumpWidget( + const example.CupertinoFormRowApp(), + ); + + expect(find.byType(CupertinoFormSection), findsOneWidget); + expect(find.byType(CupertinoFormRow), findsNWidgets(4)); + expect(find.widgetWithText(CupertinoFormSection, 'Connectivity'), findsOneWidget); + expect(find.widgetWithText(CupertinoFormRow, 'Airplane Mode'), findsOneWidget); + expect(find.widgetWithText(CupertinoFormRow, 'Wi-Fi'), findsOneWidget); + expect(find.widgetWithText(CupertinoFormRow, 'Bluetooth'), findsOneWidget); + expect(find.widgetWithText(CupertinoFormRow, 'Mobile Data'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/list_section/list_section_base.0_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/list_section/list_section_base.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..dc736329fd900373652f21ffbe01b3732a8403be --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/list_section/list_section_base.0_test.dart @@ -0,0 +1,29 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter_api_samples/cupertino/list_section/list_section_base.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Has exactly 1 CupertinoListSection base widget', (WidgetTester tester) async { + await tester.pumpWidget( + const example.CupertinoListSectionBaseApp(), + ); + + final Finder listSectionFinder = find.byType(CupertinoListSection); + expect(listSectionFinder, findsOneWidget); + + final CupertinoListSection listSectionWidget = tester.widget(listSectionFinder); + expect(listSectionWidget.type, equals(CupertinoListSectionType.base)); + }); + + testWidgets('CupertinoListSection has 3 CupertinoListTile children', (WidgetTester tester) async { + await tester.pumpWidget( + const example.CupertinoListSectionBaseApp(), + ); + + expect(find.byType(CupertinoListTile), findsNWidgets(3)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/list_section/list_section_inset.0_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/list_section/list_section_inset.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..7bdc4946d0a47415d70134adcf92f4b250bf7a3d --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/list_section/list_section_inset.0_test.dart @@ -0,0 +1,29 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter_api_samples/cupertino/list_section/list_section_inset.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Has exactly 1 CupertinoListSection inset grouped widget', (WidgetTester tester) async { + await tester.pumpWidget( + const example.CupertinoListSectionInsetApp(), + ); + + final Finder listSectionFinder = find.byType(CupertinoListSection); + expect(listSectionFinder, findsOneWidget); + + final CupertinoListSection listSectionWidget = tester.widget(listSectionFinder); + expect(listSectionWidget.type, equals(CupertinoListSectionType.insetGrouped)); + }); + + testWidgets('CupertinoListSection has 3 CupertinoListTile children', (WidgetTester tester) async { + await tester.pumpWidget( + const example.CupertinoListSectionInsetApp(), + ); + + expect(find.byType(CupertinoListTile), findsNWidgets(3)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/nav_bar/cupertino_navigation_bar.0_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/nav_bar/cupertino_navigation_bar.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..0b8dc1b2d33dbf219cb7a791ab54ae4d8e79c535 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/nav_bar/cupertino_navigation_bar.0_test.dart @@ -0,0 +1,20 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter_api_samples/cupertino/nav_bar/cupertino_navigation_bar.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('CupertinoNavigationBar is semi transparent', (WidgetTester tester) async { + await tester.pumpWidget( + const example.NavBarApp(), + ); + + final Finder navBarFinder = find.byType(CupertinoNavigationBar); + expect(navBarFinder, findsOneWidget); + final CupertinoNavigationBar cupertinoNavigationBar = tester.widget(navBarFinder); + expect(cupertinoNavigationBar.backgroundColor, CupertinoColors.systemGrey.withOpacity(0.5)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/nav_bar/cupertino_sliver_nav_bar.0_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/nav_bar/cupertino_sliver_nav_bar.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..208e76326ada38122bb6a86ab3766a42a82a8275 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/nav_bar/cupertino_sliver_nav_bar.0_test.dart @@ -0,0 +1,68 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter_api_samples/cupertino/nav_bar/cupertino_sliver_nav_bar.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +const Offset dragUp = Offset(0.0, -150.0); + +void main() { + testWidgets('Collapse and expand CupertinoSliverNavigationBar changes title position', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SliverNavBarApp(), + ); + + // Large title is visible and at lower position. + expect(tester.getBottomLeft(find.text('Contacts').first).dy, 88.0); + await tester.fling(find.text('Drag me up'), dragUp, 500.0); + await tester.pumpAndSettle(); + + // Large title is hidden and at higher position. + expect(tester.getBottomLeft(find.text('Contacts').first).dy, 36.0 + 8.0); // Static part + _kNavBarBottomPadding. + }); + + testWidgets('Middle widget is visible in both collapsed and expanded states', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SliverNavBarApp(), + ); + + // Navigate to a page that has both middle and large titles. + final Finder nextButton = find.text('Go to Next Page'); + expect(nextButton, findsOneWidget); + await tester.tap(nextButton); + await tester.pumpAndSettle(); + + // Both middle and large titles are visible. + expect(tester.getBottomLeft(find.text('Contacts Group').first).dy, 30.5); + expect(tester.getBottomLeft(find.text('Family').first).dy, 88.0); + + await tester.fling(find.text('Drag me up'), dragUp, 500.0); + await tester.pumpAndSettle(); + + // Large title is hidden and middle title is visible. + expect(tester.getBottomLeft(find.text('Contacts Group').first).dy, 30.5); + expect(tester.getBottomLeft(find.text('Family').first).dy, 36.0 + 8.0); // Static part + _kNavBarBottomPadding. + }); + + testWidgets('CupertinoSliverNavigationBar with previous route has back button', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SliverNavBarApp(), + ); + + // Navigate to a page that has back button + final Finder nextButton = find.text('Go to Next Page'); + expect(nextButton, findsOneWidget); + await tester.tap(nextButton); + await tester.pumpAndSettle(); + expect(nextButton, findsNothing); + + // Go back to the previous page. + final Finder backButton = find.byType(CupertinoButton); + expect(backButton, findsOneWidget); + await tester.tap(backButton); + await tester.pumpAndSettle(); + expect(nextButton, findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/page_scaffold/cupertino_page_scaffold.0_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/page_scaffold/cupertino_page_scaffold.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..44de060e8e32354a17cd45fa4a76f3a21e73f5e6 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/page_scaffold/cupertino_page_scaffold.0_test.dart @@ -0,0 +1,21 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter_api_samples/cupertino/page_scaffold/cupertino_page_scaffold.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can increment counter', (WidgetTester tester) async { + await tester.pumpWidget( + const example.PageScaffoldApp(), + ); + + expect(find.byType(CupertinoPageScaffold), findsOneWidget); + expect(find.text('You have pressed the button 0 times.'), findsOneWidget); + await tester.tap(find.byType(CupertinoButton)); + await tester.pumpAndSettle(); + expect(find.text('You have pressed the button 1 times.'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/picker/cupertino_picker.0_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/picker/cupertino_picker.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..178764ae7c4471d7378c73592bead71834756e60 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/picker/cupertino_picker.0_test.dart @@ -0,0 +1,43 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter_api_samples/cupertino/picker/cupertino_picker.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +const Offset _kRowOffset = Offset(0.0, -50.0); + +void main() { + testWidgets('Change selected fruit using CupertinoPicker', (WidgetTester tester) async { + await tester.pumpWidget( + const example.CupertinoPickerApp(), + ); + + // Open the Cupertino picker. + await tester.tap(find.widgetWithText(CupertinoButton, 'Apple')); + await tester.pumpAndSettle(); + + // Test the initial item. + CupertinoPicker picker = tester.widget(find.byType(CupertinoPicker)); + expect(picker.scrollController!.initialItem, 0); + + // Drag the wheel to change fruit selection. + await tester.drag(find.text('Mango'), _kRowOffset, touchSlopY: 0, warnIfMissed: false); // see top of file + await tester.pump(); + await tester.pump(const Duration(milliseconds: 500)); + + // Close the Cupertino picker. + await tester.tapAt(const Offset(1.0, 1.0)); + await tester.pumpAndSettle(); + + expect(find.widgetWithText(CupertinoButton, 'Banana'), findsOneWidget); + + // Test if the initial item has updated. + await tester.tap(find.widgetWithText(CupertinoButton, 'Banana')); + await tester.pumpAndSettle(); + + picker = tester.widget(find.byType(CupertinoPicker)); + expect(picker.scrollController!.initialItem, 2); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/radio/cupertino_radio.0_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/radio/cupertino_radio.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..a77059338efa951732a22ff05c67d3d5c64cf061 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/radio/cupertino_radio.0_test.dart @@ -0,0 +1,32 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter_api_samples/cupertino/radio/cupertino_radio.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Has 2 CupertinoRadio widgets', (WidgetTester tester) async { + await tester.pumpWidget( + const example.CupertinoRadioApp(), + ); + + expect(find.byType(CupertinoRadio), findsNWidgets(2)); + + CupertinoRadio radio = tester.widget(find.byType(CupertinoRadio).first); + expect(radio.groupValue, example.SingingCharacter.lafayette); + + radio = tester.widget(find.byType(CupertinoRadio).last); + expect(radio.groupValue, example.SingingCharacter.lafayette); + + await tester.tap(find.byType(CupertinoRadio).last); + await tester.pumpAndSettle(); + + radio = tester.widget(find.byType(CupertinoRadio).last); + expect(radio.groupValue, example.SingingCharacter.jefferson); + + radio = tester.widget(find.byType(CupertinoRadio).first); + expect(radio.groupValue, example.SingingCharacter.jefferson); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/radio/cupertino_radio.toggleable.0_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/radio/cupertino_radio.toggleable.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..3f434fc8e6352a5065e23bb461abd8a150910e96 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/radio/cupertino_radio.toggleable.0_test.dart @@ -0,0 +1,38 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter_api_samples/cupertino/radio/cupertino_radio.toggleable.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Has 2 CupertinoRadio widgets that can be toggled off', (WidgetTester tester) async { + await tester.pumpWidget( + const example.CupertinoRadioApp(), + ); + + expect(find.byType(CupertinoRadio), findsNWidgets(2)); + + CupertinoRadio radio = tester.widget(find.byType(CupertinoRadio).first); + expect(radio.groupValue, example.SingingCharacter.mulligan); + + radio = tester.widget(find.byType(CupertinoRadio).last); + expect(radio.groupValue, example.SingingCharacter.mulligan); + + await tester.tap(find.byType(CupertinoRadio).last); + await tester.pumpAndSettle(); + + radio = tester.widget(find.byType(CupertinoRadio).last); + expect(radio.groupValue, example.SingingCharacter.hamilton); + + radio = tester.widget(find.byType(CupertinoRadio).first); + expect(radio.groupValue, example.SingingCharacter.hamilton); + + await tester.tap(find.byType(CupertinoRadio).last); + await tester.pumpAndSettle(); + + radio = tester.widget(find.byType(CupertinoRadio).last); + expect(radio.groupValue, null); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/refresh/cupertino_sliver_refresh_control.0_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/refresh/cupertino_sliver_refresh_control.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..d230c34b09ddbe1df932293540ea409508146133 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/refresh/cupertino_sliver_refresh_control.0_test.dart @@ -0,0 +1,26 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter_api_samples/cupertino/refresh/cupertino_sliver_refresh_control.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can pull down to reveal CupertinoSliverRefreshControl', (WidgetTester tester) async { + await tester.pumpWidget( + const example.RefreshControlApp(), + ); + + expect(find.byType(CupertinoSliverRefreshControl), findsNothing); + expect(find.byType(Container), findsNWidgets(3)); + + final Finder firstItem = find.byType(Container).first; + await tester.drag(firstItem, const Offset(0.0, 150.0), touchSlopY: 0); + await tester.pump(); + expect(find.byType(CupertinoSliverRefreshControl), findsOneWidget); + await tester.pumpAndSettle(); + expect(find.byType(CupertinoSliverRefreshControl), findsNothing); + expect(find.byType(Container), findsNWidgets(4)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/route/show_cupertino_dialog.0_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/route/show_cupertino_dialog.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..4a7df9b7d40c2d14289c33faad9879f04b0bd007 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/route/show_cupertino_dialog.0_test.dart @@ -0,0 +1,26 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter_api_samples/cupertino/route/show_cupertino_dialog.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Tap on button displays cupertino dialog', (WidgetTester tester) async { + await tester.pumpWidget( + const example.CupertinoDialogApp(), + ); + + final Finder dialogTitle = find.text('Title'); + expect(dialogTitle, findsNothing); + + await tester.tap(find.byType(CupertinoButton)); + await tester.pumpAndSettle(); + expect(dialogTitle, findsOneWidget); + + await tester.tap(find.text('Yes')); + await tester.pumpAndSettle(); + expect(dialogTitle, findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/route/show_cupertino_modal_popup.0_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/route/show_cupertino_modal_popup.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..cb208ff3ccd1145b83ae036a64fce3eb87454b4c --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/route/show_cupertino_modal_popup.0_test.dart @@ -0,0 +1,26 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter_api_samples/cupertino/route/show_cupertino_modal_popup.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Tap on button displays cupertino modal dialog', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ModalPopupApp(), + ); + + final Finder actionOne = find.text('Action One'); + expect(actionOne, findsNothing); + + await tester.tap(find.byType(CupertinoButton)); + await tester.pumpAndSettle(); + expect(actionOne, findsOneWidget); + + await tester.tap(find.text('Action One')); + await tester.pumpAndSettle(); + expect(actionOne, findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/scrollbar/cupertino_scrollbar.0_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/scrollbar/cupertino_scrollbar.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..27161faca7c33796d827e6431e9e0729b5ba3eb9 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/scrollbar/cupertino_scrollbar.0_test.dart @@ -0,0 +1,26 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter_api_samples/cupertino/scrollbar/cupertino_scrollbar.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('List view displays CupertinoScrollbar', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ScrollbarApp(), + ); + + expect(find.text('Item 0'), findsOneWidget); + final TestGesture gesture = await tester.startGesture(tester.getCenter(find.byType(ListView))); + await gesture.moveBy(const Offset(0.0, -100.0)); + await tester.pumpAndSettle(); + expect(find.text('Item 0'), findsNothing); + + final Finder scrollbar = find.byType(CupertinoScrollbar); + expect(scrollbar, findsOneWidget); + expect(tester.getTopLeft(scrollbar).dy, 0.0); + expect(tester.getBottomLeft(scrollbar).dy, 600.0); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/scrollbar/cupertino_scrollbar.1_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/scrollbar/cupertino_scrollbar.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..e1bb02f4f50695ea0114f2b30626dff4958a831e --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/scrollbar/cupertino_scrollbar.1_test.dart @@ -0,0 +1,26 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter_api_samples/cupertino/scrollbar/cupertino_scrollbar.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('List view displays CupertinoScrollbar', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ScrollbarApp(), + ); + + expect(find.text('Item 0'), findsOneWidget); + final TestGesture gesture = await tester.startGesture(tester.getCenter(find.byType(ListView))); + await gesture.moveBy(const Offset(0.0, -100.0)); + await tester.pumpAndSettle(); + expect(find.text('Item 0'), findsNothing); + + final Finder scrollbar = find.byType(CupertinoScrollbar); + expect(scrollbar, findsOneWidget); + expect(tester.getTopLeft(scrollbar).dy, 0.0); + expect(tester.getBottomLeft(scrollbar).dy, 600.0); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/search_field/cupertino_search_field.0_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/search_field/cupertino_search_field.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..43c1ddbc02130ebf9fc8fb12647b41377fa14631 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/search_field/cupertino_search_field.0_test.dart @@ -0,0 +1,26 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter_api_samples/cupertino/search_field/cupertino_search_field.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('CupertinoTextField has initial text', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SearchTextFieldApp(), + ); + + expect(find.byType(CupertinoSearchTextField), findsOneWidget); + expect(find.text('initial text'), findsOneWidget); + + await tester.tap(find.byIcon(CupertinoIcons.xmark_circle_fill)); + await tester.pump(); + expect(find.text('initial text'), findsNothing); + + await tester.enterText(find.byType(CupertinoSearchTextField), 'photos'); + await tester.pump(); + expect(find.text('photos'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/search_field/cupertino_search_field.1_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/search_field/cupertino_search_field.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..09625d59b881b05e2b2044a4418bfb0099a02d4f --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/search_field/cupertino_search_field.1_test.dart @@ -0,0 +1,27 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter_api_samples/cupertino/search_field/cupertino_search_field.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Value changed callback updates entered text', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SearchTextFieldApp(), + ); + + expect(find.byType(CupertinoSearchTextField), findsOneWidget); + + await tester.enterText(find.byType(CupertinoSearchTextField), 'photos'); + await tester.pump(); + expect(find.text('The text has changed to: photos'), findsOneWidget); + + await tester.enterText(find.byType(CupertinoSearchTextField), 'photos from vacation'); + await tester.showKeyboard(find.byType(CupertinoTextField)); + await tester.testTextInput.receiveAction(TextInputAction.done); + await tester.pump(); + expect(find.text('Submitted text: photos from vacation'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/segmented_control/cupertino_segmented_control.0_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/segmented_control/cupertino_segmented_control.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..3eb15abb6fa6a763d129ae1454142bc981f80a84 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/segmented_control/cupertino_segmented_control.0_test.dart @@ -0,0 +1,21 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_api_samples/cupertino/segmented_control/cupertino_segmented_control.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can change a selected segmented control', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SegmentedControlApp(), + ); + + expect(find.text('Selected Segment: midnight'), findsOneWidget); + + await tester.tap(find.text('Cerulean')); + await tester.pumpAndSettle(); + + expect(find.text('Selected Segment: cerulean'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/segmented_control/cupertino_sliding_segmented_control.0_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/segmented_control/cupertino_sliding_segmented_control.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..bcc7efbc16000ccf4b2ed2531bec2667a803266a --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/segmented_control/cupertino_sliding_segmented_control.0_test.dart @@ -0,0 +1,19 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_api_samples/cupertino/segmented_control/cupertino_sliding_segmented_control.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can change a selected segmented control', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SegmentedControlApp(), + ); + + expect(find.text('Selected Segment: midnight'), findsOneWidget); + await tester.tap(find.text('Cerulean')); + await tester.pumpAndSettle(); + expect(find.text('Selected Segment: cerulean'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/slider/cupertino_slider.0_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/slider/cupertino_slider.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..d37a6c2cc2822543ff54e3651e22bb780c40d1bb --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/slider/cupertino_slider.0_test.dart @@ -0,0 +1,31 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter_api_samples/cupertino/slider/cupertino_slider.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + Future dragSlider(WidgetTester tester, Key sliderKey) { + final Offset topLeft = tester.getTopLeft(find.byKey(sliderKey)); + const double unit = CupertinoThumbPainter.radius; + const double delta = 3.0 * unit; + return tester.dragFrom(topLeft + const Offset(unit, unit), const Offset(delta, 0.0)); + } + + testWidgets('Can change value using CupertinoSlider', (WidgetTester tester) async { + await tester.pumpWidget( + const example.CupertinoSliderApp(), + ); + + // Check for the initial slider value. + expect(find.text('0.0'), findsOneWidget); + + await dragSlider(tester, const Key('slider')); + await tester.pumpAndSettle(); + + // Check for the updated slider value. + expect(find.text('40.0'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/switch/cupertino_switch.0_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/switch/cupertino_switch.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..ae0211d904d9629a1334d257982df7954dd6aef3 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/switch/cupertino_switch.0_test.dart @@ -0,0 +1,24 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter_api_samples/cupertino/switch/cupertino_switch.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Toggling cupertino switch updates icon', (WidgetTester tester) async { + await tester.pumpWidget( + const example.CupertinoSwitchApp(), + ); + + final Finder switchFinder = find.byType(CupertinoSwitch); + CupertinoSwitch cupertinoSwitch = tester.widget(switchFinder); + expect(cupertinoSwitch.value, true); + + await tester.tap(switchFinder); + await tester.pumpAndSettle(); + cupertinoSwitch = tester.widget(switchFinder); + expect(cupertinoSwitch.value, false); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/tab_scaffold/cupertino_tab_controller.0_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/tab_scaffold/cupertino_tab_controller.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..2cca405920f2ccb080488d1b4200554b5d87b204 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/tab_scaffold/cupertino_tab_controller.0_test.dart @@ -0,0 +1,24 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter_api_samples/cupertino/tab_scaffold/cupertino_tab_controller.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can switch tabs using CupertinoTabController', (WidgetTester tester) async { + await tester.pumpWidget( + const example.TabControllerApp(), + ); + + expect(find.text('Content of tab 0'), findsOneWidget); + await tester.tap(find.byIcon(CupertinoIcons.star_circle_fill)); + await tester.pumpAndSettle(); + expect(find.text('Content of tab 1'), findsOneWidget); + + await tester.tap(find.text('Go to first tab')); + await tester.pumpAndSettle(); + expect(find.text('Content of tab 0'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/tab_scaffold/cupertino_tab_scaffold.0_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/tab_scaffold/cupertino_tab_scaffold.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..8eb00a9f839f5346f0416250d862c3e476ef042a --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/tab_scaffold/cupertino_tab_scaffold.0_test.dart @@ -0,0 +1,27 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter_api_samples/cupertino/tab_scaffold/cupertino_tab_scaffold.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can use CupertinoTabView as the root widget', (WidgetTester tester) async { + await tester.pumpWidget( + const example.TabScaffoldApp(), + ); + + expect(find.text('Page 1 of tab 0'), findsOneWidget); + await tester.tap(find.byIcon(CupertinoIcons.search_circle_fill)); + await tester.pumpAndSettle(); + expect(find.text('Page 1 of tab 1'), findsOneWidget); + + await tester.tap(find.text('Next page')); + await tester.pumpAndSettle(); + expect(find.text('Page 2 of tab 1'), findsOneWidget); + await tester.tap(find.text('Back')); + await tester.pumpAndSettle(); + expect(find.text('Page 1 of tab 1'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/text_field/cupertino_text_field.0_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/text_field/cupertino_text_field.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..ae6f2db4de933209c1c0dc605aea98f6f1191f55 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/text_field/cupertino_text_field.0_test.dart @@ -0,0 +1,23 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter_api_samples/cupertino/text_field/cupertino_text_field.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('CupertinoTextField has initial text', (WidgetTester tester) async { + await tester.pumpWidget( + const example.CupertinoTextFieldApp(), + ); + + expect(find.byType(CupertinoTextField), findsOneWidget); + expect(find.text('initial text'), findsOneWidget); + + await tester.enterText(find.byType(CupertinoTextField), 'new text'); + await tester.pump(); + + expect(find.text('new text'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/cupertino/text_form_field_row/cupertino_text_form_field_row.1_test.dart b/novelforge-project/flutter/examples/api/test/cupertino/text_form_field_row/cupertino_text_form_field_row.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..63d42c9fb4ee85059794f93b732ea9d5388c1f4b --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/cupertino/text_form_field_row/cupertino_text_form_field_row.1_test.dart @@ -0,0 +1,24 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter_api_samples/cupertino/text_form_field_row/cupertino_text_form_field_row.1.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can enter text in CupertinoTextFormFieldRow', (WidgetTester tester) async { + await tester.pumpWidget( + const example.FormSectionApp(), + ); + + expect(find.byType(CupertinoFormSection), findsOneWidget); + expect(find.byType(CupertinoTextFormFieldRow), findsNWidgets(5)); + + expect(find.widgetWithText(CupertinoTextFormFieldRow, 'abcd'), findsNothing); + await tester.enterText(find.byType(CupertinoTextFormFieldRow).first, 'abcd'); + await tester.pump(); + expect(find.widgetWithText(CupertinoTextFormFieldRow, 'abcd'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/flutter_test_config.dart b/novelforge-project/flutter/examples/api/test/flutter_test_config.dart new file mode 100644 index 0000000000000000000000000000000000000000..69ad13655ba3f775e6cc67eafdcdf0bf9d50b3b1 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/flutter_test_config.dart @@ -0,0 +1,13 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; + + +import 'goldens_io.dart' if (dart.library.html) 'goldens_web.dart' as flutter_goldens; + +Future testExecutable(FutureOr Function() testMain) { + // Enable golden file testing using Skia Gold. + return flutter_goldens.testExecutable(testMain, namePrefix: 'api'); +} diff --git a/novelforge-project/flutter/examples/api/test/gestures/tap_and_drag/tap_and_drag.0_test.dart b/novelforge-project/flutter/examples/api/test/gestures/tap_and_drag/tap_and_drag.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..991d8ef49379540b9891f9601ebe821f9e59afd4 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/gestures/tap_and_drag/tap_and_drag.0_test.dart @@ -0,0 +1,88 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/gestures/tap_and_drag/tap_and_drag.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Single tap + drag should not change the scale of child', (WidgetTester tester) async { + await tester.pumpWidget( + const example.TapAndDragToZoomApp(), + ); + + double getScale() { + final RenderBox box = tester.renderObject(find.byType(Container).first); + return box.getTransformTo(null)[0]; + } + + final Finder containerFinder = find.byType(Container).first; + final Offset centerOfChild = tester.getCenter(containerFinder); + + expect(getScale(), 1.0); + + // Single tap + drag down. + final TestGesture gesture = await tester.startGesture(centerOfChild); + await tester.pump(); + await gesture.moveTo(centerOfChild + const Offset(0, 100.0)); + await tester.pump(); + expect(getScale(), 1.0); + + // Single tap + drag up. + await gesture.moveTo(centerOfChild); + await tester.pump(); + expect(getScale(), 1.0); + }); + + testWidgets('Double tap + drag should change the scale of the child', (WidgetTester tester) async { + await tester.pumpWidget( + const example.TapAndDragToZoomApp(), + ); + + double getScale() { + final RenderBox box = tester.renderObject(find.byType(Container).first); + return box.getTransformTo(null)[0]; + } + + final Finder containerFinder = find.byType(Container).first; + final Offset centerOfChild = tester.getCenter(containerFinder); + + expect(getScale(), 1.0); + + // Double tap + drag down to scale up. + final TestGesture gesture = await tester.startGesture(centerOfChild); + await tester.pump(); + await gesture.up(); + await tester.pump(); + + await gesture.down(centerOfChild); + await tester.pump(); + await gesture.moveTo(centerOfChild + const Offset(0, 100.0)); + await tester.pump(); + expect(getScale(), greaterThan(1.0)); + + // Scale is reset on drag end. + await gesture.up(); + await tester.pumpAndSettle(); + expect(getScale(), 1.0); + + // Double tap + drag up to scale down. + await gesture.down(centerOfChild); + await tester.pump(); + await gesture.up(); + await tester.pump(); + + await gesture.down(centerOfChild); + await tester.pump(); + await gesture.moveTo(centerOfChild + const Offset(0, -100.0)); + await tester.pump(); + expect(getScale(), lessThan(1.0)); + + // Scale is reset on drag end. + await gesture.up(); + await tester.pumpAndSettle(); + expect(getScale(), 1.0); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/goldens_io.dart b/novelforge-project/flutter/examples/api/test/goldens_io.dart new file mode 100644 index 0000000000000000000000000000000000000000..d552235d6903e5b4037732ba4aea8c0e5055da50 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/goldens_io.dart @@ -0,0 +1,5 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +export 'package:flutter_goldens/flutter_goldens.dart' show testExecutable; diff --git a/novelforge-project/flutter/examples/api/test/goldens_web.dart b/novelforge-project/flutter/examples/api/test/goldens_web.dart new file mode 100644 index 0000000000000000000000000000000000000000..57c0fbad759ff0e863cf47d6ee4827aaec4277e4 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/goldens_web.dart @@ -0,0 +1,8 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; + +// package:flutter_goldens is not used as part of the test process for web. +Future testExecutable(FutureOr Function() testMain) async => testMain(); diff --git a/novelforge-project/flutter/examples/api/test/material/about/about_list_tile.0_test.dart b/novelforge-project/flutter/examples/api/test/material/about/about_list_tile.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..389a6d2dfd6c23bf355a446cb3f80c560f9978a9 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/about/about_list_tile.0_test.dart @@ -0,0 +1,67 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/about/about_list_tile.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('It should show the about dialog after clicking on the button', (WidgetTester tester) async { + await tester.pumpWidget(const example.AboutListTileExampleApp()); + + expect(find.widgetWithText(AppBar, 'Show About Example'), findsOne); + + await tester.tap(find.widgetWithText(ElevatedButton, 'Show About Example')); + await tester.pumpAndSettle(); + + expect(find.byType(AboutDialog), findsOne); + expect(find.widgetWithText(AboutDialog, 'Show About Example'), findsOne); + expect(find.text('August 2019'), findsOne); + expect(find.byType(FlutterLogo), findsOne); + expect(find.text('\u{a9} 2014 The Flutter Authors'), findsOne); + expect( + find.text( + "Flutter is Google's UI toolkit for building beautiful, " + 'natively compiled applications for mobile, web, and desktop ' + 'from a single codebase. Learn more about Flutter at ' + 'https://flutter.dev.', + findRichText: true, + ), + findsOne, + ); + }); + + testWidgets('It should show the about dialog after clicking on about list tile in the drawer', (WidgetTester tester) async { + await tester.pumpWidget(const example.AboutListTileExampleApp()); + + expect(find.widgetWithText(AppBar, 'Show About Example'), findsOne); + + await tester.tap(find.byType(DrawerButton)); + await tester.pumpAndSettle(); + + expect(find.byType(Drawer), findsOne); + expect(find.widgetWithText(AboutListTile, 'About Show About Example'), findsOne); + expect(find.widgetWithIcon(AboutListTile, Icons.info), findsOne); + + await tester.tap(find.widgetWithIcon(AboutListTile, Icons.info)); + await tester.pumpAndSettle(); + + expect(find.byType(AboutDialog), findsOne); + expect(find.widgetWithText(AboutDialog, 'Show About Example'), findsOne); + expect(find.text('August 2019'), findsOne); + expect(find.byType(FlutterLogo), findsOne); + expect(find.text('\u{a9} 2014 The Flutter Authors'), findsOne); + expect( + find.text( + "Flutter is Google's UI toolkit for building beautiful, " + 'natively compiled applications for mobile, web, and desktop ' + 'from a single codebase. Learn more about Flutter at ' + 'https://flutter.dev.', + findRichText: true, + ), + findsOne, + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/action_buttons/action_icon_theme.0_test.dart b/novelforge-project/flutter/examples/api/test/material/action_buttons/action_icon_theme.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..a8cedc30026e559533edb937abbccc7038d30523 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/action_buttons/action_icon_theme.0_test.dart @@ -0,0 +1,51 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/action_buttons/action_icon_theme.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Action Icon Buttons', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: Scaffold( + body: example.ActionIconThemeExampleApp(), + ), + ), + ); + + + expect(find.byType(DrawerButton), findsOneWidget); + final Icon drawerButtonIcon = tester.widget( + find.descendant( + of: find.byType(DrawerButton), + matching: find.byType(Icon), + ), + ); + expect(drawerButtonIcon.icon, Icons.segment); + + // open next page + await tester.tap(find.byType(example.NextPageButton)); + await tester.pumpAndSettle(); + + expect(find.byType(EndDrawerButton), findsOneWidget); + final Icon endDrawerButtonIcon = tester.widget( + find.descendant( + of: find.byType(EndDrawerButton), + matching: find.byType(Icon), + ), + ); + expect(endDrawerButtonIcon.icon, Icons.more_horiz); + + expect(find.byType(BackButton), findsOneWidget); + final Icon backButtonIcon = tester.widget( + find.descendant( + of: find.byType(BackButton), + matching: find.byType(Icon), + ), + ); + expect(backButtonIcon.icon, Icons.arrow_back_ios_new_rounded); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/action_chip/action_chip.0_test.dart b/novelforge-project/flutter/examples/api/test/material/action_chip/action_chip.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..939db75ec4e6e5a34ca4cdff15cc996988fb7687 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/action_chip/action_chip.0_test.dart @@ -0,0 +1,22 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/action_chip/action_chip.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('ActionChip updates avatar when tapped', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ChipApp(), + ); + + expect(find.byIcon(Icons.favorite_border), findsOneWidget); + + await tester.tap(find.byType(ActionChip)); + await tester.pumpAndSettle(); + + expect(find.byIcon(Icons.favorite), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/animated_icon/animated_icon.0_test.dart b/novelforge-project/flutter/examples/api/test/material/animated_icon/animated_icon.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..d0a8a75e54777c2bfe558a7050221780f157a1dc --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/animated_icon/animated_icon.0_test.dart @@ -0,0 +1,31 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/animated_icon/animated_icon.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('AnimatedIcon animates', (WidgetTester tester) async { + await tester.pumpWidget( + const example.AnimatedIconApp(), + ); + + // Test the AnimatedIcon size. + final Size iconSize = tester.getSize(find.byType(AnimatedIcon)); + expect(iconSize.width, 72.0); + expect(iconSize.height, 72.0); + + // Check if AnimatedIcon is animating. + await tester.pump(const Duration(milliseconds: 500)); + AnimatedIcon animatedIcon = tester.widget(find.byType(AnimatedIcon)); + expect(animatedIcon.progress.value, 0.25); + + // Check if animation is completed. + await tester.pump(const Duration(milliseconds: 1500)); + animatedIcon = tester.widget(find.byType(AnimatedIcon)); + expect(animatedIcon.progress.value, 1.0); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/animated_icon/animated_icons_data.0_test.dart b/novelforge-project/flutter/examples/api/test/material/animated_icon/animated_icons_data.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..8b54373a2d60cd47387242baa379b08d7d3dbd37 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/animated_icon/animated_icons_data.0_test.dart @@ -0,0 +1,34 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/animated_icon/animated_icons_data.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Show all the animated icons', (WidgetTester tester) async { + await tester.pumpWidget( + const example.AnimatedIconApp(), + ); + + // Check if the total number of AnimatedIcons matches the icons list. + expect(find.byType(AnimatedIcon, skipOffstage: false), findsNWidgets(example.iconsList.length)); + + // Test the AnimatedIcon size. + final Size iconSize = tester.getSize(find.byType(AnimatedIcon).first); + expect(iconSize.width, 72.0); + expect(iconSize.height, 72.0); + + // Check if AnimatedIcon is animating. + await tester.pump(const Duration(milliseconds: 500)); + AnimatedIcon animatedIcon = tester.widget(find.byType(AnimatedIcon).first); + expect(animatedIcon.progress.value, 0.25); + + // Check if animation is completed. + await tester.pump(const Duration(milliseconds: 1500)); + animatedIcon = tester.widget(find.byType(AnimatedIcon).first); + expect(animatedIcon.progress.value, 1.0); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/app/app.0_test.dart b/novelforge-project/flutter/examples/api/test/material/app/app.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..007b95683fb44ed459ee0b78ff24960d603cfb8c --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/app/app.0_test.dart @@ -0,0 +1,76 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/app/app.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Theme animation can be customized using AnimationStyle', (WidgetTester tester) async { + await tester.pumpWidget( + const example.MaterialAppExample(), + ); + + Material getScaffoldMaterial() { + return tester.widget(find.descendant( + of: find.byType(Scaffold), + matching: find.byType(Material).first, + )); + } + + final ThemeData lightTheme = ThemeData(colorSchemeSeed: Colors.green); + final ThemeData darkTheme = ThemeData( + colorSchemeSeed: Colors.green, + brightness: Brightness.dark, + ); + + // Test the default animation. + expect(getScaffoldMaterial().color, lightTheme.colorScheme.background); + + await tester.tap(find.text( 'Switch Theme Mode')); + await tester.pump(); + // Advance the animation by half of the default duration. + await tester.pump(const Duration(milliseconds: 100)); + + // The Scaffold background color is updated. + expect( + getScaffoldMaterial().color, + Color.lerp(lightTheme.colorScheme.background, darkTheme.colorScheme.background, 0.5), + ); + + await tester.pumpAndSettle(); + + // The Scaffold background color is now fully dark. + expect(getScaffoldMaterial().color, darkTheme.colorScheme.background); + + // Test the custom animation curve and duration. + await tester.tap(find.text('Custom')); + await tester.pumpAndSettle(); + + await tester.tap(find.text('Switch Theme Mode')); + await tester.pump(); + // Advance the animation by half of the custom duration. + await tester.pump(const Duration(milliseconds: 500)); + + // The Scaffold background color is updated. + expect(getScaffoldMaterial().color, const Color(0xff3c3e3b)); + + await tester.pumpAndSettle(); + + // The Scaffold background color is now fully light. + expect(getScaffoldMaterial().color, lightTheme.colorScheme.background); + + // Test the no animation style. + await tester.tap(find.text('None')); + await tester.pumpAndSettle(); + + await tester.tap(find.text('Switch Theme Mode')); + // Advance the animation by only one frame. + await tester.pump(); + + // The Scaffold background color is updated immediately. + expect(getScaffoldMaterial().color, darkTheme.colorScheme.background); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/app_bar/app_bar.0_test.dart b/novelforge-project/flutter/examples/api/test/material/app_bar/app_bar.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..b131b297f7cbff797fd1585f87789118133b9239 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/app_bar/app_bar.0_test.dart @@ -0,0 +1,24 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/app_bar/app_bar.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Appbar updates on navigation', (WidgetTester tester) async { + await tester.pumpWidget( + const example.AppBarApp(), + ); + + expect(find.widgetWithText(AppBar, 'AppBar Demo'), findsOneWidget); + expect(find.text('This is the home page'), findsOneWidget); + + await tester.tap(find.byIcon(Icons.navigate_next)); + await tester.pumpAndSettle(); + + expect(find.widgetWithText(AppBar, 'Next page'), findsOneWidget); + expect(find.text('This is the next page'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/app_bar/app_bar.1_test.dart b/novelforge-project/flutter/examples/api/test/material/app_bar/app_bar.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..180605347f3607857d7d0dc5e75d1adc453df800 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/app_bar/app_bar.1_test.dart @@ -0,0 +1,55 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/app_bar/app_bar.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +const Offset _kOffset = Offset(0.0, -100.0); + +void main() { + testWidgets('Appbar Material 3 test', (WidgetTester tester) async { + await tester.pumpWidget( + const example.AppBarApp() + ); + + expect(find.widgetWithText(AppBar, 'AppBar Demo'), findsOneWidget); + Material appbarMaterial = _getAppBarMaterial(tester); + expect(appbarMaterial.shadowColor, Colors.transparent); + expect(appbarMaterial.elevation, 0); + + await tester.drag(find.text('Item 4'), _kOffset, touchSlopY: 0, warnIfMissed: false); + + await tester.pump(); + await tester.pump(const Duration(milliseconds: 500)); + + await tester.tap(find.text('shadow color')); + await tester.pumpAndSettle(); + appbarMaterial = _getAppBarMaterial(tester); + expect(appbarMaterial.shadowColor, Colors.black); + expect(appbarMaterial.elevation, 3.0); + + await tester.tap(find.text('scrolledUnderElevation: default')); + await tester.pumpAndSettle(); + + appbarMaterial = _getAppBarMaterial(tester); + expect(appbarMaterial.shadowColor, Colors.black); + expect(appbarMaterial.elevation, 4.0); + + await tester.tap(find.text('scrolledUnderElevation: 4.0')); + await tester.pumpAndSettle(); + appbarMaterial = _getAppBarMaterial(tester); + expect(appbarMaterial.shadowColor, Colors.black); + expect(appbarMaterial.elevation, 5.0); + }); +} + +Material _getAppBarMaterial(WidgetTester tester) { + return tester.widget( + find.descendant( + of: find.byType(AppBar), + matching: find.byType(Material), + ), + ); +} diff --git a/novelforge-project/flutter/examples/api/test/material/app_bar/app_bar.2_test.dart b/novelforge-project/flutter/examples/api/test/material/app_bar/app_bar.2_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..b064e95435c44cdc0a87ccaa1629e907a893ecfb --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/app_bar/app_bar.2_test.dart @@ -0,0 +1,19 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/app_bar/app_bar.2.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Appbar and actions', (WidgetTester tester) async { + await tester.pumpWidget( + const example.AppBarApp(), + ); + + expect(find.byType(AppBar), findsOneWidget); + expect(find.widgetWithText(TextButton, 'Action 1'), findsOneWidget); + expect(find.widgetWithText(TextButton, 'Action 2'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/app_bar/app_bar.3_test.dart b/novelforge-project/flutter/examples/api/test/material/app_bar/app_bar.3_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..b8fb9b570fa4cfc5c2d7e5e00e0245fdb2e949d3 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/app_bar/app_bar.3_test.dart @@ -0,0 +1,31 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/app_bar/app_bar.3.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets( + 'AppBar elevates when nested scroll view is scrolled underneath the AppBar', + (WidgetTester tester) async { + Material getMaterial() => tester.widget(find.descendant( + of: find.byType(AppBar), + matching: find.byType(Material), + )); + + await tester.pumpWidget( + const example.AppBarApp(), + ); + + // Starts with the base elevation. + expect(getMaterial().elevation, 0.0); + + await tester.fling(find.text('Beach 3'), const Offset(0.0, -600.0), 2000.0); + await tester.pumpAndSettle(); + + // After scrolling it should be the scrolledUnderElevation. + expect(getMaterial().elevation, 4.0); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/app_bar/app_bar.4_test.dart b/novelforge-project/flutter/examples/api/test/material/app_bar/app_bar.4_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..f1f8e530f1ea86b23a03e51451eeebbeb1fbfb3d --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/app_bar/app_bar.4_test.dart @@ -0,0 +1,34 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/app_bar/app_bar.4.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('AppBar uses custom shape', (WidgetTester tester) async { + await tester.pumpWidget( + const example.AppBarExampleApp(), + ); + + Material getMaterial() => tester.widget(find.descendant( + of: find.byType(AppBar), + matching: find.byType(Material), + )); + expect(getMaterial().shape, const example.CustomAppBarShape()); + }); + + testWidgets('AppBar bottom contains TextField', (WidgetTester tester) async { + await tester.pumpWidget( + const example.AppBarExampleApp(), + ); + + final Finder textFieldFinder = find.descendant( + of: find.byType(AppBar), + matching: find.byType(TextField), + ); + + expect(textFieldFinder, findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/app_bar/sliver_app_bar.1_test.dart b/novelforge-project/flutter/examples/api/test/material/app_bar/sliver_app_bar.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..5a7cb784a8b7ec7de41744502f62718076c0ae46 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/app_bar/sliver_app_bar.1_test.dart @@ -0,0 +1,25 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/app_bar/sliver_app_bar.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +const Offset _kOffset = Offset(0.0, -200.0); + +void main() { + testWidgets('SliverAppbar can be pinned', (WidgetTester tester) async { + await tester.pumpWidget( + const example.AppBarApp(), + ); + + expect(find.widgetWithText(SliverAppBar, 'SliverAppBar'), findsOneWidget); + expect(tester.getBottomLeft(find.text('SliverAppBar')).dy, 144.0); + + await tester.drag(find.text('0'), _kOffset, touchSlopY: 0, warnIfMissed: false); + await tester.pump(); + await tester.pump(const Duration(milliseconds: 500)); + expect(tester.getBottomLeft(find.text('SliverAppBar')).dy, 40.0); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/app_bar/sliver_app_bar.4_test.dart b/novelforge-project/flutter/examples/api/test/material/app_bar/sliver_app_bar.4_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..35fe792ce4bbdd830c50ac3492896c1241203089 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/app_bar/sliver_app_bar.4_test.dart @@ -0,0 +1,46 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/app_bar/sliver_app_bar.4.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +const Offset _kOffset = Offset(0.0, 200.0); + +void main() { + testWidgets('SliverAppbar can be stretched', (WidgetTester tester) async { + await tester.pumpWidget( + const example.StretchableSliverAppBar(), + ); + + final Finder switchFinder = find.byType(Switch); + Switch materialSwitch = tester.widget(switchFinder); + expect(materialSwitch.value, true); + + expect(find.widgetWithText(SliverAppBar, 'SliverAppBar'), findsOneWidget); + expect(tester.getBottomLeft(find.text('SliverAppBar')).dy, 184.0); + + await tester.drag(find.text('0'), _kOffset, + touchSlopY: 0, warnIfMissed: false); + await tester.pump(); + await tester.pump(const Duration(milliseconds: 500)); + expect(find.widgetWithText(SliverAppBar, 'SliverAppBar'), findsOneWidget); + expect( + tester.getBottomLeft(find.text('SliverAppBar')).dy, 187.63506380825314); + + await tester.tap(switchFinder); + await tester.pumpAndSettle(); + materialSwitch = tester.widget(switchFinder); + expect(materialSwitch.value, false); + + await tester.drag(find.text('0'), _kOffset, + touchSlopY: 0, warnIfMissed: false); + await tester.pump(); + await tester.pump(const Duration(milliseconds: 500)); + + expect(find.text('SliverAppBar'), findsOneWidget); + expect(tester.getBottomLeft(find.text('SliverAppBar')).dy, 184.0); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/autocomplete/autocomplete.0_test.dart b/novelforge-project/flutter/examples/api/test/material/autocomplete/autocomplete.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..70d12aecc7bd53cf62c1732d4cb42c2547dbcff2 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/autocomplete/autocomplete.0_test.dart @@ -0,0 +1,31 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/autocomplete/autocomplete.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('can search and find options', (WidgetTester tester) async { + await tester.pumpWidget(const example.AutocompleteExampleApp()); + + expect(find.text('aardvark'), findsNothing); + expect(find.text('bobcat'), findsNothing); + expect(find.text('chameleon'), findsNothing); + + await tester.enterText(find.byType(TextFormField), 'a'); + await tester.pump(); + + expect(find.text('aardvark'), findsOneWidget); + expect(find.text('bobcat'), findsOneWidget); + expect(find.text('chameleon'), findsOneWidget); + + await tester.enterText(find.byType(TextFormField), 'aa'); + await tester.pump(); + + expect(find.text('aardvark'), findsOneWidget); + expect(find.text('bobcat'), findsNothing); + expect(find.text('chameleon'), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/autocomplete/autocomplete.1_test.dart b/novelforge-project/flutter/examples/api/test/material/autocomplete/autocomplete.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..9dc0510ec6d34202217fa19b23e6c8dafa22103e --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/autocomplete/autocomplete.1_test.dart @@ -0,0 +1,31 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/autocomplete/autocomplete.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('can search and find options by email and name', (WidgetTester tester) async { + await tester.pumpWidget(const example.AutocompleteExampleApp()); + + expect(find.text('Alice'), findsNothing); + expect(find.text('Bob'), findsNothing); + expect(find.text('Charlie'), findsNothing); + + await tester.enterText(find.byType(TextFormField), 'Ali'); + await tester.pump(); + + expect(find.text('Alice'), findsOneWidget); + expect(find.text('Bob'), findsNothing); + expect(find.text('Charlie'), findsNothing); + + await tester.enterText(find.byType(TextFormField), 'gmail'); + await tester.pump(); + + expect(find.text('Alice'), findsNothing); + expect(find.text('Bob'), findsNothing); + expect(find.text('Charlie'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/autocomplete/autocomplete.2_test.dart b/novelforge-project/flutter/examples/api/test/material/autocomplete/autocomplete.2_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..0ee047af7d74637b8ad42e98d128c4aa974c27cd --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/autocomplete/autocomplete.2_test.dart @@ -0,0 +1,31 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/autocomplete/autocomplete.2.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('can search and find options after waiting for fake network delay', (WidgetTester tester) async { + await tester.pumpWidget(const example.AutocompleteExampleApp()); + + expect(find.text('aardvark'), findsNothing); + expect(find.text('bobcat'), findsNothing); + expect(find.text('chameleon'), findsNothing); + + await tester.enterText(find.byType(TextFormField), 'a'); + await tester.pump(example.fakeAPIDuration); + + expect(find.text('aardvark'), findsOneWidget); + expect(find.text('bobcat'), findsOneWidget); + expect(find.text('chameleon'), findsOneWidget); + + await tester.enterText(find.byType(TextFormField), 'aa'); + await tester.pump(example.fakeAPIDuration); + + expect(find.text('aardvark'), findsOneWidget); + expect(find.text('bobcat'), findsNothing); + expect(find.text('chameleon'), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/autocomplete/autocomplete.3_test.dart b/novelforge-project/flutter/examples/api/test/material/autocomplete/autocomplete.3_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..00e5df1afc6d71b4e63ff03b31a7b6057d0d9adb --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/autocomplete/autocomplete.3_test.dart @@ -0,0 +1,113 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/autocomplete/autocomplete.3.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('can search and find options after waiting for fake network delay and debounce delay', (WidgetTester tester) async { + await tester.pumpWidget(const example.AutocompleteExampleApp()); + + expect(find.text('aardvark'), findsNothing); + expect(find.text('bobcat'), findsNothing); + expect(find.text('chameleon'), findsNothing); + + await tester.enterText(find.byType(TextFormField), 'a'); + await tester.pump(example.fakeAPIDuration); + + // No results yet, need to also wait for the debounce duration. + expect(find.text('aardvark'), findsNothing); + expect(find.text('bobcat'), findsNothing); + expect(find.text('chameleon'), findsNothing); + + await tester.pump(example.debounceDuration); + + expect(find.text('aardvark'), findsOneWidget); + expect(find.text('bobcat'), findsOneWidget); + expect(find.text('chameleon'), findsOneWidget); + + await tester.enterText(find.byType(TextFormField), 'aa'); + await tester.pump(example.debounceDuration + example.fakeAPIDuration); + + expect(find.text('aardvark'), findsOneWidget); + expect(find.text('bobcat'), findsNothing); + expect(find.text('chameleon'), findsNothing); + }); + + testWidgets('debounce is reset each time a character is entered', (WidgetTester tester) async { + await tester.pumpWidget(const example.AutocompleteExampleApp()); + + await tester.enterText(find.byType(TextFormField), 'c'); + await tester.pump(example.debounceDuration - const Duration(milliseconds: 100)); + + expect(find.text('aardvark'), findsNothing); + expect(find.text('bobcat'), findsNothing); + expect(find.text('chameleon'), findsNothing); + + await tester.enterText(find.byType(TextFormField), 'ch'); + await tester.pump(example.debounceDuration - const Duration(milliseconds: 100)); + + expect(find.text('aardvark'), findsNothing); + expect(find.text('bobcat'), findsNothing); + expect(find.text('chameleon'), findsNothing); + + await tester.enterText(find.byType(TextFormField), 'cha'); + await tester.pump(example.debounceDuration - const Duration(milliseconds: 100)); + + expect(find.text('aardvark'), findsNothing); + expect(find.text('bobcat'), findsNothing); + expect(find.text('chameleon'), findsNothing); + + await tester.enterText(find.byType(TextFormField), 'cham'); + await tester.pump(example.debounceDuration - const Duration(milliseconds: 100)); + + // Despite the total elapsed time being greater than debounceDuration + + // fakeAPIDuration, the search has not yet completed, because the debounce + // was reset each time text input happened. + expect(find.text('aardvark'), findsNothing); + expect(find.text('bobcat'), findsNothing); + expect(find.text('chameleon'), findsNothing); + + await tester.enterText(find.byType(TextFormField), 'chame'); + await tester.pump(example.debounceDuration + example.fakeAPIDuration); + + expect(find.text('aardvark'), findsNothing); + expect(find.text('bobcat'), findsNothing); + expect(find.text('chameleon'), findsOneWidget); + }); + + testWidgets('multiple pending requests', (WidgetTester tester) async { + await tester.pumpWidget(const example.AutocompleteExampleApp()); + + await tester.enterText(find.byType(TextFormField), 'a'); + + // Wait until the debounce duration has expired, but the request is still + // pending. + await tester.pump(example.debounceDuration); + + expect(find.text('aardvark'), findsNothing); + expect(find.text('bobcat'), findsNothing); + expect(find.text('chameleon'), findsNothing); + + await tester.enterText(find.byType(TextFormField), 'aa'); + + // Wait until the first request has completed. + await tester.pump(example.fakeAPIDuration - example.debounceDuration); + + // The results from the first request are thrown away since the query has + // changed. + expect(find.text('aardvark'), findsNothing); + expect(find.text('bobcat'), findsNothing); + expect(find.text('chameleon'), findsNothing); + + // Wait until the second request has completed. + await tester.pump(example.fakeAPIDuration); + + // The results of the second request are reflected. + expect(find.text('aardvark'), findsOneWidget); + expect(find.text('bobcat'), findsNothing); + expect(find.text('chameleon'), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/autocomplete/autocomplete.4_test.dart b/novelforge-project/flutter/examples/api/test/material/autocomplete/autocomplete.4_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..12b1154fd696a2abb0bff8507151e7c6f16d7fd9 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/autocomplete/autocomplete.4_test.dart @@ -0,0 +1,119 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/autocomplete/autocomplete.4.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('can search and find options after waiting for fake network delay and debounce delay', (WidgetTester tester) async { + await tester.pumpWidget(const example.AutocompleteExampleApp()); + + expect(find.text('aardvark'), findsNothing); + expect(find.text('bobcat'), findsNothing); + expect(find.text('chameleon'), findsNothing); + + await tester.enterText(find.byType(TextFormField), 'a'); + await tester.pump(example.fakeAPIDuration); + + // No results yet, need to also wait for the debounce duration. + expect(find.text('aardvark'), findsNothing); + expect(find.text('bobcat'), findsNothing); + expect(find.text('chameleon'), findsNothing); + + await tester.pump(example.debounceDuration); + + expect(find.text('aardvark'), findsOneWidget); + expect(find.text('bobcat'), findsOneWidget); + expect(find.text('chameleon'), findsOneWidget); + + await tester.enterText(find.byType(TextFormField), 'aa'); + await tester.pump(example.debounceDuration + example.fakeAPIDuration); + + expect(find.text('aardvark'), findsOneWidget); + expect(find.text('bobcat'), findsNothing); + expect(find.text('chameleon'), findsNothing); + }); + + testWidgets('debounce is reset each time a character is entered', (WidgetTester tester) async { + await tester.pumpWidget(const example.AutocompleteExampleApp()); + + await tester.enterText(find.byType(TextFormField), 'c'); + await tester.pump(example.debounceDuration - const Duration(milliseconds: 100)); + + expect(find.text('aardvark'), findsNothing); + expect(find.text('bobcat'), findsNothing); + expect(find.text('chameleon'), findsNothing); + + await tester.enterText(find.byType(TextFormField), 'ch'); + await tester.pump(example.debounceDuration - const Duration(milliseconds: 100)); + + expect(find.text('aardvark'), findsNothing); + expect(find.text('bobcat'), findsNothing); + expect(find.text('chameleon'), findsNothing); + + await tester.enterText(find.byType(TextFormField), 'cha'); + await tester.pump(example.debounceDuration - const Duration(milliseconds: 100)); + + expect(find.text('aardvark'), findsNothing); + expect(find.text('bobcat'), findsNothing); + expect(find.text('chameleon'), findsNothing); + + await tester.enterText(find.byType(TextFormField), 'cham'); + await tester.pump(example.debounceDuration - const Duration(milliseconds: 100)); + + // Despite the total elapsed time being greater than debounceDuration + + // fakeAPIDuration, the search has not yet completed, because the debounce + // was reset each time text input happened. + expect(find.text('aardvark'), findsNothing); + expect(find.text('bobcat'), findsNothing); + expect(find.text('chameleon'), findsNothing); + + await tester.enterText(find.byType(TextFormField), 'chame'); + await tester.pump(example.debounceDuration + example.fakeAPIDuration); + + expect(find.text('aardvark'), findsNothing); + expect(find.text('bobcat'), findsNothing); + expect(find.text('chameleon'), findsOneWidget); + }); + + testWidgets('shows an error message for network errors', (WidgetTester tester) async { + await tester.pumpWidget(const example.AutocompleteExampleApp()); + + await tester.enterText(find.byType(TextFormField), 'chame'); + await tester.pump(example.debounceDuration + example.fakeAPIDuration); + + expect(find.text('aardvark'), findsNothing); + expect(find.text('bobcat'), findsNothing); + expect(find.text('chameleon'), findsOneWidget); + InputDecorator inputDecorator = tester.widget(find.byType(InputDecorator)); + expect(inputDecorator.decoration.errorText, isNull); + + // Turn the network off. + await tester.tap(find.byType(Switch)); + await tester.pump(); + + await tester.enterText(find.byType(TextFormField), 'chamel'); + await tester.pump(example.debounceDuration + example.fakeAPIDuration); + + expect(find.text('aardvark'), findsNothing); + expect(find.text('bobcat'), findsNothing); + expect(find.text('chameleon'), findsNothing); + inputDecorator = tester.widget(find.byType(InputDecorator)); + expect(inputDecorator.decoration.errorText, isNotNull); + + // Turn the network back on. + await tester.tap(find.byType(Switch)); + await tester.pump(); + + await tester.enterText(find.byType(TextFormField), 'chamele'); + await tester.pump(example.debounceDuration + example.fakeAPIDuration); + + expect(find.text('aardvark'), findsNothing); + expect(find.text('bobcat'), findsNothing); + expect(find.text('chameleon'), findsOneWidget); + inputDecorator = tester.widget(find.byType(InputDecorator)); + expect(inputDecorator.decoration.errorText, isNull); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/badge/badge.0_test.dart b/novelforge-project/flutter/examples/api/test/material/badge/badge.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..f91ed9d62760c8e60105e3f407a5356927ae8f7f --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/badge/badge.0_test.dart @@ -0,0 +1,23 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/badge/badge.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Verify Badges have label and count', (WidgetTester tester) async { + await tester.pumpWidget( + const example.BadgeExampleApp(), + ); + // Verify that two Badge(s) are present + expect(find.byType(Badge), findsNWidgets(2)); + + // Verify that Badge.count displays label 999+ when count is greater than 999 + expect(find.text('999+'), findsOneWidget); + + // Verify that Badge displays custom label + expect(find.text('Your label'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/banner/material_banner.0_test.dart b/novelforge-project/flutter/examples/api/test/material/banner/material_banner.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..68b14c62489edbed0b0b3df649291ab79ec0f2cd --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/banner/material_banner.0_test.dart @@ -0,0 +1,48 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/banner/material_banner.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Shows all elements', (WidgetTester tester) async { + await tester.pumpWidget( + const example.MaterialBannerExampleApp(), + ); + + expect(find.byType(MaterialBanner), findsOneWidget); + expect(find.byType(AppBar), findsOneWidget); + expect(find.byType(TextButton), findsNWidgets(2)); + expect(find.text('Hello, I am a Material Banner'), findsOneWidget); + expect(find.text('The MaterialBanner is below'), findsOneWidget); + expect(find.text('OPEN'), findsOneWidget); + expect(find.text('DISMISS'), findsOneWidget); + expect(find.byIcon(Icons.agriculture_outlined), findsOneWidget); + }); + + testWidgets('BottomNavigationBar Updates Screen Content', (WidgetTester tester) async { + await tester.pumpWidget( + const example.MaterialBannerExampleApp(), + ); + + expect(find.byType(MaterialBanner), findsOne); + expect(find.text('Hello, I am a Material Banner'), findsOne); + expect(find.byIcon(Icons.agriculture_outlined), findsOne); + expect(find.widgetWithText(TextButton, 'OPEN'), findsOne); + expect(find.widgetWithText(TextButton, 'DISMISS'), findsOne); + }); + + testWidgets('The banner is below the text saying so', (WidgetTester tester) async { + await tester.pumpWidget( + const example.MaterialBannerExampleApp(), + ); + + expect(find.byType(MaterialBanner), findsOneWidget); + expect(find.text('The MaterialBanner is below'), findsOneWidget); + final double bannerY = tester.getCenter(find.byType(MaterialBanner)).dy; + final double textY = tester.getCenter(find.text('The MaterialBanner is below')).dy; + expect(bannerY, greaterThan(textY)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/banner/material_banner.1_test.dart b/novelforge-project/flutter/examples/api/test/material/banner/material_banner.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..0d6523837732742efc9e30c8055f58c4f373850b --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/banner/material_banner.1_test.dart @@ -0,0 +1,58 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/banner/material_banner.1.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Shows all elements when needed', (WidgetTester tester) async { + await tester.pumpWidget(const example.MaterialBannerExampleApp()); + await tester.pumpAndSettle(); + expect(find.text('The MaterialBanner is below'), findsOneWidget); + expect(find.text('Show MaterialBanner'), findsOneWidget); + expect(find.byType(MaterialBanner), findsNothing); + expect(find.text('DISMISS'), findsNothing); + expect(find.byIcon(Icons.agriculture_outlined), findsNothing); + + await tester.tap(find.text('Show MaterialBanner')); + await tester.pumpAndSettle(); + expect(find.byType(MaterialBanner), findsOneWidget); + expect(find.text('DISMISS'), findsOneWidget); + expect(find.byIcon(Icons.agriculture_outlined), findsOneWidget); + + final MaterialBanner banner = tester.widget( + find.byType(MaterialBanner), + ); + expect(banner.backgroundColor, Colors.green); + }); + + testWidgets('BottomNavigationBar Updates Screen Content', (WidgetTester tester) async { + await tester.pumpWidget( + const example.MaterialBannerExampleApp(), + ); + + expect(find.byType(MaterialBanner), findsNothing); + await tester.tap(find.widgetWithText(ElevatedButton, 'Show MaterialBanner')); + await tester.pumpAndSettle(); + + expect(find.byType(MaterialBanner), findsOne); + expect(find.text('Hello, I am a Material Banner'), findsOne); + expect(find.byIcon(Icons.agriculture_outlined), findsOne); + expect(find.widgetWithText(TextButton, 'DISMISS'), findsOne); + }); + + testWidgets('The banner is below the text saying so', (WidgetTester tester) async { + await tester.pumpWidget(const example.MaterialBannerExampleApp()); + await tester.tap(find.text('Show MaterialBanner')); + await tester.pumpAndSettle(); + + expect(find.byType(MaterialBanner), findsOneWidget); + expect(find.text('The MaterialBanner is below'), findsOneWidget); + final double bannerY = tester.getCenter(find.byType(MaterialBanner)).dy; + final double textY = tester.getCenter(find.text('The MaterialBanner is below')).dy; + expect(bannerY, greaterThan(textY)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/bottom_navigation_bar/bottom_navigation_bar.0_test.dart b/novelforge-project/flutter/examples/api/test/material/bottom_navigation_bar/bottom_navigation_bar.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..bfedc014c64e642113342c3ff903ad176aa4e078 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/bottom_navigation_bar/bottom_navigation_bar.0_test.dart @@ -0,0 +1,32 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/bottom_navigation_bar/bottom_navigation_bar.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('BottomNavigationBar Updates Screen Content', (WidgetTester tester) async { + await tester.pumpWidget( + const example.BottomNavigationBarExampleApp(), + ); + + expect(find.widgetWithText(AppBar, 'BottomNavigationBar Sample'), findsOneWidget); + expect(find.byType(BottomNavigationBar), findsOneWidget); + expect(find.widgetWithText(Center, 'Index 0: Home'), findsOneWidget); + + await tester.tap(find.byIcon(Icons.business)); + await tester.pumpAndSettle(); + expect(find.widgetWithText(Center, 'Index 1: Business'), findsOneWidget); + + await tester.tap(find.byIcon(Icons.school)); + await tester.pumpAndSettle(); + expect(find.widgetWithText(Center, 'Index 2: School'), findsOneWidget); + + // Verify we can go back + await tester.tap(find.byIcon(Icons.home)); + await tester.pumpAndSettle(); + expect(find.widgetWithText(Center, 'Index 0: Home'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/bottom_navigation_bar/bottom_navigation_bar.1_test.dart b/novelforge-project/flutter/examples/api/test/material/bottom_navigation_bar/bottom_navigation_bar.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..d914867adb11dc65092a4d70563489e9c6c8ed98 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/bottom_navigation_bar/bottom_navigation_bar.1_test.dart @@ -0,0 +1,36 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/bottom_navigation_bar/bottom_navigation_bar.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('BottomNavigationBar Updates Screen Content', (WidgetTester tester) async { + await tester.pumpWidget( + const example.BottomNavigationBarExampleApp(), + ); + + expect(find.widgetWithText(AppBar, 'BottomNavigationBar Sample'), findsOneWidget); + expect(find.byType(BottomNavigationBar), findsOneWidget); + expect(find.widgetWithText(Center, 'Index 0: Home'), findsOneWidget); + + await tester.tap(find.byIcon(Icons.business)); + await tester.pumpAndSettle(); + expect(find.widgetWithText(Center, 'Index 1: Business'), findsOneWidget); + + await tester.tap(find.byIcon(Icons.school)); + await tester.pumpAndSettle(); + expect(find.widgetWithText(Center, 'Index 2: School'), findsOneWidget); + + await tester.tap(find.byIcon(Icons.settings)); + await tester.pumpAndSettle(); + expect(find.widgetWithText(Center, 'Index 3: Settings'), findsOneWidget); + + // Verify we can go back + await tester.tap(find.byIcon(Icons.home)); + await tester.pumpAndSettle(); + expect(find.widgetWithText(Center, 'Index 0: Home'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/bottom_navigation_bar/bottom_navigation_bar.2_test.dart b/novelforge-project/flutter/examples/api/test/material/bottom_navigation_bar/bottom_navigation_bar.2_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..4607d7a22eebbbceb6607f7f9e854a1fa36dc2d7 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/bottom_navigation_bar/bottom_navigation_bar.2_test.dart @@ -0,0 +1,34 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/bottom_navigation_bar/bottom_navigation_bar.2.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('BottomNavigationBar Updates Screen Content', (WidgetTester tester) async { + await tester.pumpWidget( + const example.BottomNavigationBarExampleApp(), + ); + + expect(find.widgetWithText(AppBar, 'BottomNavigationBar Sample'), findsOneWidget); + expect(find.byType(BottomNavigationBar), findsOneWidget); + expect(find.widgetWithText(Center, 'Item 0'), findsOneWidget); + + await tester.scrollUntilVisible(find.widgetWithText(Center, 'Item 49'), 100); + await tester.pumpAndSettle(); + expect(find.widgetWithText(Center, 'Item 49'), findsOneWidget); + + await tester.tap(find.byIcon(Icons.home)); + await tester.tap(find.byIcon(Icons.home)); + await tester.pumpAndSettle(); + + final Scrollable bodyScrollView = tester.widget(find.byType(Scrollable)); + expect(bodyScrollView.controller?.offset, 0.0); + + await tester.tap(find.byIcon(Icons.open_in_new_rounded)); + await tester.pumpAndSettle(); + expect(find.byType(AlertDialog), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/bottom_sheet/show_bottom_sheet.0_test.dart b/novelforge-project/flutter/examples/api/test/material/bottom_sheet/show_bottom_sheet.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..9347cfe55140056e5a3139728efefb58d220d487 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/bottom_sheet/show_bottom_sheet.0_test.dart @@ -0,0 +1,66 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/bottom_sheet/show_bottom_sheet.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Bottom sheet animation can be customized using AnimationStyle', (WidgetTester tester) async { + await tester.pumpWidget( + const example.BottomSheetExampleApp(), + ); + + // Show the bottom sheet with default animation style. + await tester.tap(find.widgetWithText(ElevatedButton, 'showBottomSheet')); + await tester.pump(); + // Advance the animation by 1/2 of the default forward duration. + await tester.pump(const Duration(milliseconds: 125)); + + // The bottom sheet is partially visible. + expect(tester.getTopLeft(find.byType(BottomSheet)).dy, closeTo(178.0, 0.1)); + + // Advance the animation by 1/2 of the default forward duration. + await tester.pump(const Duration(milliseconds: 125)); + + // The bottom sheet is fully visible. + expect(tester.getTopLeft(find.byType(BottomSheet)).dy, equals(56.0)); + + // Dismiss the bottom sheet. + await tester.tap(find.widgetWithText(ElevatedButton, 'Close')); + await tester.pumpAndSettle(); + + // Select custom animation style. + await tester.tap(find.text('Custom')); + await tester.pumpAndSettle(); + + // Show the bottom sheet with custom animation style. + await tester.tap(find.widgetWithText(ElevatedButton, 'showBottomSheet')); + await tester.pump(); + // Advance the animation by 1/2 of the custom forward duration. + await tester.pump(const Duration(milliseconds: 1500)); + + // The bottom sheet is partially visible. + expect(tester.getTopLeft(find.byType(BottomSheet)).dy, closeTo(178.0, 0.1)); + + // Advance the animation by 1/2 of the custom forward duration. + await tester.pump(const Duration(milliseconds: 1500)); + + // The bottom sheet is fully visible. + expect(tester.getTopLeft(find.byType(BottomSheet)).dy, equals(56.0)); + + // Dismiss the bottom sheet. + await tester.tap(find.widgetWithText(ElevatedButton, 'Close')); + await tester.pumpAndSettle(); + + // Select no animation style. + await tester.tap(find.text('None')); + await tester.pumpAndSettle(); + + // Show the bottom sheet with no animation style. + await tester.tap(find.widgetWithText(ElevatedButton, 'showBottomSheet')); + await tester.pump(); + expect(tester.getTopLeft(find.byType(BottomSheet)).dy, equals(56.0)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/bottom_sheet/show_modal_bottom_sheet.0_test.dart b/novelforge-project/flutter/examples/api/test/material/bottom_sheet/show_modal_bottom_sheet.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..7b5e1450760ec3eebe3077a9a2e5150174508f0d --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/bottom_sheet/show_modal_bottom_sheet.0_test.dart @@ -0,0 +1,29 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/bottom_sheet/show_modal_bottom_sheet.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('BottomSheet can be opened and closed', (WidgetTester tester) async { + const String titleText = 'Modal BottomSheet'; + const String closeText = 'Close BottomSheet'; + + await tester.pumpWidget( + const example.BottomSheetApp(), + ); + + expect(find.text(titleText), findsNothing); + expect(find.text(closeText), findsNothing); + + // Open the bottom sheet. + await tester.tap(find.widgetWithText(ElevatedButton, 'showModalBottomSheet')); + await tester.pumpAndSettle(); + + // Verify that the bottom sheet is open. + expect(find.text(titleText), findsOneWidget); + expect(find.text(closeText), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/bottom_sheet/show_modal_bottom_sheet.1_test.dart b/novelforge-project/flutter/examples/api/test/material/bottom_sheet/show_modal_bottom_sheet.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..3fc63af4f755fe291f890834dfd253132d1f5c53 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/bottom_sheet/show_modal_bottom_sheet.1_test.dart @@ -0,0 +1,29 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/bottom_sheet/show_modal_bottom_sheet.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('BottomSheet can be opened and closed', (WidgetTester tester) async { + const String titleText = 'Modal BottomSheet'; + const String closeText = 'Close BottomSheet'; + + await tester.pumpWidget( + const example.BottomSheetApp(), + ); + + expect(find.text(titleText), findsNothing); + expect(find.text(closeText), findsNothing); + + // Open the bottom sheet. + await tester.tap(find.widgetWithText(ElevatedButton, 'showModalBottomSheet')); + await tester.pumpAndSettle(); + + // Verify that the bottom sheet is open. + expect(find.text(titleText), findsOneWidget); + expect(find.text(closeText), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/bottom_sheet/show_modal_bottom_sheet.2_test.dart b/novelforge-project/flutter/examples/api/test/material/bottom_sheet/show_modal_bottom_sheet.2_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..6a582a344997b5442c544663705c99bb2630fb26 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/bottom_sheet/show_modal_bottom_sheet.2_test.dart @@ -0,0 +1,66 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/bottom_sheet/show_modal_bottom_sheet.2.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Modal bottom sheet animation can be customized using AnimationStyle', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ModalBottomSheetApp(), + ); + + // Show the bottom sheet with default animation style. + await tester.tap(find.widgetWithText(ElevatedButton, 'showModalBottomSheet')); + await tester.pump(); + // Advance the animation by 1/2 of the default forward duration. + await tester.pump(const Duration(milliseconds: 125)); + + // The bottom sheet is partially visible. + expect(tester.getTopLeft(find.byType(BottomSheet)).dy, closeTo(316.7, 0.1)); + + // Advance the animation by 1/2 of the default forward duration. + await tester.pump(const Duration(milliseconds: 125)); + + // The bottom sheet is fully visible. + expect(tester.getTopLeft(find.byType(BottomSheet)).dy, equals(262.5)); + + // Dismiss the bottom sheet. + await tester.tap(find.widgetWithText(ElevatedButton, 'Close')); + await tester.pumpAndSettle(); + + // Select custom animation style. + await tester.tap(find.text('Custom')); + await tester.pumpAndSettle(); + + // Show the bottom sheet with custom animation style. + await tester.tap(find.widgetWithText(ElevatedButton, 'showModalBottomSheet')); + await tester.pump(); + // Advance the animation by 1/2 of the custom forward duration. + await tester.pump(const Duration(milliseconds: 1500)); + + // The bottom sheet is partially visible. + expect(tester.getTopLeft(find.byType(BottomSheet)).dy, closeTo(316.7, 0.1)); + + // Advance the animation by 1/2 of the custom forward duration. + await tester.pump(const Duration(milliseconds: 1500)); + + // The bottom sheet is fully visible. + expect(tester.getTopLeft(find.byType(BottomSheet)).dy, equals(262.5)); + + // Dismiss the bottom sheet. + await tester.tap(find.widgetWithText(ElevatedButton, 'Close')); + await tester.pumpAndSettle(); + + // Select no animation style. + await tester.tap(find.text('None')); + await tester.pumpAndSettle(); + + // Show the bottom sheet with no animation style. + await tester.tap(find.widgetWithText(ElevatedButton, 'showModalBottomSheet')); + await tester.pump(); + expect(tester.getTopLeft(find.byType(BottomSheet)).dy, equals(262.5)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/button_style/button_style.0_test.dart b/novelforge-project/flutter/examples/api/test/material/button_style/button_style.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..db4251fb21dbaeb21a2397cb027cae87a35e1a76 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/button_style/button_style.0_test.dart @@ -0,0 +1,74 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/button_style/button_style.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets( + 'Shows ElevatedButtons, FilledButtons, OutlinedButtons and TextButtons in enabled and disabled states', + (WidgetTester tester) async { + await tester.pumpWidget(const example.ButtonApp()); + + expect( + find.byWidgetPredicate((Widget widget) { + return widget is ElevatedButton && widget.onPressed == null; + }), + findsOne, + ); + + expect( + find.byWidgetPredicate((Widget widget) { + return widget is ElevatedButton && widget.onPressed != null; + }), + findsOne, + ); + + // One OutlinedButton with onPressed null. + expect( + find.byWidgetPredicate((Widget widget) { + return widget is OutlinedButton && widget.onPressed == null; + }), + findsOne, + ); + + // One OutlinedButton with onPressed not null. + expect( + find.byWidgetPredicate((Widget widget) { + return widget is OutlinedButton && widget.onPressed != null; + }), + findsOne, + ); + + expect( + find.byWidgetPredicate((Widget widget) { + return widget is TextButton && widget.onPressed == null; + }), + findsOne, + ); + + expect( + find.byWidgetPredicate((Widget widget) { + return widget is TextButton && widget.onPressed != null; + }), + findsOne, + ); + + expect( + find.byWidgetPredicate((Widget widget) { + return widget is FilledButton && widget.onPressed != null; + }), + findsNWidgets(2), + ); + + expect( + find.byWidgetPredicate((Widget widget) { + return widget is FilledButton && widget.onPressed == null; + }), + findsNWidgets(2), + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/button_style_button/button_style_button.icon_alignment.0_test.dart b/novelforge-project/flutter/examples/api/test/material/button_style_button/button_style_button.icon_alignment.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..2895d22e6d4429993db67cebe1cb17bbe29ce57b --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/button_style_button/button_style_button.icon_alignment.0_test.dart @@ -0,0 +1,102 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/button_style_button/button_style_button.icon_alignment.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('ButtonStyleButton.iconAlignment updates button icons alignment', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ButtonStyleButtonIconAlignmentApp(), + ); + + Finder findButtonMaterial(String text) { + return find.ancestor( + of: find.text(text), + matching: find.byType(Material), + ).first; + } + + void expectedLeftIconPosition({ + required double iconOffset, + required double textButtonIconOffset, + }) { + expect( + tester.getTopLeft(findButtonMaterial('ElevatedButton')).dx, + tester.getTopLeft(find.byIcon(Icons.sunny)).dx - iconOffset, + ); + expect( + tester.getTopLeft(findButtonMaterial('FilledButton')).dx, + tester.getTopLeft(find.byIcon(Icons.beach_access)).dx - iconOffset, + ); + expect( + tester.getTopLeft(findButtonMaterial('FilledButton Tonal')).dx, + tester.getTopLeft(find.byIcon(Icons.cloud)).dx - iconOffset, + ); + expect( + tester.getTopLeft(findButtonMaterial('OutlinedButton')).dx, + tester.getTopLeft(find.byIcon(Icons.light)).dx - iconOffset, + ); + expect( + tester.getTopLeft(findButtonMaterial('TextButton')).dx, + tester.getTopLeft(find.byIcon(Icons.flight_takeoff)).dx - textButtonIconOffset, + ); + } + + void expectedRightIconPosition({ + required double iconOffset, + required double textButtonIconOffset, + }) { + expect( + tester.getTopRight(findButtonMaterial('ElevatedButton')).dx, + tester.getTopRight(find.byIcon(Icons.sunny)).dx + iconOffset, + ); + expect( + tester.getTopRight(findButtonMaterial('FilledButton')).dx, + tester.getTopRight(find.byIcon(Icons.beach_access)).dx + iconOffset, + ); + expect( + tester.getTopRight(findButtonMaterial('FilledButton Tonal')).dx, + tester.getTopRight(find.byIcon(Icons.cloud)).dx + iconOffset, + ); + expect( + tester.getTopRight(findButtonMaterial('OutlinedButton')).dx, + tester.getTopRight(find.byIcon(Icons.light)).dx + iconOffset, + ); + expect( + tester.getTopRight(findButtonMaterial('TextButton')).dx, + tester.getTopRight(find.byIcon(Icons.flight_takeoff)).dx + textButtonIconOffset, + ); + } + + // Test initial icon alignment in LTR. + expectedLeftIconPosition(iconOffset: 16, textButtonIconOffset: 12); + + // Update icon alignment to end. + await tester.tap(find.text('end')); + await tester.pumpAndSettle(); + + // Test icon alignment end in LTR. + expectedRightIconPosition(iconOffset: 24, textButtonIconOffset: 16); + + // Reset icon alignment to start. + await tester.tap(find.text('start')); + await tester.pumpAndSettle(); + + // Change text direction to RTL. + await tester.tap(find.text('RTL')); + await tester.pumpAndSettle(); + + // Test icon alignment start in LTR. + expectedRightIconPosition(iconOffset: 16, textButtonIconOffset: 12); + + // Update icon alignment to end. + await tester.tap(find.text('end')); + await tester.pumpAndSettle(); + + // Test icon alignment end in LTR. + expectedLeftIconPosition(iconOffset: 24, textButtonIconOffset: 16); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/card/card.0_test.dart b/novelforge-project/flutter/examples/api/test/material/card/card.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..c7899853c5ab72980f51596f3054e6dc69f57944 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/card/card.0_test.dart @@ -0,0 +1,21 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/card/card.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Card Smoke Test', (WidgetTester tester) async { + await tester.pumpWidget( + const example.CardExampleApp(), + ); + expect(find.byType(Card), findsOneWidget); + expect(find.widgetWithIcon(Card, Icons.album), findsOneWidget); + expect(find.widgetWithText(Card, 'The Enchanted Nightingale'), findsOneWidget); + expect(find.widgetWithText(Card, 'Music by Julie Gable. Lyrics by Sidney Stein.'), findsOneWidget); + expect(find.widgetWithText(Card, 'BUY TICKETS'), findsOneWidget); + expect(find.widgetWithText(Card, 'LISTEN'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/card/card.1_test.dart b/novelforge-project/flutter/examples/api/test/material/card/card.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..6bdf1cb437ca293efcf2eb06c21067c14b2eb61e --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/card/card.1_test.dart @@ -0,0 +1,16 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/card/card.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Card has clip applied', (WidgetTester tester) async { + await tester.pumpWidget(const example.CardExampleApp()); + + final Card card = tester.firstWidget(find.byType(Card)); + expect(card.clipBehavior, Clip.hardEdge); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/card/card.2_test.dart b/novelforge-project/flutter/examples/api/test/material/card/card.2_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..1c0d93affbaf824cd668e5656cb4eb218215a0fe --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/card/card.2_test.dart @@ -0,0 +1,59 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/card/card.2.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Card variants', (WidgetTester tester) async { + await tester.pumpWidget(const example.CardExamplesApp()); + + expect(find.byType(Card), findsNWidgets(3)); + + expect(find.widgetWithText(Card, 'Elevated Card'), findsOneWidget); + expect(find.widgetWithText(Card, 'Filled Card'), findsOneWidget); + expect(find.widgetWithText(Card, 'Outlined Card'), findsOneWidget); + + Material getCardMaterial(WidgetTester tester, int cardIndex) { + return tester.widget( + find.descendant( + of: find.byType(Card).at(cardIndex), + matching: find.byType(Material), + ), + ); + } + + final Material defaultCard = getCardMaterial(tester, 0); + expect(defaultCard.clipBehavior, Clip.none); + expect(defaultCard.elevation, 1.0); + expect(defaultCard.shape, const RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(12.0)), + )); + expect(defaultCard.color, const Color(0xfffffbfe)); + expect(defaultCard.shadowColor, const Color(0xff000000)); + expect(defaultCard.surfaceTintColor, const Color(0xff6750a4)); + + final Material filledCard = getCardMaterial(tester, 1); + expect(filledCard.clipBehavior, Clip.none); + expect(filledCard.elevation, 0.0); + expect(filledCard.shape, const RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(12.0)), + )); + expect(filledCard.color, const Color(0xffe7e0ec)); + expect(filledCard.shadowColor, const Color(0xff000000)); + expect(filledCard.surfaceTintColor, const Color(0x00000000)); + + final Material outlinedCard = getCardMaterial(tester, 2); + expect(outlinedCard.clipBehavior, Clip.none); + expect(outlinedCard.elevation, 0.0); + expect(outlinedCard.shape, const RoundedRectangleBorder( + side: BorderSide(color: Color(0xffcac4d0)), + borderRadius: BorderRadius.all(Radius.circular(12.0)), + )); + expect(outlinedCard.color, const Color(0xfffffbfe)); + expect(outlinedCard.shadowColor, const Color(0xff000000)); + expect(outlinedCard.surfaceTintColor, const Color(0xff6750a4)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/carousel/carousel.0_test.dart b/novelforge-project/flutter/examples/api/test/material/carousel/carousel.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..5f104612ea9581919ccf61ede5a2fa49201804a1 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/carousel/carousel.0_test.dart @@ -0,0 +1,19 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/carousel/carousel.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Carousel Smoke Test', (WidgetTester tester) async { + await tester.pumpWidget( + const example.CarouselExampleApp(), + ); + expect(find.byType(CarouselView), findsOneWidget); + + expect(find.widgetWithText(example.UncontainedLayoutCard, 'Item 0'), findsOneWidget); + expect(find.widgetWithText(example.UncontainedLayoutCard, 'Item 1'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/checkbox/checkbox.0_test.dart b/novelforge-project/flutter/examples/api/test/material/checkbox/checkbox.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..568c03f2078ee57eb9e3816080a6acf03ccfe508 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/checkbox/checkbox.0_test.dart @@ -0,0 +1,59 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/checkbox/checkbox.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Checkbox can be checked', (WidgetTester tester) async { + await tester.pumpWidget( + const example.CheckboxExampleApp(), + ); + + Checkbox checkbox = tester.widget(find.byType(Checkbox)); + expect(checkbox.value, isFalse); + + await tester.tap(find.byType(Checkbox)); + await tester.pump(); + + checkbox = tester.widget(find.byType(Checkbox)); + expect(checkbox.value, isTrue); + + await tester.tap(find.byType(Checkbox)); + await tester.pump(); + + checkbox = tester.widget(find.byType(Checkbox)); + expect(checkbox.value, isFalse); + }); + + testWidgets('Checkbox color can be changed', (WidgetTester tester) async { + await tester.pumpWidget( + const example.CheckboxExampleApp(), + ); + final Checkbox checkbox = tester.widget(find.byType(Checkbox)); + + expect( + checkbox.checkColor, + Colors.white, + ); + expect( + checkbox.fillColor!.resolve({}), + Colors.red, + ); + expect( + checkbox.fillColor!.resolve({MaterialState.pressed}), + Colors.blue, + ); + expect( + checkbox.fillColor!.resolve({MaterialState.hovered}), + Colors.blue, + ); + expect( + checkbox.fillColor!.resolve({MaterialState.focused}), + Colors.blue, + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/checkbox/checkbox.1_test.dart b/novelforge-project/flutter/examples/api/test/material/checkbox/checkbox.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..7d1500aa24c379410d0d7d15b1b3c240908f1080 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/checkbox/checkbox.1_test.dart @@ -0,0 +1,68 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/checkbox/checkbox.1.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Checkbox can be checked', (WidgetTester tester) async { + await tester.pumpWidget( + const example.CheckboxExampleApp(), + ); + + expect(find.byType(Checkbox), findsNWidgets(3)); + Checkbox checkbox = tester.widget(find.byType(Checkbox).first); + Checkbox checkboxWithError = tester.widget(find.byType(Checkbox).at(1)); + Checkbox checkboxDisabled = tester.widget(find.byType(Checkbox).last); + + // Verify the initial state of the checkboxes. + expect(checkbox.value, isTrue); + expect(checkboxWithError.value, isTrue); + expect(checkboxDisabled.value, isTrue); + + expect(checkboxWithError.isError, isTrue); + expect(checkboxDisabled.onChanged, null); + + expect(checkbox.tristate, isTrue); + expect(checkboxWithError.tristate, isTrue); + expect(checkboxDisabled.tristate, isTrue); + + // Tap the first Checkbox and verify the state change. + await tester.tap(find.byType(Checkbox).first); + await tester.pump(); + checkbox = tester.widget(find.byType(Checkbox).first); + checkboxWithError = tester.widget(find.byType(Checkbox).at(1)); + checkboxDisabled = tester.widget(find.byType(Checkbox).last); + + expect(checkbox.value, isNull); + expect(checkboxWithError.value, isNull); + expect(checkboxDisabled.value, isNull); + + // Tap the second Checkbox and verify the state change. + await tester.tap(find.byType(Checkbox).at(1)); + await tester.pump(); + + checkbox = tester.widget(find.byType(Checkbox).first); + checkboxWithError = tester.widget(find.byType(Checkbox).at(1)); + checkboxDisabled = tester.widget(find.byType(Checkbox).last); + + expect(checkbox.value, isFalse); + expect(checkboxWithError.value, isFalse); + expect(checkboxDisabled.value, isFalse); + + // Tap the third Checkbox and verify that should remain unchanged. + await tester.tap(find.byType(Checkbox).last); + await tester.pump(); + + checkbox = tester.widget(find.byType(Checkbox).first); + checkboxWithError = tester.widget(find.byType(Checkbox).at(1)); + checkboxDisabled = tester.widget(find.byType(Checkbox).last); + + expect(checkbox.value, isFalse); + expect(checkboxWithError.value, isFalse); + expect(checkboxDisabled.value, isFalse); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/checkbox_list_tile/checkbox_list_tile.0_test.dart b/novelforge-project/flutter/examples/api/test/material/checkbox_list_tile/checkbox_list_tile.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..bd65306d8a0b3b9d03e25adc6187154dcce21d62 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/checkbox_list_tile/checkbox_list_tile.0_test.dart @@ -0,0 +1,32 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/scheduler.dart'; +import 'package:flutter_api_samples/material/checkbox_list_tile/checkbox_list_tile.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('CheckboxListTile can be checked', (WidgetTester tester) async { + await tester.pumpWidget( + const example.CheckboxListTileApp(), + ); + + CheckboxListTile checkboxListTile = tester.widget(find.byType(CheckboxListTile)); + expect(checkboxListTile.value, isFalse); + + await tester.tap(find.byType(CheckboxListTile)); + await tester.pump(); + timeDilation = 1.0; + + checkboxListTile = tester.widget(find.byType(CheckboxListTile)); + expect(checkboxListTile.value, isTrue); + + await tester.tap(find.byType(CheckboxListTile)); + await tester.pump(); + + checkboxListTile = tester.widget(find.byType(CheckboxListTile)); + expect(checkboxListTile.value, isFalse); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/checkbox_list_tile/checkbox_list_tile.1_test.dart b/novelforge-project/flutter/examples/api/test/material/checkbox_list_tile/checkbox_list_tile.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..bcc747f63d71beb528290ecf53ce52c7d5d1873d --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/checkbox_list_tile/checkbox_list_tile.1_test.dart @@ -0,0 +1,75 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/checkbox_list_tile/checkbox_list_tile.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Checkbox aligns appropriately', (WidgetTester tester) async { + await tester.pumpWidget( + const example.CheckboxListTileApp(), + ); + + expect(find.byType(CheckboxListTile), findsNWidgets(3)); + + Offset tileTopLeft = tester.getTopLeft(find.byType(CheckboxListTile).at(0)); + Offset checkboxTopLeft = tester.getTopLeft(find.byType(Checkbox).at(0)); + + // The checkbox is centered vertically with the text. + expect(checkboxTopLeft - tileTopLeft, const Offset(736.0, 16.0)); + + tileTopLeft = tester.getTopLeft(find.byType(CheckboxListTile).at(1)); + checkboxTopLeft = tester.getTopLeft(find.byType(Checkbox).at(1)); + + // The checkbox is centered vertically with the text. + expect(checkboxTopLeft - tileTopLeft, const Offset(736.0, 30.0)); + + tileTopLeft = tester.getTopLeft(find.byType(CheckboxListTile).at(2)); + checkboxTopLeft = tester.getTopLeft(find.byType(Checkbox).at(2)); + + // The checkbox is aligned to the top vertically with the text. + expect(checkboxTopLeft - tileTopLeft, const Offset(736.0, 8.0)); + }); + + testWidgets('Checkboxes can be checked', (WidgetTester tester) async { + await tester.pumpWidget( + const example.CheckboxListTileApp(), + ); + + expect(find.byType(CheckboxListTile), findsNWidgets(3)); + + // All checkboxes are checked. + expect(tester.widget(find.byType(Checkbox).at(0)).value, isTrue); + expect(tester.widget(find.byType(Checkbox).at(1)).value, isTrue); + expect(tester.widget(find.byType(Checkbox).at(2)).value, isTrue); + + // Tap the first checkbox. + await tester.tap(find.byType(Checkbox).at(0)); + await tester.pumpAndSettle(); + + // The first checkbox is unchecked. + expect(tester.widget(find.byType(Checkbox).at(0)).value, isFalse); + expect(tester.widget(find.byType(Checkbox).at(1)).value, isTrue); + expect(tester.widget(find.byType(Checkbox).at(2)).value, isTrue); + + // Tap the second checkbox. + await tester.tap(find.byType(Checkbox).at(1)); + await tester.pumpAndSettle(); + + // The first and second checkboxes are unchecked. + expect(tester.widget(find.byType(Checkbox).at(0)).value, isFalse); + expect(tester.widget(find.byType(Checkbox).at(1)).value, isFalse); + expect(tester.widget(find.byType(Checkbox).at(2)).value, isTrue); + + // Tap the third checkbox. + await tester.tap(find.byType(Checkbox).at(2)); + await tester.pumpAndSettle(); + + // All checkboxes are unchecked. + expect(tester.widget(find.byType(Checkbox).at(0)).value, isFalse); + expect(tester.widget(find.byType(Checkbox).at(1)).value, isFalse); + expect(tester.widget(find.byType(Checkbox).at(2)).value, isFalse); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/checkbox_list_tile/custom_labeled_checkbox.0_test.dart b/novelforge-project/flutter/examples/api/test/material/checkbox_list_tile/custom_labeled_checkbox.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..863103c92735a731959460512715ffe29914954c --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/checkbox_list_tile/custom_labeled_checkbox.0_test.dart @@ -0,0 +1,31 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/checkbox_list_tile/custom_labeled_checkbox.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('LinkedLabelCheckbox contains RichText and Checkbox', (WidgetTester tester) async { + await tester.pumpWidget( + const example.LabeledCheckboxApp(), + ); + + // Label text is in a RichText widget with the correct text. + final RichText richText = tester.widget(find.byType(RichText).first); + expect(richText.text.toPlainText(), 'Linked, tappable label text'); + + // Checkbox is initially unchecked. + Checkbox checkbox = tester.widget(find.byType(Checkbox)); + expect(checkbox.value, isFalse); + + // Tap the checkbox to check it. + await tester.tap(find.byType(Checkbox)); + await tester.pumpAndSettle(); + + // Checkbox is now checked. + checkbox = tester.widget(find.byType(Checkbox)); + expect(checkbox.value, isTrue); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/checkbox_list_tile/custom_labeled_checkbox.1_test.dart b/novelforge-project/flutter/examples/api/test/material/checkbox_list_tile/custom_labeled_checkbox.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..1353287ff3c30ddcf9b8b82c4d212120a47f7256 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/checkbox_list_tile/custom_labeled_checkbox.1_test.dart @@ -0,0 +1,27 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/checkbox_list_tile/custom_labeled_checkbox.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Tapping LabeledCheckbox toggles the checkbox', (WidgetTester tester) async { + await tester.pumpWidget( + const example.LabeledCheckboxApp(), + ); + + // Checkbox is initially unchecked. + Checkbox checkbox = tester.widget(find.byType(Checkbox)); + expect(checkbox.value, isFalse); + + // Tap the LabeledCheckBoxApp to toggle the checkbox. + await tester.tap(find.byType(example.LabeledCheckbox)); + await tester.pumpAndSettle(); + + // Checkbox is now checked. + checkbox = tester.widget(find.byType(Checkbox)); + expect(checkbox.value, isTrue); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/chip/chip_attributes.avatar_box_constraints.0_test.dart b/novelforge-project/flutter/examples/api/test/material/chip/chip_attributes.avatar_box_constraints.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..e28dedf1b67290881cebdd2cfdeaed8040b9e54b --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/chip/chip_attributes.avatar_box_constraints.0_test.dart @@ -0,0 +1,55 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/chip/chip_attributes.avatar_box_constraints.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('RawChip.avatarBoxConstraints updates avatar size constraints', (WidgetTester tester) async { + const double border = 1.0; + const double iconSize = 18.0; + const double padding = 8.0; + + await tester.pumpWidget( + const example.AvatarBoxConstraintsApp(), + ); + + expect(tester.getSize(find.byType(RawChip).at(0)).width, equals(202.0)); + expect(tester.getSize(find.byType(RawChip).at(0)).height, equals(58.0)); + + Offset chipTopLeft = tester.getTopLeft(find.byWidget(tester.widget( + find.descendant( + of: find.byType(RawChip).at(0), + matching: find.byType(Material), + ), + ))); + Offset avatarCenter = tester.getCenter(find.byIcon(Icons.star).at(0)); + expect(chipTopLeft.dx, avatarCenter.dx - (iconSize / 2) - padding - border); + + expect(tester.getSize(find.byType(RawChip).at(1)).width, equals(202.0)); + expect(tester.getSize(find.byType(RawChip).at(1)).height, equals(78.0)); + + chipTopLeft = tester.getTopLeft(find.byWidget(tester.widget( + find.descendant( + of: find.byType(RawChip).at(1), + matching: find.byType(Material), + ), + ))); + avatarCenter = tester.getCenter(find.byIcon(Icons.star).at(1)); + expect(chipTopLeft.dx, avatarCenter.dx - (iconSize / 2) - padding - border); + + expect(tester.getSize(find.byType(RawChip).at(2)).width, equals(202.0)); + expect(tester.getSize(find.byType(RawChip).at(2)).height, equals(78.0)); + + chipTopLeft = tester.getTopLeft(find.byWidget(tester.widget( + find.descendant( + of: find.byType(RawChip).at(2), + matching: find.byType(Material), + ), + ))); + avatarCenter = tester.getCenter(find.byIcon(Icons.star).at(2)); + expect(chipTopLeft.dx, avatarCenter.dx - (iconSize / 2) - padding - border); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/chip/chip_attributes.chip_animation_style.0_test.dart b/novelforge-project/flutter/examples/api/test/material/chip/chip_attributes.chip_animation_style.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..a22e91b69a435e7b5158b323fba4628ce3f732c2 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/chip/chip_attributes.chip_animation_style.0_test.dart @@ -0,0 +1,135 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/chip/chip_attributes.chip_animation_style.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('ChipAnimationStyle.enableAnimation overrides chip enable animation', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ChipAnimationStyleExampleApp(), + ); + + final RenderBox materialBox = tester.firstRenderObject( + find.descendant( + of: find.widgetWithText(RawChip, 'Enabled'), + matching: find.byType(CustomPaint), + ), + ); + + expect(materialBox, paints..rrect(color: const Color(0xffffc107))); + + await tester.tap(find.widgetWithText(ElevatedButton, 'Disable')); + await tester.pump(); + await tester.pump(const Duration(milliseconds: 500)); // Advance enable animation by 500ms. + + expect(materialBox, paints..rrect(color: const Color(0x1f882f2b))); + + await tester.pump(const Duration(milliseconds: 500)); // Advance enable animation by 500ms. + + expect(materialBox, paints..rrect(color: const Color(0x1ff44336))); + + await tester.tap(find.widgetWithText(ElevatedButton, 'Enable')); + await tester.pump(); + await tester.pump(const Duration(milliseconds: 1500)); // Advance enable animation by 1500ms. + + expect(materialBox, paints..rrect(color: const Color(0xfffbd980))); + + await tester.pump(const Duration(milliseconds: 1500)); // Advance enable animation by 1500ms. + + expect(materialBox, paints..rrect(color: const Color(0xffffc107))); + }); + + testWidgets('ChipAnimationStyle.selectAnimation overrides chip select animation', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ChipAnimationStyleExampleApp(), + ); + + final RenderBox materialBox = tester.firstRenderObject( + find.descendant( + of: find.widgetWithText(RawChip, 'Unselected'), + matching: find.byType(CustomPaint), + ), + ); + + expect(materialBox, paints..rrect(color: const Color(0xffffc107))); + + await tester.tap(find.widgetWithText(ElevatedButton, 'Select')); + await tester.pump(); + await tester.pump(const Duration(milliseconds: 1500)); // Advance select animation by 1500ms. + + expect(materialBox, paints..rrect(color: const Color(0xff4da6f4))); + + await tester.pump(const Duration(milliseconds: 1500)); // Advance select animation by 1500ms. + + expect(materialBox, paints..rrect(color: const Color(0xff2196f3))); + + await tester.tap(find.widgetWithText(ElevatedButton, 'Unselect')); + await tester.pump(); + await tester.pump(const Duration(milliseconds: 500)); // Advance select animation by 500ms. + + expect(materialBox, paints..rrect(color: const Color(0xfff8e7c3))); + + await tester.pump(const Duration(milliseconds: 500)); // Advance select animation by 500ms. + + expect(materialBox, paints..rrect(color: const Color(0xffffc107))); + }); + + testWidgets('ChipAnimationStyle.avatarDrawerAnimation overrides chip checkmark animation', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ChipAnimationStyleExampleApp(), + ); + + expect(tester.getSize(find.widgetWithText(RawChip, 'Checked')).width, closeTo(152.6, 0.1)); + + await tester.tap(find.widgetWithText(ElevatedButton, 'Hide checkmark')); + await tester.pump(); + await tester.pump(const Duration(milliseconds: 500)); // Advance avatar animation by 500ms. + + expect(tester.getSize(find.widgetWithText(RawChip, 'Unchecked')).width, closeTo(160.9, 0.1)); + + await tester.pump(const Duration(milliseconds: 500)); // Advance avatar animation by 500ms. + + expect(tester.getSize(find.widgetWithText(RawChip, 'Unchecked')).width, closeTo(160.9, 0.1)); + + await tester.tap(find.widgetWithText(ElevatedButton, 'Show checkmark')); + await tester.pump(); + await tester.pump(const Duration(seconds: 1)); // Advance avatar animation by 1sec. + + expect(tester.getSize(find.widgetWithText(RawChip, 'Checked')).width, closeTo(132.7, 0.1)); + + await tester.pump(const Duration(seconds: 1)); // Advance avatar animation by 1sec. + + expect(tester.getSize(find.widgetWithText(RawChip, 'Checked')).width, closeTo(152.6, 0.1)); + }); + + testWidgets('ChipAnimationStyle.deleteDrawerAnimation overrides chip delete icon animation', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ChipAnimationStyleExampleApp(), + ); + + expect(tester.getSize(find.widgetWithText(RawChip, 'Deletable')).width, closeTo(180.9, 0.1)); + + await tester.tap(find.widgetWithText(ElevatedButton, 'Hide delete icon')); + await tester.pump(); + await tester.pump(const Duration(milliseconds: 500)); // Advance delete icon animation by 500ms. + + expect(tester.getSize(find.widgetWithText(RawChip, 'Undeletable')).width, closeTo(204.6, 0.1)); + + await tester.pump(const Duration(milliseconds: 500)); // Advance delete icon animation by 500ms. + + expect(tester.getSize(find.widgetWithText(RawChip, 'Undeletable')).width, closeTo(189.1, 0.1)); + + await tester.tap(find.widgetWithText(ElevatedButton, 'Show delete icon')); + await tester.pump(); + await tester.pump(const Duration(seconds: 1)); // Advance delete icon animation by 1sec. + + expect(tester.getSize(find.widgetWithText(RawChip, 'Deletable')).width, closeTo(176.4, 0.1)); + + await tester.pump(const Duration(seconds: 1)); // Advance delete icon animation by 1sec. + + expect(tester.getSize(find.widgetWithText(RawChip, 'Deletable')).width, closeTo(180.9, 0.1)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/chip/deletable_chip_attributes.delete_icon_box_constraints.0_test.dart b/novelforge-project/flutter/examples/api/test/material/chip/deletable_chip_attributes.delete_icon_box_constraints.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..8ffe215fcb58ddad25ae36d39bea6ffdaa5d3e66 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/chip/deletable_chip_attributes.delete_icon_box_constraints.0_test.dart @@ -0,0 +1,55 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/chip/deletable_chip_attributes.delete_icon_box_constraints.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('RawChip.deleteIconBoxConstraints updates delete icon size constraints', (WidgetTester tester) async { + const double border = 1.0; + const double iconSize = 18.0; + const double padding = 8.0; + + await tester.pumpWidget( + const example.DeleteIconBoxConstraintsApp(), + ); + + expect(tester.getSize(find.byType(RawChip).at(0)).width, equals(202.0)); + expect(tester.getSize(find.byType(RawChip).at(0)).height, equals(58.0)); + + Offset chipToRight = tester.getTopRight(find.byWidget(tester.widget( + find.descendant( + of: find.byType(RawChip).at(0), + matching: find.byType(Material), + ), + ))); + Offset deleteIconCenter = tester.getCenter(find.byIcon(Icons.cancel).at(0)); + expect(chipToRight.dx, deleteIconCenter.dx + (iconSize / 2) + padding + border); + + expect(tester.getSize(find.byType(RawChip).at(1)).width, equals(202.0)); + expect(tester.getSize(find.byType(RawChip).at(1)).height, equals(78.0)); + + chipToRight = tester.getTopRight(find.byWidget(tester.widget( + find.descendant( + of: find.byType(RawChip).at(1), + matching: find.byType(Material), + ), + ))); + deleteIconCenter = tester.getCenter(find.byIcon(Icons.cancel).at(1)); + expect(chipToRight.dx, deleteIconCenter.dx + (iconSize / 2) + padding + border); + + expect(tester.getSize(find.byType(RawChip).at(2)).width, equals(202.0)); + expect(tester.getSize(find.byType(RawChip).at(2)).height, equals(78.0)); + + chipToRight = tester.getTopRight(find.byWidget(tester.widget( + find.descendant( + of: find.byType(RawChip).at(2), + matching: find.byType(Material), + ), + ))); + deleteIconCenter = tester.getCenter(find.byIcon(Icons.cancel).at(2)); + expect(chipToRight.dx, deleteIconCenter.dx + (iconSize / 2) + padding + border); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/choice_chip/choice_chip.0_test.dart b/novelforge-project/flutter/examples/api/test/material/choice_chip/choice_chip.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..bf744810d7a8649da7594dfcb590be9138faf3db --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/choice_chip/choice_chip.0_test.dart @@ -0,0 +1,24 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/choice_chip/choice_chip.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can choose an item using ChoiceChip', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ChipApp(), + ); + + ChoiceChip chosenChip = tester.widget(find.byType(ChoiceChip).at(1)); + expect(chosenChip.selected, true); + + await tester.tap(find.byType(ChoiceChip).at(0)); + await tester.pumpAndSettle(); + + chosenChip = tester.widget(find.byType(ChoiceChip).at(0)); + expect(chosenChip.selected, true); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/color_scheme/color_scheme.0_test.dart b/novelforge-project/flutter/examples/api/test/material/color_scheme/color_scheme.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..60df0a98d3e1ad1cc8e0ab5f4339579cac140317 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/color_scheme/color_scheme.0_test.dart @@ -0,0 +1,41 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/color_scheme/color_scheme.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('ColorScheme Smoke Test', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ColorSchemeExample(), + ); + expect(find.text('tonalSpot (Default)'), findsOneWidget); + + expect(find.byType(example.ColorChip), findsNWidgets(43 * 9)); + }); + + testWidgets('Change color seed', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ColorSchemeExample(), + ); + + ColoredBox coloredBox() { + return tester.widget( + find.descendant( + of: find.widgetWithText(example.ColorChip, 'primary').first, + matching: find.byType(ColoredBox) + ) + ); + } + expect(coloredBox().color, const Color(0xff65558f)); + await tester.tap(find.byType(example.SettingsButton)); + await tester.pumpAndSettle(); + expect(find.text('Settings'), findsOneWidget); + await tester.tap(find.byType(IconButton).at(6)); + await tester.pumpAndSettle(); + + expect(coloredBox().color, const Color(0xFF685F12)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/context_menu/context_menu_controller.0_test.dart b/novelforge-project/flutter/examples/api/test/material/context_menu/context_menu_controller.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..a2d717767b5b34f26dfb4f17355f018b6b7836ad --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/context_menu/context_menu_controller.0_test.dart @@ -0,0 +1,48 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/foundation.dart'; +import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_api_samples/material/context_menu/context_menu_controller.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('showing and hiding the custom context menu in the whole app', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ContextMenuControllerExampleApp(), + ); + + expect(BrowserContextMenu.enabled, !kIsWeb); + + expect(find.byType(AdaptiveTextSelectionToolbar), findsNothing); + + // Right clicking the middle of the app shows the custom context menu. + final Offset center = tester.getCenter(find.byType(Scaffold)); + final TestGesture gesture = await tester.startGesture( + center, + kind: PointerDeviceKind.mouse, + buttons: kSecondaryMouseButton, + ); + await tester.pump(); + await gesture.up(); + await tester.pumpAndSettle(); + + expect(find.byType(AdaptiveTextSelectionToolbar), findsOneWidget); + expect(find.text('Print'), findsOneWidget); + + // Tap to dismiss. + await tester.tapAt(center); + await tester.pumpAndSettle(); + + expect(find.byType(AdaptiveTextSelectionToolbar), findsNothing); + + // Long pressing also shows the custom context menu. + await tester.longPressAt(center); + + expect(find.byType(AdaptiveTextSelectionToolbar), findsOneWidget); + expect(find.text('Print'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/context_menu/editable_text_toolbar_builder.0_test.dart b/novelforge-project/flutter/examples/api/test/material/context_menu/editable_text_toolbar_builder.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..b7b7adfe2462abe562290c41a7356fa4053c7ef5 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/context_menu/editable_text_toolbar_builder.0_test.dart @@ -0,0 +1,40 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_api_samples/material/context_menu/editable_text_toolbar_builder.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('showing and hiding the context menu in TextField with custom buttons', (WidgetTester tester) async { + await tester.pumpWidget( + const example.EditableTextToolbarBuilderExampleApp(), + ); + + expect(BrowserContextMenu.enabled, !kIsWeb); + + await tester.tap(find.byType(EditableText)); + await tester.pump(); + + expect(find.byType(AdaptiveTextSelectionToolbar), findsNothing); + + // Long pressing the field shows the default context menu but with custom + // buttons. + await tester.longPress(find.byType(EditableText)); + await tester.pumpAndSettle(); + + expect(find.byType(AdaptiveTextSelectionToolbar), findsOneWidget); + expect(find.byType(CupertinoButton), findsAtLeastNWidgets(1)); + + // Tap to dismiss. + await tester.tapAt(tester.getTopLeft(find.byType(EditableText))); + await tester.pumpAndSettle(); + + expect(find.byType(AdaptiveTextSelectionToolbar), findsNothing); + expect(find.byType(CupertinoButton), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/context_menu/editable_text_toolbar_builder.1_test.dart b/novelforge-project/flutter/examples/api/test/material/context_menu/editable_text_toolbar_builder.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..ed7e432927663bdd6864ec9ceecbcdc7f73dba59 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/context_menu/editable_text_toolbar_builder.1_test.dart @@ -0,0 +1,73 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/foundation.dart'; +import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_api_samples/material/context_menu/editable_text_toolbar_builder.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('showing and hiding the custom context menu in TextField with a specific selection', (WidgetTester tester) async { + await tester.pumpWidget( + const example.EditableTextToolbarBuilderExampleApp(), + ); + + expect(BrowserContextMenu.enabled, !kIsWeb); + + expect(find.byType(AdaptiveTextSelectionToolbar), findsNothing); + + // Right clicking the Text in the TextField shows the custom context menu, + // but no email button since no email address is selected. + TestGesture gesture = await tester.startGesture( + tester.getTopLeft(find.text(example.text)), + kind: PointerDeviceKind.mouse, + buttons: kSecondaryMouseButton, + ); + await tester.pump(); + await gesture.up(); + await tester.pumpAndSettle(); + + expect(find.byType(AdaptiveTextSelectionToolbar), findsOneWidget); + expect(find.text('Send email'), findsNothing); + + // Tap to dismiss. + await tester.tapAt(tester.getTopLeft(find.byType(EditableText))); + await tester.pumpAndSettle(); + + expect(find.byType(AdaptiveTextSelectionToolbar), findsNothing); + + // Select the email address. + final EditableTextState state = + tester.state(find.byType(EditableText)); + state.updateEditingValue(state.textEditingValue.copyWith( + selection: TextSelection( + baseOffset: example.text.indexOf(example.emailAddress), + extentOffset: example.text.length, + ), + )); + await tester.pump(); + + // Right clicking the Text in the TextField shows the custom context menu + // with the email button. + gesture = await tester.startGesture( + tester.getCenter(find.text(example.text)), + kind: PointerDeviceKind.mouse, + buttons: kSecondaryMouseButton, + ); + await tester.pump(); + await gesture.up(); + await tester.pumpAndSettle(); + + expect(find.byType(AdaptiveTextSelectionToolbar), findsOneWidget); + expect(find.text('Send email'), findsOneWidget); + + // Tap to dismiss. + await tester.tapAt(tester.getTopLeft(find.byType(EditableText))); + await tester.pumpAndSettle(); + + expect(find.byType(AdaptiveTextSelectionToolbar), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/context_menu/editable_text_toolbar_builder.2_test.dart b/novelforge-project/flutter/examples/api/test/material/context_menu/editable_text_toolbar_builder.2_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..2bcf2ea61d78a61d85d0edb160845116f53fd813 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/context_menu/editable_text_toolbar_builder.2_test.dart @@ -0,0 +1,63 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_api_samples/material/context_menu/editable_text_toolbar_builder.2.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('showing and hiding the context menu in TextField with a custom toolbar', (WidgetTester tester) async { + await tester.pumpWidget( + const example.EditableTextToolbarBuilderExampleApp(), + ); + + expect(BrowserContextMenu.enabled, !kIsWeb); + + await tester.tap(find.byType(EditableText)); + await tester.pump(); + + expect(find.byType(AdaptiveTextSelectionToolbar), findsNothing); + + // Long pressing the field shows the custom context menu. + await tester.longPress(find.byType(EditableText)); + await tester.pumpAndSettle(); + + expect(find.byType(AdaptiveTextSelectionToolbar), findsNothing); + + // The buttons use the default widgets but with custom labels. + switch (defaultTargetPlatform) { + case TargetPlatform.iOS: + expect(find.byType(CupertinoTextSelectionToolbarButton), findsAtLeastNWidgets(1)); + case TargetPlatform.android: + case TargetPlatform.fuchsia: + expect(find.byType(TextSelectionToolbarTextButton), findsAtLeastNWidgets(1)); + case TargetPlatform.linux: + case TargetPlatform.windows: + expect(find.byType(DesktopTextSelectionToolbarButton), findsAtLeastNWidgets(1)); + case TargetPlatform.macOS: + expect(find.byType(CupertinoDesktopTextSelectionToolbarButton), findsAtLeastNWidgets(1)); + } + expect(find.text('Copy'), findsNothing); + expect(find.text('Cut'), findsNothing); + expect(find.text('Paste'), findsNothing); + expect(find.text('Select all'), findsNothing); + + // Tap to dismiss. + await tester.tapAt(tester.getTopLeft(find.byType(EditableText))); + await tester.pumpAndSettle(); + + expect(find.byType(AdaptiveTextSelectionToolbar), findsNothing); + expect(find.byType(CupertinoTextSelectionToolbarButton), findsNothing); + expect(find.byType(TextSelectionToolbarTextButton), findsNothing); + expect(find.byType(DesktopTextSelectionToolbarButton), findsNothing); + expect(find.byType(CupertinoDesktopTextSelectionToolbarButton), findsNothing); + expect(find.text('Copy'), findsNothing); + expect(find.text('Cut'), findsNothing); + expect(find.text('Paste'), findsNothing); + expect(find.text('Select all'), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/context_menu/selectable_region_toolbar_builder.0_test.dart b/novelforge-project/flutter/examples/api/test/material/context_menu/selectable_region_toolbar_builder.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..a7147873fbe4a7359fc68586129720ba2f02cc11 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/context_menu/selectable_region_toolbar_builder.0_test.dart @@ -0,0 +1,50 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/foundation.dart'; +import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_api_samples/material/context_menu/selectable_region_toolbar_builder.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('showing and hiding the custom context menu on SelectionArea', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SelectableRegionToolbarBuilderExampleApp(), + ); + + expect(BrowserContextMenu.enabled, !kIsWeb); + + // Allow the selection overlay geometry to be created. + await tester.pumpAndSettle(); + + expect(find.byType(AdaptiveTextSelectionToolbar), findsNothing); + + // Right clicking the Text in the SelectionArea shows the custom context + // menu. + final TestGesture primaryMouseButtonGesture = await tester.createGesture( + kind: PointerDeviceKind.mouse, + ); + final TestGesture gesture = await tester.startGesture( + tester.getCenter(find.text(example.text)), + kind: PointerDeviceKind.mouse, + buttons: kSecondaryMouseButton, + ); + await tester.pump(); + await gesture.up(); + await tester.pumpAndSettle(); + + expect(find.byType(AdaptiveTextSelectionToolbar), findsOneWidget); + expect(find.text('Print'), findsOneWidget); + + // Tap to dismiss. + await primaryMouseButtonGesture.down(tester.getCenter(find.byType(Scaffold))); + await tester.pump(); + await primaryMouseButtonGesture.up(); + await tester.pumpAndSettle(); + + expect(find.byType(AdaptiveTextSelectionToolbar), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/data_table/data_table.0_test.dart b/novelforge-project/flutter/examples/api/test/material/data_table/data_table.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..346fbd5577c72cd1b7cc62e21b198a89fa2f384a --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/data_table/data_table.0_test.dart @@ -0,0 +1,35 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/data_table/data_table.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('DataTable Smoke Test', (WidgetTester tester) async { + await tester.pumpWidget( + const example.DataTableExampleApp(), + ); + expect(find.widgetWithText(AppBar, 'DataTable Sample'), findsOneWidget); + expect(find.byType(DataTable), findsOneWidget); + final DataTable dataTable = tester.widget(find.byType(DataTable)); + expect(dataTable.columns.length, 3); + expect(dataTable.rows.length, 3); + for (int i = 0; i < dataTable.rows.length; i++) { + expect(dataTable.rows[i].cells.length, 3); + } + expect(find.text('Name'), findsOneWidget); + expect(find.text('Age'), findsOneWidget); + expect(find.text('Role'), findsOneWidget); + expect(find.text('Sarah'), findsOneWidget); + expect(find.text('19'), findsOneWidget); + expect(find.text('Student'), findsOneWidget); + expect(find.text('Janine'), findsOneWidget); + expect(find.text('43'), findsOneWidget); + expect(find.text('Professor'), findsOneWidget); + expect(find.text('William'), findsOneWidget); + expect(find.text('27'), findsOneWidget); + expect(find.text('Associate Professor'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/data_table/data_table.1_test.dart b/novelforge-project/flutter/examples/api/test/material/data_table/data_table.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..6b14a8cefb721bb734b6a21632c1f1949ffac776 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/data_table/data_table.1_test.dart @@ -0,0 +1,24 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/data_table/data_table.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('DataTable is scrollable', (WidgetTester tester) async { + await tester.pumpWidget( + const example.DataTableExampleApp(), + ); + + expect(find.byType(SingleChildScrollView), findsOneWidget); + + expect(tester.getTopLeft(find.text('Row 5')), const Offset(66.0, 366.0)); + + await tester.drag(find.byType(SingleChildScrollView), const Offset(0.0, -200.0)); + await tester.pumpAndSettle(); + + expect(tester.getTopLeft(find.text('Row 5')), const Offset(66.0, 186.0)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/date_picker/date_picker_theme_day_shape.0_test.dart b/novelforge-project/flutter/examples/api/test/material/date_picker/date_picker_theme_day_shape.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..dc239d90494be63a5b0fcb7ed877bb6858587b0c --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/date_picker/date_picker_theme_day_shape.0_test.dart @@ -0,0 +1,55 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/date_picker/date_picker_theme_day_shape.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('DatePickerThemeData.dayShape updates day selection shape decoration', (WidgetTester tester) async { + final ThemeData theme = ThemeData(); + final OutlinedBorder dayShape = RoundedRectangleBorder(borderRadius: BorderRadius.circular(8.0)); + const Color todayBackgroundColor = Colors.amber; + const Color todayForegroundColor = Colors.black; + const BorderSide todayBorder = BorderSide(width: 2); + + await tester.pumpWidget( + const example.DatePickerApp(), + ); + + await tester.tap(find.text('Open Date Picker')); + await tester.pumpAndSettle(); + + ShapeDecoration dayShapeDecoration = tester.widget(find.ancestor( + of: find.text('15'), + matching: find.byType(DecoratedBox), + )).decoration as ShapeDecoration; + + // Test the current day shape decoration. + expect(dayShapeDecoration.color, todayBackgroundColor); + expect(dayShapeDecoration.shape, dayShape.copyWith(side: todayBorder.copyWith(color: todayForegroundColor))); + + dayShapeDecoration = tester.widget(find.ancestor( + of: find.text('20'), + matching: find.byType(DecoratedBox), + )).decoration as ShapeDecoration; + + // Test the selected day shape decoration. + expect(dayShapeDecoration.color, theme.colorScheme.primary); + expect(dayShapeDecoration.shape, dayShape); + + // Tap to select current day as the selected day. + await tester.tap(find.text('15')); + await tester.pumpAndSettle(); + + dayShapeDecoration = tester.widget(find.ancestor( + of: find.text('15'), + matching: find.byType(DecoratedBox), + )).decoration as ShapeDecoration; + + // Test the selected day shape decoration. + expect(dayShapeDecoration.color, todayBackgroundColor); + expect(dayShapeDecoration.shape, dayShape.copyWith(side: todayBorder.copyWith(color: todayForegroundColor))); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/date_picker/show_date_picker.0_test.dart b/novelforge-project/flutter/examples/api/test/material/date_picker/show_date_picker.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..732d0d992a12c1ed00138bc1672dec05175775ab --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/date_picker/show_date_picker.0_test.dart @@ -0,0 +1,46 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/date_picker/show_date_picker.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can show date picker', (WidgetTester tester) async { + const String datePickerTitle = 'Select date'; + const String initialDate = 'Sun, Jul 25'; + + await tester.pumpWidget( + const example.DatePickerApp(), + ); + + // The date picker is not shown initially. + expect(find.text(datePickerTitle), findsNothing); + expect(find.text(initialDate), findsNothing); + + // Tap the button to show the date picker. + await tester.tap(find.byType(OutlinedButton)); + await tester.pumpAndSettle(); + + // The initial date is shown. + expect(find.text(datePickerTitle), findsOneWidget); + expect(find.text(initialDate), findsOneWidget); + + // Tap another date to select it. + await tester.tap(find.text('30')); + await tester.pumpAndSettle(); + + // The selected date is shown. + expect(find.text(datePickerTitle), findsOneWidget); + expect(find.text('Fri, Jul 30'), findsOneWidget); + + // Tap OK to confirm the selection and close the date picker. + await tester.tap(find.text('OK')); + await tester.pumpAndSettle(); + + // The date picker is closed and the selected date is shown. + expect(find.text(datePickerTitle), findsNothing); + expect(find.text('Selected: 30/7/2021'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/date_picker/show_date_range_picker.0_test.dart b/novelforge-project/flutter/examples/api/test/material/date_picker/show_date_range_picker.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..36059487ab067a66fcc9b7424846580198ed5d1c --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/date_picker/show_date_range_picker.0_test.dart @@ -0,0 +1,51 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/date_picker/show_date_range_picker.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can show date range picker', (WidgetTester tester) async { + const String datePickerTitle = 'Select range'; + + await tester.pumpWidget( + const example.DatePickerApp(), + ); + + // The date range picker is not shown initially. + expect(find.text(datePickerTitle), findsNothing); + expect(find.text('Jan 1'), findsNothing); + expect(find.text('Jan 5, 2021'), findsNothing); + + // Tap the button to show the date range picker. + await tester.tap(find.byType(OutlinedButton)); + await tester.pumpAndSettle(); + + // The date range picker shows initial date range. + expect(find.text(datePickerTitle), findsOneWidget); + expect(find.text('Jan 1'), findsOneWidget); + expect(find.text('Jan 5, 2021'), findsOneWidget); + + // Tap to select new date range. + await tester.tap(find.text('18').first); + await tester.pumpAndSettle(); + await tester.tap(find.text('22').first); + await tester.pumpAndSettle(); + + // The selected date range is shown. + expect(find.text(datePickerTitle), findsOneWidget); + expect(find.text('Jan 18'), findsOneWidget); + expect(find.text('Jan 22, 2021'), findsOneWidget); + + // Tap Save to confirm the selection and close the date range picker. + await tester.tap(find.text('Save')); + await tester.pumpAndSettle(); + + // The date range picker is closed. + expect(find.text(datePickerTitle), findsNothing); + expect(find.text('Jan 18'), findsNothing); + expect(find.text('Jan 22, 2021'), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/dialog/adaptive_alert_dialog.0_test.dart b/novelforge-project/flutter/examples/api/test/material/dialog/adaptive_alert_dialog.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..b16048e125926cc6c2feb389e371047333dedf3c --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/dialog/adaptive_alert_dialog.0_test.dart @@ -0,0 +1,30 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/dialog/adaptive_alert_dialog.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Show Adaptive Alert dialog', (WidgetTester tester) async { + const String dialogTitle = 'AlertDialog Title'; + await tester.pumpWidget( + const MaterialApp( + home: Scaffold( + body: example.AdaptiveAlertDialogApp(), + ), + ), + ); + + expect(find.text(dialogTitle), findsNothing); + + await tester.tap(find.widgetWithText(TextButton, 'Show Dialog')); + await tester.pumpAndSettle(); + expect(find.text(dialogTitle), findsOneWidget); + + await tester.tap(find.text('OK')); + await tester.pumpAndSettle(); + expect(find.text(dialogTitle), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/dialog/alert_dialog.0_test.dart b/novelforge-project/flutter/examples/api/test/material/dialog/alert_dialog.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..550487b2feda55f7d031a9d9ce5af5e0020aecf6 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/dialog/alert_dialog.0_test.dart @@ -0,0 +1,30 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/dialog/alert_dialog.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Show Alert dialog', (WidgetTester tester) async { + const String dialogTitle = 'AlertDialog Title'; + await tester.pumpWidget( + const MaterialApp( + home: Scaffold( + body: example.AlertDialogExampleApp(), + ), + ), + ); + + expect(find.text(dialogTitle), findsNothing); + + await tester.tap(find.widgetWithText(TextButton, 'Show Dialog')); + await tester.pumpAndSettle(); + expect(find.text(dialogTitle), findsOneWidget); + + await tester.tap(find.text('OK')); + await tester.pumpAndSettle(); + expect(find.text(dialogTitle), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/dialog/alert_dialog.1_test.dart b/novelforge-project/flutter/examples/api/test/material/dialog/alert_dialog.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..6bf829e6605690bb03fcce52756b28d682b97e51 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/dialog/alert_dialog.1_test.dart @@ -0,0 +1,30 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/dialog/alert_dialog.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Show Alert dialog', (WidgetTester tester) async { + const String dialogTitle = 'AlertDialog Title'; + await tester.pumpWidget( + const MaterialApp( + home: Scaffold( + body: example.AlertDialogExampleApp(), + ), + ), + ); + + expect(find.text(dialogTitle), findsNothing); + + await tester.tap(find.widgetWithText(TextButton, 'Show Dialog')); + await tester.pumpAndSettle(); + expect(find.text(dialogTitle), findsOneWidget); + + await tester.tap(find.text('OK')); + await tester.pumpAndSettle(); + expect(find.text(dialogTitle), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/dialog/dialog.0_test.dart b/novelforge-project/flutter/examples/api/test/material/dialog/dialog.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..617c54667e5232dbd51d1db6700cfd7bf9b5d2f5 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/dialog/dialog.0_test.dart @@ -0,0 +1,53 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/dialog/dialog.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Show Dialog', (WidgetTester tester) async { + const String dialogText = 'This is a typical dialog.'; + + await tester.pumpWidget( + const MaterialApp( + home: Scaffold( + body: example.DialogExampleApp(), + ), + ), + ); + + expect(find.text(dialogText), findsNothing); + + await tester.tap(find.text('Show Dialog')); + await tester.pumpAndSettle(); + expect(find.text(dialogText), findsOneWidget); + + await tester.tap(find.text('Close')); + await tester.pumpAndSettle(); + expect(find.text(dialogText), findsNothing); + }); + + testWidgets('Show Dialog.fullscreen', (WidgetTester tester) async { + const String dialogText = 'This is a fullscreen dialog.'; + + await tester.pumpWidget( + const MaterialApp( + home: Scaffold( + body: example.DialogExampleApp(), + ), + ), + ); + + expect(find.text(dialogText), findsNothing); + + await tester.tap(find.text('Show Fullscreen Dialog')); + await tester.pumpAndSettle(); + expect(find.text(dialogText), findsOneWidget); + + await tester.tap(find.text('Close')); + await tester.pumpAndSettle(); + expect(find.text(dialogText), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/dialog/show_dialog.0_test.dart b/novelforge-project/flutter/examples/api/test/material/dialog/show_dialog.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..5bd4b3626bb70b35af5a56cf106f3ff3437af385 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/dialog/show_dialog.0_test.dart @@ -0,0 +1,30 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/dialog/show_dialog.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Show dialog', (WidgetTester tester) async { + const String dialogTitle = 'Basic dialog title'; + await tester.pumpWidget( + const MaterialApp( + home: Scaffold( + body: example.ShowDialogExampleApp(), + ), + ), + ); + + expect(find.text(dialogTitle), findsNothing); + + await tester.tap(find.widgetWithText(OutlinedButton, 'Open Dialog')); + await tester.pumpAndSettle(); + expect(find.text(dialogTitle), findsOneWidget); + + await tester.tap(find.text('Enable')); + await tester.pumpAndSettle(); + expect(find.text(dialogTitle), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/dialog/show_dialog.1_test.dart b/novelforge-project/flutter/examples/api/test/material/dialog/show_dialog.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..0cc8e83409b63f6df081c08a2fdf499c4a7bec47 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/dialog/show_dialog.1_test.dart @@ -0,0 +1,30 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/dialog/show_dialog.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Show dialog', (WidgetTester tester) async { + const String dialogTitle = 'Basic dialog title'; + await tester.pumpWidget( + const MaterialApp( + home: Scaffold( + body: example.ShowDialogExampleApp(), + ), + ), + ); + + expect(find.text(dialogTitle), findsNothing); + + await tester.tap(find.widgetWithText(OutlinedButton, 'Open Dialog')); + await tester.pumpAndSettle(); + expect(find.text(dialogTitle), findsOneWidget); + + await tester.tap(find.text('Enable')); + await tester.pumpAndSettle(); + expect(find.text(dialogTitle), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/dialog/show_dialog.2_test.dart b/novelforge-project/flutter/examples/api/test/material/dialog/show_dialog.2_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..06fe8ca4e2d18fe79bf4e28609fd6e747c1c39f0 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/dialog/show_dialog.2_test.dart @@ -0,0 +1,30 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/dialog/show_dialog.2.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Show dialog', (WidgetTester tester) async { + const String dialogTitle = 'Basic dialog title'; + await tester.pumpWidget( + const MaterialApp( + home: Scaffold( + body: example.ShowDialogExampleApp(), + ), + ), + ); + + expect(find.text(dialogTitle), findsNothing); + + await tester.tap(find.widgetWithText(OutlinedButton, 'Open Dialog')); + await tester.pumpAndSettle(); + expect(find.text(dialogTitle), findsOneWidget); + + await tester.tap(find.text('Enable')); + await tester.pumpAndSettle(); + expect(find.text(dialogTitle), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/divider/divider.0_test.dart b/novelforge-project/flutter/examples/api/test/material/divider/divider.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..ac135a18caa379eb271d8fa3966a3bbaf26acac2 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/divider/divider.0_test.dart @@ -0,0 +1,28 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/divider/divider.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Horizontal Divider', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: Scaffold( + body: example.DividerExampleApp(), + ), + ), + ); + + expect(find.byType(Divider), findsOneWidget); + + // Divider is positioned horizontally. + final Offset container = tester.getBottomLeft(find.byType(ColoredBox).first); + expect(container.dy, tester.getTopLeft(find.byType(Divider)).dy); + + final Offset subheader = tester.getTopLeft(find.text('Subheader')); + expect(subheader.dy, tester.getBottomLeft(find.byType(Divider)).dy); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/divider/divider.1_test.dart b/novelforge-project/flutter/examples/api/test/material/divider/divider.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..afd441ae64670b361f9b5056f327f196a2d5c579 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/divider/divider.1_test.dart @@ -0,0 +1,28 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/divider/divider.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Horizontal Divider', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: Scaffold( + body: example.DividerExampleApp(), + ), + ), + ); + + expect(find.byType(Divider), findsOneWidget); + + // Divider is positioned horizontally. + Offset card = tester.getBottomLeft(find.byType(Card).first); + expect(card.dy, tester.getTopLeft(find.byType(Divider)).dy); + + card = tester.getTopLeft(find.byType(Card).last); + expect(card.dy, tester.getBottomLeft(find.byType(Divider)).dy); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/divider/vertical_divider.0_test.dart b/novelforge-project/flutter/examples/api/test/material/divider/vertical_divider.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..3b61173784c81958e01f537211c8139226230dc4 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/divider/vertical_divider.0_test.dart @@ -0,0 +1,28 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/divider/vertical_divider.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Vertical Divider', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: Scaffold( + body: example.VerticalDividerExampleApp(), + ), + ), + ); + + expect(find.byType(VerticalDivider), findsOneWidget); + + // Divider is positioned horizontally. + Offset expanded = tester.getTopRight(find.byType(Expanded).first); + expect(expanded.dx, tester.getTopLeft(find.byType(VerticalDivider)).dx); + + expanded = tester.getTopLeft(find.byType(Expanded).last); + expect(expanded.dx, tester.getTopRight(find.byType(VerticalDivider)).dx); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/divider/vertical_divider.1_test.dart b/novelforge-project/flutter/examples/api/test/material/divider/vertical_divider.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..8dbe5c1ac442db20d4a4ba48558c7fee2192f001 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/divider/vertical_divider.1_test.dart @@ -0,0 +1,28 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/divider/vertical_divider.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Vertical Divider', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: Scaffold( + body: example.VerticalDividerExampleApp(), + ), + ), + ); + + expect(find.byType(VerticalDivider), findsOneWidget); + + // Divider is positioned vertically. + Offset card = tester.getTopRight(find.byType(Card).first); + expect(card.dx, tester.getTopLeft(find.byType(VerticalDivider)).dx); + + card = tester.getTopLeft(find.byType(Card).last); + expect(card.dx, tester.getTopRight(find.byType(VerticalDivider)).dx); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/drawer/drawer.0_test.dart b/novelforge-project/flutter/examples/api/test/material/drawer/drawer.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..6b942022173e18252a277fff99e4a27f40bf5979 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/drawer/drawer.0_test.dart @@ -0,0 +1,43 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/drawer/drawer.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Navigation bar updates destination on tap', + (WidgetTester tester) async { + await tester.pumpWidget( + const example.DrawerApp(), + ); + + await tester.tap(find.byIcon(Icons.menu)); + await tester.pumpAndSettle(); + + /// NavigationDestinations must be rendered + expect(find.text('Messages'), findsOneWidget); + expect(find.text('Profile'), findsOneWidget); + expect(find.text('Settings'), findsOneWidget); + + /// Initial index must be zero + expect(find.text('Page: '), findsOneWidget); + + /// Switch to second tab + await tester.tap(find.ancestor(of: find.text('Messages'), matching: find.byType(InkWell))); + await tester.pumpAndSettle(); + expect(find.text('Page: Messages'), findsOneWidget); + + /// Switch to third tab + await tester.tap(find.ancestor(of: find.text('Profile'), matching: find.byType(InkWell))); + await tester.pumpAndSettle(); + expect(find.text('Page: Profile'), findsOneWidget); + + /// Switch to fourth tab + await tester.tap(find.ancestor(of: find.text('Settings'), matching: find.byType(InkWell))); + await tester.pumpAndSettle(); + expect(find.text('Page: Settings'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/dropdown/dropdown_button.0_test.dart b/novelforge-project/flutter/examples/api/test/material/dropdown/dropdown_button.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..9ceca884dbef1a0c5595157f9430513710687e43 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/dropdown/dropdown_button.0_test.dart @@ -0,0 +1,27 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/dropdown/dropdown_button.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Select an item from DropdownButton', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: Scaffold( + body: example.DropdownButtonApp(), + ), + ), + ); + + expect(find.text('One'), findsOneWidget); + + await tester.tap(find.text('One')); + await tester.pumpAndSettle(); + await tester.tap(find.text('Two').last); + await tester.pumpAndSettle(); + expect(find.text('Two'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/dropdown/dropdown_button.selected_item_builder.0_test.dart b/novelforge-project/flutter/examples/api/test/material/dropdown/dropdown_button.selected_item_builder.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..b046d848727feb0ddad19ae1370ef20dfd8b9d80 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/dropdown/dropdown_button.selected_item_builder.0_test.dart @@ -0,0 +1,27 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/dropdown/dropdown_button.selected_item_builder.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Select an item from DropdownButton', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: Scaffold( + body: example.DropdownButtonApp(), + ), + ), + ); + + expect(find.text('NYC'), findsOneWidget); + + await tester.tap(find.text('NYC')); + await tester.pumpAndSettle(); + await tester.tap(find.text('San Francisco').last); + await tester.pumpAndSettle(); + expect(find.text('SF'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/dropdown/dropdown_button.style.0_test.dart b/novelforge-project/flutter/examples/api/test/material/dropdown/dropdown_button.style.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..b34e38ac9622b1ad31554aec559a98c9f30f5968 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/dropdown/dropdown_button.style.0_test.dart @@ -0,0 +1,30 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/dropdown/dropdown_button.style.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Select an item from DropdownButton', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: Scaffold( + body: example.DropdownButtonApp(), + ), + ), + ); + + expect(find.text('One'), findsOneWidget); + expect(find.text('One', skipOffstage: false), findsNWidgets(4)); + + await tester.tap(find.text('One').first); + await tester.pumpAndSettle(); + expect(find.text('Two'), findsOneWidget); + await tester.tap(find.text('Two')); + await tester.pumpAndSettle(); + expect(find.text('Two'), findsOneWidget); + expect(find.text('Two', skipOffstage: false), findsNWidgets(4)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/dropdown_menu/dropdown_menu.0_test.dart b/novelforge-project/flutter/examples/api/test/material/dropdown_menu/dropdown_menu.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..c1c662f0ec4c445f0b4e5937977cf68212386a7b --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/dropdown_menu/dropdown_menu.0_test.dart @@ -0,0 +1,77 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/dropdown_menu/dropdown_menu.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('DropdownMenu', (WidgetTester tester) async { + await tester.pumpWidget( + const example.DropdownMenuExample(), + ); + + expect(find.text('You selected a Blue Smile'), findsNothing); + + final Finder colorMenu = find.byType(DropdownMenu); + final Finder iconMenu = find.byType(DropdownMenu); + expect(colorMenu, findsOneWidget); + expect(iconMenu, findsOneWidget); + + Finder findMenuItem(String label) { + return find.widgetWithText(MenuItemButton, label).last; + } + + await tester.tap(colorMenu); + await tester.pumpAndSettle(); + expect(findMenuItem('Blue'), findsOneWidget); + expect(findMenuItem('Pink'), findsOneWidget); + expect(findMenuItem('Green'), findsOneWidget); + expect(findMenuItem('Orange'), findsOneWidget); + expect(findMenuItem('Grey'), findsOneWidget); + + await tester.tap(findMenuItem('Blue')); + + // The DropdownMenu's onSelected callback is delayed + // with SchedulerBinding.instance.addPostFrameCallback + // to give the focus a chance to return to where it was + // before the menu appeared. The pumpAndSettle() + // give the callback a chance to run. + await tester.pumpAndSettle(); + + await tester.tap(iconMenu); + await tester.pumpAndSettle(); + expect(findMenuItem('Smile'), findsOneWidget); + expect(findMenuItem('Cloud'), findsOneWidget); + expect(findMenuItem('Brush'), findsOneWidget); + expect(findMenuItem('Heart'), findsOneWidget); + + await tester.tap(findMenuItem('Smile')); + await tester.pumpAndSettle(); + + expect(find.text('You selected a Blue Smile'), findsOneWidget); + }); + + testWidgets('DropdownMenu has focus when tapping on the text field', (WidgetTester tester) async { + await tester.pumpWidget( + const example.DropdownMenuExample(), + ); + + // Make sure the dropdown menus are there. + final Finder colorMenu = find.byType(DropdownMenu); + final Finder iconMenu = find.byType(DropdownMenu); + expect(colorMenu, findsOneWidget); + expect(iconMenu, findsOneWidget); + + // Tap on the color menu and make sure it is focused. + await tester.tap(colorMenu); + await tester.pumpAndSettle(); + expect(FocusScope.of(tester.element(colorMenu)).hasFocus, isTrue); + + // Tap on the icon menu and make sure it is focused. + await tester.tap(iconMenu); + await tester.pumpAndSettle(); + expect(FocusScope.of(tester.element(iconMenu)).hasFocus, isTrue); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/dropdown_menu/dropdown_menu.1_test.dart b/novelforge-project/flutter/examples/api/test/material/dropdown_menu/dropdown_menu.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..8bc15dea02479830292559f51e3912ef8fa7b8b2 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/dropdown_menu/dropdown_menu.1_test.dart @@ -0,0 +1,56 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/dropdown_menu/dropdown_menu.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('The DropdownMenu should display a menu with the list of entries the user can select', (WidgetTester tester) async { + await tester.pumpWidget( + const example.DropdownMenuApp(), + ); + + expect(find.widgetWithText(TextField, 'One'), findsOne); + final Finder menu = find.byType(DropdownMenu); + expect(menu, findsOne); + + Finder findMenuItem(String label) { + return find.widgetWithText(MenuItemButton, label).last; + } + + await tester.tap(menu); + await tester.pumpAndSettle(); + expect(findMenuItem('One'), findsOne); + expect(findMenuItem('Two'), findsOne); + expect(findMenuItem('Three'), findsOne); + expect(findMenuItem('Four'), findsOne); + + await tester.tap(findMenuItem('Two')); + + // The DropdownMenu's onSelected callback is delayed + // with SchedulerBinding.instance.addPostFrameCallback + // to give the focus a chance to return to where it was + // before the menu appeared. The pumpAndSettle() + // give the callback a chance to run. + await tester.pumpAndSettle(); + + expect(find.widgetWithText(TextField, 'Two'), findsOne); + }); + + testWidgets('DropdownMenu has focus when tapping on the text field', (WidgetTester tester) async { + await tester.pumpWidget( + const example.DropdownMenuApp(), + ); + + // Make sure the dropdown menus are there. + final Finder menu = find.byType(DropdownMenu); + expect(menu, findsOne); + + // Tap on the menu and make sure it is focused. + await tester.tap(menu); + await tester.pumpAndSettle(); + expect(FocusScope.of(tester.element(menu)).hasFocus, isTrue); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/dropdown_menu/dropdown_menu.2_test.dart b/novelforge-project/flutter/examples/api/test/material/dropdown_menu/dropdown_menu.2_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..2e62b4228c41a875d91b4fbc53ac344afce18e11 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/dropdown_menu/dropdown_menu.2_test.dart @@ -0,0 +1,43 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:ui'; + +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; +import 'package:flutter_api_samples/material/dropdown_menu/dropdown_menu.2.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('DropdownMenu cursor behavior', (WidgetTester tester) async { + await tester.pumpWidget( + const example.DropdownMenuApp(), + ); + + Finder textFieldFinder(int index) { + return find.byType(TextField).at(index); + } + + // Hover over the "enabled and requestFocusOnTap set to true" text field. + final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse, pointer: 1); + await gesture.moveTo(tester.getCenter(textFieldFinder(0))); + + expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text); + + // Hover over the "enabled and requestFocusOnTap set to false" text field. + await gesture.moveTo(tester.getCenter(textFieldFinder(1))); + + expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.click); + + // Hover over the "disabled and requestFocusOnTap set to true" text field. + await gesture.moveTo(tester.getCenter(textFieldFinder(2))); + + expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic); + + // Hover over the "disabled and requestFocusOnTap set to false" text field. + await gesture.moveTo(tester.getCenter(textFieldFinder(3))); + + expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/dropdown_menu/dropdown_menu_entry_label_widget.0_test.dart b/novelforge-project/flutter/examples/api/test/material/dropdown_menu/dropdown_menu_entry_label_widget.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..773c991e9cc0890e52dcf93f5fb16f405b7c606d --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/dropdown_menu/dropdown_menu_entry_label_widget.0_test.dart @@ -0,0 +1,36 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/dropdown_menu/dropdown_menu_entry_label_widget.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('DropdownEntryLabelWidget appears', (WidgetTester tester) async { + await tester.pumpWidget( + const example.DropdownMenuEntryLabelWidgetExampleApp(), + ); + + const String longText = 'is a color that sings of hope, A hue that shines like gold. It is the color of dreams, A shade that never grows old.'; + Finder findMenuItemText(String label) { + final String labelText = '$label $longText\n'; + return find.descendant( + of: find.widgetWithText(MenuItemButton, labelText), + matching: find.byType(Text), + ).last; + } + + // Open the menu + await tester.tap(find.byType(TextField)); + expect(findMenuItemText('Blue'), findsOneWidget); + expect(findMenuItemText('Pink'), findsOneWidget); + expect(findMenuItemText('Green'), findsOneWidget); + expect(findMenuItemText('Yellow'), findsOneWidget); + expect(findMenuItemText('Grey'), findsOneWidget); + + // Close the menu + await tester.tap(find.byType(TextField)); + await tester.pumpAndSettle(); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/elevated_button/elevated_button.0_test.dart b/novelforge-project/flutter/examples/api/test/material/elevated_button/elevated_button.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..7a792195db98bd0d1de2367a785c8b0291f80654 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/elevated_button/elevated_button.0_test.dart @@ -0,0 +1,23 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/elevated_button/elevated_button.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('ElevatedButton Smoke Test', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ElevatedButtonExampleApp(), + ); + + expect(find.widgetWithText(AppBar, 'ElevatedButton Sample'), findsOneWidget); + final Finder disabledButton = find.widgetWithText(ElevatedButton, 'Disabled'); + expect(disabledButton, findsOneWidget); + expect(tester.widget(disabledButton).onPressed.runtimeType, Null); + final Finder enabledButton = find.widgetWithText(ElevatedButton, 'Enabled'); + expect(enabledButton, findsOneWidget); + expect(tester.widget(enabledButton).onPressed.runtimeType, VoidCallback); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/expansion_panel/expansion_panel_list.0_test.dart b/novelforge-project/flutter/examples/api/test/material/expansion_panel/expansion_panel_list.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..fc64f447c9d3db118e79eb82075c39be05b9fd9b --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/expansion_panel/expansion_panel_list.0_test.dart @@ -0,0 +1,75 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/expansion_panel/expansion_panel_list.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('ExpansionPanel can be expanded', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ExpansionPanelListExampleApp(), + ); + + // Verify the first tile is collapsed. + expect(tester.widget(find.byType(ExpandIcon).first).isExpanded, false); + + // Tap to expand the first tile. + await tester.tap(find.byType(ExpandIcon).first); + await tester.pumpAndSettle(); + + // Verify that the first tile is expanded. + expect(tester.widget(find.byType(ExpandIcon).first).isExpanded, true); + }); + + testWidgets('Tap to delete a ExpansionPanel', (WidgetTester tester) async { + const int index = 3; + + await tester.pumpWidget( + const example.ExpansionPanelListExampleApp(), + ); + + expect(find.widgetWithText(ListTile, 'Panel $index'), findsOneWidget); + expect(tester.widget(find.byType(ExpandIcon).at(index)).isExpanded, false); + + // Tap to expand the tile at index 3. + await tester.tap(find.byType(ExpandIcon).at(index)); + await tester.pumpAndSettle(); + + expect(tester.widget(find.byType(ExpandIcon).at(index)).isExpanded, true); + + // Tap to delete the tile at index 3. + await tester.tap(find.byIcon(Icons.delete).at(index)); + await tester.pumpAndSettle(); + + // Verify that the tile at index 3 is deleted. + expect(find.widgetWithText(ListTile, 'Panel $index'), findsNothing); + }); + + testWidgets('ExpansionPanelList is scrollable', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ExpansionPanelListExampleApp(), + ); + + expect(find.byType(SingleChildScrollView), findsOneWidget); + + // Expand all the tiles. + for (int i = 0; i < 8; i++) { + await tester.tap(find.byType(ExpandIcon).at(i)); + } + await tester.pumpAndSettle(); + + // Check panel 3 tile position. + Offset tilePosition = tester.getBottomLeft(find.widgetWithText(ListTile, 'Panel 3')); + expect(tilePosition.dy, 656.0); + + // Scroll up. + await tester.drag(find.byType(SingleChildScrollView), const Offset(0, -300)); + await tester.pumpAndSettle(); + + // Verify panel 3 tile position is updated after scrolling. + tilePosition = tester.getBottomLeft(find.widgetWithText(ListTile, 'Panel 3')); + expect(tilePosition.dy, 376.0); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/expansion_tile/expansion_tile.0_test.dart b/novelforge-project/flutter/examples/api/test/material/expansion_tile/expansion_tile.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..75c3246add952d9cb0efd71432d7b1905ce74b8e --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/expansion_tile/expansion_tile.0_test.dart @@ -0,0 +1,40 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/expansion_tile/expansion_tile.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('When expansion tiles are expanded tile numbers are revealed', (WidgetTester tester) async { + const int totalTiles = 3; + + await tester.pumpWidget( + const example.ExpansionTileApp(), + ); + + expect(find.byType(ExpansionTile), findsNWidgets(totalTiles)); + + const String tileOne = 'This is tile number 1'; + expect(find.text(tileOne), findsNothing); + + await tester.tap(find.text('ExpansionTile 1')); + await tester.pumpAndSettle(); + expect(find.text(tileOne), findsOneWidget); + + const String tileTwo = 'This is tile number 2'; + expect(find.text(tileTwo), findsNothing); + + await tester.tap(find.text('ExpansionTile 2')); + await tester.pumpAndSettle(); + expect(find.text(tileTwo), findsOneWidget); + + const String tileThree = 'This is tile number 3'; + expect(find.text(tileThree), findsNothing); + + await tester.tap(find.text('ExpansionTile 3')); + await tester.pumpAndSettle(); + expect(find.text(tileThree), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/expansion_tile/expansion_tile.1_test.dart b/novelforge-project/flutter/examples/api/test/material/expansion_tile/expansion_tile.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..1ecb31bee10db769fcf7db730b0e798f1bc06cfc --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/expansion_tile/expansion_tile.1_test.dart @@ -0,0 +1,31 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_api_samples/material/expansion_tile/expansion_tile.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Test the basics of ExpansionTileControllerApp', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ExpansionTileControllerApp(), + ); + + expect(find.text('ExpansionTile Contents'), findsNothing); + expect(find.text('Collapse This Tile'), findsNothing); + + await tester.tap(find.text('Expand/Collapse the Tile Above')); + await tester.pumpAndSettle(); + expect(find.text('ExpansionTile Contents'), findsOneWidget); + await tester.tap(find.text('Expand/Collapse the Tile Above')); + await tester.pumpAndSettle(); + expect(find.text('ExpansionTile Contents'), findsNothing); + + await tester.tap(find.text('ExpansionTile with implicit controller.')); + await tester.pumpAndSettle(); + expect(find.text('Collapse This Tile'), findsOneWidget); + await tester.tap(find.text('Collapse This Tile')); + await tester.pumpAndSettle(); + expect(find.text('Collapse This Tile'), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/expansion_tile/expansion_tile.2_test.dart b/novelforge-project/flutter/examples/api/test/material/expansion_tile/expansion_tile.2_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..97eeb14c9899ac5700aaa44ded2c2383fb333a45 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/expansion_tile/expansion_tile.2_test.dart @@ -0,0 +1,63 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/expansion_tile/expansion_tile.2.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('ExpansionTile animation can be customized using AnimationStyle', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ExpansionTileAnimationStyleApp(), + ); + + double getHeight(WidgetTester tester) { + return tester.getSize(find.byType(ExpansionTile)).height; + } + + expect(getHeight(tester), 58.0); + + // Test the default animation style. + await tester.tap(find.text('ExpansionTile')); + await tester.pump(); + await tester.pump(const Duration(milliseconds: 100)); + + expect(getHeight(tester), closeTo(93.4, 0.1)); + + await tester.pumpAndSettle(); + + expect(getHeight(tester), 170.0); + + // Tap to collapse. + await tester.tap(find.text('ExpansionTile')); + await tester.pumpAndSettle(); + + // Test the custom animation style. + await tester.tap(find.text('Custom')); + await tester.pumpAndSettle(); + + await tester.tap(find.text('ExpansionTile')); + await tester.pump(); + await tester.pump(const Duration(milliseconds: 100)); + + expect(getHeight(tester), closeTo(59.2, 0.1)); + + await tester.pumpAndSettle(); + + expect(getHeight(tester), 170.0); + + // Tap to collapse. + await tester.tap(find.text('ExpansionTile')); + await tester.pumpAndSettle(); + + // Test the no animation style. + await tester.tap(find.text('None')); + await tester.pumpAndSettle(); + + await tester.tap(find.text('ExpansionTile')); + await tester.pump(); + + expect(getHeight(tester), 170.0); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/filled_button/filled_button.0_test.dart b/novelforge-project/flutter/examples/api/test/material/filled_button/filled_button.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..0e3775ff37d26773b6f95c906a1775154f569a90 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/filled_button/filled_button.0_test.dart @@ -0,0 +1,25 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/filled_button/filled_button.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('FilledButton Smoke Test', (WidgetTester tester) async { + await tester.pumpWidget( + const example.FilledButtonApp(), + ); + + expect(find.widgetWithText(AppBar, 'FilledButton Sample'), findsOneWidget); + final Finder disabledButton = find.widgetWithText(FilledButton, 'Disabled'); + expect(disabledButton, findsNWidgets(2)); + expect(tester.widget(disabledButton.first).onPressed.runtimeType, Null); + expect(tester.widget(disabledButton.last).onPressed.runtimeType, Null); + final Finder enabledButton = find.widgetWithText(FilledButton, 'Enabled'); + expect(enabledButton, findsNWidgets(2)); + expect(tester.widget(enabledButton.first).onPressed.runtimeType, VoidCallback); + expect(tester.widget(enabledButton.last).onPressed.runtimeType, VoidCallback); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/filter_chip/filter_chip.0_test.dart b/novelforge-project/flutter/examples/api/test/material/filter_chip/filter_chip.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..92c2ac216ccfb9c22889f52243d5fe5e7f5e3d88 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/filter_chip/filter_chip.0_test.dart @@ -0,0 +1,36 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/filter_chip/filter_chip.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Filter exercises using FilterChip', (WidgetTester tester) async { + const String baseText = 'Looking for: '; + + await tester.pumpWidget( + const example.ChipApp(), + ); + + expect(find.text(baseText), findsOneWidget); + + FilterChip filterChip = tester.widget(find.byType(FilterChip).at(2)); + expect(filterChip.selected, false); + + await tester.tap(find.byType(FilterChip).at(2)); + await tester.pumpAndSettle(); + filterChip = tester.widget(find.byType(FilterChip).at(2)); + expect(filterChip.selected, true); + + expect(find.text('${baseText}cycling'), findsOneWidget); + + await tester.tap(find.byType(FilterChip).at(3)); + await tester.pumpAndSettle(); + filterChip = tester.widget(find.byType(FilterChip).at(3)); + expect(filterChip.selected, true); + + expect(find.text('${baseText}cycling, hiking'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/floating_action_button/floating_action_button.0_test.dart b/novelforge-project/flutter/examples/api/test/material/floating_action_button/floating_action_button.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..bb1f1cbb4bd7db2938d6785933c361ebcbe37fe0 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/floating_action_button/floating_action_button.0_test.dart @@ -0,0 +1,45 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/floating_action_button/floating_action_button.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('FloatingActionButton', (WidgetTester tester) async { + await tester.pumpWidget( + const example.FloatingActionButtonExampleApp(), + ); + + expect(find.byType(FloatingActionButton), findsOneWidget); + expect(find.byIcon(Icons.navigation), findsOneWidget); + + RawMaterialButton getRawMaterialButtonWidget() { + return tester.widget(find.byType(RawMaterialButton)); + } + + Color? getIconColor() { + final RichText iconRichText = tester.widget( + find.descendant(of: find.byIcon(Icons.navigation), matching: find.byType(RichText)), + ); + return iconRichText.text.style?.color; + } + + await tester.tap(find.byType(FloatingActionButton)); + await tester.pumpAndSettle(); // Wait for the animation to finish. + expect(getRawMaterialButtonWidget().fillColor, Colors.green); + + await tester.tap(find.byType(FloatingActionButton)); + await tester.pumpAndSettle(); // Wait for the animation to finish. + expect(getRawMaterialButtonWidget().fillColor, Colors.green); + expect(getIconColor(), Colors.white); + + await tester.tap(find.byType(FloatingActionButton)); + await tester.pumpAndSettle(); // Wait for the animation to finish. + expect(getRawMaterialButtonWidget().fillColor, Colors.green); + expect(getIconColor(), Colors.white); + expect(getRawMaterialButtonWidget().shape, const CircleBorder()); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/floating_action_button/floating_action_button.1_test.dart b/novelforge-project/flutter/examples/api/test/material/floating_action_button/floating_action_button.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..d503e5df27b7a53415dd0b1928f4c346e506fd6a --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/floating_action_button/floating_action_button.1_test.dart @@ -0,0 +1,49 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/floating_action_button/floating_action_button.1.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('FloatingActionButton variants', (WidgetTester tester) async { + RawMaterialButton getRawMaterialButtonWidget(Finder finder) { + return tester.widget(finder); + } + + await tester.pumpWidget( + const example.FloatingActionButtonExampleApp(), + ); + + final ThemeData theme = ThemeData(useMaterial3: true); + + expect(find.byType(FloatingActionButton), findsNWidgets(4)); + expect(find.byIcon(Icons.add), findsNWidgets(4)); + + final Finder smallFabMaterialButton = find.byType(RawMaterialButton).at(0); + final RenderBox smallFabRenderBox = tester.renderObject(smallFabMaterialButton); + expect(smallFabRenderBox.size, const Size(48.0, 48.0)); + expect(getRawMaterialButtonWidget(smallFabMaterialButton).fillColor, theme.colorScheme.primaryContainer); + expect(getRawMaterialButtonWidget(smallFabMaterialButton).shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(12.0))); + + final Finder regularFABMaterialButton = find.byType(RawMaterialButton).at(1); + final RenderBox regularFABRenderBox = tester.renderObject(regularFABMaterialButton); + expect(regularFABRenderBox.size, const Size(56.0, 56.0)); + expect(getRawMaterialButtonWidget(regularFABMaterialButton).fillColor, theme.colorScheme.primaryContainer); + expect(getRawMaterialButtonWidget(regularFABMaterialButton).shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(16.0))); + + final Finder largeFABMaterialButton = find.byType(RawMaterialButton).at(2); + final RenderBox largeFABRenderBox = tester.renderObject(largeFABMaterialButton); + expect(largeFABRenderBox.size, const Size(96.0, 96.0)); + expect(getRawMaterialButtonWidget(largeFABMaterialButton).fillColor, theme.colorScheme.primaryContainer); + expect(getRawMaterialButtonWidget(largeFABMaterialButton).shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(28.0))); + + final Finder extendedFABMaterialButton = find.byType(RawMaterialButton).at(3); + final RenderBox extendedFABRenderBox = tester.renderObject(extendedFABMaterialButton); + expect(extendedFABRenderBox.size, within(distance: 0.01, from: const Size(110.3, 56.0))); + expect(getRawMaterialButtonWidget(extendedFABMaterialButton).fillColor, theme.colorScheme.primaryContainer); + expect(getRawMaterialButtonWidget(extendedFABMaterialButton).shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(16.0))); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/floating_action_button/floating_action_button.2_test.dart b/novelforge-project/flutter/examples/api/test/material/floating_action_button/floating_action_button.2_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..1d4e9a26234ac518ba15e8027755ff4d8d00b1ad --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/floating_action_button/floating_action_button.2_test.dart @@ -0,0 +1,37 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/floating_action_button/floating_action_button.2.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('FloatingActionButton variants', (WidgetTester tester) async { + await tester.pumpWidget( + const example.FloatingActionButtonExampleApp(), + ); + + FloatingActionButton getFAB(Finder finder) { + return tester.widget(finder); + } + + final ColorScheme colorScheme = ThemeData(useMaterial3: true).colorScheme; + + // Test the FAB with surface color mapping. + FloatingActionButton fab = getFAB(find.byType(FloatingActionButton).at(0)); + expect(fab.foregroundColor, colorScheme.primary); + expect(fab.backgroundColor, colorScheme.surface); + + // Test the FAB with secondary color mapping. + fab = getFAB(find.byType(FloatingActionButton).at(1)); + expect(fab.foregroundColor, colorScheme.onSecondaryContainer); + expect(fab.backgroundColor, colorScheme.secondaryContainer); + + // Test the FAB with tertiary color mapping. + fab = getFAB(find.byType(FloatingActionButton).at(2)); + expect(fab.foregroundColor, colorScheme.onTertiaryContainer); + expect(fab.backgroundColor, colorScheme.tertiaryContainer); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/floating_action_button_location/standard_fab_location.0_test.dart b/novelforge-project/flutter/examples/api/test/material/floating_action_button_location/standard_fab_location.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..2e4d6495b3d683c7d3e4ae5eaaaee086ce9fb05f --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/floating_action_button_location/standard_fab_location.0_test.dart @@ -0,0 +1,20 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/floating_action_button_location/standard_fab_location.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('The FloatingActionButton should have a right padding', (WidgetTester tester) async { + await tester.pumpWidget( + const example.StandardFabLocationExampleApp(), + ); + + expect(find.widgetWithIcon(FloatingActionButton, Icons.add), findsOne); + final double right = tester.getCenter(find.byType(FloatingActionButton)).dx; + expect(right, closeTo(706, 1)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/icon_button/icon_button.0_test.dart b/novelforge-project/flutter/examples/api/test/material/icon_button/icon_button.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..94ce969c006b1d5fd851701e92e528e85abce585 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/icon_button/icon_button.0_test.dart @@ -0,0 +1,35 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/icon_button/icon_button.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('IconButton increments volume when tapped', (WidgetTester tester) async { + await tester.pumpWidget( + const example.IconButtonExampleApp(), + ); + + expect(find.byIcon(Icons.volume_up), findsOneWidget); + expect(find.text('Volume : 0.0'), findsOneWidget); + + await tester.tap(find.byType(IconButton)); + await tester.pumpAndSettle(); + + expect(find.text('Volume : 10.0'), findsOneWidget); + }); + + testWidgets('IconButton shows tooltip when long pressed', (WidgetTester tester) async { + await tester.pumpWidget( + const example.IconButtonExampleApp(), + ); + + expect(find.text('Increase volume by 10'), findsNothing); + await tester.longPress(find.byType(IconButton)); + await tester.pumpAndSettle(); + + expect(find.text('Increase volume by 10'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/icon_button/icon_button.1_test.dart b/novelforge-project/flutter/examples/api/test/material/icon_button/icon_button.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..92fc202401352c90536488144aebe02610de9786 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/icon_button/icon_button.1_test.dart @@ -0,0 +1,32 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/icon_button/icon_button.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('IconButton', (WidgetTester tester) async { + await tester.pumpWidget( + const example.IconButtonExampleApp(), + ); + + await tester.pumpAndSettle(); + + expect(find.byIcon(Icons.android), findsOneWidget); + final Ink ink = tester.widget( + find.ancestor( + of: find.byIcon(Icons.android), + matching: find.byType(Ink), + ), + ); + + final ShapeDecoration decoration = ink.decoration! as ShapeDecoration; + expect(decoration.color, Colors.lightBlue); + expect(decoration.shape, const CircleBorder()); + + final IconButton iconButton = ink.child! as IconButton; + expect(iconButton.color, Colors.white) ; + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/icon_button/icon_button.2_test.dart b/novelforge-project/flutter/examples/api/test/material/icon_button/icon_button.2_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..301de4efe9d8b561476ed0a13303f999c22de4c2 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/icon_button/icon_button.2_test.dart @@ -0,0 +1,23 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/icon_button/icon_button.2.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('IconButton Types', (WidgetTester tester) async { + await tester.pumpWidget( + const example.IconButtonApp(), + ); + expect(find.widgetWithIcon(IconButton, Icons.filter_drama), findsNWidgets(8)); + final Finder iconButtons = find.widgetWithIcon(IconButton, Icons.filter_drama); + for (int i = 0; i <= 3; i++) { + expect(tester.widget(iconButtons.at(i)).onPressed is VoidCallback, isTrue); + } + for (int i = 4; i <= 7; i++) { + expect(tester.widget(iconButtons.at(i)).onPressed, isNull); + } + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/icon_button/icon_button.3_test.dart b/novelforge-project/flutter/examples/api/test/material/icon_button/icon_button.3_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..b8002cc16e4a4f02067d91bb2ef3c1bede6031a9 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/icon_button/icon_button.3_test.dart @@ -0,0 +1,50 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/icon_button/icon_button.3.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('It should select and unselect the icon buttons', (WidgetTester tester) async { + await tester.pumpWidget( + const example.IconButtonToggleApp(), + ); + + expect(find.widgetWithIcon(IconButton, Icons.settings_outlined), findsExactly(8)); + final Finder unselectedIconButtons = find.widgetWithIcon(IconButton, Icons.settings_outlined); + for (int i = 0; i <= 6; i++) { + final IconButton button = tester.widget(unselectedIconButtons.at(i)); + expect(button.onPressed, i.isEven ? isA() : isNull); + expect(button.isSelected, isFalse); + } + + // Select the icons buttons. + for (int i = 0; i <= 3; i++) { + await tester.tap(unselectedIconButtons.at(2 * i)); + } + await tester.pump(); + + expect(find.widgetWithIcon(IconButton, Icons.settings), findsExactly(8)); + final Finder selectedIconButtons = find.widgetWithIcon(IconButton, Icons.settings); + for (int i = 0; i <= 6; i++) { + final IconButton button = tester.widget(selectedIconButtons.at(i)); + expect(button.onPressed, i.isEven ? isA() : isNull); + expect(button.isSelected, isTrue); + } + + // Unselect the icons buttons. + for (int i = 0; i <= 3; i++) { + await tester.tap(selectedIconButtons.at(2 * i)); + } + await tester.pump(); + + expect(find.widgetWithIcon(IconButton, Icons.settings_outlined), findsExactly(8)); + for (int i = 0; i <= 6; i++) { + final IconButton button = tester.widget(unselectedIconButtons.at(i)); + expect(button.onPressed, i.isEven ? isA() : isNull); + expect(button.isSelected, isFalse); + } + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/ink/ink.image_clip.0_test.dart b/novelforge-project/flutter/examples/api/test/material/ink/ink.image_clip.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..233b56fd8560af2aa008da5cbcf62ba6509cc2a4 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/ink/ink.image_clip.0_test.dart @@ -0,0 +1,34 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:typed_data'; + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/ink/ink.image_clip.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + const List kTransparentImage = [ + 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, + 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x06, + 0x00, 0x00, 0x00, 0x1F, 0x15, 0xC4, 0x89, 0x00, 0x00, 0x00, 0x0A, 0x49, 0x44, + 0x41, 0x54, 0x78, 0x9C, 0x63, 0x00, 0x01, 0x00, 0x00, 0x05, 0x00, 0x01, 0x0D, + 0x0A, 0x2D, 0xB4, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, + ]; + + testWidgets('Ink ancestor material is not clipped', (WidgetTester tester) async { + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: example.ImageClipExample( + image: MemoryImage(Uint8List.fromList(kTransparentImage)), + ), + ), + ), + ); + + final Finder inkMaterialFinder = find.ancestor(of: find.byType(Ink), matching: find.byType(Material)); + expect(find.ancestor(of: inkMaterialFinder, matching: find.byType(ClipRRect)), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/ink/ink.image_clip.1_test.dart b/novelforge-project/flutter/examples/api/test/material/ink/ink.image_clip.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..a1a19aeca6c3cc150862e3070b8d900d7e47e357 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/ink/ink.image_clip.1_test.dart @@ -0,0 +1,34 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:typed_data'; + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/ink/ink.image_clip.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + const List kTransparentImage = [ + 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, + 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x06, + 0x00, 0x00, 0x00, 0x1F, 0x15, 0xC4, 0x89, 0x00, 0x00, 0x00, 0x0A, 0x49, 0x44, + 0x41, 0x54, 0x78, 0x9C, 0x63, 0x00, 0x01, 0x00, 0x00, 0x05, 0x00, 0x01, 0x0D, + 0x0A, 0x2D, 0xB4, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, + ]; + + testWidgets('Ink ancestor material is clipped', (WidgetTester tester) async { + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: example.ImageClipExample( + image: MemoryImage(Uint8List.fromList(kTransparentImage)), + ), + ), + ), + ); + + final Finder inkMaterialFinder = find.ancestor(of: find.byType(Ink), matching: find.byType(Material)); + expect(find.ancestor(of: inkMaterialFinder, matching: find.byType(ClipRRect)), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/ink_well/ink_well.0_test.dart b/novelforge-project/flutter/examples/api/test/material/ink_well/ink_well.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..f48c4c9f0e8d48e880af8ea90e7c6201a109ae65 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/ink_well/ink_well.0_test.dart @@ -0,0 +1,34 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/ink_well/ink_well.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Clicking on InkWell changes the Size of 50x50 AnimatedContainer to 100x100 and vice versa', (WidgetTester tester) async { + await tester.pumpWidget( + const example.InkWellExampleApp(), + ); + expect(find.widgetWithText(AppBar, 'InkWell Sample'), findsOneWidget); + final Finder inkWell = find.byType(InkWell); + final InkWell inkWellWidget = tester.widget(inkWell); + final Finder animatedContainer = find.byType(AnimatedContainer); + AnimatedContainer animatedContainerWidget = tester.widget(animatedContainer); + expect(inkWell, findsOneWidget); + expect(inkWellWidget.onTap.runtimeType, VoidCallback); + expect(animatedContainerWidget.constraints?.minWidth, 50); + expect(animatedContainerWidget.constraints?.minHeight, 50); + await tester.tap(inkWell); + await tester.pumpAndSettle(); + animatedContainerWidget = tester.widget(animatedContainer); + expect(animatedContainerWidget.constraints?.minWidth, 100); + expect(animatedContainerWidget.constraints?.minHeight, 100); + await tester.tap(inkWell); + await tester.pumpAndSettle(); + animatedContainerWidget = tester.widget(animatedContainer); + expect(animatedContainerWidget.constraints?.minWidth, 50); + expect(animatedContainerWidget.constraints?.minHeight, 50); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/input_chip/input_chip.0_test.dart b/novelforge-project/flutter/examples/api/test/material/input_chip/input_chip.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..c8f1ec0dd2463f01fe7f5ee1ecdc0d256aa4256a --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/input_chip/input_chip.0_test.dart @@ -0,0 +1,33 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/input_chip/input_chip.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ChipApp(), + ); + + expect(find.byType(InputChip), findsNWidgets(3)); + + await tester.tap(find.byIcon(Icons.clear).at(0)); + await tester.pumpAndSettle(); + expect(find.byType(InputChip), findsNWidgets(2)); + + await tester.tap(find.byIcon(Icons.clear).at(0)); + await tester.pumpAndSettle(); + expect(find.byType(InputChip), findsNWidgets(1)); + + await tester.tap(find.byIcon(Icons.clear).at(0)); + await tester.pumpAndSettle(); + expect(find.byType(InputChip), findsNWidgets(0)); + + await tester.tap(find.text('Reset')); + await tester.pumpAndSettle(); + expect(find.byType(InputChip), findsNWidgets(3)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/input_chip/input_chip.1_test.dart b/novelforge-project/flutter/examples/api/test/material/input_chip/input_chip.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..e55a483efd76180674f25f5af55282a090131517 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/input_chip/input_chip.1_test.dart @@ -0,0 +1,62 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/input_chip/input_chip.1.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + final String replacementChar = String.fromCharCode( + example.ChipsInputEditingController.kObjectReplacementChar); + + testWidgets('User input generates InputChips', (WidgetTester tester) async { + await tester.pumpWidget( + const example.EditableChipFieldApp(), + ); + await tester.pumpAndSettle(); + + expect(find.byType(example.EditableChipFieldApp), findsOneWidget); + expect(find.byType(example.ChipsInput), findsOneWidget); + expect(find.byType(InputChip), findsOneWidget); + + example.ChipsInputState state = + tester.state(find.byType(example.ChipsInput)); + expect(state.controller.textWithoutReplacements.isEmpty, true); + + await tester.tap(find.byType(example.ChipsInput)); + await tester.pumpAndSettle(); + expect(tester.testTextInput.isVisible, true); + // Simulating text typing on the input field. + tester.testTextInput.enterText('${replacementChar}ham'); + await tester.pumpAndSettle(); + expect(find.byType(InputChip), findsOneWidget); + + state = tester.state(find.byType(example.ChipsInput)); + await tester.pumpAndSettle(); + expect(state.controller.textWithoutReplacements, 'ham'); + + // Add new InputChip by sending the "done" action. + await tester.testTextInput.receiveAction(TextInputAction.done); + await tester.pumpAndSettle(); + expect(state.controller.textWithoutReplacements.isEmpty, true); + + expect(find.byType(InputChip), findsNWidgets(2)); + + // Simulate item deletion. + await tester.tap(find.descendant( + of: find.byType(InputChip), + matching: find.byType(InkWell).last, + )); + await tester.pumpAndSettle(); + expect(find.byType(InputChip), findsOneWidget); + + await tester.tap(find.descendant( + of: find.byType(InputChip), + matching: find.byType(InkWell).last, + )); + await tester.pumpAndSettle(); + expect(find.byType(InputChip), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.0_test.dart b/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..3abb7db2753f43d05a036a8e3591deea4fde0c13 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.0_test.dart @@ -0,0 +1,23 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/input_decorator/input_decoration.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('TextField is decorated', (WidgetTester tester) async { + await tester.pumpWidget( + const example.InputDecorationExampleApp(), + ); + expect(find.text('InputDecoration Sample'), findsOneWidget); + + expect(find.byType(TextField), findsOneWidget); + expect(find.text('Hint Text'), findsOneWidget); + expect(find.text('Helper Text'), findsOneWidget); + expect(find.text('0 characters'), findsOneWidget); + + expect(find.byIcon(Icons.send), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.1_test.dart b/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..f619244247751ddb81d9daa8d042bc9049b6bda1 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.1_test.dart @@ -0,0 +1,28 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/input_decorator/input_decoration.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('TextField is decorated', (WidgetTester tester) async { + await tester.pumpWidget( + const example.InputDecorationExampleApp(), + ); + expect(find.text('InputDecoration Sample'), findsOneWidget); + + expect(find.byType(TextField), findsOneWidget); + expect(find.text('Hint Text'), findsOneWidget); + + expect( + tester.widget(find.byType(TextField)).decoration?.contentPadding, + EdgeInsets.zero, + ); + expect( + tester.widget(find.byType(TextField)).decoration?.border, + const OutlineInputBorder(), + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.2_test.dart b/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.2_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..cf45965d873daa29af1b9e138dabf4e739ac0a6e --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.2_test.dart @@ -0,0 +1,27 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/input_decorator/input_decoration.2.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('TextField is decorated', (WidgetTester tester) async { + await tester.pumpWidget( + const example.InputDecorationExampleApp(), + ); + expect(find.text('InputDecoration Sample'), findsOneWidget); + + expect(find.byType(TextField), findsOneWidget); + expect(find.text('Hint Text'), findsOneWidget); + expect(find.text('Error Text'), findsOneWidget); + + expect( + tester.widget(find.byType(TextField)) + .decoration + ?.border, + isNotNull, + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.3_test.dart b/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.3_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..9974ca8c88030bf7dd15b49e12633c2de55059c3 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.3_test.dart @@ -0,0 +1,41 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/input_decorator/input_decoration.3.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('TextFormField is decorated', (WidgetTester tester) async { + await tester.pumpWidget( + const example.InputDecorationExampleApp(), + ); + expect(find.text('InputDecoration Sample'), findsOneWidget); + + expect(find.byType(TextFormField), findsOneWidget); + expect(find.text('Prefix'), findsOneWidget); + expect(find.text('abc'), findsOneWidget); + expect(find.text('Suffix'), findsOneWidget); + expect( + tester.widget(find.byType(TextField)).decoration?.border, + const OutlineInputBorder(), + ); + }); + + testWidgets('Decorations are correctly ordered', (WidgetTester tester) async { + await tester.pumpWidget( + const example.InputDecorationExampleApp(), + ); + expect(find.text('InputDecoration Sample'), findsOneWidget); + + expect(find.byType(TextFormField), findsOneWidget); + + final double prefixX = tester.getCenter(find.text('Prefix')).dx; + final double contentX = tester.getCenter(find.text('abc')).dx; + final double suffixX = tester.getCenter(find.text('Suffix')).dx; + + expect(prefixX, lessThan(contentX)); + expect(contentX, lessThan(suffixX)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.floating_label_style_error.0_test.dart b/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.floating_label_style_error.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..0ee58183e45be645fa2d46a7307649e0692b1ebd --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.floating_label_style_error.0_test.dart @@ -0,0 +1,22 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/input_decorator/input_decoration.floating_label_style_error.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('InputDecorator label uses error color', (WidgetTester tester) async { + await tester.pumpWidget( + const example.FloatingLabelStyleErrorExampleApp(), + ); + final Theme theme = tester.firstWidget(find.byType(Theme)); + + await tester.tap(find.byType(TextFormField)); + await tester.pumpAndSettle(); + + final AnimatedDefaultTextStyle label = tester.firstWidget(find.ancestor(of: find.text('Name'), matching: find.byType(AnimatedDefaultTextStyle))); + expect(label.style.color, theme.data.colorScheme.error); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.helper.0_test.dart b/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.helper.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..ece9852df42656551bb9bcf37f95cf9a8ac5b642 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.helper.0_test.dart @@ -0,0 +1,19 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/input_decorator/input_decoration.helper.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Shows multi element InputDecorator help decoration', (WidgetTester tester) async { + await tester.pumpWidget( + const example.HelperExampleApp(), + ); + + expect(find.byType(TextField), findsOneWidget); + expect(find.text('Helper Text '), findsOneWidget); + expect(find.byIcon(Icons.help_outline), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.label.0_test.dart b/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.label.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..7cd71bda33b6f8118a27dc5fc239395659e390cf --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.label.0_test.dart @@ -0,0 +1,20 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/input_decorator/input_decoration.label.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Decorates TextField in sample app with label', (WidgetTester tester) async { + await tester.pumpWidget( + const example.LabelExampleApp(), + ); + expect(find.text('InputDecoration.label Sample'), findsOneWidget); + + expect(find.byType(TextField), findsOneWidget); + expect(find.text('Username'), findsOneWidget); + expect(find.text('*'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.label_style_error.0_test.dart b/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.label_style_error.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..640b8fd228a0874d1408679fd920846dd0645eae --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.label_style_error.0_test.dart @@ -0,0 +1,19 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/input_decorator/input_decoration.label_style_error.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('InputDecorator label uses error color', (WidgetTester tester) async { + await tester.pumpWidget( + const example.LabelStyleErrorExampleApp(), + ); + final Theme theme = tester.firstWidget(find.byType(Theme)); + + final AnimatedDefaultTextStyle label = tester.firstWidget(find.ancestor(of: find.text('Name'), matching: find.byType(AnimatedDefaultTextStyle))); + expect(label.style.color, theme.data.colorScheme.error); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.prefix_icon.0_test.dart b/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.prefix_icon.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..359f1fd1f555653d264c8a5fe3dea13916ea86b5 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.prefix_icon.0_test.dart @@ -0,0 +1,16 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/input_decorator/input_decoration.prefix_icon.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('InputDecorator prefixIcon alignment', (WidgetTester tester) async { + await tester.pumpWidget( + const example.PrefixIconExampleApp(), + ); + expect(tester.getCenter(find.byIcon(Icons.person)).dy, 32.0); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.prefix_icon_constraints.0_test.dart b/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.prefix_icon_constraints.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..a83252be8579e7903e21656c4c50848a35e0c986 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.prefix_icon_constraints.0_test.dart @@ -0,0 +1,71 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/input_decorator/input_decoration.prefix_icon_constraints.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Shows two TextFields decorated with prefix icon sizes matching their hint text', (WidgetTester tester) async { + await tester.pumpWidget( + const example.PrefixIconConstraintsExampleApp(), + ); + expect(find.text('InputDecoration Sample'), findsOneWidget); + + expect(find.byType(TextField), findsNWidgets(2)); + expect(find.byIcon(Icons.search), findsNWidgets(2)); + expect(find.text('Normal Icon Constraints'), findsOneWidget); + expect(find.text('Smaller Icon Constraints'), findsOneWidget); + + final Finder normalIcon = find.descendant( + of: find.ancestor( + of: find.text('Normal Icon Constraints'), + matching: find.byType(TextField), + ), + matching: find.byIcon(Icons.search), + ); + final Finder smallerIcon = find.descendant( + of: find.ancestor( + of: find.text('Smaller Icon Constraints'), + matching: find.byType(TextField), + ), + matching: find.byIcon(Icons.search), + ); + + expect( + tester.getSize(normalIcon).longestSide, + greaterThan(tester.getSize(smallerIcon).longestSide), + ); + }); + + testWidgets('prefixIcons are placed left of hintText', (WidgetTester tester) async { + await tester.pumpWidget( + const example.PrefixIconConstraintsExampleApp(), + ); + + final Finder normalIcon = find.descendant( + of: find.ancestor( + of: find.text('Normal Icon Constraints'), + matching: find.byType(TextField), + ), + matching: find.byIcon(Icons.search), + ); + final Finder smallerIcon = find.descendant( + of: find.ancestor( + of: find.text('Smaller Icon Constraints'), + matching: find.byType(TextField), + ), + matching: find.byIcon(Icons.search), + ); + + expect( + tester.getCenter(find.text('Normal Icon Constraints')).dx, + greaterThan(tester.getCenter(normalIcon).dx), + ); + expect( + tester.getCenter(find.text('Smaller Icon Constraints')).dx, + greaterThan(tester.getCenter(smallerIcon).dx), + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.suffix_icon.0_test.dart b/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.suffix_icon.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..0d26b422e4a112e29a8e980cb6a24cb63a086f4c --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.suffix_icon.0_test.dart @@ -0,0 +1,16 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/input_decorator/input_decoration.suffix_icon.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('InputDecorator suffixIcon alignment', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SuffixIconExampleApp(), + ); + expect(tester.getCenter(find.byIcon(Icons.remove_red_eye)).dy, 32.0); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.suffix_icon_constraints.0_test.dart b/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.suffix_icon_constraints.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..0a4c09a178279f1f0fe10cd1bc6b02ff8dc60ea5 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.suffix_icon_constraints.0_test.dart @@ -0,0 +1,69 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/input_decorator/input_decoration.suffix_icon_constraints.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Shows two TextFields decorated with suffix icon sizes matching their hint text', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SuffixIconConstraintsExampleApp(), + ); + expect(find.text('InputDecoration Sample'), findsOneWidget); + + expect(find.byType(TextField), findsNWidgets(2)); + expect(find.byIcon(Icons.search), findsNWidgets(2)); + expect(find.text('Normal Icon Constraints'), findsOneWidget); + expect(find.text('Smaller Icon Constraints'), findsOneWidget); + + final Finder normalIcon = find.descendant( + of: find.ancestor( + of: find.text('Normal Icon Constraints'), + matching: find.byType(TextField), + ), + matching: find.byIcon(Icons.search), + ); + final Finder smallerIcon = find.descendant( + of: find.ancestor( + of: find.text('Smaller Icon Constraints'), + matching: find.byType(TextField), + ), + matching: find.byIcon(Icons.search), + ); + + expect(tester.getSize(normalIcon).longestSide, + greaterThan(tester.getSize(smallerIcon).longestSide)); + }); + + testWidgets('suffixIcons are placed right of hintText', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SuffixIconConstraintsExampleApp(), + ); + + final Finder normalIcon = find.descendant( + of: find.ancestor( + of: find.text('Normal Icon Constraints'), + matching: find.byType(TextField), + ), + matching: find.byIcon(Icons.search), + ); + final Finder smallerIcon = find.descendant( + of: find.ancestor( + of: find.text('Smaller Icon Constraints'), + matching: find.byType(TextField), + ), + matching: find.byIcon(Icons.search), + ); + + expect( + tester.getCenter(find.text('Normal Icon Constraints')).dx, + lessThan(tester.getCenter(normalIcon).dx), + ); + expect( + tester.getCenter(find.text('Smaller Icon Constraints')).dx, + lessThan(tester.getCenter(smallerIcon).dx), + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.widget_state.0_test.dart b/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.widget_state.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..c1efad4151e95dc7d67471503b942dd50f2336f7 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.widget_state.0_test.dart @@ -0,0 +1,27 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/input_decorator/input_decoration.widget_state.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('TextFormField updates decorations depending on state', (WidgetTester tester) async { + await tester.pumpWidget( + const example.MaterialStateExampleApp(), + ); + expect(find.text('InputDecoration Sample'), findsOneWidget); + + expect(find.byType(TextFormField), findsOneWidget); + expect(find.text('abc'), findsOneWidget); + expect(find.byIcon(Icons.person), findsOneWidget); + + expect( + tester.widget(find.byType(TextField)).decoration?.prefixIconColor, + isA() + .having((WidgetStateColor color) => color.resolve({}), 'default', Colors.grey) + .having((WidgetStateColor color) => color.resolve({WidgetState.focused}), 'focused', Colors.green), + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.widget_state.1_test.dart b/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.widget_state.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..20a20ca8f3338915276d00eecdaa09afe62c3e5e --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/input_decorator/input_decoration.widget_state.1_test.dart @@ -0,0 +1,40 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/input_decorator/input_decoration.widget_state.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('TextFormField updates decorations depending on state', (WidgetTester tester) async { + await tester.pumpWidget( + const example.MaterialStateExampleApp(), + ); + expect(find.text('InputDecoration Sample'), findsOneWidget); + + expect(find.byType(TextFormField), findsOneWidget); + expect(find.text('example.com'), findsOneWidget); + expect(find.byIcon(Icons.web), findsOneWidget); + + expect( + tester.widget(find.byType(TextField)).decoration?.prefixIconColor, + isA() + .having((WidgetStateColor color) => color.resolve({}), 'default', Colors.grey) + .having((WidgetStateColor color) => color.resolve({WidgetState.focused}), 'focused', Colors.blue) + .having((WidgetStateColor color) => color.resolve({WidgetState.error}), 'error', Colors.red) + .having((WidgetStateColor color) => color.resolve({WidgetState.error, WidgetState.focused}), 'error', Colors.red), + ); + }); + + testWidgets('Validates field input', (WidgetTester tester) async { + await tester.pumpWidget( + const example.MaterialStateExampleApp(), + ); + + expect(find.text('No .com tld'), findsNothing); + await tester.enterText(find.byType(TextFormField), 'noUrl'); + await tester.pump(); + expect(find.text('No .com tld'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/list_tile/custom_list_item.0_test.dart b/novelforge-project/flutter/examples/api/test/material/list_tile/custom_list_item.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..3aec3a3a217481f5615a43e909c99a0d17e312bb --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/list_tile/custom_list_item.0_test.dart @@ -0,0 +1,43 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/list_tile/custom_list_item.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Custom list item uses Expanded widgets for the layout', (WidgetTester tester) async { + await tester.pumpWidget( + const example.CustomListItemApp(), + ); + + // The Expanded widget is used to control the size of the thumbnail. + Expanded thumbnailExpanded = tester.widget(find.ancestor( + of: find.byType(Container).first, + matching: find.byType(Expanded), + )); + expect(thumbnailExpanded.flex, 2); + + // The Expanded widget is used to control the size of the text. + Expanded textExpanded = tester.widget(find.ancestor( + of: find.text('The Flutter YouTube Channel'), + matching: find.byType(Expanded), + )); + expect(textExpanded.flex, 3); + + // The Expanded widget is used to control the size of the thumbnail. + thumbnailExpanded = tester.widget(find.ancestor( + of: find.byType(Container).last, + matching: find.byType(Expanded), + )); + expect(thumbnailExpanded.flex, 2); + + // The Expanded widget is used to control the size of the text. + textExpanded = tester.widget(find.ancestor( + of: find.text('Announcing Flutter 1.0'), + matching: find.byType(Expanded), + )); + expect(textExpanded.flex, 3); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/list_tile/custom_list_item.1_test.dart b/novelforge-project/flutter/examples/api/test/material/list_tile/custom_list_item.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..862350b60c27a6791d8f3ad761f25212a9ccdd0e --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/list_tile/custom_list_item.1_test.dart @@ -0,0 +1,36 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/list_tile/custom_list_item.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Custom list item uses AspectRatio and Expanded widgets for the layout', (WidgetTester tester) async { + await tester.pumpWidget( + const example.CustomListItemApp(), + ); + + // The AspectRatio widget is used to constrain the size of the thumbnail. + AspectRatio thumbnailAspectRatio = tester.widget(find.ancestor( + of: find.byType(Container).first, + matching: find.byType(AspectRatio), + )); + expect(thumbnailAspectRatio.aspectRatio, 1.0); + + // The Expanded widget is used to control the size of the text. + final Expanded textExpanded = tester.widget(find.ancestor( + of: find.text('Flutter 1.0 Launch'), + matching: find.byType(Expanded).at(0), + )); + expect(textExpanded.flex, 1); + + // The AspectRatio widget is used to constrain the size of the thumbnail. + thumbnailAspectRatio = tester.widget(find.ancestor( + of: find.byType(Container).last, + matching: find.byType(AspectRatio), + )); + expect(thumbnailAspectRatio.aspectRatio, 1.0); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/list_tile/list_tile.0_test.dart b/novelforge-project/flutter/examples/api/test/material/list_tile/list_tile.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..7b11b573792f450ebca707a39126d581c5721a0c --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/list_tile/list_tile.0_test.dart @@ -0,0 +1,35 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/list_tile/list_tile.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('ListTile with Hero does not throw', (WidgetTester tester) async { + const int totalTiles = 3; + + await tester.pumpWidget( + const example.ListTileApp(), + ); + + expect(find.byType(ListTile), findsNWidgets(totalTiles)); + + const String heroTransitionText = 'Tap here for Hero transition'; + const String goBackText = 'Tap here to go back'; + + expect(find.text(heroTransitionText), findsOneWidget); + expect(find.text(goBackText), findsNothing); + + // Tap on the ListTile widget to trigger the Hero transition. + await tester.tap(find.text(heroTransitionText)); + await tester.pumpAndSettle(); + + // The Hero transition is triggered and tap to go back text is displayed. + expect(find.text(heroTransitionText), findsNothing); + expect(find.text(goBackText), findsOneWidget); + + expect(tester.takeException(), null); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/list_tile/list_tile.1_test.dart b/novelforge-project/flutter/examples/api/test/material/list_tile/list_tile.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..c651aceed56507d1388e18ad98aeb75d5dd83fe8 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/list_tile/list_tile.1_test.dart @@ -0,0 +1,30 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/list_tile/list_tile.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('ListTiles wrapped in Card widgets', (WidgetTester tester) async { + const int totalTiles = 7; + + await tester.pumpWidget( + const example.ListTileApp(), + ); + + expect(find.byType(ListTile), findsNWidgets(totalTiles)); + + // The ListTile widget is wrapped in a Card widget. + for (int i = 0; i < totalTiles; i++) { + expect( + find.ancestor( + of: find.byType(ListTile).at(i), + matching: find.byType(Card).at(i), + ), + findsOneWidget, + ); + } + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/list_tile/list_tile.2_test.dart b/novelforge-project/flutter/examples/api/test/material/list_tile/list_tile.2_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..ba26d0a34d840f79dbd461a6f11315074f2ed573 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/list_tile/list_tile.2_test.dart @@ -0,0 +1,41 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/list_tile/list_tile.2.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('ListTile leading and trailing widgets are aligned appropriately', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ListTileApp(), + ); + + expect(find.byType(ListTile), findsNWidgets(3)); + + Offset listTileTopLeft = tester.getTopLeft(find.byType(ListTile).at(0)); + Offset leadingTopLeft = tester.getTopLeft(find.byType(CircleAvatar).at(0)); + Offset trailingTopLeft = tester.getTopLeft(find.byType(Icon).at(0)); + + // The leading and trailing widgets are centered vertically with the text. + expect(leadingTopLeft - listTileTopLeft, const Offset(16.0, 16.0)); + expect(trailingTopLeft - listTileTopLeft, const Offset(752.0, 24.0)); + + listTileTopLeft = tester.getTopLeft(find.byType(ListTile).at(1)); + leadingTopLeft = tester.getTopLeft(find.byType(CircleAvatar).at(1)); + trailingTopLeft = tester.getTopLeft(find.byType(Icon).at(1)); + + // The leading and trailing widgets are centered vertically with the text. + expect(leadingTopLeft - listTileTopLeft, const Offset(16.0, 30.0)); + expect(trailingTopLeft - listTileTopLeft, const Offset(752.0, 38.0)); + + listTileTopLeft = tester.getTopLeft(find.byType(ListTile).at(2)); + leadingTopLeft = tester.getTopLeft(find.byType(CircleAvatar).at(2)); + trailingTopLeft = tester.getTopLeft(find.byType(Icon).at(2)); + + // The leading and trailing widgets are aligned to the top vertically with the text. + expect(leadingTopLeft - listTileTopLeft, const Offset(16.0, 8.0)); + expect(trailingTopLeft - listTileTopLeft, const Offset(752.0, 8.0)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/list_tile/list_tile.3_test.dart b/novelforge-project/flutter/examples/api/test/material/list_tile/list_tile.3_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..50f685262e29c61b011b7d92c8fd100f05e45aaa --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/list_tile/list_tile.3_test.dart @@ -0,0 +1,58 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; +import 'package:flutter_api_samples/material/list_tile/list_tile.3.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('ListTile color properties respect Material state color', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ListTileApp(), + ); + ListTile listTile = tester.widget(find.byType(ListTile)); + + // Enabled list tile uses black color for icon and headline. + expect(listTile.enabled, true); + expect(listTile.selected, false); + RenderParagraph headline = _getTextRenderObject(tester, 'Headline'); + expect(headline.text.style!.color, Colors.black); + RichText icon = tester.widget(find.byType(RichText).at(0)); + expect(icon.text.style!.color, Colors.black); + + // Tap list tile to select it. + await tester.tap(find.byType(ListTile)); + await tester.pumpAndSettle(); + + // Selected list tile uses green color for icon and headline. + listTile = tester.widget(find.byType(ListTile)); + expect(listTile.enabled, true); + expect(listTile.selected, true); + headline = _getTextRenderObject(tester, 'Headline'); + expect(headline.text.style!.color, Colors.green); + icon = tester.widget(find.byType(RichText).at(0)); + expect(icon.text.style!.color, Colors.green); + + // Tap switch to disable list tile. + await tester.tap(find.byType(Switch)); + await tester.pumpAndSettle(); + + // Disabled list tile uses red color for icon and headline. + listTile = tester.widget(find.byType(ListTile)); + expect(listTile.enabled, false); + expect(listTile.selected, true); + headline = _getTextRenderObject(tester, 'Headline'); + expect(headline.text.style!.color, Colors.red); + icon = tester.widget(find.byType(RichText).at(0)); + expect(icon.text.style!.color, Colors.red); + }); +} + +RenderParagraph _getTextRenderObject(WidgetTester tester, String text) { + return tester.renderObject(find.descendant( + of: find.byType(ListTile), + matching: find.text(text), + )); +} diff --git a/novelforge-project/flutter/examples/api/test/material/list_tile/list_tile.4_test.dart b/novelforge-project/flutter/examples/api/test/material/list_tile/list_tile.4_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..5cd47ad0269bf2cd2ddcff0f76c1ae769284efd6 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/list_tile/list_tile.4_test.dart @@ -0,0 +1,51 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/list_tile/list_tile.4.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can choose different title alignments from popup menu', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ListTileApp(), + ); + + Offset titleOffset = tester.getTopLeft(find.text('Headline Text')); + Offset leadingOffset = tester.getTopLeft(find.byType(Checkbox)); + Offset trailingOffset = tester.getTopRight(find.byIcon(Icons.adaptive.more)); + + // The default title alignment is threeLine. + expect(leadingOffset.dy - titleOffset.dy, 48.0); + expect(trailingOffset.dy - titleOffset.dy, 60.0); + + await tester.tap(find.byIcon(Icons.adaptive.more)); + await tester.pumpAndSettle(); + + // Change the title alignment to titleHeight. + await tester.tap(find.text('titleHeight')); + await tester.pumpAndSettle(); + + titleOffset = tester.getTopLeft(find.text('Headline Text')); + leadingOffset = tester.getTopLeft(find.byType(Checkbox)); + trailingOffset = tester.getTopRight(find.byIcon(Icons.adaptive.more)); + + expect(leadingOffset.dy - titleOffset.dy, 8.0); + expect(trailingOffset.dy - titleOffset.dy, 20.0); + + await tester.tap(find.byIcon(Icons.adaptive.more)); + await tester.pumpAndSettle(); + + // Change the title alignment to bottom. + await tester.tap(find.text('bottom')); + await tester.pumpAndSettle(); + + titleOffset = tester.getTopLeft(find.text('Headline Text')); + leadingOffset = tester.getTopLeft(find.byType(Checkbox)); + trailingOffset = tester.getTopRight(find.byIcon(Icons.adaptive.more)); + + expect(leadingOffset.dy - titleOffset.dy, 96.0); + expect(trailingOffset.dy - titleOffset.dy, 108.0); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/list_tile/list_tile.selected.0_test.dart b/novelforge-project/flutter/examples/api/test/material/list_tile/list_tile.selected.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..155c88c36ecfd51c93a60dde4819a3fef174b389 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/list_tile/list_tile.selected.0_test.dart @@ -0,0 +1,28 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/list_tile/list_tile.selected.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('ListTile item can be selected', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ListTileApp(), + ); + + expect(find.byType(ListTile), findsNWidgets(10)); + + // The first item is selected by default. + expect(tester.widget(find.byType(ListTile).at(0)).selected, true); + + // Tap a list item to select it. + await tester.tap(find.byType(ListTile).at(5)); + await tester.pump(); + + // The first item is no longer selected. + expect(tester.widget(find.byType(ListTile).at(0)).selected, false); + expect(tester.widget(find.byType(ListTile).at(5)).selected, true); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/material_state/material_state_mouse_cursor.0_test.dart b/novelforge-project/flutter/examples/api/test/material/material_state/material_state_mouse_cursor.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..5208f5b54ff9185abc4cc80243ab183f73361675 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/material_state/material_state_mouse_cursor.0_test.dart @@ -0,0 +1,77 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:ui'; + +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; +import 'package:flutter_api_samples/material/material_state/material_state_mouse_cursor.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets( + 'MaterialStateMouseCursorExampleApp displays ListTile', + (WidgetTester tester) async { + await tester.pumpWidget( + const example.MaterialStateMouseCursorExampleApp(), + ); + + expect(find.byType(ListTile), findsOneWidget); + expect(find.text('ListTile'), findsOneWidget); + }, + ); + + testWidgets( + 'ListTile displays correct mouse cursor when enabled', + (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: Scaffold( + body: example.MaterialStateMouseCursorExample(enabled: true), + ), + ), + ); + + final TestGesture gesture = await tester.createGesture( + kind: PointerDeviceKind.mouse, + ); + await gesture.addPointer( + location: tester.getCenter(find.byType(ListTile)), + ); + addTearDown(gesture.removePointer); + + expect( + RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), + SystemMouseCursors.click, + ); + }, + ); + + testWidgets( + 'ListTile displays correct mouse cursor when disabled', + (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: Scaffold( + body: example.MaterialStateMouseCursorExample(enabled: false), + ), + ), + ); + + final TestGesture gesture = await tester.createGesture( + kind: PointerDeviceKind.mouse, + ); + await gesture.addPointer( + location: tester.getCenter(find.byType(ListTile)), + ); + addTearDown(gesture.removePointer); + + expect( + RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), + SystemMouseCursors.forbidden, + ); + }, + ); +} diff --git a/novelforge-project/flutter/examples/api/test/material/menu_anchor/checkbox_menu_button.0_test.dart b/novelforge-project/flutter/examples/api/test/material/menu_anchor/checkbox_menu_button.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..52515058684299b1231943a6d09643634edcc244 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/menu_anchor/checkbox_menu_button.0_test.dart @@ -0,0 +1,41 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/menu_anchor/checkbox_menu_button.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can open menu and show message', (WidgetTester tester) async { + await tester.pumpWidget( + const example.MenuApp(), + ); + + await tester.tap(find.byType(TextButton)); + await tester.pumpAndSettle(); + + expect(find.text('Show Message'), findsOneWidget); + expect(find.text(example.MenuApp.kMessage), findsNothing); + + await tester.tap(find.text('Show Message')); + await tester.pumpAndSettle(); + + expect(find.text('Show Message'), findsNothing); + expect(find.text(example.MenuApp.kMessage), findsOneWidget); + }); + + testWidgets('MenuAnchor is wrapped in a SafeArea', (WidgetTester tester) async { + const double safeAreaPadding = 100.0; + await tester.pumpWidget( + const MediaQuery( + data: MediaQueryData( + padding: EdgeInsets.symmetric(vertical: safeAreaPadding), + ), + child: example.MenuApp(), + ), + ); + + expect(tester.getTopLeft(find.byType(MenuAnchor)), const Offset(0.0, safeAreaPadding)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/menu_anchor/menu_accelerator_label.0_test.dart b/novelforge-project/flutter/examples/api/test/material/menu_anchor/menu_accelerator_label.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..5e69f5d8c1b4a07618324d0838ccc27d0fb7a7df --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/menu_anchor/menu_accelerator_label.0_test.dart @@ -0,0 +1,69 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_api_samples/material/menu_anchor/menu_accelerator_label.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can open menu', (WidgetTester tester) async { + Finder findMenu(String label) { + return find + .ancestor( + of: find.text(label, findRichText: true), + matching: find.byType(FocusScope), + ) + .first; + } + + await tester.pumpWidget(const example.MenuAcceleratorApp()); + + await tester.sendKeyDownEvent(LogicalKeyboardKey.altLeft); + await tester.pump(); + await tester.sendKeyEvent(LogicalKeyboardKey.keyF, character: 'f'); + await tester.pumpAndSettle(); + await tester.pump(); + + expect(find.text('About', findRichText: true), findsOneWidget); + expect(tester.getRect(findMenu('About')).left, equals(4.0)); + expect(tester.getRect(findMenu('About')).top, equals(48.0)); + expect(tester.getRect(findMenu('About')).right, closeTo(98.5, 0.1)); + expect(tester.getRect(findMenu('About')).bottom, equals(208.0)); + + expect(find.text('Save', findRichText: true), findsOneWidget); + expect(find.text('Quit', findRichText: true), findsOneWidget); + expect(find.text('Magnify', findRichText: true), findsNothing); + expect(find.text('Minify', findRichText: true), findsNothing); + + // Open the About dialog. + await tester.sendKeyEvent(LogicalKeyboardKey.keyA, character: 'a'); + await tester.sendKeyUpEvent(LogicalKeyboardKey.altLeft); + await tester.pumpAndSettle(); + + expect(find.text('Save', findRichText: true), findsNothing); + expect(find.text('Quit', findRichText: true), findsNothing); + expect(find.text('Magnify', findRichText: true), findsNothing); + expect(find.text('Minify', findRichText: true), findsNothing); + expect(find.text('Close'), findsOneWidget); + + await tester.tap(find.text('Close')); + await tester.pumpAndSettle(); + expect(find.text('Close'), findsNothing); + }); + + testWidgets('MenuBar is wrapped in a SafeArea', (WidgetTester tester) async { + const double safeAreaPadding = 100.0; + await tester.pumpWidget( + const MediaQuery( + data: MediaQueryData( + padding: EdgeInsets.symmetric(vertical: safeAreaPadding), + ), + child: example.MenuAcceleratorApp(), + ), + ); + + expect(tester.getTopLeft(find.byType(MenuBar)), const Offset(0.0, safeAreaPadding)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/menu_anchor/menu_anchor.0_test.dart b/novelforge-project/flutter/examples/api/test/material/menu_anchor/menu_anchor.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..11a6becc68004a304c1d427ae8e52d1746a6b795 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/menu_anchor/menu_anchor.0_test.dart @@ -0,0 +1,121 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_api_samples/material/menu_anchor/menu_anchor.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can open menu', (WidgetTester tester) async { + await tester.pumpWidget( + const example.MenuApp(), + ); + + await tester.tap(find.byType(TextButton)); + await tester.pump(); + + expect(find.text(example.MenuEntry.about.label), findsOneWidget); + expect(find.text(example.MenuEntry.showMessage.label), findsOneWidget); + expect(find.text(example.MenuEntry.hideMessage.label), findsNothing); + expect(find.text('Background Color'), findsOneWidget); + expect(find.text(example.MenuEntry.colorRed.label), findsNothing); + expect(find.text(example.MenuEntry.colorGreen.label), findsNothing); + expect(find.text(example.MenuEntry.colorBlue.label), findsNothing); + expect(find.text(example.MenuApp.kMessage), findsNothing); + + await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown); + await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown); + await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown); + await tester.pump(); + + expect(find.text('Background Color'), findsOneWidget); + + await tester.tap(find.text('Background Color')); + await tester.pump(); + + expect(find.text(example.MenuEntry.colorRed.label), findsOneWidget); + expect(find.text(example.MenuEntry.colorGreen.label), findsOneWidget); + expect(find.text(example.MenuEntry.colorBlue.label), findsOneWidget); + + await tester.sendKeyEvent(LogicalKeyboardKey.arrowUp); + await tester.sendKeyEvent(LogicalKeyboardKey.enter); + await tester.pumpAndSettle(); + + expect(find.text(example.MenuApp.kMessage), findsOneWidget); + expect(find.text('Last Selected: ${example.MenuEntry.showMessage.label}'), findsOneWidget); + }); + + testWidgets('Shortcuts work', (WidgetTester tester) async { + await tester.pumpWidget( + const example.MenuApp(), + ); + + // Open the menu so we can watch state changes resulting from the shortcuts + // firing. + await tester.tap(find.byType(TextButton)); + await tester.pump(); + + expect(find.text(example.MenuEntry.showMessage.label), findsOneWidget); + expect(find.text(example.MenuEntry.hideMessage.label), findsNothing); + expect(find.text(example.MenuApp.kMessage), findsNothing); + + await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft); + await tester.sendKeyEvent(LogicalKeyboardKey.keyS); + await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft); + await tester.pump(); + // Need to pump twice because of the one frame delay in the notification to + // update the overlay entry. + await tester.pump(); + + expect(find.text(example.MenuEntry.showMessage.label), findsNothing); + expect(find.text(example.MenuEntry.hideMessage.label), findsOneWidget); + expect(find.text(example.MenuApp.kMessage), findsOneWidget); + + await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft); + await tester.sendKeyEvent(LogicalKeyboardKey.keyS); + await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft); + await tester.pump(); + await tester.pump(); + + expect(find.text(example.MenuEntry.showMessage.label), findsOneWidget); + expect(find.text(example.MenuEntry.hideMessage.label), findsNothing); + expect(find.text(example.MenuApp.kMessage), findsNothing); + + await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft); + await tester.sendKeyEvent(LogicalKeyboardKey.keyR); + await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft); + await tester.pump(); + + expect(find.text('Last Selected: ${example.MenuEntry.colorRed.label}'), findsOneWidget); + + await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft); + await tester.sendKeyEvent(LogicalKeyboardKey.keyG); + await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft); + await tester.pump(); + + expect(find.text('Last Selected: ${example.MenuEntry.colorGreen.label}'), findsOneWidget); + + await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft); + await tester.sendKeyEvent(LogicalKeyboardKey.keyB); + await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft); + await tester.pump(); + + expect(find.text('Last Selected: ${example.MenuEntry.colorBlue.label}'), findsOneWidget); + }); + + testWidgets('MenuAnchor is wrapped in a SafeArea', (WidgetTester tester) async { + const double safeAreaPadding = 100.0; + await tester.pumpWidget( + const MediaQuery( + data: MediaQueryData( + padding: EdgeInsets.symmetric(vertical: safeAreaPadding), + ), + child: example.MenuApp(), + ), + ); + + expect(tester.getTopLeft(find.byType(MenuAnchor)), const Offset(0.0, safeAreaPadding)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/menu_anchor/menu_anchor.1_test.dart b/novelforge-project/flutter/examples/api/test/material/menu_anchor/menu_anchor.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..f7633726f3340553d1ac625d35a4ea36dbbf6899 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/menu_anchor/menu_anchor.1_test.dart @@ -0,0 +1,136 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_api_samples/material/menu_anchor/menu_anchor.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can open menu', (WidgetTester tester) async { + Finder findMenu() { + return find.ancestor( + of: find.text(example.MenuEntry.about.label), + matching: find.byType(FocusScope), + ).first; + } + + await tester.pumpWidget(const example.ContextMenuApp()); + + await tester.tapAt(const Offset(100, 200), buttons: kSecondaryButton); + await tester.pumpAndSettle(); + expect(tester.getRect(findMenu()).left, equals(100.0)); + expect(tester.getRect(findMenu()).top, equals(200.0)); + expect(tester.getRect(findMenu()).right, closeTo(389.8, 0.1)); + expect(tester.getRect(findMenu()).bottom, equals(360.0)); + + // Make sure tapping in a different place causes the menu to move. + await tester.tapAt(const Offset(200, 100), buttons: kSecondaryButton); + await tester.pump(); + + expect(tester.getRect(findMenu()).left, equals(200.0)); + expect(tester.getRect(findMenu()).top, equals(100.0)); + expect(tester.getRect(findMenu()).right, closeTo(489.8, 0.1)); + expect(tester.getRect(findMenu()).bottom, equals(260.0)); + + expect(find.text(example.MenuEntry.about.label), findsOneWidget); + expect(find.text(example.MenuEntry.showMessage.label), findsOneWidget); + expect(find.text(example.MenuEntry.hideMessage.label), findsNothing); + expect(find.text('Background Color'), findsOneWidget); + expect(find.text(example.MenuEntry.colorRed.label), findsNothing); + expect(find.text(example.MenuEntry.colorGreen.label), findsNothing); + expect(find.text(example.MenuEntry.colorBlue.label), findsNothing); + expect(find.text(example.ContextMenuApp.kMessage), findsNothing); + + await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown); + await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown); + await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown); + await tester.pump(); + + expect(find.text('Background Color'), findsOneWidget); + + // Focusing the background color item with the keyboard caused the submenu + // to open. Tapping it should cause it to close. + await tester.tap(find.text('Background Color')); + await tester.pump(); + await tester.pumpAndSettle(); + + expect(find.text(example.MenuEntry.colorRed.label), findsNothing); + expect(find.text(example.MenuEntry.colorGreen.label), findsNothing); + expect(find.text(example.MenuEntry.colorBlue.label), findsNothing); + + await tester.tap(find.text('Background Color')); + await tester.pump(); + await tester.pumpAndSettle(); + + expect(find.text(example.MenuEntry.colorRed.label), findsOneWidget); + expect(find.text(example.MenuEntry.colorGreen.label), findsOneWidget); + expect(find.text(example.MenuEntry.colorBlue.label), findsOneWidget); + + await tester.sendKeyEvent(LogicalKeyboardKey.arrowUp); + await tester.sendKeyEvent(LogicalKeyboardKey.enter); + await tester.pumpAndSettle(); + + expect(find.text(example.ContextMenuApp.kMessage), findsOneWidget); + expect(find.text('Last Selected: ${example.MenuEntry.showMessage.label}'), findsOneWidget); + }); + + testWidgets('Shortcuts work', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ContextMenuApp(), + ); + + // Open the menu so we can look for state changes reflected in the menu. + await tester.tapAt(const Offset(100, 200), buttons: kSecondaryButton); + await tester.pump(); + + expect(find.text(example.MenuEntry.showMessage.label), findsOneWidget); + expect(find.text(example.MenuEntry.hideMessage.label), findsNothing); + expect(find.text(example.ContextMenuApp.kMessage), findsNothing); + + await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft); + await tester.sendKeyEvent(LogicalKeyboardKey.keyS); + await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft); + await tester.pump(); + // Need to pump twice because of the one frame delay in the notification to + // update the overlay entry. + await tester.pump(); + + expect(find.text(example.MenuEntry.showMessage.label), findsNothing); + expect(find.text(example.MenuEntry.hideMessage.label), findsOneWidget); + expect(find.text(example.ContextMenuApp.kMessage), findsOneWidget); + + await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft); + await tester.sendKeyEvent(LogicalKeyboardKey.keyS); + await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft); + await tester.pump(); + await tester.pump(); + + expect(find.text(example.MenuEntry.showMessage.label), findsOneWidget); + expect(find.text(example.MenuEntry.hideMessage.label), findsNothing); + expect(find.text(example.ContextMenuApp.kMessage), findsNothing); + + await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft); + await tester.sendKeyEvent(LogicalKeyboardKey.keyR); + await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft); + await tester.pump(); + + expect(find.text('Last Selected: ${example.MenuEntry.colorRed.label}'), findsOneWidget); + + await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft); + await tester.sendKeyEvent(LogicalKeyboardKey.keyG); + await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft); + await tester.pump(); + + expect(find.text('Last Selected: ${example.MenuEntry.colorGreen.label}'), findsOneWidget); + + await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft); + await tester.sendKeyEvent(LogicalKeyboardKey.keyB); + await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft); + await tester.pump(); + + expect(find.text('Last Selected: ${example.MenuEntry.colorBlue.label}'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/menu_anchor/menu_anchor.3_test.dart b/novelforge-project/flutter/examples/api/test/material/menu_anchor/menu_anchor.3_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..ee9172c84b8c0c9ca0493b85edb3053ce722cab3 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/menu_anchor/menu_anchor.3_test.dart @@ -0,0 +1,36 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/menu_anchor/menu_anchor.3.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Menu button opens and closes the menu', (WidgetTester tester) async { + await tester.pumpWidget(const example.SimpleCascadingMenuApp()); + + // Find the menu button. + final Finder menuButton = find.byType(IconButton); + expect(menuButton, findsOneWidget); + + // Tap the menu button to open the menu. + await tester.tap(menuButton); + await tester.pumpAndSettle(); + + // Verify that the menu is open. + expect(find.text('Revert'), findsOneWidget); + + // Tap the menu button again to close the menu. + await tester.tap(menuButton); + await tester.pumpAndSettle(); + + // Verify that the menu is closed. + expect(find.text('Revert'), findsNothing); + }); + + testWidgets('Does not show debug banner', (WidgetTester tester) async { + await tester.pumpWidget(const example.SimpleCascadingMenuApp()); + expect(find.byType(CheckedModeBanner), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/menu_anchor/menu_bar.0_test.dart b/novelforge-project/flutter/examples/api/test/material/menu_anchor/menu_bar.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..1ba69519c1b074589505d6c8dd1822be7c9f3a65 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/menu_anchor/menu_bar.0_test.dart @@ -0,0 +1,108 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_api_samples/material/menu_anchor/menu_bar.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can open menu', (WidgetTester tester) async { + await tester.pumpWidget( + const example.MenuBarApp(), + ); + + final Finder menuBarFinder = find.byType(MenuBar); + final MenuBar menuBar = tester.widget(menuBarFinder); + expect(menuBar.children, isNotEmpty); + expect(menuBar.children.length, equals(1)); + + final Finder menuButtonFinder = find.byType(SubmenuButton).first; + await tester.tap(menuButtonFinder); + await tester.pumpAndSettle(); + + expect(find.text('About'), findsOneWidget); + expect(find.text('Show Message'), findsOneWidget); + expect(find.text('Reset Message'), findsOneWidget); + expect(find.text('Background Color'), findsOneWidget); + expect(find.text('Red Background'), findsNothing); + expect(find.text('Green Background'), findsNothing); + expect(find.text('Blue Background'), findsNothing); + expect(find.text(example.MenuBarApp.kMessage), findsNothing); + + await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown); + await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown); + await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown); + await tester.pumpAndSettle(); + + expect(find.text('About'), findsOneWidget); + expect(find.text('Show Message'), findsOneWidget); + expect(find.text('Reset Message'), findsOneWidget); + expect(find.text('Background Color'), findsOneWidget); + expect(find.text('Red Background'), findsOneWidget); + expect(find.text('Green Background'), findsOneWidget); + expect(find.text('Blue Background'), findsOneWidget); + + await tester.sendKeyEvent(LogicalKeyboardKey.arrowUp); + await tester.sendKeyEvent(LogicalKeyboardKey.enter); + await tester.pumpAndSettle(); + + expect(find.text(example.MenuBarApp.kMessage), findsOneWidget); + expect(find.text('Last Selected: Show Message'), findsOneWidget); + }); + testWidgets('Shortcuts work', (WidgetTester tester) async { + await tester.pumpWidget( + const example.MenuBarApp(), + ); + + expect(find.text(example.MenuBarApp.kMessage), findsNothing); + + await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft); + await tester.sendKeyEvent(LogicalKeyboardKey.keyS); + await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft); + await tester.pump(); + + expect(find.text(example.MenuBarApp.kMessage), findsOneWidget); + await tester.sendKeyEvent(LogicalKeyboardKey.escape); + await tester.pump(); + + expect(find.text(example.MenuBarApp.kMessage), findsNothing); + expect(find.text('Last Selected: Reset Message'), findsOneWidget); + + await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft); + await tester.sendKeyEvent(LogicalKeyboardKey.keyR); + await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft); + await tester.pump(); + + expect(find.text('Last Selected: Red Background'), findsOneWidget); + + await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft); + await tester.sendKeyEvent(LogicalKeyboardKey.keyG); + await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft); + await tester.pump(); + + expect(find.text('Last Selected: Green Background'), findsOneWidget); + + await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft); + await tester.sendKeyEvent(LogicalKeyboardKey.keyB); + await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft); + await tester.pump(); + + expect(find.text('Last Selected: Blue Background'), findsOneWidget); + }); + + testWidgets('MenuBar is wrapped in a SafeArea', (WidgetTester tester) async { + const double safeAreaPadding = 100.0; + await tester.pumpWidget( + const MediaQuery( + data: MediaQueryData( + padding: EdgeInsets.symmetric(vertical: safeAreaPadding), + ), + child: example.MenuBarApp(), + ), + ); + + expect(tester.getTopLeft(find.byType(MenuBar)), const Offset(0.0, safeAreaPadding)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/menu_anchor/radio_menu_button.0_test.dart b/novelforge-project/flutter/examples/api/test/material/menu_anchor/radio_menu_button.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..bbc91423e8b5b00b64cb8b0062f45f02af740b46 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/menu_anchor/radio_menu_button.0_test.dart @@ -0,0 +1,91 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_api_samples/material/menu_anchor/radio_menu_button.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can open menu', (WidgetTester tester) async { + await tester.pumpWidget( + const example.MenuApp(), + ); + + await tester.tap(find.byType(TextButton)); + await tester.pump(); + await tester.pump(); + + expect(find.text('Red Background'), findsOneWidget); + expect(find.text('Green Background'), findsOneWidget); + expect(find.text('Blue Background'), findsOneWidget); + expect(find.byType(Radio), findsNWidgets(3)); + expect(tester.widget(find.byType(Container)).color, equals(Colors.red)); + + await tester.tap(find.text('Green Background')); + await tester.pumpAndSettle(); + + expect(tester.widget(find.byType(Container)).color, equals(Colors.green)); + }); + + testWidgets('Shortcuts work', (WidgetTester tester) async { + await tester.pumpWidget( + const example.MenuApp(), + ); + + // Open the menu so we can watch state changes resulting from the shortcuts + // firing. + await tester.tap(find.byType(TextButton)); + await tester.pump(); + + expect(find.text('Red Background'), findsOneWidget); + expect(find.text('Green Background'), findsOneWidget); + expect(find.text('Blue Background'), findsOneWidget); + expect(find.byType(Radio), findsNWidgets(3)); + expect(tester.widget(find.byType(Container)).color, equals(Colors.red)); + + await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft); + await tester.sendKeyEvent(LogicalKeyboardKey.keyG); + await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft); + await tester.pump(); + // Need to pump twice because of the one frame delay in the notification to + // update the overlay entry. + await tester.pump(); + + expect(tester.widget>(find.descendant(of: find.byType(RadioMenuButton).at(0), matching: find.byType(Radio))).groupValue, equals(Colors.green)); + expect(tester.widget(find.byType(Container)).color, equals(Colors.green)); + + await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft); + await tester.sendKeyEvent(LogicalKeyboardKey.keyR); + await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft); + await tester.pump(); + await tester.pump(); + + expect(tester.widget>(find.descendant(of: find.byType(RadioMenuButton).at(1), matching: find.byType(Radio))).groupValue, equals(Colors.red)); + expect(tester.widget(find.byType(Container)).color, equals(Colors.red)); + + await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft); + await tester.sendKeyEvent(LogicalKeyboardKey.keyB); + await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft); + await tester.pump(); + await tester.pump(); + + expect(tester.widget>(find.descendant(of: find.byType(RadioMenuButton).at(2), matching: find.byType(Radio))).groupValue, equals(Colors.blue)); + expect(tester.widget(find.byType(Container)).color, equals(Colors.blue)); + }); + + testWidgets('MenuAnchor is wrapped in a SafeArea', (WidgetTester tester) async { + const double safeAreaPadding = 100.0; + await tester.pumpWidget( + const MediaQuery( + data: MediaQueryData( + padding: EdgeInsets.symmetric(vertical: safeAreaPadding), + ), + child: example.MenuApp(), + ), + ); + + expect(tester.getTopLeft(find.byType(MenuAnchor)), const Offset(0.0, safeAreaPadding)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/navigation_bar/navigation_bar.0_test.dart b/novelforge-project/flutter/examples/api/test/material/navigation_bar/navigation_bar.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..d89d8db5a20b36ba7aa90ecb6a0dcbcce94fa80e --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/navigation_bar/navigation_bar.0_test.dart @@ -0,0 +1,52 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/navigation_bar/navigation_bar.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Navigation bar updates destination on tap', + (WidgetTester tester) async { + await tester.pumpWidget( + const example.NavigationBarApp(), + ); + final NavigationBar navigationBarWidget = tester.firstWidget(find.byType(NavigationBar)); + + /// NavigationDestinations must be rendered + expect(find.text('Home'), findsOneWidget); + expect(find.text('Notifications'), findsOneWidget); + expect(find.text('Messages'), findsOneWidget); + + /// Test notification badge. + final Badge notificationBadge = tester.firstWidget(find.ancestor( + of: find.byIcon(Icons.notifications_sharp), + matching: find.byType(Badge), + )); + expect(notificationBadge.label, null); + + /// Test messages badge. + final Badge messagesBadge = tester.firstWidget(find.ancestor( + of: find.byIcon(Icons.messenger_sharp), + matching: find.byType(Badge), + )); + expect(messagesBadge.label, isNotNull); + + /// Initial index must be zero + expect(navigationBarWidget.selectedIndex, 0); + expect(find.text('Home page'), findsOneWidget); + + /// Switch to second tab + await tester.tap(find.text('Notifications')); + await tester.pumpAndSettle(); + expect(find.text('This is a notification'), findsNWidgets(2)); + + /// Switch to third tab + await tester.tap(find.text('Messages')); + await tester.pumpAndSettle(); + expect(find.text('Hi!'), findsOneWidget); + expect(find.text('Hello'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/navigation_bar/navigation_bar.1_test.dart b/novelforge-project/flutter/examples/api/test/material/navigation_bar/navigation_bar.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..13005652c05e71b53bee6a197d00105c07dbeb1b --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/navigation_bar/navigation_bar.1_test.dart @@ -0,0 +1,43 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/navigation_bar/navigation_bar.1.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Navigation bar updates label behavior when tapping buttons', + (WidgetTester tester) async { + await tester.pumpWidget( + const example.NavigationBarApp(), + ); + NavigationBar navigationBarWidget = tester.firstWidget(find.byType(NavigationBar)); + + expect(find.text('Label behavior: alwaysShow'), findsOneWidget); + + /// Test alwaysShow label behavior button. + await tester.tap(find.widgetWithText(ElevatedButton, 'alwaysShow')); + await tester.pumpAndSettle(); + + expect(find.text('Label behavior: alwaysShow'), findsOneWidget); + expect(navigationBarWidget.labelBehavior, NavigationDestinationLabelBehavior.alwaysShow); + + /// Test onlyShowSelected label behavior button. + await tester.tap(find.widgetWithText(ElevatedButton, 'onlyShowSelected')); + await tester.pumpAndSettle(); + + expect(find.text('Label behavior: onlyShowSelected'), findsOneWidget); + navigationBarWidget = tester.firstWidget(find.byType(NavigationBar)); + expect(navigationBarWidget.labelBehavior, NavigationDestinationLabelBehavior.onlyShowSelected); + + /// Test alwaysHide label behavior button. + await tester.tap(find.widgetWithText(ElevatedButton, 'alwaysHide')); + await tester.pumpAndSettle(); + + expect(find.text('Label behavior: alwaysHide'), findsOneWidget); + navigationBarWidget = tester.firstWidget(find.byType(NavigationBar)); + expect(navigationBarWidget.labelBehavior, NavigationDestinationLabelBehavior.alwaysHide); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/navigation_bar/navigation_bar.2_test.dart b/novelforge-project/flutter/examples/api/test/material/navigation_bar/navigation_bar.2_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..cba73818e3cd39886f3db3da1e85c024cff028b6 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/navigation_bar/navigation_bar.2_test.dart @@ -0,0 +1,108 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/navigation_bar/navigation_bar.2.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('RootPage: only selected destination is on stage', (WidgetTester tester) async { + await tester.pumpWidget(const MaterialApp(home: example.Home())); + + const String tealTitle = 'Teal RootPage - /'; + const String cyanTitle = 'Cyan RootPage - /'; + const String orangeTitle = 'Orange RootPage - /'; + const String blueTitle = 'Blue RootPage - /'; + + await tester.tap(find.widgetWithText(NavigationDestination, 'Teal')); + await tester.pumpAndSettle(); + expect(find.text(tealTitle), findsOneWidget); + expect(find.text(cyanTitle), findsNothing); + expect(find.text(orangeTitle), findsNothing); + expect(find.text(blueTitle), findsNothing); + + await tester.tap(find.widgetWithText(NavigationDestination, 'Cyan')); + await tester.pumpAndSettle(); + expect(find.text(tealTitle), findsNothing); + expect(find.text(cyanTitle), findsOneWidget); + expect(find.text(orangeTitle), findsNothing); + expect(find.text(blueTitle), findsNothing); + + await tester.tap(find.widgetWithText(NavigationDestination, 'Orange')); + await tester.pumpAndSettle(); + expect(find.text(tealTitle), findsNothing); + expect(find.text(cyanTitle), findsNothing); + expect(find.text(orangeTitle), findsOneWidget); + expect(find.text(blueTitle), findsNothing); + + await tester.tap(find.widgetWithText(NavigationDestination, 'Blue')); + await tester.pumpAndSettle(); + expect(find.text(tealTitle), findsNothing); + expect(find.text(cyanTitle), findsNothing); + expect(find.text(orangeTitle), findsNothing); + expect(find.text(blueTitle), findsOneWidget); + }); + + testWidgets('RootPage', (WidgetTester tester) async { + await tester.pumpWidget(const MaterialApp(home: example.Home())); + + await tester.tap(find.widgetWithText(NavigationDestination, 'Teal')); + await tester.pumpAndSettle(); + await tester.tap(find.text('Local Dialog')); + await tester.pumpAndSettle(); + expect(find.text('Teal AlertDialog'), findsOneWidget); + await tester.tap(find.text('OK')); + await tester.pumpAndSettle(); + expect(find.text('Teal AlertDialog'), findsNothing); + + await tester.pumpAndSettle(); + await tester.tap(find.text('Root Dialog')); + await tester.pumpAndSettle(); + expect(find.text('Teal AlertDialog'), findsOneWidget); + await tester.tapAt(const Offset(5, 5)); + await tester.pumpAndSettle(); + expect(find.text('Teal AlertDialog'), findsNothing); + + await tester.tap(find.text('Local BottomSheet')); + await tester.pumpAndSettle(); + expect(find.byType(BottomSheet), findsOneWidget); + await tester.tap(find.byType(BackButton)); + await tester.pumpAndSettle(); + expect(find.byType(BottomSheet), findsNothing); + + await tester.tap(find.text('Push /list')); + await tester.pumpAndSettle(); + expect(find.text('Teal ListPage - /list'), findsOneWidget); + }); + + + testWidgets('ListPage', (WidgetTester tester) async { + await tester.pumpWidget(const MaterialApp(home: example.Home())); + expect(find.text('Teal RootPage - /'), findsOneWidget); + + await tester.tap(find.widgetWithText(ElevatedButton, 'Push /list')); + await tester.pumpAndSettle(); + expect(find.text('Teal ListPage - /list'), findsOneWidget); + expect(find.text('Push /text [0]'), findsOneWidget); + + await tester.tap(find.widgetWithText(NavigationDestination, 'Orange')); + await tester.pumpAndSettle(); + await tester.tap(find.widgetWithText(ElevatedButton, 'Push /list')); + await tester.pumpAndSettle(); + expect(find.text('Orange ListPage - /list'), findsOneWidget); + expect(find.text('Push /text [0]'), findsOneWidget); + + await tester.tap(find.byType(BackButton)); + await tester.pumpAndSettle(); + expect(find.text('Orange RootPage - /'), findsOneWidget); + + await tester.tap(find.widgetWithText(NavigationDestination, 'Teal')); + await tester.pumpAndSettle(); + expect(find.text('Teal ListPage - /list'), findsOneWidget); + + await tester.tap(find.byType(BackButton)); + await tester.pumpAndSettle(); + expect(find.text('Teal RootPage - /'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/navigation_drawer/navigation_drawer.0_test.dart b/novelforge-project/flutter/examples/api/test/material/navigation_drawer/navigation_drawer.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..a7e9916d827fcd935c358cfde16a307c415d581e --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/navigation_drawer/navigation_drawer.0_test.dart @@ -0,0 +1,41 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/navigation_drawer/navigation_drawer.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Navigation bar updates destination on tap', + (WidgetTester tester) async { + await tester.pumpWidget( + const example.NavigationDrawerApp(), + ); + + await tester.tap(find.text('Open Drawer')); + await tester.pumpAndSettle(); + + final NavigationDrawer navigationDrawerWidget = tester.firstWidget(find.byType(NavigationDrawer)); + + /// NavigationDestinations must be rendered + expect(find.text('Messages'), findsNWidgets(2)); + expect(find.text('Profile'), findsNWidgets(2)); + expect(find.text('Settings'), findsNWidgets(2)); + + /// Initial index must be zero + expect(navigationDrawerWidget.selectedIndex, 0); + expect(find.text('Page Index = 0'), findsOneWidget); + + /// Switch to second tab + await tester.tap(find.ancestor(of: find.text('Profile'), matching: find.byType(InkWell))); + await tester.pumpAndSettle(); + expect(find.text('Page Index = 1'), findsOneWidget); + + /// Switch to fourth tab + await tester.tap(find.ancestor(of: find.text('Settings'), matching: find.byType(InkWell))); + await tester.pumpAndSettle(); + expect(find.text('Page Index = 2'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/navigation_rail/navigation_rail.0_test.dart b/novelforge-project/flutter/examples/api/test/material/navigation_rail/navigation_rail.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..afe0ac9f54eda701c17d01d381107c32be5cbbc0 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/navigation_rail/navigation_rail.0_test.dart @@ -0,0 +1,97 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/navigation_rail/navigation_rail.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Navigation rail updates destination on tap', + (WidgetTester tester) async { + await tester.pumpWidget( + const example.NavigationRailExampleApp(), + ); + final NavigationRail navigationRailWidget = + tester.firstWidget(find.byType(NavigationRail)); + + /// NavigationRailDestinations must be rendered + expect(find.text('First'), findsOneWidget); + expect(find.text('Second'), findsOneWidget); + expect(find.text('Third'), findsOneWidget); + + /// initial index must be zero + expect(navigationRailWidget.selectedIndex, 0); + + /// switch to second tab + await tester.tap(find.text('Second')); + await tester.pumpAndSettle(); + expect(find.text('selectedIndex: 1'), findsOneWidget); + + /// switch to third tab + await tester.tap(find.text('Third')); + await tester.pumpAndSettle(); + expect(find.text('selectedIndex: 2'), findsOneWidget); + }); + + testWidgets('Navigation rail updates label type', (WidgetTester tester) async { + await tester.pumpWidget( + const example.NavigationRailExampleApp(), + ); + + // initial label type set to all. + expect(find.text('Label type: all'), findsOneWidget); + + // switch to selected label type + await tester.tap(find.widgetWithText(ElevatedButton, 'Selected')); + await tester.pumpAndSettle(); + expect(find.text('Label type: selected'), findsOneWidget); + + // switch to none label type + await tester.tap(find.widgetWithText(ElevatedButton, 'None')); + await tester.pumpAndSettle(); + expect(find.text('Label type: none'), findsOneWidget); + }); + + testWidgets('Navigation rail updates group alignment', (WidgetTester tester) async { + await tester.pumpWidget( + const example.NavigationRailExampleApp(), + ); + + // initial group alignment set top top. + expect(find.text('Group alignment: -1.0'), findsOneWidget); + + // switch to center alignment + await tester.tap(find.widgetWithText(ElevatedButton, 'Center')); + await tester.pumpAndSettle(); + expect(find.text('Group alignment: 0.0'), findsOneWidget); + + // switch to bottom alignment + await tester.tap(find.widgetWithText(ElevatedButton, 'Bottom')); + await tester.pumpAndSettle(); + expect(find.text('Group alignment: 1.0'), findsOneWidget); + }); + + testWidgets('Navigation rail shows leading/trailing widgets', (WidgetTester tester) async { + await tester.pumpWidget( + const example.NavigationRailExampleApp(), + ); + + // Initially leading/trailing widgets are hidden. + expect(find.byType(FloatingActionButton), findsNothing); + expect(find.byType(IconButton), findsNothing); + + // Tap to show leading Widget. + await tester.tap(find.widgetWithText(ElevatedButton, 'Show Leading')); + await tester.pumpAndSettle(); + expect(find.byType(FloatingActionButton), findsOneWidget); + expect(find.byType(IconButton), findsNothing); + + // Tap to show trailing Widget. + await tester.tap(find.widgetWithText(ElevatedButton, 'Show Trailing')); + await tester.pumpAndSettle(); + expect(find.byType(FloatingActionButton), findsOneWidget); + expect(find.byType(IconButton), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/navigation_rail/navigation_rail.1_test.dart b/novelforge-project/flutter/examples/api/test/material/navigation_rail/navigation_rail.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..d3526d4adc4308a733f5b5a497b5974da2c1fcc4 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/navigation_rail/navigation_rail.1_test.dart @@ -0,0 +1,117 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/navigation_rail/navigation_rail.1.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Navigation rail updates destination on tap', + (WidgetTester tester) async { + await tester.pumpWidget( + const example.NavigationRailExampleApp(), + ); + final NavigationRail navigationRailWidget = + tester.firstWidget(find.byType(NavigationRail)); + + /// NavigationRailDestinations must be rendered + expect(find.text('First'), findsOneWidget); + expect(find.text('Second'), findsOneWidget); + expect(find.text('Third'), findsOneWidget); + + /// initial index must be zero + expect(navigationRailWidget.selectedIndex, 0); + + /// switch to second tab + await tester.tap(find.text('Second')); + await tester.pumpAndSettle(); + expect(find.text('selectedIndex: 1'), findsOneWidget); + + /// switch to third tab + await tester.tap(find.text('Third')); + await tester.pumpAndSettle(); + expect(find.text('selectedIndex: 2'), findsOneWidget); + }); + + testWidgets('Navigation rail updates label type', (WidgetTester tester) async { + await tester.pumpWidget( + const example.NavigationRailExampleApp(), + ); + + // initial label type set to all. + expect(find.text('Label type: all'), findsOneWidget); + + // switch to selected label type + await tester.tap(find.widgetWithText(ElevatedButton, 'Selected')); + await tester.pumpAndSettle(); + expect(find.text('Label type: selected'), findsOneWidget); + + // switch to none label type + await tester.tap(find.widgetWithText(ElevatedButton, 'None')); + await tester.pumpAndSettle(); + expect(find.text('Label type: none'), findsOneWidget); + }); + + testWidgets('Navigation rail updates group alignment', (WidgetTester tester) async { + await tester.pumpWidget( + const example.NavigationRailExampleApp(), + ); + + // initial group alignment set top top. + expect(find.text('Group alignment: -1.0'), findsOneWidget); + + // switch to center alignment + await tester.tap(find.widgetWithText(ElevatedButton, 'Center')); + await tester.pumpAndSettle(); + expect(find.text('Group alignment: 0.0'), findsOneWidget); + + // switch to bottom alignment + await tester.tap(find.widgetWithText(ElevatedButton, 'Bottom')); + await tester.pumpAndSettle(); + expect(find.text('Group alignment: 1.0'), findsOneWidget); + }); + + testWidgets('Navigation rail shows leading/trailing widgets', (WidgetTester tester) async { + await tester.pumpWidget( + const example.NavigationRailExampleApp(), + ); + + // Initially leading/trailing widgets are hidden. + expect(find.byType(FloatingActionButton), findsNothing); + expect(find.byType(IconButton), findsNothing); + + // Tap to show leading Widget. + await tester.tap(find.widgetWithText(ElevatedButton, 'Show Leading')); + await tester.pumpAndSettle(); + expect(find.byType(FloatingActionButton), findsOneWidget); + expect(find.byType(IconButton), findsNothing); + + // Tap to show trailing Widget. + await tester.tap(find.widgetWithText(ElevatedButton, 'Show Trailing')); + await tester.pumpAndSettle(); + expect(find.byType(FloatingActionButton), findsOneWidget); + expect(find.byType(IconButton), findsOneWidget); + }); + + testWidgets('Destinations have badge', (WidgetTester tester) async { + await tester.pumpWidget( + const example.NavigationRailExampleApp(), + ); + + // Test badge wthout label. + final Badge notificationBadge = tester.firstWidget(find.ancestor( + of: find.byIcon(Icons.bookmark_border), + matching: find.byType(Badge), + )); + expect(notificationBadge.label, null); + + // Test badge with label. + final Badge messagesBadge = tester.firstWidget(find.ancestor( + of: find.byIcon(Icons.star_border), + matching: find.byType(Badge), + )); + expect(messagesBadge.label, isNotNull); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/outlined_button/outlined_button.0_test.dart b/novelforge-project/flutter/examples/api/test/material/outlined_button/outlined_button.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..1e6940aeb0cb3372348f5f987294892ef286913a --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/outlined_button/outlined_button.0_test.dart @@ -0,0 +1,21 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/outlined_button/outlined_button.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('OutlinedButton Smoke Test', (WidgetTester tester) async { + await tester.pumpWidget( + const example.OutlinedButtonExampleApp(), + ); + + expect(find.widgetWithText(AppBar, 'OutlinedButton Sample'), findsOneWidget); + final Finder outlinedButton = find.widgetWithText(OutlinedButton, 'Click Me'); + expect(outlinedButton, findsOneWidget); + final OutlinedButton outlinedButtonWidget = tester.widget(outlinedButton); + expect(outlinedButtonWidget.onPressed.runtimeType, VoidCallback); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/page_transitions_theme/page_transitions_theme.0_test.dart b/novelforge-project/flutter/examples/api/test/material/page_transitions_theme/page_transitions_theme.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..0e08c29f64ec8e8cf63ca42dcb2bbc267f93228c --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/page_transitions_theme/page_transitions_theme.0_test.dart @@ -0,0 +1,48 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/page_transitions_theme/page_transitions_theme.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('MaterialApp defines a custom PageTransitionsTheme', (WidgetTester tester) async { + await tester.pumpWidget( + const example.PageTransitionsThemeApp(), + ); + + final Finder homePage = find.byType(example.HomePage); + expect(homePage, findsOneWidget); + + final PageTransitionsTheme theme = Theme.of(tester.element(homePage)).pageTransitionsTheme; + expect(theme.builders, isNotNull); + + // Check defined page transitions builder for each platform. + for (final TargetPlatform platform in TargetPlatform.values) { + switch (platform) { + case TargetPlatform.iOS: + expect(theme.builders[platform], isA()); + case TargetPlatform.linux: + expect(theme.builders[platform], isA()); + case TargetPlatform.macOS: + expect(theme.builders[platform], isA()); + case TargetPlatform.android: + case TargetPlatform.fuchsia: + case TargetPlatform.windows: + expect(theme.builders[platform], isNull); + } + } + + // Can navigate to the second page. + expect(find.text('To SecondPage'), findsOneWidget); + await tester.tap(find.text('To SecondPage')); + await tester.pumpAndSettle(); + + // Can navigate back to the home page. + expect(find.text('Back to HomePage'), findsOneWidget); + await tester.tap(find.text('Back to HomePage')); + await tester.pumpAndSettle(); + expect(find.text('To SecondPage'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/page_transitions_theme/page_transitions_theme.1_test.dart b/novelforge-project/flutter/examples/api/test/material/page_transitions_theme/page_transitions_theme.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..3b924b970fe03878090747f03c2c0e9eefe2b650 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/page_transitions_theme/page_transitions_theme.1_test.dart @@ -0,0 +1,48 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/page_transitions_theme/page_transitions_theme.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('MaterialApp defines a custom PageTransitionsTheme', (WidgetTester tester) async { + await tester.pumpWidget( + const example.PageTransitionsThemeApp(), + ); + + final Finder homePage = find.byType(example.HomePage); + expect(homePage, findsOneWidget); + + final PageTransitionsTheme theme = Theme.of(tester.element(homePage)).pageTransitionsTheme; + expect(theme.builders, isNotNull); + + // Check defined page transitions builder for each platform. + for (final TargetPlatform platform in TargetPlatform.values) { + switch (platform) { + case TargetPlatform.android: + expect(theme.builders[platform], isA()); + final ZoomPageTransitionsBuilder builder = theme.builders[platform]! as ZoomPageTransitionsBuilder; + expect(builder.allowSnapshotting, isFalse); + case TargetPlatform.iOS: + case TargetPlatform.macOS: + case TargetPlatform.linux: + case TargetPlatform.fuchsia: + case TargetPlatform.windows: + expect(theme.builders[platform], isNull); + } + } + + // Can navigate to the second page. + expect(find.text('To SecondPage'), findsOneWidget); + await tester.tap(find.text('To SecondPage')); + await tester.pumpAndSettle(); + + // Can navigate back to the home page. + expect(find.text('Back to HomePage'), findsOneWidget); + await tester.tap(find.text('Back to HomePage')); + await tester.pumpAndSettle(); + expect(find.text('To SecondPage'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/paginated_data_table/paginated_data_table.0_test.dart b/novelforge-project/flutter/examples/api/test/material/paginated_data_table/paginated_data_table.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..31084fc2634e83953349d705ac4766960df84a38 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/paginated_data_table/paginated_data_table.0_test.dart @@ -0,0 +1,13 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_api_samples/material/paginated_data_table/paginated_data_table.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('PaginatedDataTable 0', (WidgetTester tester) async { + await tester.pumpWidget(const example.DataTableExampleApp()); + expect(find.text('Associate Professor'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/paginated_data_table/paginated_data_table.1_test.dart b/novelforge-project/flutter/examples/api/test/material/paginated_data_table/paginated_data_table.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..7a3bb9168586a12e8fb77586181bca29f0a99702 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/paginated_data_table/paginated_data_table.1_test.dart @@ -0,0 +1,23 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/paginated_data_table/paginated_data_table.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('PaginatedDataTable 1', (WidgetTester tester) async { + await tester.pumpWidget(const example.DataTableExampleApp()); + expect(find.text('Strange New Worlds'), findsOneWidget); + await tester.tap(find.byIcon(Icons.arrow_upward).at(1)); + await tester.pump(); + expect(find.text('Strange New Worlds'), findsNothing); + await tester.tap(find.byIcon(Icons.chevron_right)); + await tester.pump(); + expect(find.text('Strange New Worlds'), findsOneWidget); + await tester.tap(find.byIcon(Icons.arrow_upward).at(1)); + await tester.pump(); + expect(find.text('Strange New Worlds'), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/popup_menu/popup_menu.0_test.dart b/novelforge-project/flutter/examples/api/test/material/popup_menu/popup_menu.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..ea43a19750416c223b124a5780e7c0e29013c340 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/popup_menu/popup_menu.0_test.dart @@ -0,0 +1,33 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/popup_menu/popup_menu.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can open popup menu', (WidgetTester tester) async { + const String menuItem = 'Item 1'; + + await tester.pumpWidget( + const MaterialApp( + home: Scaffold( + body: example.PopupMenuApp(), + ), + ), + ); + + expect(find.text(menuItem), findsNothing); + + // Open popup menu. + await tester.tap(find.byIcon(Icons.adaptive.more)); + await tester.pumpAndSettle(); + expect(find.text(menuItem), findsOneWidget); + + // Close popup menu. + await tester.tapAt(const Offset(1, 1)); + await tester.pumpAndSettle(); + expect(find.text(menuItem), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/popup_menu/popup_menu.1_test.dart b/novelforge-project/flutter/examples/api/test/material/popup_menu/popup_menu.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..f68993449525d2369d1f264338fcd203f7c2e5e6 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/popup_menu/popup_menu.1_test.dart @@ -0,0 +1,33 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/popup_menu/popup_menu.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can open popup menu', (WidgetTester tester) async { + const String menuItem = 'Item 1'; + + await tester.pumpWidget( + const MaterialApp( + home: Scaffold( + body: example.PopupMenuApp(), + ), + ), + ); + + expect(find.text(menuItem), findsNothing); + + // Open popup menu. + await tester.tap(find.byIcon(Icons.adaptive.more)); + await tester.pumpAndSettle(); + expect(find.text(menuItem), findsOneWidget); + + // Close popup menu. + await tester.tapAt(const Offset(1, 1)); + await tester.pumpAndSettle(); + expect(find.text(menuItem), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/popup_menu/popup_menu.2_test.dart b/novelforge-project/flutter/examples/api/test/material/popup_menu/popup_menu.2_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..e8e130c7dc9cdae606a6b38d2c0c6aa30af69d19 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/popup_menu/popup_menu.2_test.dart @@ -0,0 +1,63 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/popup_menu/popup_menu.2.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Popup animation can be customized using AnimationStyle', (WidgetTester tester) async { + await tester.pumpWidget( + const example.PopupMenuApp(), + ); + + // Test the default popup animation. + await tester.tap(find.byIcon(Icons.more_vert)); + await tester.pump(); + // Advance the animation by half of the default duration. + await tester.pump(const Duration(milliseconds: 100)); + + expect(tester.getSize(find.byType(Material).last), within(distance: 0.1, from: const Size(224.0, 130.0))); + + // Let the animation finish. + await tester.pumpAndSettle(); + + expect(tester.getSize(find.byType(Material).last), within(distance: 0.1, from: const Size(224.0, 312.0))); + + // Tap outside the popup menu to close it. + await tester.tapAt(const Offset(1, 1)); + await tester.pumpAndSettle(); + + // Test the custom animation curve and duration. + await tester.tap(find.text('Custom')); + await tester.pumpAndSettle(); + + await tester.tap(find.byIcon(Icons.more_vert)); + await tester.pump(); + // Advance the animation by one third of the custom duration. + await tester.pump(const Duration(milliseconds: 1000)); + + expect(tester.getSize(find.byType(Material).last), within(distance: 0.1, from: const Size(224.0, 312.0))); + + // Let the animation finish. + await tester.pumpAndSettle(); + + expect(tester.getSize(find.byType(Material).last), within(distance: 0.1, from: const Size(224.0, 312.0))); + + // Tap outside the popup menu to close it. + await tester.tapAt(const Offset(1, 1)); + await tester.pumpAndSettle(); + + // Test the no animation style. + await tester.tap(find.text('None')); + await tester.pumpAndSettle(); + + await tester.tap(find.byIcon(Icons.more_vert)); + // Advance the animation by only one frame. + await tester.pump(); + + // The popup menu is shown immediately. + expect(tester.getSize(find.byType(Material).last), within(distance: 0.1, from: const Size(224.0, 312.0))); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/progress_indicator/circular_progress_indicator.0_test.dart b/novelforge-project/flutter/examples/api/test/material/progress_indicator/circular_progress_indicator.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..787acd9816a0765c523e10390de77c02ae6b87aa --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/progress_indicator/circular_progress_indicator.0_test.dart @@ -0,0 +1,24 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_api_samples/material/progress_indicator/circular_progress_indicator.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Finds CircularProgressIndicator', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ProgressIndicatorApp(), + ); + + expect( + find.bySemanticsLabel('Circular progress indicator'), + findsOneWidget, + ); + + // Test if CircularProgressIndicator is animating. + await tester.pump(const Duration(seconds: 2)); + expect(tester.hasRunningAnimations, isTrue); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/progress_indicator/circular_progress_indicator.1_test.dart b/novelforge-project/flutter/examples/api/test/material/progress_indicator/circular_progress_indicator.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..8078c63c352ab22e3a3ca4c456c9f12d1e0e6a85 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/progress_indicator/circular_progress_indicator.1_test.dart @@ -0,0 +1,36 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/progress_indicator/circular_progress_indicator.1.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Finds CircularProgressIndicator', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ProgressIndicatorApp(), + ); + + expect( + find.bySemanticsLabel('Circular progress indicator').first, + findsOneWidget, + ); + + // Test if CircularProgressIndicator is animating. + expect(tester.hasRunningAnimations, isTrue); + + await tester.pump(const Duration(seconds: 1)); + expect(tester.hasRunningAnimations, isTrue); + + // Test determinate mode button. + await tester.tap(find.byType(Switch)); + await tester.pumpAndSettle(); + expect(tester.hasRunningAnimations, isFalse); + + await tester.tap(find.byType(Switch)); + await tester.pump(const Duration(seconds: 1)); + expect(tester.hasRunningAnimations, isTrue); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/progress_indicator/linear_progress_indicator.0_test.dart b/novelforge-project/flutter/examples/api/test/material/progress_indicator/linear_progress_indicator.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..339e3dc7eee5ef4d795651fa8ca31454c922209d --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/progress_indicator/linear_progress_indicator.0_test.dart @@ -0,0 +1,24 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_api_samples/material/progress_indicator/linear_progress_indicator.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Finds LinearProgressIndicator', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ProgressIndicatorApp(), + ); + + expect( + find.bySemanticsLabel('Linear progress indicator'), + findsOneWidget, + ); + + // Test if LinearProgressIndicator is animating. + await tester.pump(const Duration(seconds: 2)); + expect(tester.hasRunningAnimations, isTrue); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/progress_indicator/linear_progress_indicator.1_test.dart b/novelforge-project/flutter/examples/api/test/material/progress_indicator/linear_progress_indicator.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..9cf4e91d6d12fea91447f9d4a2a4d00bdb89919f --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/progress_indicator/linear_progress_indicator.1_test.dart @@ -0,0 +1,36 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/progress_indicator/linear_progress_indicator.1.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Finds LinearProgressIndicator', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ProgressIndicatorApp(), + ); + + expect( + find.bySemanticsLabel('Linear progress indicator').first, + findsOneWidget, + ); + + // Test if LinearProgressIndicator is animating. + expect(tester.hasRunningAnimations, isTrue); + + await tester.pump(const Duration(seconds: 1)); + expect(tester.hasRunningAnimations, isTrue); + + // Test determinate mode button. + await tester.tap(find.byType(Switch)); + await tester.pumpAndSettle(); + expect(tester.hasRunningAnimations, isFalse); + + await tester.tap(find.byType(Switch)); + await tester.pump(const Duration(seconds: 1)); + expect(tester.hasRunningAnimations, isTrue); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/radio/radio.0_test.dart b/novelforge-project/flutter/examples/api/test/material/radio/radio.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..2278d4ff686b4cb3f8e2c1e826194fb978e25f1d --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/radio/radio.0_test.dart @@ -0,0 +1,33 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/radio/radio.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Radio Smoke Test', (WidgetTester tester) async { + await tester.pumpWidget( + const example.RadioExampleApp(), + ); + + expect(find.widgetWithText(AppBar, 'Radio Sample'), findsOneWidget); + final Finder listTile1 = find.widgetWithText(ListTile, 'Lafayette'); + expect(listTile1, findsOneWidget); + final Finder listTile2 = find.widgetWithText(ListTile, 'Thomas Jefferson'); + expect(listTile2, findsOneWidget); + + final Finder radioButton1 = find.byType(Radio).first; + final Finder radioButton2 = find.byType(Radio).last; + + await tester.tap(radioButton1); + await tester.pumpAndSettle(); + expect(tester.widget>(radioButton1).groupValue, tester.widget>(radioButton1).value); + expect(tester.widget>(radioButton2).groupValue, isNot(tester.widget>(radioButton2).value)); + await tester.tap(radioButton2); + await tester.pumpAndSettle(); + expect(tester.widget>(radioButton1).groupValue, isNot(tester.widget>(radioButton1).value)); + expect(tester.widget>(radioButton2).groupValue, tester.widget>(radioButton2).value); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/radio/radio.toggleable.0_test.dart b/novelforge-project/flutter/examples/api/test/material/radio/radio.toggleable.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..9b071ad9b16bdb2855947db6f606f207bba3f8b0 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/radio/radio.toggleable.0_test.dart @@ -0,0 +1,32 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/radio/radio.toggleable.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('StreamBuilder listens to internal stream', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ToggleableExampleApp(), + ); + + expect(find.byType(Radio), findsExactly(5)); + expect(find.text('Hercules Mulligan'), findsOne); + expect(find.text('Eliza Hamilton'), findsOne); + expect(find.text('Philip Schuyler'), findsOne); + expect(find.text('Maria Reynolds'), findsOne); + expect(find.text('Samuel Seabury'), findsOne); + + for (int i = 0; i < 5; i++) { + await tester.tap(find.byType(Radio).at(i)); + await tester.pump(); + expect( + find.byWidgetPredicate((Widget widget) => widget is Radio && widget.groupValue == i), + findsExactly(5), + ); + } + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/radio_list_tile/custom_labeled_radio.0_test.dart b/novelforge-project/flutter/examples/api/test/material/radio_list_tile/custom_labeled_radio.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..67842b1de84c5515ac07d66e437c122b5fb637f0 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/radio_list_tile/custom_labeled_radio.0_test.dart @@ -0,0 +1,43 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/radio_list_tile/custom_labeled_radio.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('LinkedLabelRadio contains RichText and Radio', (WidgetTester tester) async { + await tester.pumpWidget( + const example.LabeledRadioApp(), + ); + + // Label text is in a RichText widget with the correct text. + final RichText richText = tester.widget(find.byType(RichText).first); + expect(richText.text.toPlainText(), 'First tappable label text'); + + // First Radio is initially unchecked. + Radio radio = tester.widget(find.byType(Radio).first); + expect(radio.value, true); + expect(radio.groupValue, false); + + // Last Radio is initially checked. + radio = tester.widget(find.byType(Radio).last); + expect(radio.value, false); + expect(radio.groupValue, false); + + // Tap the first radio. + await tester.tap(find.byType(Radio).first); + await tester.pump(); + + // First Radio is now checked. + radio = tester.widget(find.byType(Radio).first); + expect(radio.value, true); + expect(radio.groupValue, true); + + // Last Radio is now unchecked. + radio = tester.widget(find.byType(Radio).last); + expect(radio.value, false); + expect(radio.groupValue, true); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/radio_list_tile/custom_labeled_radio.1_test.dart b/novelforge-project/flutter/examples/api/test/material/radio_list_tile/custom_labeled_radio.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..087f8d9eac3e852285273de8d912e0e01664e053 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/radio_list_tile/custom_labeled_radio.1_test.dart @@ -0,0 +1,39 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/radio_list_tile/custom_labeled_radio.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Tapping LabeledRadio toggles the radio', (WidgetTester tester) async { + await tester.pumpWidget( + const example.LabeledRadioApp(), + ); + + // First Radio is initially unchecked. + Radio radio = tester.widget(find.byType(Radio).first); + expect(radio.value, true); + expect(radio.groupValue, false); + + // Last Radio is initially checked. + radio = tester.widget(find.byType(Radio).last); + expect(radio.value, false); + expect(radio.groupValue, false); + + // Tap the first labeled radio to toggle the Radio widget. + await tester.tap(find.byType(example.LabeledRadio).first); + await tester.pumpAndSettle(); + + // First Radio is now checked. + radio = tester.widget(find.byType(Radio).first); + expect(radio.value, true); + expect(radio.groupValue, true); + + // Last Radio is now unchecked. + radio = tester.widget(find.byType(Radio).last); + expect(radio.value, false); + expect(radio.groupValue, true); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/radio_list_tile/radio_list_tile.0_test.dart b/novelforge-project/flutter/examples/api/test/material/radio_list_tile/radio_list_tile.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..7da8c3f15238d08b327a0facde90019165d274af --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/radio_list_tile/radio_list_tile.0_test.dart @@ -0,0 +1,38 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/radio_list_tile/radio_list_tile.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can update RadioListTile group value', (WidgetTester tester) async { + await tester.pumpWidget( + const example.RadioListTileApp(), + ); + + // Find the number of RadioListTiles. + expect(find.byType(RadioListTile), findsNWidgets(2)); + + // The initial group value is lafayette for the first RadioListTile. + RadioListTile radioListTile = tester.widget(find.byType(RadioListTile).first); + expect(radioListTile.groupValue, example.SingingCharacter.lafayette); + + // The initial group value is lafayette for the last RadioListTile. + radioListTile = tester.widget(find.byType(RadioListTile).last); + expect(radioListTile.groupValue, example.SingingCharacter.lafayette); + + // Tap the last RadioListTile to change the group value to jefferson. + await tester.tap(find.byType(RadioListTile).last); + await tester.pump(); + + // The group value is now jefferson for the first RadioListTile. + radioListTile = tester.widget(find.byType(RadioListTile).first); + expect(radioListTile.groupValue, example.SingingCharacter.jefferson); + + // The group value is now jefferson for the last RadioListTile. + radioListTile = tester.widget(find.byType(RadioListTile).last); + expect(radioListTile.groupValue, example.SingingCharacter.jefferson); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/radio_list_tile/radio_list_tile.1_test.dart b/novelforge-project/flutter/examples/api/test/material/radio_list_tile/radio_list_tile.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..2fcf0c6c631d33e04560cf1ce5163e76213a1a63 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/radio_list_tile/radio_list_tile.1_test.dart @@ -0,0 +1,94 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/radio_list_tile/radio_list_tile.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Radio aligns appropriately', (WidgetTester tester) async { + await tester.pumpWidget( + const example.RadioListTileApp(), + ); + + expect(find.byType(RadioListTile), findsNWidgets(3)); + + Offset tileTopLeft = tester.getTopLeft(find.byType(RadioListTile).at(0)); + Offset radioTopLeft = tester.getTopLeft(find.byType(Radio).at(0)); + + // The radio is centered vertically with the text. + expect(radioTopLeft - tileTopLeft, const Offset(16.0, 16.0)); + + tileTopLeft = tester.getTopLeft(find.byType(RadioListTile).at(1)); + radioTopLeft = tester.getTopLeft(find.byType(Radio).at(1)); + + // The radio is centered vertically with the text. + expect(radioTopLeft - tileTopLeft, const Offset(16.0, 30.0)); + + tileTopLeft = tester.getTopLeft(find.byType(RadioListTile).at(2)); + radioTopLeft = tester.getTopLeft(find.byType(Radio).at(2)); + + // The radio is aligned to the top vertically with the text. + expect(radioTopLeft - tileTopLeft, const Offset(16.0, 8.0)); + }); + + testWidgets('Radios can be checked', (WidgetTester tester) async { + await tester.pumpWidget( + const example.RadioListTileApp(), + ); + + expect(find.byType(RadioListTile), findsNWidgets(3)); + final Finder radioListTile = find.byType(RadioListTile); + + // Initially the first radio is checked. + expect( + tester.widget>(radioListTile.at(0)).groupValue, + example.Groceries.pickles, + ); + expect( + tester.widget>(radioListTile.at(1)).groupValue, + example.Groceries.pickles, + ); + expect( + tester.widget>(radioListTile.at(2)).groupValue, + example.Groceries.pickles, + ); + + // Tap the second radio. + await tester.tap(find.byType(Radio).at(1)); + await tester.pumpAndSettle(); + + // The second radio is checked. + expect( + tester.widget>(radioListTile.at(0)).groupValue, + example.Groceries.tomato, + ); + expect( + tester.widget>(radioListTile.at(1)).groupValue, + example.Groceries.tomato, + ); + expect( + tester.widget>(radioListTile.at(2)).groupValue, + example.Groceries.tomato, + ); + + // Tap the third radio. + await tester.tap(find.byType(Radio).at(2)); + await tester.pumpAndSettle(); + + // The third radio is checked. + expect( + tester.widget>(radioListTile.at(0)).groupValue, + example.Groceries.lettuce, + ); + expect( + tester.widget>(radioListTile.at(1)).groupValue, + example.Groceries.lettuce, + ); + expect( + tester.widget>(radioListTile.at(2)).groupValue, + example.Groceries.lettuce, + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/radio_list_tile/radio_list_tile.toggleable.0_test.dart b/novelforge-project/flutter/examples/api/test/material/radio_list_tile/radio_list_tile.toggleable.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..f88b2764c201e1567030f06ea550a60872acd89a --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/radio_list_tile/radio_list_tile.toggleable.0_test.dart @@ -0,0 +1,38 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/radio_list_tile/radio_list_tile.toggleable.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('RadioListTile is toggleable', (WidgetTester tester) async { + await tester.pumpWidget( + const example.RadioListTileApp(), + ); + + // Initially the third radio button is not selected. + Radio radio = tester.widget(find.byType(Radio).at(2)); + expect(radio.value, 2); + expect(radio.groupValue, null); + + // Tap the third radio button. + await tester.tap(find.text('Philip Schuyler')); + await tester.pumpAndSettle(); + + // The third radio button is now selected. + radio = tester.widget(find.byType(Radio).at(2)); + expect(radio.value, 2); + expect(radio.groupValue, 2); + + // Tap the third radio button again. + await tester.tap(find.text('Philip Schuyler')); + await tester.pumpAndSettle(); + + // The third radio button is now unselected. + radio = tester.widget(find.byType(Radio).at(2)); + expect(radio.value, 2); + expect(radio.groupValue, null); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/refresh_indicator/refresh_indicator.0_test.dart b/novelforge-project/flutter/examples/api/test/material/refresh_indicator/refresh_indicator.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..418f7468e53d5cf7c6aba84b40f78133ddb48aba --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/refresh_indicator/refresh_indicator.0_test.dart @@ -0,0 +1,35 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/refresh_indicator/refresh_indicator.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Trigger RefreshIndicator - Pull from top', (WidgetTester tester) async { + await tester.pumpWidget( + const example.RefreshIndicatorExampleApp(), + ); + + await tester.fling(find.text('Item 1'), const Offset(0.0, 300.0), 1000.0); + await tester.pump(); + await tester.pump(const Duration(seconds: 1)); + await tester.pump(const Duration(seconds: 1)); + expect(tester.getCenter(find.byType(RefreshProgressIndicator)).dy, lessThan(300.0)); + await tester.pumpAndSettle(); // Advance pending time + }); + + testWidgets('Trigger RefreshIndicator - Button', (WidgetTester tester) async { + await tester.pumpWidget( + const example.RefreshIndicatorExampleApp(), + ); + + await tester.tap(find.byType(FloatingActionButton)); + await tester.pump(); + await tester.pump(const Duration(seconds: 1)); + await tester.pump(const Duration(seconds: 1)); + expect(tester.getCenter(find.byType(RefreshProgressIndicator)).dy, lessThan(300.0)); + await tester.pumpAndSettle(); // Advance pending time + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/refresh_indicator/refresh_indicator.1_test.dart b/novelforge-project/flutter/examples/api/test/material/refresh_indicator/refresh_indicator.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..9a97fe876324516528d943296658f4703cacb850 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/refresh_indicator/refresh_indicator.1_test.dart @@ -0,0 +1,27 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/refresh_indicator/refresh_indicator.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Pulling from nested scroll view triggers refresh indicator', (WidgetTester tester) async { + await tester.pumpWidget( + const example.RefreshIndicatorExampleApp(), + ); + + // Pull from the upper scroll view. + await tester.fling(find.text('Pull down here').first, const Offset(0.0, 300.0), 1000.0); + await tester.pump(); + expect(find.byType(RefreshProgressIndicator), findsNothing); + await tester.pumpAndSettle(); // Advance pending time + + // Pull from the nested scroll view. + await tester.fling(find.text('Pull down here').at(3), const Offset(0.0, 300.0), 1000.0); + await tester.pump(); + expect(find.byType(RefreshProgressIndicator), findsOneWidget); + await tester.pumpAndSettle(); // Advance pending time + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/reorderable_list/reorderable_list_view.0_test.dart b/novelforge-project/flutter/examples/api/test/material/reorderable_list/reorderable_list_view.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..5c35aa94ac70e7e07d05e4246d95c0517744ee77 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/reorderable_list/reorderable_list_view.0_test.dart @@ -0,0 +1,34 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/reorderable_list/reorderable_list_view.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Content is reordered after a drag', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ReorderableApp(), + ); + + bool item1IsBeforeItem2() { + final Iterable texts = tester.widgetList(find.byType(Text)); + final List labels = texts.map((final Text text) => text.data).toList(); + return labels.indexOf('Item 1') < labels.indexOf('Item 2'); + } + + expect(item1IsBeforeItem2(), true); + + // Drag 'Item 1' after 'Item 4'. + final TestGesture drag = await tester.startGesture(tester.getCenter(find.text('Item 1'))); + await tester.pump(kLongPressTimeout + kPressTimeout); + await tester.pumpAndSettle(); + await drag.moveTo(tester.getCenter(find.text('Item 4'))); + await drag.up(); + await tester.pumpAndSettle(); + + expect(item1IsBeforeItem2(), false); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/reorderable_list/reorderable_list_view.1_test.dart b/novelforge-project/flutter/examples/api/test/material/reorderable_list/reorderable_list_view.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..12d003cf95069ad50be2f291b0d5654ab97750f9 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/reorderable_list/reorderable_list_view.1_test.dart @@ -0,0 +1,33 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/reorderable_list/reorderable_list_view.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Dragged item color is updated', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ReorderableApp(), + ); + + final ThemeData theme = Theme.of(tester.element(find.byType(MaterialApp))); + + // Dragged item is wrapped in a Material widget with correct color. + final TestGesture drag = await tester.startGesture(tester.getCenter(find.text('Item 1'))); + await tester.pump(kLongPressTimeout + kPressTimeout); + await tester.pumpAndSettle(); + final Material material = tester.widget(find.ancestor( + of: find.text('Item 1'), + matching: find.byType(Material), + )); + expect(material.color, theme.colorScheme.secondary); + + // Ends the drag gesture. + await drag.moveTo(tester.getCenter(find.text('Item 4'))); + await drag.up(); + await tester.pumpAndSettle(); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/reorderable_list/reorderable_list_view.2_test.dart b/novelforge-project/flutter/examples/api/test/material/reorderable_list/reorderable_list_view.2_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..6254d530d702e121f3f37e7c73966146c0401c6f --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/reorderable_list/reorderable_list_view.2_test.dart @@ -0,0 +1,35 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/reorderable_list/reorderable_list_view.2.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Dragged Card is elevated', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ReorderableApp(), + ); + + Card findCardOne() { + return tester.widget(find.ancestor(of: find.text('Card 1'), matching: find.byType(Card))); + } + + // Card has default elevation when not dragged. + expect(findCardOne().elevation, null); + + // Dragged card is elevated. + final TestGesture drag = await tester.startGesture(tester.getCenter(find.text('Card 1'))); + await tester.pump(kLongPressTimeout + kPressTimeout); + await tester.pumpAndSettle(); + expect(findCardOne().elevation, 6); + + // After the drag gesture ends, the card elevation has default value. + await drag.moveTo(tester.getCenter(find.text('Card 4'))); + await drag.up(); + await tester.pumpAndSettle(); + expect(findCardOne().elevation, null); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/reorderable_list/reorderable_list_view.build_default_drag_handles.0_test.dart b/novelforge-project/flutter/examples/api/test/material/reorderable_list/reorderable_list_view.build_default_drag_handles.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..a95e4a8fced4bec833c2535e2235d5fe667e7c03 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/reorderable_list/reorderable_list_view.build_default_drag_handles.0_test.dart @@ -0,0 +1,36 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/reorderable_list/reorderable_list_view.build_default_drag_handles.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + Future longPressDrag(WidgetTester tester, Offset start, Offset end) async { + final TestGesture drag = await tester.startGesture(start); + await tester.pump(kLongPressTimeout + kPressTimeout); + await drag.moveTo(end); + await tester.pump(kPressTimeout); + await drag.up(); + } + + testWidgets('Reorder list item', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.ReorderableApp(), + ), + ); + + expect(tester.getCenter(find.text('Item 3')).dy, 280.0); + await longPressDrag( + tester, + tester.getCenter(find.text('Item 3')), + tester.getCenter(find.text('Item 2')), + ); + await tester.pumpAndSettle(); + expect(tester.getCenter(find.text('Item 3')).dy, 216.0); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/reorderable_list/reorderable_list_view.reorderable_list_view_builder.0_test.dart b/novelforge-project/flutter/examples/api/test/material/reorderable_list/reorderable_list_view.reorderable_list_view_builder.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..b678d076f191343c737224bdf1a7d12f4f746b60 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/reorderable_list/reorderable_list_view.reorderable_list_view_builder.0_test.dart @@ -0,0 +1,36 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/reorderable_list/reorderable_list_view.reorderable_list_view_builder.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + Future longPressDrag(WidgetTester tester, Offset start, Offset end) async { + final TestGesture drag = await tester.startGesture(start); + await tester.pump(kLongPressTimeout + kPressTimeout); + await drag.moveTo(end); + await tester.pump(kPressTimeout); + await drag.up(); + } + + testWidgets('Reorder list item', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.ReorderableApp(), + ), + ); + + expect(tester.getCenter(find.text('Item 3')).dy, 252.0); + await longPressDrag( + tester, + tester.getCenter(find.text('Item 3')), + tester.getCenter(find.text('Item 2')), + ); + await tester.pumpAndSettle(); + expect(tester.getCenter(find.text('Item 3')).dy, 196.0); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/scaffold/scaffold.0_test.dart b/novelforge-project/flutter/examples/api/test/material/scaffold/scaffold.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..6716da938045a13573ff3f80478fa0c19b5a0e7b --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/scaffold/scaffold.0_test.dart @@ -0,0 +1,25 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/scaffold/scaffold.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('The count should be incremented when the floating action button is tapped', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ScaffoldExampleApp(), + ); + + expect(find.widgetWithText(AppBar, 'Sample Code'), findsOne); + expect(find.widgetWithIcon(FloatingActionButton, Icons.add), findsOne); + expect(find.text('You have pressed the button 0 times.'), findsOne); + + for (int i = 1; i <= 5; i++) { + await tester.tap(find.byType(FloatingActionButton)); + await tester.pump(); + expect(find.text('You have pressed the button $i times.'), findsOne); + } + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/scaffold/scaffold.1_test.dart b/novelforge-project/flutter/examples/api/test/material/scaffold/scaffold.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..e456910162ae32111c7b0867f8ed8676c06e0def --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/scaffold/scaffold.1_test.dart @@ -0,0 +1,28 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/scaffold/scaffold.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('The count should be incremented when the floating action button is tapped', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ScaffoldExampleApp(), + ); + + expect(find.widgetWithText(AppBar, 'Sample Code'), findsOne); + expect(find.widgetWithIcon(FloatingActionButton, Icons.add), findsOne); + expect(find.text('You have pressed the button 0 times.'), findsOne); + + for (int i = 1; i <= 5; i++) { + await tester.tap(find.byType(FloatingActionButton)); + await tester.pump(); + expect(find.text('You have pressed the button $i times.'), findsOne); + } + + final Scaffold scaffold = tester.firstWidget(find.byType(Scaffold)); + expect(scaffold.backgroundColor, Colors.blueGrey.shade200); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/scaffold/scaffold.2_test.dart b/novelforge-project/flutter/examples/api/test/material/scaffold/scaffold.2_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..1c27441e5c39930eaf094336da29a82a7ec1d02f --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/scaffold/scaffold.2_test.dart @@ -0,0 +1,27 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/scaffold/scaffold.2.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('The count should be incremented when the centered floating action button is tapped', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ScaffoldExampleApp(), + ); + + expect(find.widgetWithText(AppBar, 'Sample Code'), findsOne); + expect(find.widgetWithIcon(FloatingActionButton, Icons.add), findsOne); + expect(find.text('You have pressed the button 0 times.'), findsOne); + expect(find.byType(BottomAppBar), findsOne); + expect(tester.getCenter(find.byType(FloatingActionButton)).dx, 400); + + for (int i = 1; i <= 5; i++) { + await tester.tap(find.byType(FloatingActionButton)); + await tester.pump(); + expect(find.text('You have pressed the button $i times.'), findsOne); + } + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/scaffold/scaffold.drawer.0_test.dart b/novelforge-project/flutter/examples/api/test/material/scaffold/scaffold.drawer.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..b9cc5c077da58d1231ccddb77f87ccd094933348 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/scaffold/scaffold.drawer.0_test.dart @@ -0,0 +1,55 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/scaffold/scaffold.drawer.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('The page should contain a drawer than can be opened and closed', (WidgetTester tester) async { + await tester.pumpWidget( + const example.DrawerExampleApp(), + ); + + expect(find.byType(Drawer), findsNothing); + + // Open the drawer by tapping the button at the center of the screen. + await tester.tap(find.widgetWithText(ElevatedButton, 'Open Drawer')); + await tester.pumpAndSettle(); + + expect(find.byType(Drawer), findsOne); + expect(tester.getCenter( + find.byType(Drawer)).dx, + lessThan(400), + reason: 'The drawer should be on the left side of the screen', + ); + expect(find.text('This is the Drawer'), findsOne); + + // Close the drawer by tapping the button inside the drawer. + await tester.tap(find.widgetWithText(ElevatedButton, 'Close Drawer')); + await tester.pumpAndSettle(); + + expect(find.byType(Drawer), findsNothing); + + // Open the drawer by tapping the drawer button in the app bar. + expect(tester.getCenter( + find.byType(DrawerButton)).dx, + lessThan(400), + reason: 'The drawer button should be on the left side of the app bar', + ); + await tester.tap(find.byType(DrawerButton)); + await tester.pumpAndSettle(); + + expect(find.byType(Drawer), findsOne); + expect(find.text('This is the Drawer'), findsOne); + + // Close the drawer by tapping outside the drawer. + final Rect drawerRect = tester.getRect(find.byType(Drawer)); + final Offset outsideDrawer = drawerRect.centerRight + const Offset(50, 0); + await tester.tapAt(outsideDrawer); + await tester.pumpAndSettle(); + + expect(find.byType(Drawer), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/scaffold/scaffold.end_drawer.0_test.dart b/novelforge-project/flutter/examples/api/test/material/scaffold/scaffold.end_drawer.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..ad6ae00de42e7c5965639d24fabed4ecb8eb86ba --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/scaffold/scaffold.end_drawer.0_test.dart @@ -0,0 +1,55 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/scaffold/scaffold.end_drawer.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('The page should contain an end drawer than can be opened and closed', (WidgetTester tester) async { + await tester.pumpWidget( + const example.EndDrawerExampleApp(), + ); + + expect(find.byType(Drawer), findsNothing); + + // Open the drawer by tapping the button at the center of the screen. + await tester.tap(find.widgetWithText(ElevatedButton, 'Open End Drawer')); + await tester.pumpAndSettle(); + + expect(find.byType(Drawer), findsOne); + expect(tester.getCenter( + find.byType(Drawer)).dx, + greaterThan(400), + reason: 'The drawer should be on the right side of the screen', + ); + expect(find.text('This is the Drawer'), findsOne); + + // Close the drawer by tapping the button inside the drawer. + await tester.tap(find.widgetWithText(ElevatedButton, 'Close Drawer')); + await tester.pumpAndSettle(); + + expect(find.byType(Drawer), findsNothing); + + // Open the drawer by tapping the drawer button in the app bar. + expect(tester.getCenter( + find.byType(EndDrawerButton)).dx, + greaterThan(400), + reason: 'The drawer button should be on the right side of the app bar', + ); + await tester.tap(find.byType(EndDrawerButton)); + await tester.pumpAndSettle(); + + expect(find.byType(Drawer), findsOne); + expect(find.text('This is the Drawer'), findsOne); + + // Close the drawer by tapping outside the drawer. + final Rect drawerRect = tester.getRect(find.byType(Drawer)); + final Offset outsideDrawer = drawerRect.centerLeft - const Offset(50, 0); + await tester.tapAt(outsideDrawer); + await tester.pumpAndSettle(); + + expect(find.byType(Drawer), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/scaffold/scaffold.floating_action_button_animator.0_test.dart b/novelforge-project/flutter/examples/api/test/material/scaffold/scaffold.floating_action_button_animator.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..ca9be38492285c5220cbdc027fe4b0959d28b286 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/scaffold/scaffold.floating_action_button_animator.0_test.dart @@ -0,0 +1,60 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/scaffold/scaffold.floating_action_button_animator.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('FloatingActionButton animation can be customized', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ScaffoldFloatingActionButtonAnimatorApp(), + ); + + expect(find.byType(FloatingActionButton), findsNothing); + + // Test default FloatingActionButtonAnimator. + // Tap the toggle button to show the FAB. + await tester.tap(find.text('Toggle FAB')); + await tester.pump(); + await tester.pump(const Duration(milliseconds: 100)); // Advance animation by 100ms. + // FAB is partially animated in. + expect(tester.getTopLeft(find.byType(FloatingActionButton)).dx, closeTo(743.8, 0.1)); + + await tester.pump(const Duration(milliseconds: 100)); // Advance animation by 100ms. + // FAB is fully animated in. + expect(tester.getTopLeft(find.byType(FloatingActionButton)).dx, equals(728.0)); + + // Tap the toggle button to hide the FAB. + await tester.tap(find.text('Toggle FAB')); + await tester.pump(); + await tester.pump(const Duration(milliseconds: 100)); // Advance animation by 100ms. + // FAB is partially animated out. + expect(tester.getTopLeft(find.byType(FloatingActionButton)).dx, closeTo(747.1, 0.1)); + + await tester.pump(const Duration(milliseconds: 100)); // Advance animation by 100ms. + // FAB is fully animated out. + expect(tester.getTopLeft(find.byType(FloatingActionButton)).dx, equals(756.0)); + + await tester.pump(const Duration(milliseconds: 50)); // Advance animation by 50ms. + // FAB is hidden. + expect(find.byType(FloatingActionButton), findsNothing); + + // Select 'None' to disable animation. + await tester.tap(find.text('None')); + await tester.pump(); + + // Test no animation FloatingActionButtonAnimator. + await tester.tap(find.text('Toggle FAB')); + await tester.pump(); + // FAB is immediately shown. + expect(tester.getTopLeft(find.byType(FloatingActionButton)).dx, equals(728.0)); + + // Tap the toggle button to hide the FAB. + await tester.tap(find.text('Toggle FAB')); + await tester.pump(); + // FAB is immediately hidden. + expect(find.byType(FloatingActionButton), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/scaffold/scaffold.of.0_test.dart b/novelforge-project/flutter/examples/api/test/material/scaffold/scaffold.of.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..ea88245dc723f2aaa5d33395ce4bd2c59aaba820 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/scaffold/scaffold.of.0_test.dart @@ -0,0 +1,67 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/scaffold/scaffold.of.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Verify correct labels are displayed', (WidgetTester tester) async { + await tester.pumpWidget( + const example.OfExampleApp(), + ); + + expect(find.text('Scaffold.of Example'), findsOneWidget); + expect(find.text('SHOW BOTTOM SHEET'), findsOneWidget); + }); + + testWidgets('Bottom sheet can be shown', (WidgetTester tester) async { + await tester.pumpWidget( + const example.OfExampleApp(), + ); + + expect(find.text('BottomSheet'), findsNothing); + expect( + find.widgetWithText(ElevatedButton, 'Close BottomSheet'), + findsNothing, + ); + + // Tap the button to show the bottom sheet. + await tester.tap( + find.widgetWithText(ElevatedButton, 'SHOW BOTTOM SHEET'), + ); + await tester.pumpAndSettle(); + + expect(find.text('BottomSheet'), findsOneWidget); + expect( + find.widgetWithText(ElevatedButton, 'Close BottomSheet'), + findsOneWidget, + ); + }); + + testWidgets('Bottom sheet can be closed', (WidgetTester tester) async { + await tester.pumpWidget( + const example.OfExampleApp(), + ); + + expect(find.text('BottomSheet'), findsNothing); + + // Tap the button to show the bottom sheet. + await tester.tap( + find.widgetWithText(ElevatedButton, 'SHOW BOTTOM SHEET'), + ); + await tester.pumpAndSettle(); + + expect(find.text('BottomSheet'), findsOneWidget); + + // Tap the button to close the bottom sheet. + await tester.tap( + find.widgetWithText(ElevatedButton, 'Close BottomSheet'), + ); + await tester.pumpAndSettle(); + + expect(find.text('BottomSheet'), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/scaffold/scaffold.of.1_test.dart b/novelforge-project/flutter/examples/api/test/material/scaffold/scaffold.of.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..2de3d02854868743f8a6ce57b6d1300cbbde4a2a --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/scaffold/scaffold.of.1_test.dart @@ -0,0 +1,67 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/scaffold/scaffold.of.1.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Verify correct labels are displayed', (WidgetTester tester) async { + await tester.pumpWidget( + const example.OfExampleApp(), + ); + + expect(find.text('Scaffold.of Example'), findsOneWidget); + expect(find.text('SHOW BOTTOM SHEET'), findsOneWidget); + }); + + testWidgets('Bottom sheet can be shown', (WidgetTester tester) async { + await tester.pumpWidget( + const example.OfExampleApp(), + ); + + expect(find.text('BottomSheet'), findsNothing); + expect( + find.widgetWithText(ElevatedButton, 'Close BottomSheet'), + findsNothing, + ); + + // Tap the button to show the bottom sheet. + await tester.tap( + find.widgetWithText(ElevatedButton, 'SHOW BOTTOM SHEET'), + ); + await tester.pumpAndSettle(); + + expect(find.text('BottomSheet'), findsOneWidget); + expect( + find.widgetWithText(ElevatedButton, 'Close BottomSheet'), + findsOneWidget, + ); + }); + + testWidgets('Bottom sheet can be closed', (WidgetTester tester) async { + await tester.pumpWidget( + const example.OfExampleApp(), + ); + + expect(find.text('BottomSheet'), findsNothing); + + // Tap the button to show the bottom sheet. + await tester.tap( + find.widgetWithText(ElevatedButton, 'SHOW BOTTOM SHEET'), + ); + await tester.pumpAndSettle(); + + expect(find.text('BottomSheet'), findsOneWidget); + + // Tap the button to close the bottom sheet. + await tester.tap( + find.widgetWithText(ElevatedButton, 'Close BottomSheet'), + ); + await tester.pumpAndSettle(); + + expect(find.text('BottomSheet'), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/scaffold/scaffold_messenger_state.show_snack_bar.1_test.dart b/novelforge-project/flutter/examples/api/test/material/scaffold/scaffold_messenger_state.show_snack_bar.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..27b967a4b3623c37cb69d805f5ffc05359ce065b --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/scaffold/scaffold_messenger_state.show_snack_bar.1_test.dart @@ -0,0 +1,36 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/scaffold/scaffold_messenger_state.show_snack_bar.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Floating SnackBar is visible', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SnackBarApp(), + ); + + final Finder buttonFinder = find.byType(ElevatedButton); + await tester.tap(buttonFinder.first); + // Have the SnackBar fully animate out. + await tester.pumpAndSettle(); + + final Finder snackBarFinder = find.byType(SnackBar); + expect(snackBarFinder, findsOneWidget); + + // Grow logo to send SnackBar off screen. + await tester.tap(buttonFinder.last); + await tester.pumpAndSettle(); + + final AssertionError exception = tester.takeException() as AssertionError; + const String message = 'Floating SnackBar presented off screen.\n' + 'A SnackBar with behavior property set to SnackBarBehavior.floating is fully ' + 'or partially off screen because some or all the widgets provided to ' + 'Scaffold.floatingActionButton, Scaffold.persistentFooterButtons and ' + 'Scaffold.bottomNavigationBar take up too much vertical space.\n' + 'Consider constraining the size of these widgets to allow room for the SnackBar to be visible.'; + expect(exception.message, message); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/scaffold/scaffold_messenger_state.show_snack_bar.2_test.dart b/novelforge-project/flutter/examples/api/test/material/scaffold/scaffold_messenger_state.show_snack_bar.2_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..8133cc5d872a36cdf9a640d4492d5331a05c0d7a --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/scaffold/scaffold_messenger_state.show_snack_bar.2_test.dart @@ -0,0 +1,72 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/scaffold/scaffold_messenger_state.show_snack_bar.2.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('ScaffoldMessenger showSnackBar animation can be customized using AnimationStyle', + (WidgetTester tester) async { + await tester.pumpWidget( + const example.SnackBarApp(), + ); + + // Tap the button to show the SnackBar with default animation style. + await tester.tap(find.byType(ElevatedButton)); + await tester.pump(); + await tester.pump(const Duration(milliseconds: 125)); // Advance the animation by 125ms. + + expect(tester.getTopLeft(find.text('I am a snack bar.')).dy, closeTo(576.7, 0.1)); + + await tester.pump(const Duration(milliseconds: 125)); // Advance the animation by 125ms. + + expect(tester.getTopLeft(find.text('I am a snack bar.')).dy, closeTo(566, 0.1)); + + // Tap the close button to dismiss the SnackBar. + await tester.tap(find.byType(IconButton)); + await tester.pump(); + await tester.pump(const Duration(milliseconds: 250)); // Advance the animation by 250ms. + + expect(tester.getTopLeft(find.text('I am a snack bar.')).dy, closeTo(614, 0.1)); + + // Select custom animation style. + await tester.tap(find.text('Custom')); + await tester.pumpAndSettle(); + + // Tap the button to show the SnackBar with custom animation style. + await tester.tap(find.byType(ElevatedButton)); + await tester.pump(); + await tester.pump(const Duration(milliseconds: 1500)); // Advance the animation by 125ms. + + expect(tester.getTopLeft(find.text('I am a snack bar.')).dy, closeTo(576.7, 0.1)); + + await tester.pump(const Duration(milliseconds: 1500)); // Advance the animation by 125ms. + + expect(tester.getTopLeft(find.text('I am a snack bar.')).dy, closeTo(566, 0.1)); + + // Tap the close button to dismiss the SnackBar. + await tester.tap(find.byType(IconButton)); + await tester.pump(); + await tester.pump(const Duration(seconds: 1)); // Advance the animation by 1sec. + + expect(tester.getTopLeft(find.text('I am a snack bar.')).dy, closeTo(614, 0.1)); + + // Select no animation style. + await tester.tap(find.text('None')); + await tester.pumpAndSettle(); + + // Tap the button to show the SnackBar with no animation style. + await tester.tap(find.byType(ElevatedButton)); + await tester.pump(); + + expect(tester.getTopLeft(find.text('I am a snack bar.')).dy, closeTo(566, 0.1)); + + // Tap the close button to dismiss the SnackBar. + await tester.tap(find.byType(IconButton)); + await tester.pump(); + + expect(find.text('I am a snack bar.'), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/scaffold/scaffold_state.show_bottom_sheet.1_test.dart b/novelforge-project/flutter/examples/api/test/material/scaffold/scaffold_state.show_bottom_sheet.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..8ff0a1fc8f2edd9b50e2a1d40327f2cea147c1e0 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/scaffold/scaffold_state.show_bottom_sheet.1_test.dart @@ -0,0 +1,66 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/scaffold/scaffold_state.show_bottom_sheet.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Scaffold showBottomSheet animation can be customized using AnimationStyle', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ShowBottomSheetExampleApp(), + ); + + // Show the bottom sheet with default animation style. + await tester.tap(find.widgetWithText(ElevatedButton, 'showBottomSheet')); + await tester.pump(); + // Advance the animation by 1/2 of the default forward duration. + await tester.pump(const Duration(milliseconds: 125)); + + // The bottom sheet is partially visible. + expect(tester.getTopLeft(find.byType(BottomSheet)).dy, closeTo(444.8, 0.1)); + + // Advance the animation by 1/2 of the default forward duration. + await tester.pump(const Duration(milliseconds: 125)); + + // The bottom sheet is fully visible. + expect(tester.getTopLeft(find.byType(BottomSheet)).dy, equals(400.0)); + + // Dismiss the bottom sheet. + await tester.tap(find.widgetWithText(ElevatedButton, 'Close')); + await tester.pumpAndSettle(); + + // Select custom animation style. + await tester.tap(find.text('Custom')); + await tester.pumpAndSettle(); + + // Show the bottom sheet with custom animation style. + await tester.tap(find.widgetWithText(ElevatedButton, 'showBottomSheet')); + await tester.pump(); + // Advance the animation by 1/2 of the custom forward duration. + await tester.pump(const Duration(milliseconds: 1500)); + + // The bottom sheet is partially visible. + expect(tester.getTopLeft(find.byType(BottomSheet)).dy, closeTo(444.8, 0.1)); + + // Advance the animation by 1/2 of the custom forward duration. + await tester.pump(const Duration(milliseconds: 1500)); + + // The bottom sheet is fully visible. + expect(tester.getTopLeft(find.byType(BottomSheet)).dy, equals(400.0)); + + // Dismiss the bottom sheet. + await tester.tap(find.widgetWithText(ElevatedButton, 'Close')); + await tester.pumpAndSettle(); + + // Select no animation style. + await tester.tap(find.text('None')); + await tester.pumpAndSettle(); + + // Show the bottom sheet with no animation style. + await tester.tap(find.widgetWithText(ElevatedButton, 'showBottomSheet')); + await tester.pump(); + expect(tester.getTopLeft(find.byType(BottomSheet)).dy, equals(400.0)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/scrollbar/scrollbar.0_test.dart b/novelforge-project/flutter/examples/api/test/material/scrollbar/scrollbar.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..330f4f9408fcfaad568de539ca569097485d000b --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/scrollbar/scrollbar.0_test.dart @@ -0,0 +1,21 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/scrollbar/scrollbar.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Scrollbar.0 works well on all platforms', (WidgetTester tester) async { + + await tester.pumpWidget( + const example.ScrollbarExampleApp(), + ); + + final Finder buttonFinder = find.byType(Scrollbar); + await tester.drag(buttonFinder.last, const Offset(0, 100.0)); + + expect(tester.takeException(), isNull); + }, variant: TargetPlatformVariant.all()); +} diff --git a/novelforge-project/flutter/examples/api/test/material/search_anchor/search_anchor.3_test.dart b/novelforge-project/flutter/examples/api/test/material/search_anchor/search_anchor.3_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..484c5cdfe0e1863ee44d1a2a19af5c2ed8b07d65 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/search_anchor/search_anchor.3_test.dart @@ -0,0 +1,34 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/search_anchor/search_anchor.3.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('can search and find options after waiting for fake network delay', (WidgetTester tester) async { + await tester.pumpWidget(const example.SearchAnchorAsyncExampleApp()); + + await tester.tap(find.byIcon(Icons.search)); + await tester.pumpAndSettle(); + + expect(find.widgetWithText(ListTile, 'aardvark'), findsNothing); + expect(find.widgetWithText(ListTile, 'bobcat'), findsNothing); + expect(find.widgetWithText(ListTile, 'chameleon'), findsNothing); + + await tester.enterText(find.byType(SearchBar), 'a'); + await tester.pump(example.fakeAPIDuration); + + expect(find.widgetWithText(ListTile, 'aardvark'), findsOneWidget); + expect(find.widgetWithText(ListTile, 'bobcat'), findsOneWidget); + expect(find.widgetWithText(ListTile, 'chameleon'), findsOneWidget); + + await tester.enterText(find.byType(SearchBar), 'aa'); + await tester.pump(example.fakeAPIDuration); + + expect(find.widgetWithText(ListTile, 'aardvark'), findsOneWidget); + expect(find.widgetWithText(ListTile, 'bobcat'), findsNothing); + expect(find.widgetWithText(ListTile, 'chameleon'), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/search_anchor/search_anchor.4_test.dart b/novelforge-project/flutter/examples/api/test/material/search_anchor/search_anchor.4_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..9074fb95b3f21f8832a8689b2338c06e862fd99b --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/search_anchor/search_anchor.4_test.dart @@ -0,0 +1,86 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/search_anchor/search_anchor.4.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('can search and find options after waiting for fake network delay and debounce delay', (WidgetTester tester) async { + await tester.pumpWidget(const example.SearchAnchorAsyncExampleApp()); + + await tester.tap(find.byIcon(Icons.search)); + await tester.pumpAndSettle(); + + expect(find.widgetWithText(ListTile, 'aardvark'), findsNothing); + expect(find.widgetWithText(ListTile, 'bobcat'), findsNothing); + expect(find.widgetWithText(ListTile, 'chameleon'), findsNothing); + + await tester.enterText(find.byType(SearchBar), 'a'); + await tester.pump(example.fakeAPIDuration); + + // No results yet, need to also wait for the debounce duration. + expect(find.widgetWithText(ListTile, 'aardvark'), findsNothing); + expect(find.widgetWithText(ListTile, 'bobcat'), findsNothing); + expect(find.widgetWithText(ListTile, 'chameleon'), findsNothing); + + await tester.pump(example.debounceDuration); + + expect(find.widgetWithText(ListTile, 'aardvark'), findsOneWidget); + expect(find.widgetWithText(ListTile, 'bobcat'), findsOneWidget); + expect(find.widgetWithText(ListTile, 'chameleon'), findsOneWidget); + + await tester.enterText(find.byType(SearchBar), 'aa'); + await tester.pump(example.debounceDuration + example.fakeAPIDuration); + + expect(find.widgetWithText(ListTile, 'aardvark'), findsOneWidget); + expect(find.widgetWithText(ListTile, 'bobcat'), findsNothing); + expect(find.widgetWithText(ListTile, 'chameleon'), findsNothing); + }); + + testWidgets('debounce is reset each time a character is entered', (WidgetTester tester) async { + await tester.pumpWidget(const example.SearchAnchorAsyncExampleApp()); + + await tester.tap(find.byIcon(Icons.search)); + await tester.pumpAndSettle(); + + await tester.enterText(find.byType(SearchBar), 'c'); + await tester.pump(example.debounceDuration - const Duration(milliseconds: 100)); + + expect(find.widgetWithText(ListTile, 'aardvark'), findsNothing); + expect(find.widgetWithText(ListTile, 'bobcat'), findsNothing); + expect(find.widgetWithText(ListTile, 'chameleon'), findsNothing); + + await tester.enterText(find.byType(SearchBar), 'ch'); + await tester.pump(example.debounceDuration - const Duration(milliseconds: 100)); + + expect(find.widgetWithText(ListTile, 'aardvark'), findsNothing); + expect(find.widgetWithText(ListTile, 'bobcat'), findsNothing); + expect(find.widgetWithText(ListTile, 'chameleon'), findsNothing); + + await tester.enterText(find.byType(SearchBar), 'cha'); + await tester.pump(example.debounceDuration - const Duration(milliseconds: 100)); + + expect(find.widgetWithText(ListTile, 'aardvark'), findsNothing); + expect(find.widgetWithText(ListTile, 'bobcat'), findsNothing); + expect(find.widgetWithText(ListTile, 'chameleon'), findsNothing); + + await tester.enterText(find.byType(SearchBar), 'cham'); + await tester.pump(example.debounceDuration - const Duration(milliseconds: 100)); + + // Despite the total elapsed time being greater than debounceDuration + + // fakeAPIDuration, the search has not yet completed, because the debounce + // was reset each time text input happened. + expect(find.widgetWithText(ListTile, 'aardvark'), findsNothing); + expect(find.widgetWithText(ListTile, 'bobcat'), findsNothing); + expect(find.widgetWithText(ListTile, 'chameleon'), findsNothing); + + await tester.enterText(find.byType(SearchBar), 'chame'); + await tester.pump(example.debounceDuration + example.fakeAPIDuration); + + expect(find.widgetWithText(ListTile, 'aardvark'), findsNothing); + expect(find.widgetWithText(ListTile, 'bobcat'), findsNothing); + expect(find.widgetWithText(ListTile, 'chameleon'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/search_anchor/search_bar.0_test.dart b/novelforge-project/flutter/examples/api/test/material/search_anchor/search_bar.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..0dac8a82cd31ce9bb7c3d2fda6feb5c719aa6ed7 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/search_anchor/search_bar.0_test.dart @@ -0,0 +1,37 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/search_anchor/search_bar.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can open search view', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SearchBarApp(), + ); + + final Finder searchBarFinder = find.byType(SearchBar); + final SearchBar searchBar = tester.widget(searchBarFinder); + expect(find.byIcon(Icons.search), findsOneWidget); + expect(searchBar.trailing, isNotEmpty); + expect(searchBar.trailing?.length, equals(1)); + final Finder trailingButtonFinder = find.widgetWithIcon(IconButton, Icons.wb_sunny_outlined); + expect(trailingButtonFinder, findsOneWidget); + + await tester.tap(trailingButtonFinder); + await tester.pumpAndSettle(); + + expect(find.widgetWithIcon(IconButton, Icons.brightness_2_outlined), findsOneWidget); + + await tester.tap(searchBarFinder); + await tester.pumpAndSettle(); + + expect(find.text('item 0'), findsOneWidget); + expect(find.text('item 1'), findsOneWidget); + expect(find.text('item 2'), findsOneWidget); + expect(find.text('item 3'), findsOneWidget); + expect(find.text('item 4'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/segmented_button/segmented_button.0_test.dart b/novelforge-project/flutter/examples/api/test/material/segmented_button/segmented_button.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..f33de9163f82acccfeab3d5b36bb8f8380e0732b --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/segmented_button/segmented_button.0_test.dart @@ -0,0 +1,110 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/segmented_button/segmented_button.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Segmented button can be used with a single selection', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SegmentedButtonApp(), + ); + + void expectOneCalendarButton(example.Calendar period) { + expect( + find.byWidgetPredicate( + (Widget widget) => widget is SegmentedButton && setEquals(widget.selected, {period}), + ), + findsOne, + ); + } + + expect(find.text('Single choice'), findsOne); + expect(find.text('Day'), findsOne); + expect(find.text('Week'), findsOne); + expect(find.text('Month'), findsOne); + expect(find.text('Year'), findsOne); + + expectOneCalendarButton(example.Calendar.day); + + // Select the day. + await tester.tap(find.text('Week')); + await tester.pump(); + + expectOneCalendarButton(example.Calendar.week); + + // Select the month. + await tester.tap(find.text('Month')); + await tester.pump(); + + expectOneCalendarButton(example.Calendar.month); + + // Select the year. + await tester.tap(find.text('Year')); + await tester.pump(); + + expectOneCalendarButton(example.Calendar.year); + + // Select the day. + await tester.tap(find.text('Day')); + await tester.pump(); + + expectOneCalendarButton(example.Calendar.day); + + // Try to unselect the day. + await tester.tap(find.text('Day')); + await tester.pump(); + + expectOneCalendarButton(example.Calendar.day); + }); + + testWidgets('Segmented button can be used with a multiple selection', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SegmentedButtonApp(), + ); + + void expectSizeButtons(Set sizes) { + expect( + find.byWidgetPredicate( + (Widget widget) => widget is SegmentedButton && setEquals(widget.selected, sizes), + ), + findsOne, + ); + } + + expect(find.text('Multiple choice'), findsOne); + expect(find.text('XS'), findsOne); + expect(find.text('S'), findsOne); + expect(find.text('M'), findsOne); + expect(find.text('L'), findsOne); + expect(find.text('XL'), findsOne); + + expectSizeButtons(const {example.Sizes.large, example.Sizes.extraLarge}); + + // Select everything. + await tester.tap(find.text('XS')); + await tester.pump(); + await tester.tap(find.text('S')); + await tester.pump(); + await tester.tap(find.text('M')); + await tester.pump(); + + expectSizeButtons(example.Sizes.values.toSet()); + + // Unselect everything but XS. + await tester.tap(find.text('S')); + await tester.pump(); + await tester.tap(find.text('M')); + await tester.pump(); + await tester.tap(find.text('L')); + await tester.pump(); + await tester.tap(find.text('XL')); + await tester.pump(); + + expectSizeButtons(const {example.Sizes.extraSmall}); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/segmented_button/segmented_button.1_test.dart b/novelforge-project/flutter/examples/api/test/material/segmented_button/segmented_button.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..885bf0e722f4a0a9011093aafa53fb92fdac67e1 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/segmented_button/segmented_button.1_test.dart @@ -0,0 +1,36 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/segmented_button/segmented_button.1.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can use SegmentedButton.styleFrom to customize SegmentedButton', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SegmentedButtonApp(), + ); + + final Color unselectedBackgroundColor = Colors.grey[200]!; + const Color unselectedForegroundColor = Colors.red; + const Color selectedBackgroundColor = Colors.green; + const Color selectedForegroundColor = Colors.white; + + Material getMaterial(String text) { + return tester.widget(find.ancestor( + of: find.text(text), + matching: find.byType(Material), + ).first); + } + + // Verify the unselected button style. + expect(getMaterial('Day').textStyle?.color, unselectedForegroundColor); + expect(getMaterial('Day').color, unselectedBackgroundColor); + + // Verify the selected button style. + expect(getMaterial('Week').textStyle?.color, selectedForegroundColor); + expect(getMaterial('Week').color, selectedBackgroundColor); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/slider/slider.0_test.dart b/novelforge-project/flutter/examples/api/test/material/slider/slider.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..8ab403e3eb0e970cead80cf061a4f4b75607f022 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/slider/slider.0_test.dart @@ -0,0 +1,29 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/slider/slider.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Slider can change its value', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SliderApp(), + ); + + expect(find.byType(Slider), findsOneWidget); + + final Finder sliderFinder = find.byType(Slider); + + Slider slider = tester.widget(sliderFinder); + expect(slider.value, 20); + + final Offset center = tester.getCenter(sliderFinder); + await tester.tapAt(Offset(center.dx + 100, center.dy)); + await tester.pump(); + + slider = tester.widget(sliderFinder); + expect(slider.value, 60.0); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/slider/slider.1_test.dart b/novelforge-project/flutter/examples/api/test/material/slider/slider.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..3cdfc5cdb7cafcc655c73a9f2957e24a38b96a2d --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/slider/slider.1_test.dart @@ -0,0 +1,29 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/slider/slider.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Slider can change its value', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SliderApp(), + ); + + expect(find.byType(Slider), findsOneWidget); + + final Finder sliderFinder = find.byType(Slider); + + Slider slider = tester.widget(sliderFinder); + expect(slider.value, 20); + + final Offset center = tester.getCenter(sliderFinder); + await tester.tapAt(Offset(center.dx + 100, center.dy)); + await tester.pump(); + + slider = tester.widget(sliderFinder); + expect(slider.value, 60.0); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/slider/slider.2_test.dart b/novelforge-project/flutter/examples/api/test/material/slider/slider.2_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..1ec99374587e374897424b872a821ffc0ef0caec --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/slider/slider.2_test.dart @@ -0,0 +1,35 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/slider/slider.2.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Slider shows secondary track', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SliderApp(), + ); + + expect(find.byType(Slider), findsNWidgets(2)); + + final Finder slider1Finder = find.byType(Slider).at(0); + final Finder slider2Finder = find.byType(Slider).at(1); + + Slider slider1 = tester.widget(slider1Finder); + Slider slider2 = tester.widget(slider2Finder); + expect(slider1.secondaryTrackValue, slider2.value); + + const double targetValue = 0.8; + final Rect rect = tester.getRect(slider2Finder); + final Offset target = Offset(rect.left + (rect.right - rect.left) * targetValue, rect.top + (rect.bottom - rect.top) / 2); + await tester.tapAt(target); + await tester.pump(); + + slider1 = tester.widget(slider1Finder); + slider2 = tester.widget(slider2Finder); + expect(slider1.secondaryTrackValue, closeTo(targetValue, 0.05)); + expect(slider1.secondaryTrackValue, slider2.value); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/snack_bar/snack_bar.0_test.dart b/novelforge-project/flutter/examples/api/test/material/snack_bar/snack_bar.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..f4dac7712808623ff11d60a558a5e07d66c3300c --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/snack_bar/snack_bar.0_test.dart @@ -0,0 +1,22 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/snack_bar/snack_bar.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Clicking on Button shows a SnackBar', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SnackBarExampleApp(), + ); + + expect(find.widgetWithText(AppBar, 'SnackBar Sample'), findsOneWidget); + expect(find.widgetWithText(ElevatedButton, 'Show Snackbar'), findsOneWidget); + await tester.tap(find.widgetWithText(ElevatedButton, 'Show Snackbar')); + await tester.pumpAndSettle(); + expect(find.text('Awesome Snackbar!'), findsOneWidget); + expect(find.text('Action'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/snack_bar/snack_bar.1_test.dart b/novelforge-project/flutter/examples/api/test/material/snack_bar/snack_bar.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..5514a0d49e44a7cea9b2d3a27e6386b84c66988e --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/snack_bar/snack_bar.1_test.dart @@ -0,0 +1,60 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/snack_bar/snack_bar.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Tapping on button shows snackbar', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SnackBarExampleApp(), + ); + + expect(find.byType(SnackBar), findsNothing); + expect(find.widgetWithText(AppBar, 'SnackBar Sample'), findsOneWidget); + + await tester.tap(find.widgetWithText(ElevatedButton, 'Show Snackbar')); + await tester.pump(); + + expect(find.text('Awesome SnackBar!'), findsOneWidget); + expect(find.widgetWithText(SnackBarAction, 'Action'), findsOneWidget); + + final SnackBar bar = tester.widget(find.ancestor( + of: find.text('Awesome SnackBar!'), + matching: find.byType(SnackBar))); + expect(bar.behavior, SnackBarBehavior.floating); + }); + + testWidgets('Snackbar is styled correctly', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SnackBarExampleApp(), + ); + await tester.tap(find.byType(ElevatedButton)); + await tester.pump(); + + expect(find.byType(SnackBar), findsOneWidget); + + final SnackBar bar = tester.widget(find.byType(SnackBar)); + expect(bar.behavior, SnackBarBehavior.floating); + expect(bar.width, 280.0); + expect(bar.shape, isA() + .having((RoundedRectangleBorder b) => b.borderRadius, 'radius', BorderRadius.circular(10.0))); + }); + + testWidgets('Snackbar should disappear after timeout', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SnackBarExampleApp(), + ); + expect(find.byType(SnackBar), findsNothing); + + await tester.tap(find.byType(ElevatedButton)); + await tester.pumpAndSettle(); + expect(find.byType(SnackBar), findsOneWidget); + + await tester.pump(const Duration(milliseconds: 1500)); + await tester.pumpAndSettle(); + expect(find.byType(SnackBar), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/snack_bar/snack_bar.2_test.dart b/novelforge-project/flutter/examples/api/test/material/snack_bar/snack_bar.2_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..325454ff9b8434ec6d015f5676aa12f048d341e8 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/snack_bar/snack_bar.2_test.dart @@ -0,0 +1,154 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/snack_bar/snack_bar.2.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Shows correct static elements', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SnackBarExampleApp(), + ); + + expect(find.byType(SnackBar), findsNothing); + expect(find.widgetWithText(AppBar, 'SnackBar Sample'), findsOneWidget); + expect(find.widgetWithText(FloatingActionButton, 'Show Snackbar'), findsOneWidget); + expect(find.text('Behavior'), findsOneWidget); + expect(find.text('Fixed'), findsOneWidget); + expect(find.text('Floating'), findsOneWidget); + expect(find.text('Content'), findsOneWidget); + expect(find.widgetWithText(SwitchListTile, 'Include close Icon'), findsOneWidget); + expect(find.widgetWithText(SwitchListTile, 'Multi Line Text'), findsOneWidget); + expect(find.widgetWithText(SwitchListTile, 'Include Action'), findsOneWidget); + expect(find.widgetWithText(SwitchListTile, 'Long Action Label'), findsOneWidget); + + await tester.scrollUntilVisible(find.byType(Slider), 30); + expect(find.text('Action new-line overflow threshold'), findsOneWidget); + expect(find.byType(Slider), findsOneWidget); + }); + + testWidgets('Applies default configuration to snackbar', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SnackBarExampleApp(), + ); + + expect(find.byType(SnackBar), findsNothing); + expect(find.text('Single Line Snack Bar'), findsNothing); + expect(find.textContaining('spans across multiple lines'), findsNothing); + expect(find.text('Long Action Text'), findsNothing); + expect(find.text('Action'), findsNothing); + expect(find.byIcon(Icons.close), findsNothing); + + await tester.tap(find.text('Show Snackbar')); + await tester.pumpAndSettle(); + + expect(find.byType(SnackBar), findsOneWidget); + expect(find.text('Single Line Snack Bar'), findsOneWidget); + expect(find.text('Action'), findsOneWidget); + expect(find.byIcon(Icons.close), findsOneWidget); + expect(tester + .widget(find.byType(SnackBar)) + .behavior, + SnackBarBehavior.floating); + + await tester.tap(find.byIcon(Icons.close)); + await tester.pumpAndSettle(); + expect(find.byType(SnackBar), findsNothing); + }); + + testWidgets('Can configure fixed snack bar with long text', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SnackBarExampleApp(), + ); + + await tester.tap(find.text('Fixed')); + await tester.tap(find.text('Multi Line Text')); + await tester.tap(find.text('Long Action Label')); + await tester.tap(find.text('Show Snackbar')); + await tester.pumpAndSettle(); + + expect(find.byType(SnackBar), findsOneWidget); + expect(find.textContaining('spans across multiple lines'), findsOneWidget); + expect(find.text('Long Action Text'), findsOneWidget); + expect(find.byIcon(Icons.close), findsOneWidget); + expect(tester + .widget(find.byType(SnackBar)) + .behavior, + SnackBarBehavior.fixed); + + await tester.tap(find.byIcon(Icons.close)); + await tester.pumpAndSettle(); + expect(find.byType(SnackBar), findsNothing); + }); + + testWidgets('Can configure to remove action and close icon', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SnackBarExampleApp(), + ); + + await tester.tap(find.text('Include close Icon')); + await tester.tap(find.text('Include Action')); + await tester.tap(find.text('Show Snackbar')); + await tester.pumpAndSettle(); + + expect(find.byType(SnackBar), findsOneWidget); + expect(find.byType(SnackBarAction), findsNothing); + expect(find.byIcon(Icons.close), findsNothing); + }); + + testWidgets('Higher overflow threshold leads to smaller snack bars', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SnackBarExampleApp(), + ); + + await tester.tap(find.text('Fixed')); + await tester.tap(find.text('Multi Line Text')); + await tester.tap(find.text('Long Action Label')); + + // Establish max size with low threshold (causes overflow) + await tester.scrollUntilVisible(find.byType(Slider), 30); + TestGesture gesture = await tester.startGesture(tester.getCenter(find.byType(Slider))); + await gesture.moveTo(tester.getBottomLeft(find.byType(Slider))); + await gesture.up(); + await tester.tapAt(tester.getBottomLeft(find.byType(Slider))); + await tester.tap(find.text('Show Snackbar')); + await tester.pumpAndSettle(); + + final double highSnackBar = tester.getSize(find.byType(SnackBar)).height; + await tester.tap(find.byIcon(Icons.close)); + await tester.pumpAndSettle(); + + // Configure high threshold (everything is in one row) + gesture = await tester.startGesture(tester.getCenter(find.byType(Slider))); + await gesture.moveTo(tester.getTopRight(find.byType(Slider))); + await gesture.up(); + await tester.tapAt(tester.getTopRight(find.byType(Slider))); + await tester.tap(find.text('Show Snackbar')); + await tester.pumpAndSettle(); + + expect(tester.getSize(find.byType(SnackBar)).height, + lessThan(highSnackBar)); + }); + + testWidgets('Disable unusable elements', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SnackBarExampleApp(), + ); + + expect(find.text('Long Action Label'), findsOneWidget); + expect(tester.widget(find.ancestor( + of: find.text('Long Action Label'), + matching: find.byType(SwitchListTile), + )).onChanged, isNotNull); + + await tester.tap(find.text('Include Action')); + await tester.pumpAndSettle(); + + expect(tester.widget(find.ancestor( + of: find.text('Long Action Label'), + matching: find.byType(SwitchListTile), + )).onChanged, isNull); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/stepper/step_style.0_test.dart b/novelforge-project/flutter/examples/api/test/material/stepper/step_style.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..db15bc72c14e3bcb04bf55daec95feb8765aaa06 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/stepper/step_style.0_test.dart @@ -0,0 +1,72 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/stepper/step_style.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('StepStyle Smoke Test', (WidgetTester tester) async { + await tester.pumpWidget( + const example.StepStyleExampleApp(), + ); + + expect(find.widgetWithText(AppBar, 'Step Style Example'), findsOneWidget); + + final Stepper stepper = tester.widget(find.byType(Stepper)); + // Check that the stepper has the correct properties. + expect(stepper.type, StepperType.horizontal); + expect(stepper.stepIconHeight, 48); + expect(stepper.stepIconWidth, 48); + expect(stepper.stepIconMargin, EdgeInsets.zero); + + // Check that the first step has the correct properties. + final Step firstStep = stepper.steps[0]; + expect(firstStep.title, isA()); + expect(firstStep.content, isA()); + expect(firstStep.isActive, true); + expect(firstStep.stepStyle?.connectorThickness, 10); + expect(firstStep.stepStyle?.color, Colors.white); + expect(firstStep.stepStyle?.connectorColor, Colors.red); + expect(firstStep.stepStyle?.indexStyle?.color, Colors.black); + expect(firstStep.stepStyle?.indexStyle?.fontSize, 20); + expect(firstStep.stepStyle?.border, Border.all(width: 2)); + + // Check that the second step has the correct properties. + final Step secondStep = stepper.steps[1]; + expect(secondStep.title, isA()); + expect(secondStep.content, isA()); + expect(secondStep.isActive, true); + expect(secondStep.stepStyle?.connectorThickness, 10); + expect(secondStep.stepStyle?.connectorColor, Colors.orange); + expect(secondStep.stepStyle?.gradient, const LinearGradient( + colors: [ + Colors.white, + Colors.black, + ], + )); + + // Check that the third step has the correct properties. + final Step thirdStep = stepper.steps[2]; + expect(thirdStep.title, isA()); + expect(thirdStep.content, isA()); + expect(thirdStep.isActive, true); + expect(thirdStep.stepStyle?.connectorThickness, 10); + expect(thirdStep.stepStyle?.color, Colors.white); + expect(thirdStep.stepStyle?.connectorColor, Colors.blue); + expect(thirdStep.stepStyle?.indexStyle?.color, Colors.black); + expect(thirdStep.stepStyle?.indexStyle?.fontSize, 20); + expect(thirdStep.stepStyle?.border, Border.all(width: 2)); + + // Check that the fourth step has the correct properties. + final Step fourthStep = stepper.steps[3]; + expect(fourthStep.title, isA()); + expect(fourthStep.content, isA()); + expect(fourthStep.isActive, true); + expect(fourthStep.stepStyle?.color, Colors.white); + expect(fourthStep.stepStyle?.indexStyle?.color, Colors.black); + expect(fourthStep.stepStyle?.indexStyle?.fontSize, 20); + expect(fourthStep.stepStyle?.border, Border.all(width: 2)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/stepper/stepper.0_test.dart b/novelforge-project/flutter/examples/api/test/material/stepper/stepper.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..fe7d0ab5e49cc95e2d6afff844971b39ae30f2bf --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/stepper/stepper.0_test.dart @@ -0,0 +1,70 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/stepper/stepper.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Stepper Smoke Test', (WidgetTester tester) async { + await tester.pumpWidget( + const example.StepperExampleApp(), + ); + + expect(find.widgetWithText(AppBar, 'Stepper Sample'), findsOneWidget); + expect(find.text('Step 1 title').hitTestable(), findsOneWidget); + expect(find.text('Step 2 title').hitTestable(), findsOneWidget); + expect(find.text('Content for Step 1').hitTestable(), findsOneWidget); + expect(find.text('Content for Step 2').hitTestable(), findsNothing); + final Stepper stepper = tester.widget(find.byType(Stepper)); + + // current: 0 & clicks cancel + stepper.onStepCancel?.call(); + await tester.pumpAndSettle(); + expect(find.text('Content for Step 1').hitTestable(), findsOneWidget); + expect(find.text('Content for Step 2').hitTestable(), findsNothing); + + // current: 0 & clicks 0th step + stepper.onStepTapped?.call(0); + await tester.pumpAndSettle(); + expect(find.text('Content for Step 1').hitTestable(), findsOneWidget); + expect(find.text('Content for Step 2').hitTestable(), findsNothing); + + // current: 0 & clicks continue + stepper.onStepContinue?.call(); + await tester.pumpAndSettle(); + expect(find.text('Content for Step 1').hitTestable(), findsNothing); + expect(find.text('Content for Step 2').hitTestable(), findsOneWidget); + + // current: 1 & clicks 1st step + stepper.onStepTapped?.call(1); + await tester.pumpAndSettle(); + expect(find.text('Content for Step 1').hitTestable(), findsNothing); + expect(find.text('Content for Step 2').hitTestable(), findsOneWidget); + + // current: 1 & clicks continue + stepper.onStepContinue?.call(); + await tester.pumpAndSettle(); + expect(find.text('Content for Step 1').hitTestable(), findsNothing); + expect(find.text('Content for Step 2').hitTestable(), findsOneWidget); + + // current: 1 & clicks cancel + stepper.onStepCancel?.call(); + await tester.pumpAndSettle(); + expect(find.text('Content for Step 1').hitTestable(), findsOneWidget); + expect(find.text('Content for Step 2').hitTestable(), findsNothing); + + // current: 0 & clicks 1st step + stepper.onStepTapped?.call(1); + await tester.pumpAndSettle(); + expect(find.text('Content for Step 1').hitTestable(), findsNothing); + expect(find.text('Content for Step 2').hitTestable(), findsOneWidget); + + // current: 1 & clicks 0th step + stepper.onStepTapped?.call(0); + await tester.pumpAndSettle(); + expect(find.text('Content for Step 1').hitTestable(), findsOneWidget); + expect(find.text('Content for Step 2').hitTestable(), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/switch/switch.0_test.dart b/novelforge-project/flutter/examples/api/test/material/switch/switch.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..eb972b265dd6f58a87001ee53c0382c25aaa4f4e --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/switch/switch.0_test.dart @@ -0,0 +1,24 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/switch/switch.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can toggle switch', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SwitchApp(), + ); + + final Finder switchFinder = find.byType(Switch); + Switch materialSwitch = tester.widget(switchFinder); + expect(materialSwitch.value, true); + + await tester.tap(switchFinder); + await tester.pumpAndSettle(); + materialSwitch = tester.widget(switchFinder); + expect(materialSwitch.value, false); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/switch/switch.1_test.dart b/novelforge-project/flutter/examples/api/test/material/switch/switch.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..54f4a8bc7f3390445ee8859cb557b9c158ff1726 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/switch/switch.1_test.dart @@ -0,0 +1,24 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/switch/switch.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can toggle switch', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SwitchApp(), + ); + + final Finder switchFinder = find.byType(Switch); + Switch materialSwitch = tester.widget(switchFinder); + expect(materialSwitch.value, true); + + await tester.tap(switchFinder); + await tester.pumpAndSettle(); + materialSwitch = tester.widget(switchFinder); + expect(materialSwitch.value, false); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/switch/switch.2_test.dart b/novelforge-project/flutter/examples/api/test/material/switch/switch.2_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..67eaf775b45dabb32b5acd563e67e47cfc9ba152 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/switch/switch.2_test.dart @@ -0,0 +1,32 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/switch/switch.2.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Switch thumb icon supports material states', (WidgetTester tester) async { + const Set selected = { MaterialState.selected }; + const Set unselected = {}; + + await tester.pumpWidget( + const example.SwitchApp(), + ); + + Switch materialSwitch = tester.widget(find.byType(Switch).first); + expect(materialSwitch.thumbIcon, null); + + materialSwitch = tester.widget(find.byType(Switch).last); + expect(materialSwitch.thumbIcon, isNotNull); + expect( + materialSwitch.thumbIcon!.resolve(selected)!.icon, + Icons.check, + ); + expect( + materialSwitch.thumbIcon!.resolve(unselected)!.icon, + Icons.close, + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/switch/switch.3_test.dart b/novelforge-project/flutter/examples/api/test/material/switch/switch.3_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..bb40f9c1ec052a6e098ae56d2fefa07a69dff100 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/switch/switch.3_test.dart @@ -0,0 +1,24 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/switch/switch.3.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can toggle switch', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SwitchApp(), + ); + + final Finder switchFinder = find.byType(Switch).first; + Switch materialSwitch = tester.widget(switchFinder); + expect(materialSwitch.value, true); + + await tester.tap(switchFinder); + await tester.pumpAndSettle(); + materialSwitch = tester.widget(switchFinder); + expect(materialSwitch.value, false); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/switch/switch.4_test.dart b/novelforge-project/flutter/examples/api/test/material/switch/switch.4_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..57c419dbcd45e609e5ca7f0bd6043e5036646fa9 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/switch/switch.4_test.dart @@ -0,0 +1,63 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/switch/switch.4.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Show adaptive switch theme', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SwitchApp(), + ); + + // Default is material style switches + expect(find.text('Show cupertino style'), findsOneWidget); + expect(find.text('Show material style'), findsNothing); + + Finder adaptiveSwitch = find.byType(Switch).first; + expect( + adaptiveSwitch, + paints + ..rrect(color: const Color(0xff6750a4)) // M3 primary color. + ..rrect() + ..rrect(color: Colors.white), // Thumb color + ); + + await tester.tap(find.widgetWithText(OutlinedButton, 'Add customization')); + await tester.pumpAndSettle(); + + // Theme adaptation does not affect material-style switch. + adaptiveSwitch = find.byType(Switch).first; + expect( + adaptiveSwitch, + paints + ..rrect(color: const Color(0xff6750a4)) // M3 primary color. + ..rrect() + ..rrect(color: Colors.white), // Thumb color + ); + + await tester.tap(find.widgetWithText(OutlinedButton, 'Show cupertino style')); + await tester.pumpAndSettle(); + + expect( + adaptiveSwitch, + paints + ..rrect(color: const Color(0xff795548)) // Customized track color only for cupertino. + ..rrect()..rrect()..rrect()..rrect() + ..rrect(color: const Color(0xffffeb3b)), // Customized thumb color only for cupertino. + ); + + await tester.tap(find.widgetWithText(OutlinedButton, 'Remove customization')); + await tester.pumpAndSettle(); + + expect( + adaptiveSwitch, + paints + ..rrect(color: const Color(0xff34c759)) // Cupertino system green. + ..rrect()..rrect()..rrect()..rrect() + ..rrect(color: Colors.white), // Thumb color + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/switch_list_tile/custom_labeled_switch.0_test.dart b/novelforge-project/flutter/examples/api/test/material/switch_list_tile/custom_labeled_switch.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..a3bc6aff212c26c6f2a7d763752c9063e9dea66c --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/switch_list_tile/custom_labeled_switch.0_test.dart @@ -0,0 +1,31 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/switch_list_tile/custom_labeled_switch.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('LinkedLabelSwitch contains RichText and Switch', (WidgetTester tester) async { + await tester.pumpWidget( + const example.LabeledSwitchApp(), + ); + + // Label text is in a RichText widget with the correct text. + final RichText richText = tester.widget(find.byType(RichText).first); + expect(richText.text.toPlainText(), 'Linked, tappable label text'); + + // Switch is initially off. + Switch switchWidget = tester.widget(find.byType(Switch)); + expect(switchWidget.value, isFalse); + + // Tap to toggle the switch. + await tester.tap(find.byType(Switch)); + await tester.pumpAndSettle(); + + // Switch is now on. + switchWidget = tester.widget(find.byType(Switch)); + expect(switchWidget.value, isTrue); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/switch_list_tile/custom_labeled_switch.1_test.dart b/novelforge-project/flutter/examples/api/test/material/switch_list_tile/custom_labeled_switch.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..65ebddb56c0d83166e69a328647257c58e672480 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/switch_list_tile/custom_labeled_switch.1_test.dart @@ -0,0 +1,27 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/switch_list_tile/custom_labeled_switch.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Tapping LabeledSwitch toggles the switch', (WidgetTester tester) async { + await tester.pumpWidget( + const example.LabeledSwitchApp(), + ); + + // Switch is initially off. + Switch switchWidget = tester.widget(find.byType(Switch)); + expect(switchWidget.value, isFalse); + + // Tap to toggle the switch. + await tester.tap(find.byType(example.LabeledSwitch)); + await tester.pumpAndSettle(); + + // Switch is now on. + switchWidget = tester.widget(find.byType(Switch)); + expect(switchWidget.value, isTrue); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/switch_list_tile/switch_list_tile.0_test.dart b/novelforge-project/flutter/examples/api/test/material/switch_list_tile/switch_list_tile.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..2beeb5e0a006359503eaa2b7ae9fdbfb0b3c2b7f --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/switch_list_tile/switch_list_tile.0_test.dart @@ -0,0 +1,26 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/switch_list_tile/switch_list_tile.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('SwitchListTile can be toggled', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SwitchListTileApp(), + ); + + expect(find.byType(SwitchListTile), findsOneWidget); + + SwitchListTile switchListTile = tester.widget(find.byType(SwitchListTile)); + expect(switchListTile.value, isFalse); + + await tester.tap(find.byType(SwitchListTile)); + await tester.pumpAndSettle(); + + switchListTile = tester.widget(find.byType(SwitchListTile)); + expect(switchListTile.value, isTrue); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/switch_list_tile/switch_list_tile.1_test.dart b/novelforge-project/flutter/examples/api/test/material/switch_list_tile/switch_list_tile.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..7c7eef9012df92e3086f4fa7edb9294ec286a07b --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/switch_list_tile/switch_list_tile.1_test.dart @@ -0,0 +1,75 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/switch_list_tile/switch_list_tile.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Switch aligns appropriately', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SwitchListTileApp(), + ); + + expect(find.byType(SwitchListTile), findsNWidgets(3)); + + Offset tileTopLeft = tester.getTopLeft(find.byType(SwitchListTile).at(0)); + Offset switchTopLeft = tester.getTopLeft(find.byType(Switch).at(0)); + + // The switch is centered vertically with the text. + expect(switchTopLeft - tileTopLeft, const Offset(716.0, 16.0)); + + tileTopLeft = tester.getTopLeft(find.byType(SwitchListTile).at(1)); + switchTopLeft = tester.getTopLeft(find.byType(Switch).at(1)); + + // The switch is centered vertically with the text. + expect(switchTopLeft - tileTopLeft, const Offset(716.0, 30.0)); + + tileTopLeft = tester.getTopLeft(find.byType(SwitchListTile).at(2)); + switchTopLeft = tester.getTopLeft(find.byType(Switch).at(2)); + + // The switch is aligned to the top vertically with the text. + expect(switchTopLeft - tileTopLeft, const Offset(716.0, 8.0)); + }); + + testWidgets('Switches can be checked', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SwitchListTileApp(), + ); + + expect(find.byType(SwitchListTile), findsNWidgets(3)); + + // All switches are on. + expect(tester.widget(find.byType(Switch).at(0)).value, isTrue); + expect(tester.widget(find.byType(Switch).at(1)).value, isTrue); + expect(tester.widget(find.byType(Switch).at(2)).value, isTrue); + + // Tap the first switch. + await tester.tap(find.byType(Switch).at(0)); + await tester.pumpAndSettle(); + + // The first switch is off. + expect(tester.widget(find.byType(Switch).at(0)).value, isFalse); + expect(tester.widget(find.byType(Switch).at(1)).value, isTrue); + expect(tester.widget(find.byType(Switch).at(2)).value, isTrue); + + // Tap the second switch. + await tester.tap(find.byType(Switch).at(1)); + await tester.pumpAndSettle(); + + // The first and second switches are off. + expect(tester.widget(find.byType(Switch).at(0)).value, isFalse); + expect(tester.widget(find.byType(Switch).at(1)).value, isFalse); + expect(tester.widget(find.byType(Switch).at(2)).value, isTrue); + + // Tap the third switch. + await tester.tap(find.byType(Switch).at(2)); + await tester.pumpAndSettle(); + + // All switches are off. + expect(tester.widget(find.byType(Switch).at(0)).value, isFalse); + expect(tester.widget(find.byType(Switch).at(1)).value, isFalse); + expect(tester.widget(find.byType(Switch).at(2)).value, isFalse); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/tab_controller/tab_controller.1_test.dart b/novelforge-project/flutter/examples/api/test/material/tab_controller/tab_controller.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..b78550b17dba71f3c2fc4b0c57c5141e06510a06 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/tab_controller/tab_controller.1_test.dart @@ -0,0 +1,96 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/tab_controller/tab_controller.1.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Verify first tab is selected by default', (WidgetTester tester) async { + await tester.pumpWidget( + const example.TabControllerExampleApp(), + ); + + final Tab firstTab = example.TabControllerExampleApp.tabs.first; + + expect( + find.descendant( + of: find.byType(TabBarView), + matching: find.text('${firstTab.text} Tab'), + ), + findsOneWidget, + ); + }); + + testWidgets('Verify tabs can be changed', (WidgetTester tester) async { + final List log = []; + + final DebugPrintCallback originalDebugPrint = debugPrint; + debugPrint = (String? message, {int? wrapWidth}) { + log.add(message); + }; + + await tester.pumpWidget( + const example.TabControllerExampleApp(), + ); + + const List tabs = example.TabControllerExampleApp.tabs; + final List tabsTraversalOrder = []; + + // The traverse order is from the second tab from the start to the last, + // and then from the second tab from the end to the first. + tabsTraversalOrder.addAll(tabs.skip(1)); + tabsTraversalOrder.addAll(tabs.reversed.skip(1)); + + for (final Tab tab in tabsTraversalOrder) { + // Tap on the TabBar's tab to select it. + await tester.tap(find.descendant( + of: find.byType(TabBar), + matching: find.text(tab.text!), + )); + await tester.pumpAndSettle(); + + expect( + find.descendant( + of: find.byType(TabBarView), + matching: find.text('${tab.text} Tab'), + ), + findsOneWidget, + ); + + expect(log.length, equals(1)); + expect(log.last, equals('tab changed: ${tabs.indexOf(tab)}')); + + log.clear(); + } + + debugPrint = originalDebugPrint; + }); + + testWidgets('DefaultTabControllerListener throws when no DefaultTabController above', (WidgetTester tester) async { + await tester.pumpWidget( + example.DefaultTabControllerListener( + onTabChanged: (_) {}, + child: const SizedBox.shrink(), + ), + ); + + final dynamic exception = tester.takeException(); + expect(exception, isFlutterError); + + final FlutterError error = exception as FlutterError; + expect( + error.toStringDeep(), + equalsIgnoringHashCodes( + 'FlutterError\n' + ' No DefaultTabController for DefaultTabControllerListener.\n' + ' When creating a DefaultTabControllerListener, you must ensure\n' + ' that there is a DefaultTabController above the\n' + ' DefaultTabControllerListener.\n', + ), + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/tabs/tab_bar.0_test.dart b/novelforge-project/flutter/examples/api/test/material/tabs/tab_bar.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..ac4f86784cd94a2c280ba1fc497bc33fc8743323 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/tabs/tab_bar.0_test.dart @@ -0,0 +1,51 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/tabs/tab_bar.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Switch tabs in the TabBar', (WidgetTester tester) async { + await tester.pumpWidget( + const example.TabBarApp(), + ); + + final TabBar tabBar = tester.widget(find.byType(TabBar)); + expect(tabBar.tabs.length, 3); + + final Finder tab1 = find.widgetWithIcon(Tab, Icons.cloud_outlined); + final Finder tab2 = find.widgetWithIcon(Tab, Icons.beach_access_sharp); + final Finder tab3 = find.widgetWithIcon(Tab, Icons.brightness_5_sharp); + + const String tabBarViewText1 = "It's cloudy here"; + const String tabBarViewText2 = "It's rainy here"; + const String tabBarViewText3 = "It's sunny here"; + + expect(find.text(tabBarViewText1), findsNothing); + expect(find.text(tabBarViewText2), findsOneWidget); + expect(find.text(tabBarViewText3), findsNothing); + + await tester.tap(tab1); + await tester.pumpAndSettle(); + + expect(find.text(tabBarViewText1), findsOneWidget); + expect(find.text(tabBarViewText2), findsNothing); + expect(find.text(tabBarViewText3), findsNothing); + + await tester.tap(tab2); + await tester.pumpAndSettle(); + + expect(find.text(tabBarViewText1), findsNothing); + expect(find.text(tabBarViewText2), findsOneWidget); + expect(find.text(tabBarViewText3), findsNothing); + + await tester.tap(tab3); + await tester.pumpAndSettle(); + + expect(find.text(tabBarViewText1), findsNothing); + expect(find.text(tabBarViewText2), findsNothing); + expect(find.text(tabBarViewText3), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/tabs/tab_bar.1_test.dart b/novelforge-project/flutter/examples/api/test/material/tabs/tab_bar.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..f2078708d9f80c394697dcd2b332f15369c0f9aa --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/tabs/tab_bar.1_test.dart @@ -0,0 +1,51 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/tabs/tab_bar.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Switch tabs in the TabBar', (WidgetTester tester) async { + await tester.pumpWidget( + const example.TabBarApp(), + ); + + final TabBar tabBar = tester.widget(find.byType(TabBar)); + expect(tabBar.tabs.length, 3); + + final Finder tab1 = find.widgetWithIcon(Tab, Icons.cloud_outlined); + final Finder tab2 = find.widgetWithIcon(Tab, Icons.beach_access_sharp); + final Finder tab3 = find.widgetWithIcon(Tab, Icons.brightness_5_sharp); + + const String tabBarViewText1 = "It's cloudy here"; + const String tabBarViewText2 = "It's rainy here"; + const String tabBarViewText3 = "It's sunny here"; + + expect(find.text(tabBarViewText1), findsOneWidget); + expect(find.text(tabBarViewText2), findsNothing); + expect(find.text(tabBarViewText3), findsNothing); + + await tester.tap(tab1); + await tester.pumpAndSettle(); + + expect(find.text(tabBarViewText1), findsOneWidget); + expect(find.text(tabBarViewText2), findsNothing); + expect(find.text(tabBarViewText3), findsNothing); + + await tester.tap(tab2); + await tester.pumpAndSettle(); + + expect(find.text(tabBarViewText1), findsNothing); + expect(find.text(tabBarViewText2), findsOneWidget); + expect(find.text(tabBarViewText3), findsNothing); + + await tester.tap(tab3); + await tester.pumpAndSettle(); + + expect(find.text(tabBarViewText1), findsNothing); + expect(find.text(tabBarViewText2), findsNothing); + expect(find.text(tabBarViewText3), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/tabs/tab_bar.2_test.dart b/novelforge-project/flutter/examples/api/test/material/tabs/tab_bar.2_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..1bca1ffa9d36994f95c55181164757f99b290bb3 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/tabs/tab_bar.2_test.dart @@ -0,0 +1,66 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/tabs/tab_bar.2.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Switch tabs in the TabBar', (WidgetTester tester) async { + const String primaryTabLabel1 = 'Flights'; + const String primaryTabLabel2 = 'Trips'; + const String primaryTabLabel3 = 'Explore'; + const String secondaryTabLabel1 = 'Overview'; + const String secondaryTabLabel2 = 'Specifications'; + + await tester.pumpWidget( + const example.TabBarApp(), + ); + + final TabBar primaryTabBar = tester.widget(find.byType(TabBar).last); + expect(primaryTabBar.tabs.length, 3); + + final TabBar secondaryTabBar = tester.widget(find.byType(TabBar).first); + expect(secondaryTabBar.tabs.length, 2); + + String tabBarViewText = '$primaryTabLabel2: $secondaryTabLabel1 tab'; + expect(find.text(tabBarViewText), findsOneWidget); + + await tester.tap(find.text(primaryTabLabel1)); + await tester.pumpAndSettle(); + + tabBarViewText = '$primaryTabLabel1: $secondaryTabLabel1 tab'; + expect(find.text(tabBarViewText), findsOneWidget); + + await tester.tap(find.text(secondaryTabLabel2)); + await tester.pumpAndSettle(); + + tabBarViewText = '$primaryTabLabel1: $secondaryTabLabel2 tab'; + expect(find.text(tabBarViewText), findsOneWidget); + + await tester.tap(find.text(primaryTabLabel2)); + await tester.pumpAndSettle(); + + tabBarViewText = '$primaryTabLabel2: $secondaryTabLabel1 tab'; + expect(find.text(tabBarViewText), findsOneWidget); + + await tester.tap(find.text(secondaryTabLabel2)); + await tester.pumpAndSettle(); + + tabBarViewText = '$primaryTabLabel2: $secondaryTabLabel2 tab'; + expect(find.text(tabBarViewText), findsOneWidget); + + await tester.tap(find.text(primaryTabLabel3)); + await tester.pumpAndSettle(); + + tabBarViewText = '$primaryTabLabel3: $secondaryTabLabel1 tab'; + expect(find.text(tabBarViewText), findsOneWidget); + + await tester.tap(find.text(secondaryTabLabel2)); + await tester.pumpAndSettle(); + + tabBarViewText = '$primaryTabLabel3: $secondaryTabLabel2 tab'; + expect(find.text(tabBarViewText), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/text_button/text_button.0_test.dart b/novelforge-project/flutter/examples/api/test/material/text_button/text_button.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..9b9ec76271c5e75711419969a7259dc659c82fac --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/text_button/text_button.0_test.dart @@ -0,0 +1,95 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:io'; + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/text_button/text_button.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + + // The app being tested loads images via HTTP which the test + // framework defeats by default. + setUpAll(() { + HttpOverrides.global = null; + }); + + testWidgets('TextButtonExample smoke test', (WidgetTester tester) async { + await tester.pumpWidget(const example.TextButtonExampleApp()); + await tester.pumpAndSettle(); + + await tester.tap(find.widgetWithText(TextButton, 'Enabled')); + await tester.pumpAndSettle(); + + await tester.tap(find.widgetWithText(TextButton, 'Disabled')); + await tester.pumpAndSettle(); + + // TextButton.icon buttons are _TextButtonWithIcons rather than TextButtons. + // For the purposes of this test, just tapping in the right place is OK. + + await tester.tap(find.text('TextButton.icon #1')); + await tester.pumpAndSettle(); + + await tester.tap(find.text('TextButton.icon #2')); + await tester.pumpAndSettle(); + + await tester.tap(find.widgetWithText(TextButton, 'TextButton #3')); + await tester.pumpAndSettle(); + + + await tester.tap(find.widgetWithText(TextButton, 'TextButton #4')); + await tester.pumpAndSettle(); + + await tester.tap(find.widgetWithText(TextButton, 'TextButton #5')); + await tester.pumpAndSettle(); + + await tester.tap(find.widgetWithText(TextButton, 'TextButton #6')); + await tester.pumpAndSettle(); + + await tester.tap(find.widgetWithText(TextButton, 'TextButton #7')); + await tester.pumpAndSettle(); + + await tester.tap(find.widgetWithText(TextButton, 'TextButton #8')); + await tester.pumpAndSettle(); + + final Finder smileyButton = find.byType(TextButton).last; + await tester.tap(smileyButton); + await tester.pump(); + + String smileyButtonImageUrl() { + final AnimatedContainer container = tester.widget( + find.descendant(of: smileyButton, matching: find.byType(AnimatedContainer)), + ); + final BoxDecoration decoration = container.decoration! as BoxDecoration; + final NetworkImage image = decoration.image!.image as NetworkImage; + return image.url; + } + + // The smiley button's onPressed method changes the button image + // for one second to simulate a long action running. The button's + // image changes while the action is running. + expect(smileyButtonImageUrl().endsWith('text_button_nhu_end.png'), isTrue); + await tester.pump(const Duration(seconds: 1)); + expect(smileyButtonImageUrl().endsWith('text_button_nhu_default.png'), isTrue); + + // Pressing the smiley button while the one second action is + // underway starts a new one section action. The button's image + // doesn't change until the second action has finished. + await tester.tap(smileyButton); + await tester.pump(const Duration(milliseconds: 500)); + expect(smileyButtonImageUrl().endsWith('text_button_nhu_end.png'), isTrue); + await tester.tap(smileyButton); // Second button press. + await tester.pump(const Duration(milliseconds: 500)); + expect(smileyButtonImageUrl().endsWith('text_button_nhu_end.png'), isTrue); + await tester.pump(const Duration(milliseconds: 500)); + expect(smileyButtonImageUrl().endsWith('text_button_nhu_default.png'), isTrue); + + await tester.tap(find.byType(Switch).at(0)); // Dark Mode Switch + await tester.pumpAndSettle(); + + await tester.tap(find.byType(Switch).at(1)); // RTL Text Switch + await tester.pumpAndSettle(); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/text_button/text_button.1_test.dart b/novelforge-project/flutter/examples/api/test/material/text_button/text_button.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..795e090d038861ad9fd667c305f6bd704b0cea17 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/text_button/text_button.1_test.dart @@ -0,0 +1,51 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/text_button/text_button.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + + testWidgets('SelectableButton', (WidgetTester tester) async { + await tester.pumpWidget( + MaterialApp( + theme: ThemeData( + colorScheme: const ColorScheme.light(), + ), + home: const example.Home(), + ), + ); + + final Finder button = find.byType(example.SelectableButton); + + example.SelectableButton buttonWidget() => tester.widget(button); + + Material buttonMaterial() { + return tester.widget( + find.descendant( + of: find.byType(example.SelectableButton), + matching: find.byType(Material), + ), + ); + } + + expect(buttonWidget().selected, false); + expect(buttonMaterial().textStyle!.color, const ColorScheme.light().primary); // default button foreground color + expect(buttonMaterial().color, Colors.transparent); // default button background color + + await tester.tap(button); // Toggles the button's selected property. + await tester.pumpAndSettle(); + expect(buttonWidget().selected, true); + expect(buttonMaterial().textStyle!.color, Colors.white); + expect(buttonMaterial().color, Colors.indigo); + + + await tester.tap(button); // Toggles the button's selected property. + await tester.pumpAndSettle(); + expect(buttonWidget().selected, false); + expect(buttonMaterial().textStyle!.color, const ColorScheme.light().primary); + expect(buttonMaterial().color, Colors.transparent); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/text_field/text_field.0_test.dart b/novelforge-project/flutter/examples/api/test/material/text_field/text_field.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..ebaa998e5c611456a75d8bb6e40fdc537e731558 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/text_field/text_field.0_test.dart @@ -0,0 +1,19 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/text_field/text_field.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('TextField is obscured and has "Password" as labelText', (WidgetTester tester) async { + await tester.pumpWidget(const example.TextFieldExampleApp()); + + expect(find.byType(TextField), findsOneWidget); + + final TextField textField = tester.widget(find.byType(TextField)); + expect(textField.obscureText, isTrue); + expect(textField.decoration!.labelText, 'Password'); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/text_field/text_field.1_test.dart b/novelforge-project/flutter/examples/api/test/material/text_field/text_field.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..306c4a42a6812e0a3ec3812fe3c54e7684325036 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/text_field/text_field.1_test.dart @@ -0,0 +1,29 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/text_field/text_field.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Dialog shows submitted TextField value', (WidgetTester tester) async { + // This example is also used to illustrate special character counting. + const String sampleText = 'Some sample text 👨‍👩‍👦'; + await tester.pumpWidget(const example.TextFieldExampleApp()); + + expect(find.byType(TextField), findsOneWidget); + expect(find.byType(AlertDialog), findsNothing); + expect(find.text('Thanks!'), findsNothing); + expect(find.widgetWithText(TextButton, 'OK'), findsNothing); + expect(find.text('You typed "$sampleText", which has the length ${sampleText.length}.'), findsNothing); + + await tester.enterText(find.byType(TextField), sampleText); + await tester.testTextInput.receiveAction(TextInputAction.done); + await tester.pumpAndSettle(); + expect(find.byType(AlertDialog), findsOneWidget); + expect(find.text('Thanks!'), findsOneWidget); + expect(find.widgetWithText(TextButton, 'OK'), findsOneWidget); + expect(find.text('You typed "$sampleText", which has length ${sampleText.characters.length}.'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/text_field/text_field.2_test.dart b/novelforge-project/flutter/examples/api/test/material/text_field/text_field.2_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..2eee63b463acf7d88b7a9d4fec9c4845fc44728d --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/text_field/text_field.2_test.dart @@ -0,0 +1,44 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/text_field/text_field.2.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Creates styled text fields', (WidgetTester tester) async { + await tester.pumpWidget(const example.TextFieldExamplesApp()); + + expect(find.text('TextField Examples'), findsOneWidget); + expect(find.byType(TextField), findsNWidgets(2)); + expect(find.byType(example.FilledTextFieldExample), findsOneWidget); + expect(find.byType(example.OutlinedTextFieldExample), findsOneWidget); + + final TextField filled = tester.widget(find.descendant( + of: find.byType(example.FilledTextFieldExample), + matching: find.byType(TextField), + )); + expect(filled.decoration!.prefixIcon, isA() + .having((Icon icon) => icon.icon, 'icon', Icons.search)); + expect(filled.decoration!.suffixIcon, isA() + .having((Icon icon) => icon.icon, 'icon', Icons.clear)); + expect(filled.decoration!.labelText, 'Filled'); + expect(filled.decoration!.hintText, 'hint text'); + expect(filled.decoration!.helperText, 'supporting text'); + expect(filled.decoration!.filled, true); + + final TextField outlined = tester.widget(find.descendant( + of: find.byType(example.OutlinedTextFieldExample), + matching: find.byType(TextField), + )); + expect(outlined.decoration!.prefixIcon, isA() + .having((Icon icon) => icon.icon, 'icon', Icons.search)); + expect(outlined.decoration!.suffixIcon, isA() + .having((Icon icon) => icon.icon, 'icon', Icons.clear)); + expect(outlined.decoration!.labelText, 'Outlined'); + expect(outlined.decoration!.hintText, 'hint text'); + expect(outlined.decoration!.helperText, 'supporting text'); + expect(outlined.decoration!.border, isA()); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/text_form_field/text_form_field.1_test.dart b/novelforge-project/flutter/examples/api/test/material/text_form_field/text_form_field.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..e15d6f711f25602d5789bb67e37b8e4c67750179 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/text_form_field/text_form_field.1_test.dart @@ -0,0 +1,58 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_api_samples/material/text_form_field/text_form_field.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Pressing space should focus the next field', (WidgetTester tester) async { + await tester.pumpWidget(const example.TextFormFieldExampleApp()); + final Finder textFormField = find.byType(TextFormField); + + expect(textFormField, findsExactly(5)); + + final Finder editableText = find.byType(EditableText); + expect(editableText, findsExactly(5)); + + List getFocuses() { + return editableText.evaluate() + .map((Element finderResult) => (finderResult.widget as EditableText).focusNode.hasFocus) + .toList(); + } + + expect(getFocuses(), const [false, false, false, false, false]); + + await tester.tap(textFormField.first); + await tester.pump(); + + expect(getFocuses(), const [true, false, false, false, false]); + + await tester.sendKeyEvent(LogicalKeyboardKey.space); + await tester.pump(); + + expect(getFocuses(), const [false, true, false, false, false]); + + await tester.sendKeyEvent(LogicalKeyboardKey.space); + await tester.pump(); + + expect(getFocuses(), const [false, false, true, false, false]); + + await tester.sendKeyEvent(LogicalKeyboardKey.space); + await tester.pump(); + + expect(getFocuses(), const [false, false, false, true, false]); + + await tester.sendKeyEvent(LogicalKeyboardKey.space); + await tester.pump(); + + expect(getFocuses(), const [false, false, false, false, true]); + + await tester.sendKeyEvent(LogicalKeyboardKey.space); + await tester.pump(); + + expect(getFocuses(), const [true, false, false, false, false]); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/text_form_field/text_form_field.2_test.dart b/novelforge-project/flutter/examples/api/test/material/text_form_field/text_form_field.2_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..6aa4209a521948f280b4fdfdddfb4e9ce0c60e2d --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/text_form_field/text_form_field.2_test.dart @@ -0,0 +1,82 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/text_form_field/text_form_field.2.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + group('TextFormFieldExample2 Widget Tests', () { + testWidgets('Input validation handles empty, incorrect, and short usernames', (WidgetTester tester) async { + await tester.pumpWidget(const example.TextFormFieldExampleApp()); + final Finder textFormField = find.byType(TextFormField); + final Finder saveButton = find.byType(TextButton); + + await tester.enterText(textFormField, ''); + await tester.pump(); + await tester.tap(saveButton); + await tester.pump(); + expect(find.text('This field is required'), findsOneWidget); + + await tester.enterText(textFormField, 'jo hn'); + await tester.tap(saveButton); + await tester.pump(); + expect(find.text('Username must not contain any spaces'), findsOneWidget); + + await tester.enterText(textFormField, 'jo'); + await tester.tap(saveButton); + await tester.pump(); + expect(find.text('Username should be at least 3 characters long'), findsOneWidget); + + await tester.enterText(textFormField, '1jo'); + await tester.tap(saveButton); + await tester.pump(); + expect(find.text('Username must not start with a number'), findsOneWidget); + }); + + testWidgets('Async validation feedback is handled correctly', (WidgetTester tester) async { + await tester.pumpWidget(const example.TextFormFieldExampleApp()); + final Finder textFormField = find.byType(TextFormField); + final Finder saveButton = find.byType(TextButton); + + // Simulate entering a username already taken. + await tester.enterText(textFormField, 'jack'); + await tester.pump(); + await tester.tap(saveButton); + await tester.pump(); + expect(find.text('Username jack is already taken'), findsNothing); + await tester.pump(example.kFakeHttpRequestDuration); + expect(find.text('Username jack is already taken'), findsOneWidget); + + await tester.enterText(textFormField, 'alex'); + await tester.pump(); + await tester.tap(saveButton); + await tester.pump(); + expect(find.text('Username alex is already taken'), findsNothing); + await tester.pump(example.kFakeHttpRequestDuration); + expect(find.text('Username alex is already taken'), findsOneWidget); + + await tester.enterText(textFormField, 'jack'); + await tester.pump(); + await tester.tap(saveButton); + await tester.pump(); + expect(find.text('Username jack is already taken'), findsNothing); + await tester.pump(example.kFakeHttpRequestDuration); + expect(find.text('Username jack is already taken'), findsOneWidget); + }); + + testWidgets('Loading spinner displays correctly when saving', (WidgetTester tester) async { + await tester.pumpWidget(const example.TextFormFieldExampleApp()); + final Finder textFormField = find.byType(TextFormField); + final Finder saveButton = find.byType(TextButton); + await tester.enterText(textFormField, 'alexander'); + await tester.pump(); + await tester.tap(saveButton); + await tester.pump(); + expect(find.byType(CircularProgressIndicator), findsOneWidget); + await tester.pump(example.kFakeHttpRequestDuration); + expect(find.byType(CircularProgressIndicator), findsNothing); + }); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/theme/theme_extension.1_test.dart b/novelforge-project/flutter/examples/api/test/material/theme/theme_extension.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..f3045d5de142b37af9329079cc4f3036b493066b --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/theme/theme_extension.1_test.dart @@ -0,0 +1,112 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/theme/theme_extension.1.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('ThemeExtension can be obtained', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ThemeExtensionExampleApp(), + ); + + final ThemeData theme = Theme.of( + tester.element(find.byType(example.Home)), + ); + final example.MyColors colors = theme.extension()!; + + expect(colors.brandColor, equals(const Color(0xFF1E88E5))); + expect(colors.danger, equals(const Color(0xFFE53935))); + }); + + testWidgets('ThemeExtension can be changed', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ThemeExtensionExampleApp(), + ); + + ThemeData theme = Theme.of( + tester.element(find.byType(example.Home)), + ); + example.MyColors colors = theme.extension()!; + + expect(colors.brandColor, equals(const Color(0xFF1E88E5))); + expect(colors.danger, equals(const Color(0xFFE53935))); + + // Tap the IconButton to switch theme mode from light to dark. + await tester.tap(find.byType(IconButton)); + await tester.pumpAndSettle(); + + theme = Theme.of( + tester.element(find.byType(example.Home)), + ); + colors = theme.extension()!; + + expect(colors.brandColor, equals(const Color(0xFF90CAF9))); + expect(colors.danger, equals(const Color(0xFFEF9A9A))); + }); + + testWidgets('Home uses MyColors extension correctly', (WidgetTester tester) async { + await tester.pumpWidget( + MaterialApp( + theme: ThemeData.light().copyWith( + extensions: >[ + const example.MyColors( + brandColor: Color(0xFF0000FF), + danger: Color(0xFFFF0000), + ), + ], + ), + home: example.Home( + isLightTheme: true, + toggleTheme: () {}, + ), + ), + ); + + expect( + find.byType(example.Home), + paints + ..rect(color: const Color(0xFF0000FF)) + ..rect(color: const Color(0xFFFF0000)), + ); + }); + + testWidgets('Home updates IconButton correctly', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ThemeExtensionExampleApp(), + ); + + example.Home home = tester.widget(find.byType(example.Home)); + IconButton iconButton = tester.widget(find.byType(IconButton)); + ThemeData theme = Theme.of( + tester.element(find.byType(example.Home)), + ); + + expect(theme.brightness, equals(Brightness.light)); + expect(home.isLightTheme, isTrue); + expect( + iconButton.icon, + isA().having((Icon i) => i.icon, 'icon', equals(Icons.nightlight)), + ); + + // Tap the IconButton to switch theme mode from light to dark. + await tester.tap(find.byType(IconButton)); + await tester.pumpAndSettle(); + + home = tester.widget(find.byType(example.Home)); + iconButton = tester.widget(find.byType(IconButton)); + theme = Theme.of( + tester.element(find.byType(example.Home)), + ); + + expect(theme.brightness, equals(Brightness.dark)); + expect(home.isLightTheme, isFalse); + expect( + iconButton.icon, + isA().having((Icon i) => i.icon, 'icon', equals(Icons.wb_sunny)), + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/theme_data/theme_data.0_test.dart b/novelforge-project/flutter/examples/api/test/material/theme_data/theme_data.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..bb1de2263877d8af9a621533362154a9b849a20b --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/theme_data/theme_data.0_test.dart @@ -0,0 +1,36 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/theme_data/theme_data.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + + testWidgets('ThemeData basics', (WidgetTester tester) async { + await tester.pumpWidget(const example.ThemeDataExampleApp()); + + final ColorScheme colorScheme = ColorScheme.fromSeed( + seedColor: Colors.indigo, + ); + + final Material fabMaterial = tester.widget( + find.descendant(of: find.byType(FloatingActionButton), matching: find.byType(Material)), + ); + expect(fabMaterial.color, colorScheme.tertiary); + + final RichText iconRichText = tester.widget( + find.descendant(of: find.byIcon(Icons.add), matching: find.byType(RichText)), + ); + expect(iconRichText.text.style!.color, colorScheme.onTertiary); + + expect(find.text('8 Points'), isNotNull); + await tester.tap(find.byType(FloatingActionButton)); + await tester.pumpAndSettle(); + expect(find.text('9 Points'), isNotNull); + await tester.tap(find.byType(FloatingActionButton)); + await tester.pumpAndSettle(); + expect(find.text('10 Points'), isNotNull); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/time_picker/show_time_picker.0_test.dart b/novelforge-project/flutter/examples/api/test/material/time_picker/show_time_picker.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..0c69ab9527494a830b448ce765cd9c689282052a --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/time_picker/show_time_picker.0_test.dart @@ -0,0 +1,67 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/time_picker/show_time_picker.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can open and modify time picker', (WidgetTester tester) async { + const String openPicker = 'Open time picker'; + final List options = [ + '$TimePickerEntryMode', + ... TimePickerEntryMode.values.map((TimePickerEntryMode value) => value.name), + '$ThemeMode', + ... ThemeMode.values.map((ThemeMode value) => value.name), + '$TextDirection', + ... TextDirection.values.map((TextDirection value) => value.name), + '$MaterialTapTargetSize', + ... MaterialTapTargetSize.values.map((MaterialTapTargetSize value) => value.name), + '$Orientation', + ... Orientation.values.map((Orientation value) => value.name), + 'Time Mode', + '12-hour am/pm time', + '24-hour time', + 'Material Version', + 'Material 2', + 'Material 3', + openPicker, + ]; + + await tester.pumpWidget( + const MaterialApp( + home: Scaffold( + body: example.ShowTimePickerApp(), + ), + ), + ); + + for (final String option in options) { + expect(find.text(option), findsOneWidget, reason: 'Unable to find $option widget in example.'); + } + + // Open time picker + await tester.tap(find.text(openPicker)); + await tester.pumpAndSettle(); + expect(find.text('Select time'), findsOneWidget); + expect(find.text('Cancel'), findsOneWidget); + expect(find.text('OK'), findsOneWidget); + + // Close time picker + await tester.tapAt(const Offset(1, 1)); + await tester.pumpAndSettle(); + expect(find.text('Select time'), findsNothing); + expect(find.text('Cancel'), findsNothing); + expect(find.text('OK'), findsNothing); + + // Change an option. + await tester.tap(find.text('Material 2')); + await tester.pumpAndSettle(); + await tester.tap(find.text(openPicker)); + await tester.pumpAndSettle(); + expect(find.text('SELECT TIME'), findsOneWidget); + expect(find.text('CANCEL'), findsOneWidget); + expect(find.text('OK'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/toggle_buttons/toggle_buttons.0_test.dart b/novelforge-project/flutter/examples/api/test/material/toggle_buttons/toggle_buttons.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..e2b506349112471c207e46bac3bd381c4f822d51 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/toggle_buttons/toggle_buttons.0_test.dart @@ -0,0 +1,128 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/toggle_buttons/toggle_buttons.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + + testWidgets('Single-select ToggleButtons', (WidgetTester tester) async { + TextButton findButton(String text) { + return tester.widget(find.widgetWithText(TextButton, text)); + } + await tester.pumpWidget( + const MaterialApp( + home: Scaffold( + body: example.ToggleButtonsExampleApp(), + ), + ), + ); + + TextButton firstButton = findButton('Apple'); + TextButton secondButton = findButton('Banana'); + TextButton thirdButton = findButton('Orange'); + + const Color selectedColor = Color(0xffef9a9a); + const Color unselectedColor = Color(0x00fffbfe); + + /// First button is selected. + expect(firstButton.style!.backgroundColor!.resolve(enabled), selectedColor); + expect(secondButton.style!.backgroundColor!.resolve(enabled), unselectedColor); + expect(thirdButton.style!.backgroundColor!.resolve(enabled), unselectedColor); + + /// Tap on second button. + await tester.tap(find.widgetWithText(TextButton, 'Banana')); + await tester.pumpAndSettle(); + + firstButton = findButton('Apple'); + secondButton = findButton('Banana'); + thirdButton = findButton('Orange'); + + /// Only second button is selected. + expect(firstButton.style!.backgroundColor!.resolve(enabled), unselectedColor); + expect(secondButton.style!.backgroundColor!.resolve(enabled), selectedColor); + expect(thirdButton.style!.backgroundColor!.resolve(enabled), unselectedColor); + }); + + testWidgets('Multi-select ToggleButtons', (WidgetTester tester) async { + TextButton findButton(String text) { + return tester.widget(find.widgetWithText(TextButton, text)); + } + await tester.pumpWidget( + const MaterialApp( + home: Scaffold( + body: example.ToggleButtonsExampleApp(), + ), + ), + ); + + TextButton firstButton = findButton('Tomatoes'); + TextButton secondButton = findButton('Potatoes'); + TextButton thirdButton = findButton('Carrots'); + + const Color selectedColor = Color(0xffa5d6a7); + const Color unselectedColor = Color(0x00fffbfe); + + /// Second button is selected. + expect(firstButton.style!.backgroundColor!.resolve(enabled), unselectedColor); + expect(secondButton.style!.backgroundColor!.resolve(enabled), selectedColor); + expect(thirdButton.style!.backgroundColor!.resolve(enabled), unselectedColor); + + /// Tap on other two buttons. + await tester.tap(find.widgetWithText(TextButton, 'Tomatoes')); + await tester.tap(find.widgetWithText(TextButton, 'Carrots')); + await tester.pumpAndSettle(); + + firstButton = findButton('Tomatoes'); + secondButton = findButton('Potatoes'); + thirdButton = findButton('Carrots'); + + /// All buttons are selected. + expect(firstButton.style!.backgroundColor!.resolve(enabled), selectedColor); + expect(secondButton.style!.backgroundColor!.resolve(enabled), selectedColor); + expect(thirdButton.style!.backgroundColor!.resolve(enabled), selectedColor); + }); + + testWidgets('Icon-only ToggleButtons', (WidgetTester tester) async { + TextButton findButton(IconData iconData) { + return tester.widget(find.widgetWithIcon(TextButton, iconData)); + } + await tester.pumpWidget( + const MaterialApp( + home: Scaffold( + body: example.ToggleButtonsExampleApp(), + ), + ), + ); + + TextButton firstButton = findButton(Icons.sunny); + TextButton secondButton = findButton(Icons.cloud); + TextButton thirdButton = findButton(Icons.ac_unit); + + const Color selectedColor = Color(0xff90caf9); + const Color unselectedColor = Color(0x00fffbfe); + + + /// Third button is selected. + expect(firstButton.style!.backgroundColor!.resolve(enabled), unselectedColor); + expect(secondButton.style!.backgroundColor!.resolve(enabled), unselectedColor); + expect(thirdButton.style!.backgroundColor!.resolve(enabled), selectedColor); + + /// Tap on the first button. + await tester.tap(find.widgetWithIcon(TextButton, Icons.sunny)); + await tester.pumpAndSettle(); + + firstButton = findButton(Icons.sunny); + secondButton = findButton(Icons.cloud); + thirdButton = findButton(Icons.ac_unit); + + /// First button os selected. + expect(firstButton.style!.backgroundColor!.resolve(enabled), selectedColor); + expect(secondButton.style!.backgroundColor!.resolve(enabled), unselectedColor); + expect(thirdButton.style!.backgroundColor!.resolve(enabled), unselectedColor); + }); +} + +Set enabled = { }; diff --git a/novelforge-project/flutter/examples/api/test/material/toggle_buttons/toggle_buttons.1_test.dart b/novelforge-project/flutter/examples/api/test/material/toggle_buttons/toggle_buttons.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..cc8d7ef1bd968df69346d0e3d21ecd06e821034c --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/toggle_buttons/toggle_buttons.1_test.dart @@ -0,0 +1,137 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/toggle_buttons/toggle_buttons.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('ToggleButtons allows multiple or no selection', (WidgetTester tester) async { + final ThemeData theme = ThemeData(useMaterial3: true); + Finder findButton(String text) { + return find.descendant( + of: find.byType(ToggleButtons), + matching: find.widgetWithText(TextButton, text), + ); + } + + await tester.pumpWidget(const example.ToggleButtonsApp()); + + TextButton toggleMButton = tester.widget(findButton('M')); + TextButton toggleXLButton = tester.widget(findButton('XL')); + + // Initially, only M is selected. + expect( + toggleMButton.style!.backgroundColor!.resolve(enabled), + theme.colorScheme.primary.withOpacity(0.12), + ); + expect( + toggleXLButton.style!.backgroundColor!.resolve(enabled), + theme.colorScheme.surface.withOpacity(0.0), + ); + + // Tap on XL. + await tester.tap(findButton('XL')); + await tester.pumpAndSettle(); + + // Now both M and XL are selected. + toggleMButton = tester.widget(findButton('M')); + toggleXLButton = tester.widget(findButton('XL')); + + expect( + toggleMButton.style!.backgroundColor!.resolve(enabled), + theme.colorScheme.primary.withOpacity(0.12), + ); + expect( + toggleXLButton.style!.backgroundColor!.resolve(enabled), + theme.colorScheme.primary.withOpacity(0.12), + ); + + // Tap M to deselect it. + await tester.tap(findButton('M')); + await tester.pumpAndSettle(); + + // Tap XL to deselect it. + await tester.tap(findButton('XL')); + await tester.pumpAndSettle(); + + // Now neither M nor XL are selected. + toggleMButton = tester.widget(findButton('M')); + toggleXLButton = tester.widget(findButton('XL')); + + expect( + toggleMButton.style!.backgroundColor!.resolve(enabled), + theme.colorScheme.surface.withOpacity(0.0), + ); + expect( + toggleXLButton.style!.backgroundColor!.resolve(enabled), + theme.colorScheme.surface.withOpacity(0.0), + ); + }); + + testWidgets('SegmentedButton allows multiple or no selection', (WidgetTester tester) async { + final ThemeData theme = ThemeData(useMaterial3: true); + Finder findButton(String text) { + return find.descendant( + of: find.byType(SegmentedButton), + matching: find.widgetWithText(TextButton, text), + ); + } + + await tester.pumpWidget(const example.ToggleButtonsApp()); + + Material segmentMButton = tester.widget(find.descendant( + of: findButton('M'), + matching: find.byType(Material), + )); + Material segmentXLButton = tester.widget(find.descendant( + of: findButton('XL'), + matching: find.byType(Material), + )); + + // Initially, only M is selected. + expect(segmentMButton.color, theme.colorScheme.secondaryContainer); + expect(segmentXLButton.color, Colors.transparent); + + // Tap on XL. + await tester.tap(findButton('XL')); + await tester.pumpAndSettle(); + + // // Now both M and XL are selected. + segmentMButton = tester.widget(find.descendant( + of: findButton('M'), + matching: find.byType(Material), + )); + segmentXLButton = tester.widget(find.descendant( + of: findButton('XL'), + matching: find.byType(Material), + )); + + expect(segmentMButton.color, theme.colorScheme.secondaryContainer); + expect(segmentXLButton.color, theme.colorScheme.secondaryContainer); + + // Tap M to deselect it. + await tester.tap(findButton('M')); + await tester.pumpAndSettle(); + + // Tap XL to deselect it. + await tester.tap(findButton('XL')); + await tester.pumpAndSettle(); + + // Now neither M nor XL are selected. + segmentMButton = tester.widget(find.descendant( + of: findButton('M'), + matching: find.byType(Material), + )); + segmentXLButton = tester.widget(find.descendant( + of: findButton('XL'), + matching: find.byType(Material), + )); + + expect(segmentMButton.color, Colors.transparent); + expect(segmentXLButton.color, Colors.transparent); + }); +} + +Set enabled = { }; diff --git a/novelforge-project/flutter/examples/api/test/material/tooltip/tooltip.0_test.dart b/novelforge-project/flutter/examples/api/test/material/tooltip/tooltip.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..599b93875167650d2c572564a6102ef5875b681c --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/tooltip/tooltip.0_test.dart @@ -0,0 +1,40 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/tooltip/tooltip.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Tooltip is visible when hovering over text', (WidgetTester tester) async { + const String tooltipText = 'I am a Tooltip'; + + await tester.pumpWidget( + const example.TooltipExampleApp(), + ); + + TestGesture? gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); + addTearDown(() async { + if (gesture != null) { + return gesture.removePointer(); + } + }); + await gesture.addPointer(); + await gesture.moveTo(const Offset(1.0, 1.0)); + await tester.pump(); + expect(find.text(tooltipText), findsNothing); + // Move the mouse over the text and wait for the tooltip to appear. + final Finder tooltip = find.byType(Tooltip); + await gesture.moveTo(tester.getCenter(tooltip)); + await tester.pump(const Duration(milliseconds: 10)); + expect(find.text(tooltipText), findsOneWidget); + // Move the mouse away and wait for the tooltip to disappear. + await gesture.moveTo(const Offset(1.0, 1.0)); + await tester.pumpAndSettle(); + await gesture.removePointer(); + gesture = null; + expect(find.text(tooltipText), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/tooltip/tooltip.1_test.dart b/novelforge-project/flutter/examples/api/test/material/tooltip/tooltip.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..1509218ceb2699bef7640ecda84ced2788ccdad9 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/tooltip/tooltip.1_test.dart @@ -0,0 +1,44 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/tooltip/tooltip.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Tooltip wait and show duration', (WidgetTester tester) async { + const String tooltipText = 'I am a Tooltip'; + + await tester.pumpWidget( + const example.TooltipExampleApp(), + ); + + final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); + addTearDown(() async { + return gesture.removePointer(); + }); + await gesture.addPointer(); + await gesture.moveTo(const Offset(1.0, 1.0)); + await tester.pump(); + expect(find.text(tooltipText), findsNothing); + + // Move the mouse over the text and wait for the tooltip to appear. + final Finder tooltip = find.byType(Tooltip); + await gesture.moveTo(tester.getCenter(tooltip)); + // Wait half a second and the tooltip should still not be visible. + await tester.pump(const Duration(milliseconds: 500)); + expect(find.text(tooltipText), findsNothing); + // Wait another half a second and the tooltip should be visible now. + await tester.pump(const Duration(milliseconds: 500)); + expect(find.text(tooltipText), findsOneWidget); + // Move the mouse away and wait for the tooltip to disappear. + await gesture.moveTo(const Offset(1.0, 1.0)); + await tester.pump(); + // Wait another second and the tooltip should be gone. + await tester.pump(const Duration(seconds: 1)); + await tester.pumpAndSettle(); + expect(find.text(tooltipText), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/tooltip/tooltip.2_test.dart b/novelforge-project/flutter/examples/api/test/material/tooltip/tooltip.2_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..ba35b0232048dd52e481c431f6e45e3edf36cef0 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/tooltip/tooltip.2_test.dart @@ -0,0 +1,40 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/tooltip/tooltip.2.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Tooltip is visible when hovering over text', (WidgetTester tester) async { + const String tooltipText = 'I am a rich tooltip. I am another span of this rich tooltip'; + + await tester.pumpWidget( + const example.TooltipExampleApp(), + ); + + TestGesture? gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); + addTearDown(() async { + if (gesture != null) { + return gesture.removePointer(); + } + }); + await gesture.addPointer(); + await gesture.moveTo(const Offset(1.0, 1.0)); + await tester.pump(); + expect(find.text(tooltipText), findsNothing); + // Move the mouse over the text and wait for the tooltip to appear. + final Finder tooltip = find.byType(Tooltip); + await gesture.moveTo(tester.getCenter(tooltip)); + await tester.pump(const Duration(milliseconds: 10)); + expect(find.text(tooltipText), findsOneWidget); + // Move the mouse away and wait for the tooltip to disappear. + await gesture.moveTo(const Offset(1.0, 1.0)); + await tester.pumpAndSettle(); + await gesture.removePointer(); + gesture = null; + expect(find.text(tooltipText), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/material/tooltip/tooltip.3_test.dart b/novelforge-project/flutter/examples/api/test/material/tooltip/tooltip.3_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..0dc070ba38eff2508bdd3546714e122ff7fde896 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/material/tooltip/tooltip.3_test.dart @@ -0,0 +1,28 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/tooltip/tooltip.3.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Tooltip is visible when tapping button', (WidgetTester tester) async { + const String tooltipText = 'I am a Tooltip'; + + await tester.pumpWidget( + const example.TooltipExampleApp(), + ); + + // Tooltip is not visible before tapping the button. + expect(find.text(tooltipText), findsNothing); + // Tap on the button and wait for the tooltip to appear. + await tester.tap(find.byType(FloatingActionButton)); + await tester.pump(const Duration(milliseconds: 10)); + expect(find.text(tooltipText), findsOneWidget); + // Tap on the tooltip and wait for the tooltip to disappear. + await tester.tap(find.byTooltip(tooltipText)); + await tester.pump(const Duration(seconds: 1)); + expect(find.text(tooltipText), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/painting/axis_direction.0_test.dart b/novelforge-project/flutter/examples/api/test/painting/axis_direction.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..0a346c129080fa5764993c183ba34e2b902b36f0 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/painting/axis_direction.0_test.dart @@ -0,0 +1,37 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; +import 'package:flutter_api_samples/painting/axis_direction/axis_direction.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Example app has radio buttons to toggle AxisDirection', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ExampleApp(), + ); + + expect(find.byType(Radio), findsNWidgets(4)); + final RenderViewport viewport = tester.renderObject(find.byType(Viewport)); + expect(find.text('AxisDirection.down'), findsOneWidget); + expect(find.text('Axis.vertical'), findsOneWidget); + expect(find.text('GrowthDirection.forward'), findsOneWidget); + expect(find.byIcon(Icons.arrow_downward_rounded), findsNWidgets(2)); + expect(viewport.axisDirection, AxisDirection.down); + + await tester.tap( + find.byWidgetPredicate((Widget widget) { + return widget is Radio && widget.value == AxisDirection.up; + }) + ); + await tester.pumpAndSettle(); + + expect(find.text('AxisDirection.up'), findsOneWidget); + expect(find.text('Axis.vertical'), findsOneWidget); + expect(find.text('GrowthDirection.forward'), findsOneWidget); + expect(find.byIcon(Icons.arrow_upward_rounded), findsNWidgets(2)); + expect(viewport.axisDirection, AxisDirection.up); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/painting/axis_direction/axis_direction.0_test.dart b/novelforge-project/flutter/examples/api/test/painting/axis_direction/axis_direction.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..0a346c129080fa5764993c183ba34e2b902b36f0 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/painting/axis_direction/axis_direction.0_test.dart @@ -0,0 +1,37 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; +import 'package:flutter_api_samples/painting/axis_direction/axis_direction.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Example app has radio buttons to toggle AxisDirection', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ExampleApp(), + ); + + expect(find.byType(Radio), findsNWidgets(4)); + final RenderViewport viewport = tester.renderObject(find.byType(Viewport)); + expect(find.text('AxisDirection.down'), findsOneWidget); + expect(find.text('Axis.vertical'), findsOneWidget); + expect(find.text('GrowthDirection.forward'), findsOneWidget); + expect(find.byIcon(Icons.arrow_downward_rounded), findsNWidgets(2)); + expect(viewport.axisDirection, AxisDirection.down); + + await tester.tap( + find.byWidgetPredicate((Widget widget) { + return widget is Radio && widget.value == AxisDirection.up; + }) + ); + await tester.pumpAndSettle(); + + expect(find.text('AxisDirection.up'), findsOneWidget); + expect(find.text('Axis.vertical'), findsOneWidget); + expect(find.text('GrowthDirection.forward'), findsOneWidget); + expect(find.byIcon(Icons.arrow_upward_rounded), findsNWidgets(2)); + expect(viewport.axisDirection, AxisDirection.up); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/painting/border_side.stroke_align.0_test.dart b/novelforge-project/flutter/examples/api/test/painting/border_side.stroke_align.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..dc322cd2ba5846f111d4783a9effadc0accc5dc2 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/painting/border_side.stroke_align.0_test.dart @@ -0,0 +1,21 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/painting/borders/border_side.stroke_align.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Finds the expected BorderedBox', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.StrokeAlignExample(), + ), + ); + + expect(find.byType(example.StrokeAlignExample), findsOneWidget); + expect(find.byType(example.BorderedBox), findsNWidgets(10)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/painting/borders/border_side.stroke_align.0_test.dart b/novelforge-project/flutter/examples/api/test/painting/borders/border_side.stroke_align.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..dc322cd2ba5846f111d4783a9effadc0accc5dc2 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/painting/borders/border_side.stroke_align.0_test.dart @@ -0,0 +1,21 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/painting/borders/border_side.stroke_align.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Finds the expected BorderedBox', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.StrokeAlignExample(), + ), + ); + + expect(find.byType(example.StrokeAlignExample), findsOneWidget); + expect(find.byType(example.BorderedBox), findsNWidgets(10)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/painting/gradient/linear_gradient.0_test.dart b/novelforge-project/flutter/examples/api/test/painting/gradient/linear_gradient.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..12f0ed011fcb607da5ccf5f6ce0270386263994a --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/painting/gradient/linear_gradient.0_test.dart @@ -0,0 +1,39 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/painting/gradient/linear_gradient.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('finds a gradient', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.MoodyGradient(), + ), + ); + + expect(find.byType(example.MoodyGradient), findsOneWidget); + }); + + testWidgets('gradient matches golden', (WidgetTester tester) async { + await tester.pumpWidget( + MaterialApp( + theme: ThemeData(useMaterial3: true), + home: const SizedBox( + width: 800, + height: 600, + child: RepaintBoundary( + child: example.MoodyGradient(), + ), + ), + ), + ); + await expectLater( + find.byType(example.MoodyGradient), + matchesGoldenFile('linear_gradient.0_test.png'), + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/painting/image_provider/image_provider.0_test.dart b/novelforge-project/flutter/examples/api/test/painting/image_provider/image_provider.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..0b1ce43c0aee6a9fe2d5cab9156e4de4409942d9 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/painting/image_provider/image_provider.0_test.dart @@ -0,0 +1,20 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/foundation.dart'; +import 'package:flutter_api_samples/painting/image_provider/image_provider.0.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('$CustomNetworkImage', (WidgetTester tester) async { + const String expectedUrl = 'https://flutter.github.io/assets-for-api-docs/assets/widgets/flamingos.jpg?dpr=3.0&locale=en-US&platform=android&width=800.0&height=600.0&bidi=ltr'; + final List log = []; + final DebugPrintCallback originalDebugPrint = debugPrint; + debugPrint = (String? message, {int? wrapWidth}) { log.add('$message'); }; + await tester.pumpWidget(const ExampleApp()); + expect(tester.takeException().toString(), 'Exception: Invalid image data'); + expect(log, ['Fetching "$expectedUrl"...']); + debugPrint = originalDebugPrint; + }); +} diff --git a/novelforge-project/flutter/examples/api/test/painting/linear_border.0_test.dart b/novelforge-project/flutter/examples/api/test/painting/linear_border.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..7359ee39446377ba5d7c6edf4fb3de9392c24ce5 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/painting/linear_border.0_test.dart @@ -0,0 +1,40 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +import 'package:flutter_api_samples/painting/linear_border/linear_border.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Smoke Test', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ExampleApp(), + ); + expect(find.byType(example.Home), findsOneWidget); + + // Scroll the interpolation example into view + + await tester.scrollUntilVisible( + find.byIcon(Icons.play_arrow), + 500.0, + scrollable: find.byType(Scrollable), + ); + expect(find.byIcon(Icons.play_arrow), findsOneWidget); + + // Run the interpolation example + + await tester.tap(find.byIcon(Icons.play_arrow)); + await tester.pumpAndSettle(); + + await tester.tap(find.byIcon(Icons.play_arrow)); + await tester.pumpAndSettle(); + + final TestGesture gesture = await tester.startGesture(tester.getCenter(find.text('Interpolation'))); + await gesture.moveTo(tester.getCenter(find.text('Hover'))); + await tester.pumpAndSettle(); + await gesture.moveTo(tester.getCenter(find.text('Interpolation'))); + await tester.pumpAndSettle(); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/painting/linear_border/linear_border.0_test.dart b/novelforge-project/flutter/examples/api/test/painting/linear_border/linear_border.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..7359ee39446377ba5d7c6edf4fb3de9392c24ce5 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/painting/linear_border/linear_border.0_test.dart @@ -0,0 +1,40 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +import 'package:flutter_api_samples/painting/linear_border/linear_border.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Smoke Test', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ExampleApp(), + ); + expect(find.byType(example.Home), findsOneWidget); + + // Scroll the interpolation example into view + + await tester.scrollUntilVisible( + find.byIcon(Icons.play_arrow), + 500.0, + scrollable: find.byType(Scrollable), + ); + expect(find.byIcon(Icons.play_arrow), findsOneWidget); + + // Run the interpolation example + + await tester.tap(find.byIcon(Icons.play_arrow)); + await tester.pumpAndSettle(); + + await tester.tap(find.byIcon(Icons.play_arrow)); + await tester.pumpAndSettle(); + + final TestGesture gesture = await tester.startGesture(tester.getCenter(find.text('Interpolation'))); + await gesture.moveTo(tester.getCenter(find.text('Hover'))); + await tester.pumpAndSettle(); + await gesture.moveTo(tester.getCenter(find.text('Interpolation'))); + await tester.pumpAndSettle(); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/painting/linear_gradient.0_test.dart b/novelforge-project/flutter/examples/api/test/painting/linear_gradient.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..12f0ed011fcb607da5ccf5f6ce0270386263994a --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/painting/linear_gradient.0_test.dart @@ -0,0 +1,39 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/painting/gradient/linear_gradient.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('finds a gradient', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.MoodyGradient(), + ), + ); + + expect(find.byType(example.MoodyGradient), findsOneWidget); + }); + + testWidgets('gradient matches golden', (WidgetTester tester) async { + await tester.pumpWidget( + MaterialApp( + theme: ThemeData(useMaterial3: true), + home: const SizedBox( + width: 800, + height: 600, + child: RepaintBoundary( + child: example.MoodyGradient(), + ), + ), + ), + ); + await expectLater( + find.byType(example.MoodyGradient), + matchesGoldenFile('linear_gradient.0_test.png'), + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/rendering/box/parent_data.0_test.dart b/novelforge-project/flutter/examples/api/test/rendering/box/parent_data.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..91c4a1beb4274a21fddf27598aae7b56df916795 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/rendering/box/parent_data.0_test.dart @@ -0,0 +1,17 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/rendering/box/parent_data.0.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('parent data example', (WidgetTester tester) async { + await tester.pumpWidget(const SampleApp()); + expect(tester.getTopLeft(find.byType(Headline).at(2)), const Offset(30.0, 728.0)); + await tester.tap(find.byIcon(Icons.density_small)); + await tester.pump(); + expect(tester.getTopLeft(find.byType(Headline).at(2)), const Offset(30.0, 682.0)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/rendering/growth_direction.0_test.dart b/novelforge-project/flutter/examples/api/test/rendering/growth_direction.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..3fd61fee9b12c23c1ca125cc2631b8b255cd9ad5 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/rendering/growth_direction.0_test.dart @@ -0,0 +1,42 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; +import 'package:flutter_api_samples/rendering/growth_direction/growth_direction.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Example app has GrowthDirections represented', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ExampleApp(), + ); + + final RenderViewport viewport = tester.renderObject(find.byType(Viewport)); + expect(find.text('AxisDirection.down'), findsNWidgets(2)); + expect(find.text('Axis.vertical'), findsNWidgets(2)); + expect(find.text('GrowthDirection.forward'), findsOneWidget); + expect(find.text('GrowthDirection.reverse'), findsOneWidget); + expect(find.byIcon(Icons.arrow_upward_rounded), findsNWidgets(2)); + expect(find.byIcon(Icons.arrow_downward_rounded), findsNWidgets(2)); + expect(viewport.axisDirection, AxisDirection.down); + expect(viewport.anchor, 0.5); + expect(viewport.center, isNotNull); + + await tester.tap( + find.byWidgetPredicate((Widget widget) { + return widget is Radio && widget.value == AxisDirection.up; + }) + ); + await tester.pumpAndSettle(); + + expect(find.text('AxisDirection.up'), findsNWidgets(2)); + expect(find.text('Axis.vertical'), findsNWidgets(2)); + expect(find.text('GrowthDirection.forward'), findsOneWidget); + expect(find.text('GrowthDirection.reverse'), findsOneWidget); + expect(find.byIcon(Icons.arrow_upward_rounded), findsNWidgets(2)); + expect(find.byIcon(Icons.arrow_downward_rounded), findsNWidgets(2)); + expect(viewport.axisDirection, AxisDirection.up); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/rendering/scroll_direction.0_test.dart b/novelforge-project/flutter/examples/api/test/rendering/scroll_direction.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..5e4075c1989204c5ed9be95cd0fff98248d4f14c --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/rendering/scroll_direction.0_test.dart @@ -0,0 +1,39 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; +import 'package:flutter_api_samples/rendering/scroll_direction/scroll_direction.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Example app has ScrollDirection represented', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ExampleApp(), + ); + + expect(find.byType(Radio), findsNWidgets(4)); + final RenderViewport viewport = tester.renderObject(find.byType(Viewport)); + expect(find.text('AxisDirection.down'), findsOneWidget); + expect(find.text('Axis.vertical'), findsOneWidget); + expect(find.text('GrowthDirection.forward'), findsOneWidget); + expect(find.text('ScrollDirection.idle'), findsOneWidget); + expect(find.byIcon(Icons.arrow_downward_rounded), findsNWidgets(2)); + expect(viewport.axisDirection, AxisDirection.down); + + await tester.tap( + find.byWidgetPredicate((Widget widget) { + return widget is Radio && widget.value == AxisDirection.up; + }) + ); + await tester.pumpAndSettle(); + + expect(find.text('AxisDirection.up'), findsOneWidget); + expect(find.text('Axis.vertical'), findsOneWidget); + expect(find.text('GrowthDirection.forward'), findsOneWidget); + expect(find.text('ScrollDirection.idle'), findsOneWidget); + expect(find.byIcon(Icons.arrow_upward_rounded), findsNWidgets(2)); + expect(viewport.axisDirection, AxisDirection.up); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/sample_templates/cupertino.0_test.dart b/novelforge-project/flutter/examples/api/test/sample_templates/cupertino.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..217eaeb575c7266d4b67ce4866a88ec16729708c --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/sample_templates/cupertino.0_test.dart @@ -0,0 +1,23 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter_api_samples/sample_templates/cupertino.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +// This is an example of a test for API example code. +// +// It only tests that the example is presenting what it is supposed to, but you +// should also test the basic functionality of the example to make sure that it +// functions as expected. + +void main() { + testWidgets('Example app has a placeholder', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SampleApp(), + ); + + expect(find.byType(Placeholder), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/sample_templates/material.0_test.dart b/novelforge-project/flutter/examples/api/test/sample_templates/material.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..06285eb816f6849559dc2390ae2972b128179864 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/sample_templates/material.0_test.dart @@ -0,0 +1,24 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/sample_templates/material.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +// This is an example of a test for API example code. +// +// It only tests that the example is presenting what it is supposed to, but you +// should also test the basic functionality of the example to make sure that it +// functions as expected. + +void main() { + testWidgets('Example app has a placeholder', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SampleApp(), + ); + + expect(find.byType(Scaffold), findsOneWidget); + expect(find.byType(Placeholder), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/sample_templates/widgets.0_test.dart b/novelforge-project/flutter/examples/api/test/sample_templates/widgets.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..529b5e53d8d36313b1580f269a9604a7e0301d41 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/sample_templates/widgets.0_test.dart @@ -0,0 +1,23 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/widgets.dart'; +import 'package:flutter_api_samples/sample_templates/widgets.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +// This is an example of a test for API example code. +// +// It only tests that the example is presenting what it is supposed to, but you +// should also test the basic functionality of the example to make sure that it +// functions as expected. + +void main() { + testWidgets('Example app has a placeholder', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SampleApp(), + ); + + expect(find.byType(Placeholder), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/services/binding/handle_request_app_exit.0_test.dart b/novelforge-project/flutter/examples/api/test/services/binding/handle_request_app_exit.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..8f153ae9cc4f7c11d9b8e2c07bf8983608dc978e --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/services/binding/handle_request_app_exit.0_test.dart @@ -0,0 +1,22 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_api_samples/services/binding/handle_request_app_exit.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Application Exit example', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ApplicationExitExample(), + ); + + expect(find.text('No exit requested yet'), findsOneWidget); + expect(find.text('Do Not Allow Exit'), findsOneWidget); + expect(find.text('Allow Exit'), findsOneWidget); + expect(find.text('Quit'), findsOneWidget); + await tester.tap(find.text('Quit')); + await tester.pump(); + expect(find.text('App requesting cancelable exit'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/services/keyboard_key/logical_keyboard_key.0_test.dart b/novelforge-project/flutter/examples/api/test/services/keyboard_key/logical_keyboard_key.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..0500c109b906f4b3fa017e2dcd69017a0688113c --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/services/keyboard_key/logical_keyboard_key.0_test.dart @@ -0,0 +1,27 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/services.dart'; +import 'package:flutter_api_samples/services/keyboard_key/logical_keyboard_key.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Responds to key', (WidgetTester tester) async { + await tester.pumpWidget( + const example.KeyExampleApp(), + ); + + await tester.tap(find.text('Click to focus')); + await tester.pumpAndSettle(); + expect(find.text('Press a key'), findsOneWidget); + + await tester.sendKeyEvent(LogicalKeyboardKey.keyQ); + await tester.pumpAndSettle(); + expect(find.text('Pressed the "Q" key!'), findsOneWidget); + + await tester.sendKeyEvent(LogicalKeyboardKey.keyB); + await tester.pumpAndSettle(); + expect(find.text('Not a Q: Pressed Key B'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/services/keyboard_key/physical_keyboard_key.0_test.dart b/novelforge-project/flutter/examples/api/test/services/keyboard_key/physical_keyboard_key.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..4969c0651bc0fc5354068bc48f3494cbcb3704bc --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/services/keyboard_key/physical_keyboard_key.0_test.dart @@ -0,0 +1,26 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/services.dart'; +import 'package:flutter_api_samples/services/keyboard_key/physical_keyboard_key.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Responds to key', (WidgetTester tester) async { + await tester.pumpWidget( + const example.KeyExampleApp(), + ); + + await tester.tap(find.text('Click to focus')); + await tester.pumpAndSettle(); + expect(find.text('Press a key'), findsOneWidget); + await tester.sendKeyEvent(LogicalKeyboardKey.keyQ, physicalKey: PhysicalKeyboardKey.keyA); + await tester.pumpAndSettle(); + expect(find.text('Pressed the key next to CAPS LOCK!'), findsOneWidget); + + await tester.sendKeyEvent(LogicalKeyboardKey.keyB, physicalKey: PhysicalKeyboardKey.keyB); + await tester.pumpAndSettle(); + expect(find.text('Not the key next to CAPS LOCK: Pressed Key B'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/services/mouse_cursor/mouse_cursor.0_test.dart b/novelforge-project/flutter/examples/api/test/services/mouse_cursor/mouse_cursor.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..456bad45ad51b270a27d6f444039fba65e58f49c --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/services/mouse_cursor/mouse_cursor.0_test.dart @@ -0,0 +1,20 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/widgets.dart'; +import 'package:flutter_api_samples/services/mouse_cursor/mouse_cursor.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Uses Text Cursor', (WidgetTester tester) async { + await tester.pumpWidget( + const example.MouseCursorExampleApp(), + ); + + expect(find.byType(MouseRegion), findsNWidgets(2)); // There's one in the MaterialApp + final Finder mouseRegionFinder = find.ancestor(of: find.byType(Container), matching: find.byType(MouseRegion)); + expect(mouseRegionFinder, findsOneWidget); + expect((tester.widget(mouseRegionFinder) as MouseRegion).cursor, equals(SystemMouseCursors.text)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/services/system_chrome/system_chrome.set_system_u_i_overlay_style.0_test.dart b/novelforge-project/flutter/examples/api/test/services/system_chrome/system_chrome.set_system_u_i_overlay_style.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..208a08eabdf148bf40a045b049bcd22e494c78ac --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/services/system_chrome/system_chrome.set_system_u_i_overlay_style.0_test.dart @@ -0,0 +1,30 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_api_samples/services/system_chrome/system_chrome.set_system_u_i_overlay_style.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('AppBar.systemOverlayStyle can change system overlays styles.', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SystemOverlayStyleApp(), + ); + + final SystemUiOverlayStyle? firstStyle = SystemChrome.latestStyle; + + await tester.tap(find.byType(ElevatedButton)); + await tester.pump(); + final SystemUiOverlayStyle? secondStyle = SystemChrome.latestStyle; + expect(secondStyle?.statusBarColor, isNot(firstStyle?.statusBarColor)); + expect(secondStyle?.systemNavigationBarColor, isNot(firstStyle?.systemNavigationBarColor)); + + await tester.tap(find.byType(ElevatedButton)); + await tester.pump(); + final SystemUiOverlayStyle? thirdStyle = SystemChrome.latestStyle; + expect(thirdStyle?.statusBarColor, isNot(secondStyle?.statusBarColor)); + expect(thirdStyle?.systemNavigationBarColor, isNot(secondStyle?.systemNavigationBarColor)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/services/system_chrome/system_chrome.set_system_u_i_overlay_style.1_test.dart b/novelforge-project/flutter/examples/api/test/services/system_chrome/system_chrome.set_system_u_i_overlay_style.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..a9f170c48912d2d1ca3dcf796dc86c3b765e34e9 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/services/system_chrome/system_chrome.set_system_u_i_overlay_style.1_test.dart @@ -0,0 +1,30 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_api_samples/services/system_chrome/system_chrome.set_system_u_i_overlay_style.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('AnnotatedRegion can change system overlays style.', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SystemOverlayStyleApp(), + ); + + final SystemUiOverlayStyle? firstStyle = SystemChrome.latestStyle; + + await tester.tap(find.byType(ElevatedButton)); + await tester.pump(); + final SystemUiOverlayStyle? secondStyle = SystemChrome.latestStyle; + expect(secondStyle?.statusBarColor, isNot(firstStyle?.statusBarColor)); + expect(secondStyle?.systemNavigationBarColor, isNot(firstStyle?.systemNavigationBarColor)); + + await tester.tap(find.byType(ElevatedButton)); + await tester.pump(); + final SystemUiOverlayStyle? thirdStyle = SystemChrome.latestStyle; + expect(thirdStyle?.statusBarColor, isNot(secondStyle?.statusBarColor)); + expect(thirdStyle?.systemNavigationBarColor, isNot(secondStyle?.systemNavigationBarColor)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/services/text_input/text_input_control.0_test.dart b/novelforge-project/flutter/examples/api/test/services/text_input/text_input_control.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..0f162389da9f185d2c276134eb17af39fed8918f --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/services/text_input/text_input_control.0_test.dart @@ -0,0 +1,40 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_api_samples/services/text_input/text_input_control.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Enter text using the VKB', (WidgetTester tester) async { + await tester.pumpWidget(const example.TextInputControlExampleApp()); + await tester.pumpAndSettle(); + + await tester.tap(find.descendant( + of: find.byType(example.MyVirtualKeyboard), + matching: find.widgetWithText(ElevatedButton, 'A'), + )); + await tester.pumpAndSettle(); + expect(find.widgetWithText(TextField, 'A'), findsOneWidget); + + await tester.tap(find.descendant( + of: find.byType(example.MyVirtualKeyboard), + matching: find.widgetWithText(ElevatedButton, 'B'), + )); + await tester.pumpAndSettle(); + expect(find.widgetWithText(TextField, 'AB'), findsOneWidget); + + await tester.sendKeyEvent(LogicalKeyboardKey.arrowLeft); + await tester.pumpAndSettle(); + + await tester.tap(find.descendant( + of: find.byType(example.MyVirtualKeyboard), + matching: find.widgetWithText(ElevatedButton, 'C'), + )); + await tester.pumpAndSettle(); + expect(find.widgetWithText(TextField, 'ACB'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/ui/text/font_feature.0_test.dart b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..519bf188bbba582e57518c2c8223819551ef82d7 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.0_test.dart @@ -0,0 +1,27 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/ui/text/font_feature.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('shows font features', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.ExampleWidget(), + ), + ); + + expect(find.byType(Text), findsNWidgets(9)); + expect((tester.widget(find.byType(Text).at(0)) as Text).style!.fontSize, equals(18.0)); + expect((tester.widget(find.byType(Text).at(1)) as Text).style!.fontFamily, equals('Cardo')); + expect((tester.widget(find.byType(Text).at(3)) as Text).style!.fontFeatures, + equals(const [FontFeature.oldstyleFigures()])); + expect((tester.widget(find.byType(Text).at(5)) as Text).style!.fontFeatures, + equals(const [FontFeature.alternativeFractions()])); + expect((tester.widget(find.byType(Text).at(8)) as Text).style!.fontFeatures, + equals([FontFeature.stylisticSet(1)])); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_alternative.0_test.dart b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_alternative.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..7560913358b32b4e47f5a991b522215b4b9a0545 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_alternative.0_test.dart @@ -0,0 +1,22 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/ui/text/font_feature.font_feature_alternative.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('shows font features', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.ExampleWidget(), + ), + ); + + expect(find.byType(Text), findsOneWidget); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFamily, equals('Raleway')); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFeatures, + equals(const [FontFeature.alternative(1)])); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_alternative_fractions.0_test.dart b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_alternative_fractions.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..c8229eeacff5a351f3da1e6a7c1e08011bf4789a --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_alternative_fractions.0_test.dart @@ -0,0 +1,22 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/ui/text/font_feature.font_feature_alternative_fractions.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('shows font features', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.ExampleWidget(), + ), + ); + + expect(find.byType(Text), findsOneWidget); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFamily, equals('Ubuntu Mono')); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFeatures, + equals(const [FontFeature.alternativeFractions()])); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_case_sensitive_forms.0_test.dart b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_case_sensitive_forms.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..fe10c4414f3a4f21b318d5999e053fcef47c7bab --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_case_sensitive_forms.0_test.dart @@ -0,0 +1,22 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/ui/text/font_feature.font_feature_case_sensitive_forms.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('shows font features', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.ExampleWidget(), + ), + ); + + expect(find.byType(Text), findsOneWidget); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFamily, equals('Piazzolla')); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFeatures, + equals(const [FontFeature.caseSensitiveForms()])); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_character_variant.0_test.dart b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_character_variant.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..3e1bb6ac8552143581e2372e8531936fb6d1ce92 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_character_variant.0_test.dart @@ -0,0 +1,27 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/ui/text/font_feature.font_feature_character_variant.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('shows font features', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.ExampleWidget(), + ), + ); + + expect(find.byType(Text), findsOneWidget); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFamily, equals('Source Code Pro')); + expect( + (tester.widget(find.byType(Text).first) as Text).style!.fontFeatures, + equals([ + FontFeature.characterVariant(1), + FontFeature.characterVariant(2), + FontFeature.characterVariant(4), + ])); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_contextual_alternates.0_test.dart b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_contextual_alternates.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..59ae39e8521ff8ca06663e837c6be5b2a8c16986 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_contextual_alternates.0_test.dart @@ -0,0 +1,22 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/ui/text/font_feature.font_feature_contextual_alternates.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('shows font features', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.ExampleWidget(), + ), + ); + + expect(find.byType(Text), findsOneWidget); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFamily, equals('Barriecito')); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFeatures, + equals(const [FontFeature.contextualAlternates()])); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_denominator.0_test.dart b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_denominator.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..d2995bd5c0dbd1272647ce002f28dea9fca272fb --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_denominator.0_test.dart @@ -0,0 +1,22 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/ui/text/font_feature.font_feature_denominator.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('shows font features', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.ExampleWidget(), + ), + ); + + expect(find.byType(Text), findsOneWidget); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFamily, equals('Piazzolla')); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFeatures, + equals(const [FontFeature.denominator()])); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_fractions.0_test.dart b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_fractions.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..159237319825f0a619277c92b84bf776a1043e47 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_fractions.0_test.dart @@ -0,0 +1,22 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/ui/text/font_feature.font_feature_fractions.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('shows font features', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.ExampleWidget(), + ), + ); + + expect(find.byType(Text), findsOneWidget); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFamily, equals('Ubuntu Mono')); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFeatures, + equals(const [FontFeature.fractions()])); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_historical_forms.0_test.dart b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_historical_forms.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..e94515177252c8feb136c61cbf29614008cd1b35 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_historical_forms.0_test.dart @@ -0,0 +1,22 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/ui/text/font_feature.font_feature_historical_forms.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('shows font features', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.ExampleWidget(), + ), + ); + + expect(find.byType(Text), findsOneWidget); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFamily, equals('Sorts Mill Goudy')); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFeatures, + equals(const [FontFeature.historicalForms()])); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_historical_ligatures.0_test.dart b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_historical_ligatures.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..babd68fa1bc4abf9433c29963c8bdd47c3f14d85 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_historical_ligatures.0_test.dart @@ -0,0 +1,22 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/ui/text/font_feature.font_feature_historical_ligatures.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('shows font features', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.ExampleWidget(), + ), + ); + + expect(find.byType(Text), findsOneWidget); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFamily, equals('Sorts Mill Goudy')); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFeatures, + equals(const [FontFeature.historicalForms(), FontFeature.historicalLigatures()])); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_lining_figures.0_test.dart b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_lining_figures.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..94e7c6f67a18eb12cc434d72b27d712c8ed14cf3 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_lining_figures.0_test.dart @@ -0,0 +1,22 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/ui/text/font_feature.font_feature_lining_figures.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('shows font features', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.ExampleWidget(), + ), + ); + + expect(find.byType(Text), findsOneWidget); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFamily, equals('Sorts Mill Goudy')); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFeatures, + equals(const [FontFeature.liningFigures()])); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_locale_aware.0_test.dart b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_locale_aware.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..983bbcde713d653f06d55ce39217762f487db551 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_locale_aware.0_test.dart @@ -0,0 +1,21 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/ui/text/font_feature.font_feature_locale_aware.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('shows font features', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.ExampleWidget(), + ), + ); + + expect(find.byType(Text), findsOneWidget); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFamily, equals('Noto Sans')); + expect((tester.widget(find.byType(Text).first) as Text).locale, equals(const Locale('zh', 'CN'))); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_notational_forms.0_test.dart b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_notational_forms.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..124d3aa70f7b09294b200e7fd549c1f9e954a07b --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_notational_forms.0_test.dart @@ -0,0 +1,22 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/ui/text/font_feature.font_feature_notational_forms.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('shows font features', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.ExampleWidget(), + ), + ); + + expect(find.byType(Text), findsOneWidget); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFamily, equals('Gothic A1')); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFeatures, + equals(const [FontFeature.notationalForms(3)])); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_numerators.0_test.dart b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_numerators.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..a9dbd1935f0a087daf4047132aa1cc88ef8c0e8c --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_numerators.0_test.dart @@ -0,0 +1,22 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/ui/text/font_feature.font_feature_numerators.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('shows font features', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.ExampleWidget(), + ), + ); + + expect(find.byType(Text), findsOneWidget); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFamily, equals('Piazzolla')); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFeatures, + equals(const [FontFeature.numerators()])); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_oldstyle_figures.0_test.dart b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_oldstyle_figures.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..9210c0b8dd636cdf2273dbb2887693eeee97e197 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_oldstyle_figures.0_test.dart @@ -0,0 +1,22 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/ui/text/font_feature.font_feature_oldstyle_figures.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('shows font features', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.ExampleWidget(), + ), + ); + + expect(find.byType(Text), findsOneWidget); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFamily, equals('Piazzolla')); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFeatures, + equals(const [FontFeature.oldstyleFigures()])); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_ordinal_forms.0_test.dart b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_ordinal_forms.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..c26f8c213bba3a25eaafd37e111dac2622a6db9e --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_ordinal_forms.0_test.dart @@ -0,0 +1,22 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/ui/text/font_feature.font_feature_ordinal_forms.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('shows font features', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.ExampleWidget(), + ), + ); + + expect(find.byType(Text), findsOneWidget); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFamily, equals('Piazzolla')); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFeatures, + equals(const [FontFeature.ordinalForms()])); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_proportional_figures.0_test.dart b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_proportional_figures.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..af1d880e210b2af59a6d06ba19e9faac76ad554f --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_proportional_figures.0_test.dart @@ -0,0 +1,22 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/ui/text/font_feature.font_feature_proportional_figures.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('shows font features', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.ExampleWidget(), + ), + ); + + expect(find.byType(Text), findsOneWidget); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFamily, equals('Kufam')); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFeatures, + equals(const [FontFeature.proportionalFigures()])); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_scientific_inferiors.0_test.dart b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_scientific_inferiors.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..c1f7aa86791b439505aec781ed8c5f378e305f3b --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_scientific_inferiors.0_test.dart @@ -0,0 +1,22 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/ui/text/font_feature.font_feature_scientific_inferiors.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('shows font features', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.ExampleWidget(), + ), + ); + + expect(find.byType(Text), findsOneWidget); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFamily, equals('Piazzolla')); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFeatures, + equals(const [FontFeature.scientificInferiors()])); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_slashed_zero.0_test.dart b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_slashed_zero.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..bf9f3b4ac42bca63561e0bc88e272ba30ff24320 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_slashed_zero.0_test.dart @@ -0,0 +1,22 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/ui/text/font_feature.font_feature_slashed_zero.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('shows font features', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.ExampleWidget(), + ), + ); + + expect(find.byType(Text), findsOneWidget); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFamily, equals('Source Code Pro')); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFeatures, + equals(const [FontFeature.slashedZero()])); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_stylistic_alternates.0_test.dart b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_stylistic_alternates.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..8db703c83bbebb7e3be8d0e4ae7b9bb3eb41c273 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_stylistic_alternates.0_test.dart @@ -0,0 +1,22 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/ui/text/font_feature.font_feature_stylistic_alternates.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('shows font features', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.ExampleWidget(), + ), + ); + + expect(find.byType(Text), findsOneWidget); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFamily, equals('Source Code Pro')); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFeatures, + equals(const [FontFeature.stylisticAlternates()])); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_stylistic_set.0_test.dart b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_stylistic_set.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..1be7b35a7b000e4b40b154f0cdbba3cdf0e4bb39 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_stylistic_set.0_test.dart @@ -0,0 +1,30 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/ui/text/font_feature.font_feature_stylistic_set.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('shows font features', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.ExampleWidget(), + ), + ); + + expect(find.byType(Text), findsOneWidget); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFamily, equals('Source Code Pro')); + expect( + (tester.widget(find.byType(Text).first) as Text).style!.fontFeatures, + equals( + [ + FontFeature.stylisticSet(2), + FontFeature.stylisticSet(3), + FontFeature.stylisticSet(4), + ], + ), + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_stylistic_set.1_test.dart b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_stylistic_set.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..16fb436f198323b625109c4de87550a5b68183d8 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_stylistic_set.1_test.dart @@ -0,0 +1,29 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/ui/text/font_feature.font_feature_stylistic_set.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('shows font features', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.ExampleWidget(), + ), + ); + + expect(find.byType(Text), findsOneWidget); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFamily, equals('Piazzolla')); + expect( + (tester.widget(find.byType(Text).first) as Text).style!.fontFeatures, + equals( + [ + FontFeature.stylisticSet(1), + FontFeature.stylisticSet(2), + ], + ), + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_subscripts.0_test.dart b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_subscripts.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..9cab00823772316337bdf37ff279910f0ef4c7f7 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_subscripts.0_test.dart @@ -0,0 +1,24 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/ui/text/font_feature.font_feature_subscripts.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('shows font features', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.ExampleWidget(), + ), + ); + + expect(find.byType(Text), findsOneWidget); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFamily, equals('Piazzolla')); + expect( + (tester.widget(find.byType(Text).first) as Text).style!.fontFeatures, + equals(const [FontFeature.subscripts()]), + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_superscripts.0_test.dart b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_superscripts.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..a940b93df7fa741a853fe96f415ac24a006a561e --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_superscripts.0_test.dart @@ -0,0 +1,24 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/ui/text/font_feature.font_feature_superscripts.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('shows font features', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.ExampleWidget(), + ), + ); + + expect(find.byType(Text), findsOneWidget); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFamily, equals('Sorts Mill Goudy')); + expect( + (tester.widget(find.byType(Text).first) as Text).style!.fontFeatures, + equals(const [FontFeature.superscripts()]), + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_swash.0_test.dart b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_swash.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..ca5a68d0864bcefdc9f8bcc2600bc9cf4bf148bc --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_swash.0_test.dart @@ -0,0 +1,24 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/ui/text/font_feature.font_feature_swash.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('shows font features', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.ExampleWidget(), + ), + ); + + expect(find.byType(Text), findsOneWidget); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFamily, equals('BioRhyme Expanded')); + expect( + (tester.widget(find.byType(Text).first) as Text).style!.fontFeatures, + equals(const [FontFeature.swash()]), + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_tabular_figures.0_test.dart b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_tabular_figures.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..9cfef91334ebdefe137b4092abc77cafe958cbfa --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/ui/text/font_feature.font_feature_tabular_figures.0_test.dart @@ -0,0 +1,24 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/ui/text/font_feature.font_feature_tabular_figures.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('shows font features', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.ExampleWidget(), + ), + ); + + expect(find.byType(Text), findsOneWidget); + expect((tester.widget(find.byType(Text).first) as Text).style!.fontFamily, equals('Piazzolla')); + expect( + (tester.widget(find.byType(Text).first) as Text).style!.fontFeatures, + equals(const [FontFeature.tabularFigures()]), + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/actions/action.action_overridable.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/actions/action.action_overridable.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..8558f547129bfc02351e48e7883fd70070e83b83 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/actions/action.action_overridable.0_test.dart @@ -0,0 +1,51 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_api_samples/widgets/actions/action.action_overridable.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + final _MockClipboard mockClipboard = _MockClipboard(); + + testWidgets('Copies text on Ctrl-C', (WidgetTester tester) async { + tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, mockClipboard.handleMethodCall); + await tester.pumpWidget(const MaterialApp( + home: Scaffold( + body: Center(child: example.VerificationCodeGenerator()), + ), + ), + ); + + expect(primaryFocus, isNotNull); + expect(mockClipboard.clipboardData, isNull); + + await tester.sendKeyDownEvent(LogicalKeyboardKey.control); + await tester.sendKeyDownEvent(LogicalKeyboardKey.keyC); + await tester.sendKeyUpEvent(LogicalKeyboardKey.control); + await tester.sendKeyUpEvent(LogicalKeyboardKey.keyC); + + expect(mockClipboard.clipboardData?['text'], '111222333'); + }); +} + +class _MockClipboard { + _MockClipboard(); + + Map? clipboardData; + + Future handleMethodCall(MethodCall methodCall) async { + switch (methodCall.method) { + case 'Clipboard.setData': + clipboardData = methodCall.arguments as Map; + return null; + } + if (methodCall.method.startsWith('Clipboard')) { + throw StateError('unrecognized method call: ${methodCall.method}'); + } + return null; + } +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/actions/actions.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/actions/actions.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..1aa359203e5b039e29f10de9b044719001760f7a --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/actions/actions.0_test.dart @@ -0,0 +1,140 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/actions/actions.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + Color? getSaveButtonColor(WidgetTester tester) { + final ButtonStyleButton button = tester.widget( + find.descendant( + of: find.byType(example.SaveButton), + matching: find.byWidgetPredicate( + (Widget widget) => widget is TextButton, + ), + ), + ); + + return button.style?.foregroundColor?.resolve({}); + } + + testWidgets('Increments and decrements value', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ActionsExampleApp(), + ); + + int value = 0; + + while (value < 10) { + expect(find.text('Value: $value'), findsOneWidget); + + // Increment the value. + await tester.tap(find.byIcon(Icons.exposure_plus_1)); + await tester.pump(); + + value++; + } + + while (value >= 0) { + expect(find.text('Value: $value'), findsOneWidget); + + // Decrement the value. + await tester.tap(find.byIcon(Icons.exposure_minus_1)); + await tester.pump(); + + value--; + } + }); + + testWidgets('SaveButton indicates dirty status', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ActionsExampleApp(), + ); + + // Verify that initial color is green, as the value is not marked as dirty. + Color? saveButtonColor = getSaveButtonColor(tester); + expect(saveButtonColor, equals(Colors.green)); + + // Decrement the value, which marks it as dirty. + await tester.tap(find.byIcon(Icons.exposure_minus_1)); + await tester.pump(); + expect(find.text('Value: -1'), findsOneWidget); + + // Verify that the color is red, as the value is marked as dirty. + saveButtonColor = getSaveButtonColor(tester); + expect(saveButtonColor, equals(Colors.red)); + + // Increment the value. + await tester.tap(find.byIcon(Icons.exposure_plus_1)); + await tester.pump(); + expect(find.text('Value: 0'), findsOneWidget); + + // Verify that the color is red, as the value is still marked as dirty. + saveButtonColor = getSaveButtonColor(tester); + expect(saveButtonColor, equals(Colors.red)); + }); + + testWidgets('SaveButton tap resets dirty status and adds log', (WidgetTester tester) async { + final List log = []; + + final DebugPrintCallback originalDebugPrint = debugPrint; + debugPrint = (String? message, {int? wrapWidth}) { + log.add(message); + }; + + await tester.pumpWidget( + const example.ActionsExampleApp(), + ); + + // Verify that value is not marked as dirty. + Color? saveButtonColor = getSaveButtonColor(tester); + expect(saveButtonColor, equals(Colors.green)); + expect( + find.descendant( + of: find.byType(example.SaveButton), + matching: find.text('0'), + ), + findsOneWidget, + ); + + // Decrement the value, which marks it as dirty. + await tester.tap(find.byIcon(Icons.exposure_minus_1)); + await tester.pump(); + expect(find.text('Value: -1'), findsOneWidget); + + // Verify that value is marked as dirty. + saveButtonColor = getSaveButtonColor(tester); + expect(saveButtonColor, equals(Colors.red)); + expect( + find.descendant( + of: find.byType(example.SaveButton), + matching: find.text('0'), + ), + findsOneWidget, + ); + + // Tap SaveButton to reset dirty status. + await tester.tap(find.byType(example.SaveButton)); + await tester.pump(); + + // Verify log record. + expect(log.length, equals(1)); + expect(log.last, equals('Saved Data: -1')); + + // Verify that value is no more marked as dirty. + saveButtonColor = getSaveButtonColor(tester); + expect(saveButtonColor, equals(Colors.green)); + expect( + find.descendant( + of: find.byType(example.SaveButton), + matching: find.text('-1'), + ), + findsOneWidget, + ); + + debugPrint = originalDebugPrint; + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/animated_grid/animated_grid.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/animated_grid/animated_grid.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..896e05d14a76b3d9d592b5a08c7d4eb7d1a1d06e --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/animated_grid/animated_grid.0_test.dart @@ -0,0 +1,43 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/animated_grid/animated_grid.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('AnimatedGrid example', (WidgetTester tester) async { + await tester.pumpWidget( + const example.AnimatedGridSample(), + ); + + expect(find.text('1'), findsOneWidget); + expect(find.text('2'), findsOneWidget); + expect(find.text('3'), findsOneWidget); + expect(find.text('4'), findsOneWidget); + expect(find.text('5'), findsOneWidget); + expect(find.text('6'), findsOneWidget); + expect(find.text('7'), findsNothing); + + await tester.tap(find.byIcon(Icons.add_circle)); + await tester.pumpAndSettle(); + + expect(find.text('7'), findsOneWidget); + + await tester.tap(find.byIcon(Icons.remove_circle)); + await tester.pumpAndSettle(); + + expect(find.text('7'), findsNothing); + + await tester.tap(find.text('2')); + await tester.pumpAndSettle(); + + await tester.tap(find.byIcon(Icons.remove_circle)); + await tester.pumpAndSettle(); + + expect(find.text('2'), findsNothing); + expect(find.text('6'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/animated_grid/sliver_animated_grid.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/animated_grid/sliver_animated_grid.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..d6565af65090a16180da70bed084ec5d57169297 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/animated_grid/sliver_animated_grid.0_test.dart @@ -0,0 +1,43 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/animated_grid/sliver_animated_grid.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('SliverAnimatedGrid example', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SliverAnimatedGridSample(), + ); + + expect(find.text('1'), findsOneWidget); + expect(find.text('2'), findsOneWidget); + expect(find.text('3'), findsOneWidget); + expect(find.text('4'), findsOneWidget); + expect(find.text('5'), findsOneWidget); + expect(find.text('6'), findsOneWidget); + expect(find.text('7'), findsNothing); + + await tester.tap(find.byIcon(Icons.add_circle)); + await tester.pumpAndSettle(); + + expect(find.text('7'), findsOneWidget); + + await tester.tap(find.byIcon(Icons.remove_circle)); + await tester.pumpAndSettle(); + + expect(find.text('7'), findsNothing); + + await tester.tap(find.text('2')); + await tester.pumpAndSettle(); + + await tester.tap(find.byIcon(Icons.remove_circle)); + await tester.pumpAndSettle(); + + expect(find.text('2'), findsNothing); + expect(find.text('6'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/animated_list/animated_list_separated.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/animated_list/animated_list_separated.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..e46573af39c99299ec8344f4921f3c17d5adad18 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/animated_list/animated_list_separated.0_test.dart @@ -0,0 +1,56 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/animated_list/animated_list_separated.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets( + 'Items can be selected, added, and removed from AnimatedList.separated', + (WidgetTester tester) async { + await tester.pumpWidget(const example.AnimatedListSeparatedSample()); + + expect(find.text('Item 0'), findsOneWidget); + expect(find.text('Separator 0'), findsOneWidget); + expect(find.text('Item 1'), findsOneWidget); + expect(find.text('Separator 1'), findsOneWidget); + expect(find.text('Item 2'), findsOneWidget); + + // Add an item at the end of the list + await tester.tap(find.byIcon(Icons.add_circle)); + await tester.pumpAndSettle(); + expect(find.text('Separator 2'), findsOneWidget); + expect(find.text('Item 3'), findsOneWidget); + + // Select Item 1. + await tester.tap(find.text('Item 1')); + await tester.pumpAndSettle(); + + // Add item at the top of the list + await tester.tap(find.byIcon(Icons.add_circle)); + await tester.pumpAndSettle(); + expect(find.text('Item 4'), findsOneWidget); + // Contrary to the behavior for insertion at other places, + // the Separator for the last item of the list will be added + // before that item instead of after it. + expect(find.text('Separator 4'), findsOneWidget); + + // Remove selected item. + await tester.tap(find.byIcon(Icons.remove_circle)); + + // Item animation is not completed. + await tester.pump(); + expect(find.text('Item 1'), findsOneWidget); + expect(find.text('Separator 1'), findsNothing); + expect(find.text('Removing separator'), findsOneWidget); + + // When the animation completes, Item 1 disappears. + await tester.pumpAndSettle(); + expect(find.text('Item 1'), findsNothing); + expect(find.text('Separator 1'), findsNothing); + expect(find.text('Removing separator'), findsNothing); + }, + ); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/animated_list/sliver_animated_list.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/animated_list/sliver_animated_list.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..8951fb3e2dc2ff75fda77f662f4108276532d091 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/animated_list/sliver_animated_list.0_test.dart @@ -0,0 +1,45 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/animated_list/sliver_animated_list.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets( + 'Items can be selected, added, and removed from SliverAnimatedList', + (WidgetTester tester) async { + await tester.pumpWidget(const example.SliverAnimatedListSample()); + + expect(find.text('Item 0'), findsOneWidget); + expect(find.text('Item 1'), findsOneWidget); + expect(find.text('Item 2'), findsOneWidget); + + // Add an item at the end of the list + await tester.tap(find.byIcon(Icons.add_circle)); + await tester.pumpAndSettle(); + expect(find.text('Item 3'), findsOneWidget); + + // Select Item 1. + await tester.tap(find.text('Item 1')); + await tester.pumpAndSettle(); + + // Add item at the top of the list + await tester.tap(find.byIcon(Icons.add_circle)); + await tester.pumpAndSettle(); + expect(find.text('Item 4'), findsOneWidget); + + // Remove selected item. + await tester.tap(find.byIcon(Icons.remove_circle)); + + // Item animation is not completed. + await tester.pump(); + expect(find.text('Item 1'), findsOneWidget); + + // When the animation completes, Item 1 disappears. + await tester.pumpAndSettle(); + expect(find.text('Item 1'), findsNothing); + }, + ); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/animated_size/animated_size.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/animated_size/animated_size.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..822449cc10209023f55bf983561cea995ede1979 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/animated_size/animated_size.0_test.dart @@ -0,0 +1,76 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/animated_size/animated_size.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('AnimatedSize animates on tap', (WidgetTester tester) async { + await tester.pumpWidget( + const example.AnimatedSizeExampleApp(), + ); + + const Size beginSize = Size.square(100.0); + const Size endSize = Size.square(250.0); + + RenderBox box = tester.renderObject(find.byType(AnimatedSize)); + expect(box.size, equals(beginSize)); + + // Tap on the AnimatedSize to start the forward animation. + await tester.tap(find.byType(AnimatedSize)); + await tester.pump(); + + box = tester.renderObject(find.byType(AnimatedSize)); + expect(box.size, equals(beginSize)); + + // Advance animation to the middle. + await tester.pump( + example.AnimatedSizeExampleApp.duration ~/ 2, + ); + + final double t = example.AnimatedSizeExampleApp.curve.transform(0.5); + + box = tester.renderObject(find.byType(AnimatedSize)); + expect( + box.size, + equals(Size.lerp(beginSize, endSize, t)), + ); + + // Advance animation to the end. + await tester.pump( + example.AnimatedSizeExampleApp.duration ~/ 2, + ); + + box = tester.renderObject(find.byType(AnimatedSize)); + expect(box.size, equals(endSize)); + + // Tap on the AnimatedSize again to start the reverse animation. + await tester.tap(find.byType(AnimatedSize)); + await tester.pump(); + + box = tester.renderObject(find.byType(AnimatedSize)); + expect(box.size, equals(endSize)); + + // Advance animation to the middle. + await tester.pump( + example.AnimatedSizeExampleApp.duration ~/ 2, + ); + + box = tester.renderObject(find.byType(AnimatedSize)); + expect( + box.size, + equals(Size.lerp(endSize, beginSize, t)), + ); + + // Advance animation to the end. + await tester.pump( + example.AnimatedSizeExampleApp.duration ~/ 2, + ); + + box = tester.renderObject(find.byType(AnimatedSize)); + expect(box.size, equals(beginSize)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/animated_switcher/animated_switcher.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/animated_switcher/animated_switcher.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..dea3a416928c5870ac1a05a7e4e01da2565e359f --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/animated_switcher/animated_switcher.0_test.dart @@ -0,0 +1,99 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/animated_switcher/animated_switcher.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Increments counter on button tap', (WidgetTester tester) async { + await tester.pumpWidget( + const example.AnimatedSwitcherExampleApp(), + ); + + int counter = 0; + + expect(find.text('$counter'), findsOneWidget); + + while (counter < 10) { + // Tap on the button to increment the counter. + await tester.tap( + find.ancestor( + of: find.text('Increment'), + matching: find.byType(ElevatedButton), + ), + ); + await tester.pumpAndSettle(); + + counter += 1; + + expect(find.text('${counter - 1}'), findsNothing); + expect(find.text('$counter'), findsOneWidget); + } + }); + + testWidgets('Animates counter change', (WidgetTester tester) async { + await tester.pumpWidget( + const example.AnimatedSwitcherExampleApp(), + ); + + // The animation duration defined in the example app. + const Duration animationDuration = Duration(milliseconds: 500); + + final Finder zeroTransitionFinder = find.ancestor( + of: find.text('0'), + matching: find.byType(ScaleTransition), + ); + final Finder oneTransitionFinder = find.ancestor( + of: find.text('1'), + matching: find.byType(ScaleTransition), + ); + + expect(zeroTransitionFinder, findsOneWidget); + ScaleTransition zeroTransition = tester.widget(zeroTransitionFinder); + expect(zeroTransition.scale.value, equals(1.0)); + + expect(oneTransitionFinder, findsNothing); + + // Tap on the button to increment the counter. + await tester.tap( + find.ancestor( + of: find.text('Increment'), + matching: find.byType(ElevatedButton), + ), + ); + await tester.pump(); + + expect(zeroTransitionFinder, findsOneWidget); + zeroTransition = tester.widget(zeroTransitionFinder); + expect(zeroTransition.scale.value, equals(1.0)); + + expect(oneTransitionFinder, findsOneWidget); + ScaleTransition oneTransition = tester.widget(oneTransitionFinder); + expect(oneTransition.scale.value, equals(0.0)); + + // Advance animation to the middle. + await tester.pump(animationDuration ~/ 2); + + expect(zeroTransitionFinder, findsOneWidget); + zeroTransition = tester.widget(zeroTransitionFinder); + expect(zeroTransition.scale.value, equals(0.5)); + + expect(oneTransitionFinder, findsOneWidget); + oneTransition = tester.widget(oneTransitionFinder); + expect(oneTransition.scale.value, equals(0.5)); + + // Advance animation to the end. + await tester.pump(animationDuration ~/ 2); + + expect(zeroTransitionFinder, findsOneWidget); + zeroTransition = tester.widget(zeroTransitionFinder); + expect(zeroTransition.scale.value, equals(0.0)); + + expect(oneTransitionFinder, findsOneWidget); + oneTransition = tester.widget(oneTransitionFinder); + expect(oneTransition.scale.value, equals(1.0)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/app/widgets_app.widgets_app.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/app/widgets_app.widgets_app.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..6412fc14b46ed874ba96ddd255cc46bdb836be1a --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/app/widgets_app.widgets_app.0_test.dart @@ -0,0 +1,16 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_api_samples/widgets/app/widgets_app.widgets_app.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('WidgetsApp test', (WidgetTester tester) async { + await tester.pumpWidget( + const example.WidgetsAppExampleApp(), + ); + + expect(find.text('Hello World'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/app_lifecycle_listener/app_lifecycle_listener.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/app_lifecycle_listener/app_lifecycle_listener.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..6c37d9e10ae3b8fb29c2cdf6b4b147b6c4b63982 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/app_lifecycle_listener/app_lifecycle_listener.0_test.dart @@ -0,0 +1,17 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_api_samples/widgets/app_lifecycle_listener/app_lifecycle_listener.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('AppLifecycleListener example', (WidgetTester tester) async { + await tester.pumpWidget( + const example.AppLifecycleListenerExample(), + ); + + expect(find.textContaining('Current State:'), findsOneWidget); + expect(find.textContaining('State History:'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/app_lifecycle_listener/app_lifecycle_listener.1_test.dart b/novelforge-project/flutter/examples/api/test/widgets/app_lifecycle_listener/app_lifecycle_listener.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..3218f7348ba99505dd265f462e82756b61e9c173 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/app_lifecycle_listener/app_lifecycle_listener.1_test.dart @@ -0,0 +1,27 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_api_samples/widgets/app_lifecycle_listener/app_lifecycle_listener.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('AppLifecycleListener example', (WidgetTester tester) async { + await tester.pumpWidget( + const example.AppLifecycleListenerExample(), + ); + + expect(find.text('Do Not Allow Exit'), findsOneWidget); + expect(find.text('Allow Exit'), findsOneWidget); + expect(find.text('Quit'), findsOneWidget); + expect(find.textContaining('Exit Request:'), findsOneWidget); + await tester.tap(find.text('Quit')); + await tester.pump(); + // Responding to the the quit request happens in a Future that we don't have + // visibility for, so to avoid a flaky test with a delay, we just check to + // see if the request string prefix is still there, rather than the request + // response string. Testing it wasn't worth exposing a Completer in the + // example code. + expect(find.textContaining('Exit Request:'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/async/future_builder.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/async/future_builder.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..98587ceb4b943de56d0e0530ae723320295a4fa5 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/async/future_builder.0_test.dart @@ -0,0 +1,29 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/async/future_builder.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('StreamBuilder listens to internal stream', (WidgetTester tester) async { + await tester.pumpWidget( + const example.FutureBuilderExampleApp(), + ); + + expect(find.byType(CircularProgressIndicator), findsOne); + expect(find.text('Awaiting result...'), findsOne); + + await tester.pump(const Duration(seconds: 1)); + + expect(find.byType(CircularProgressIndicator), findsOne); + expect(find.text('Awaiting result...'), findsOne); + + await tester.pump(const Duration(seconds: 1)); + + expect(find.byIcon(Icons.check_circle_outline), findsOne); + expect(find.text('Result: Data Loaded'), findsOne); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/async/stream_builder.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/async/stream_builder.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..597f36680b3a1319fbea6f2fafe9d23cf0d2bfe8 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/async/stream_builder.0_test.dart @@ -0,0 +1,110 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/async/stream_builder.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('StreamBuilder listens to internal stream', (WidgetTester tester) async { + await tester.pumpWidget( + const example.StreamBuilderExampleApp(), + ); + + expect(find.byType(CircularProgressIndicator), findsOneWidget); + expect(find.text('Awaiting bids...'), findsOneWidget); + + await tester.pump(example.StreamBuilderExampleApp.delay); + + expect(find.byIcon(Icons.check_circle_outline), findsOneWidget); + expect(find.text(r'$1'), findsOneWidget); + + await tester.pump(example.StreamBuilderExampleApp.delay); + + expect(find.byIcon(Icons.info), findsOneWidget); + expect(find.text(r'$1 (closed)'), findsOneWidget); + }); + + testWidgets('BidsStatus correctly displays error state', (WidgetTester tester) async { + final StreamController controller = StreamController(); + addTearDown(controller.close); + + controller.onListen = () { + controller.addError('Unexpected error!', StackTrace.empty); + }; + + await tester.pumpWidget( + MaterialApp( + home: example.BidsStatus(bids: controller.stream), + ), + ); + await tester.pump(); + + expect(find.byIcon(Icons.error_outline), findsOneWidget); + expect(find.text('Error: Unexpected error!'), findsOneWidget); + expect(find.text('Stack trace: ${StackTrace.empty}'), findsOneWidget); + }); + + testWidgets('BidsStatus correctly displays none state', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.BidsStatus(bids: null), + ), + ); + + expect(find.byIcon(Icons.info), findsOneWidget); + expect(find.text('Select a lot'), findsOneWidget); + }); + + testWidgets('BidsStatus correctly displays waiting state', (WidgetTester tester) async { + final StreamController controller = StreamController(); + addTearDown(controller.close); + + await tester.pumpWidget( + MaterialApp( + home: example.BidsStatus(bids: controller.stream), + ), + ); + + expect(find.byType(CircularProgressIndicator), findsOneWidget); + expect(find.text('Awaiting bids...'), findsOneWidget); + }); + + testWidgets('BidsStatus correctly displays active state', (WidgetTester tester) async { + final StreamController controller = StreamController(); + addTearDown(controller.close); + + controller.onListen = () { + controller.add(1); + }; + + await tester.pumpWidget( + MaterialApp( + home: example.BidsStatus(bids: controller.stream), + ), + ); + await tester.pump(); + + expect(find.byIcon(Icons.check_circle_outline), findsOneWidget); + expect(find.text(r'$1'), findsOneWidget); + }); + + testWidgets('BidsStatus correctly displays done state', (WidgetTester tester) async { + final StreamController controller = StreamController(); + controller.close(); + + await tester.pumpWidget( + MaterialApp( + home: example.BidsStatus(bids: controller.stream), + ), + ); + await tester.pump(); + + expect(find.byIcon(Icons.info), findsOneWidget); + expect(find.text('(closed)'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/autocomplete/raw_autocomplete.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/autocomplete/raw_autocomplete.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..80bae5d87094c28fd4c6f2d470c5bc1800832b95 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/autocomplete/raw_autocomplete.0_test.dart @@ -0,0 +1,47 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/autocomplete/raw_autocomplete.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Autocomplete example is visible', (WidgetTester tester) async { + await tester.pumpWidget(const example.AutocompleteExampleApp()); + expect(find.text('RawAutocomplete Basic'), findsOneWidget); + expect(find.byType(TextFormField), findsOneWidget); + + expect(find.text('aardvark'), findsNothing); + expect(find.text('bobcat'), findsNothing); + expect(find.text('chameleon'), findsNothing); + }); + + testWidgets('Options are shown correctly and selectable', (WidgetTester tester) async { + await tester.pumpWidget(const example.AutocompleteExampleApp()); + await tester.tap(find.byType(TextFormField)); + await tester.pump(); + + expect(find.byType(ListTile), findsNWidgets(3)); + expect(find.text('aardvark'), findsOneWidget); + expect(find.text('bobcat'), findsOneWidget); + expect(find.text('chameleon'), findsOneWidget); + + await tester.enterText(find.byType(TextFormField), 'b'); + await tester.pump(); + + expect(find.byType(ListTile), findsOneWidget); + expect(find.text('aardvark'), findsNothing); + expect(find.text('bobcat'), findsOneWidget); + expect(find.text('chameleon'), findsNothing); + + await tester.tap(find.text('bobcat')); + await tester.pump(); + + expect(find.byType(ListTile), findsNothing); + expect(find.descendant( + of: find.byType(TextFormField), + matching: find.text('bobcat'), + ), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/autocomplete/raw_autocomplete.1_test.dart b/novelforge-project/flutter/examples/api/test/widgets/autocomplete/raw_autocomplete.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..b625c64e2335f034c87482a9f2d12ca87c5b7f9c --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/autocomplete/raw_autocomplete.1_test.dart @@ -0,0 +1,76 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/autocomplete/raw_autocomplete.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Autocomplete example is visible', (WidgetTester tester) async { + await tester.pumpWidget(const example.AutocompleteExampleApp()); + expect(find.text('RawAutocomplete Custom Type'), findsOneWidget); + expect(find.byType(TextFormField), findsOneWidget); + + expect(find.text('Alice'), findsNothing); + expect(find.text('Bob'), findsNothing); + expect(find.text('Charlie'), findsNothing); + }); + + testWidgets('Options are shown correctly and selectable', (WidgetTester tester) async { + await tester.pumpWidget(const example.AutocompleteExampleApp()); + await tester.tap(find.byType(TextFormField)); + await tester.pump(); + + expect(find.byType(ListTile), findsNWidgets(3)); + expect(find.text('Alice'), findsOneWidget); + expect(find.text('Bob'), findsOneWidget); + expect(find.text('Charlie'), findsOneWidget); + + await tester.enterText(find.byType(TextFormField), 'b'); + await tester.pump(); + + expect(find.byType(ListTile), findsOneWidget); + expect(find.text('Alice'), findsNothing); + expect(find.text('Bob'), findsOneWidget); + expect(find.text('Charlie'), findsNothing); + + await tester.tap(find.text('Bob')); + await tester.pump(); + + expect(find.byType(ListTile), findsNothing); + expect(find.descendant( + of: find.byType(TextFormField), + matching: find.text('Bob'), + ), findsOneWidget); + }); + + testWidgets('Finds users by email address', (WidgetTester tester) async { + await tester.pumpWidget(const example.AutocompleteExampleApp()); + + await tester.enterText(find.byType(TextFormField), '@'); + await tester.pump(); + + expect(find.byType(ListTile), findsNWidgets(3)); + expect(find.text('Alice'), findsOneWidget); + expect(find.text('Bob'), findsOneWidget); + expect(find.text('Charlie'), findsOneWidget); + + await tester.enterText(find.byType(TextFormField), '@gmail'); + await tester.pump(); + + expect(find.byType(ListTile), findsOneWidget); + expect(find.text('Alice'), findsNothing); + expect(find.text('Bob'), findsNothing); + expect(find.text('Charlie'), findsOneWidget); + + await tester.tap(find.text('Charlie')); + await tester.pump(); + + expect(find.byType(ListTile), findsNothing); + expect(find.descendant( + of: find.byType(TextFormField), + matching: find.text('Charlie'), + ), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/autocomplete/raw_autocomplete.2_test.dart b/novelforge-project/flutter/examples/api/test/widgets/autocomplete/raw_autocomplete.2_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..313ed73366f1b0e91f8567d28a6df89331ebe3ac --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/autocomplete/raw_autocomplete.2_test.dart @@ -0,0 +1,86 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/autocomplete/raw_autocomplete.2.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Form is entirely visible and rejects invalid responses', (WidgetTester tester) async { + await tester.pumpWidget(const example.AutocompleteExampleApp()); + expect(find.text('RawAutocomplete Form'), findsOneWidget); + expect(find.byType(TextFormField), findsNWidgets(2)); + expect(find.byIcon(Icons.arrow_downward), findsOneWidget); + expect(find.text('This is a regular DropdownButtonFormField'), findsOneWidget); + expect(find.text('This is a regular TextFormField'), findsOneWidget); + expect(find.text('This is a RawAutocomplete!'), findsOneWidget); + expect(find.text('Submit'), findsOneWidget); + + expect(find.text('One'), findsNothing); + expect(find.text('Two'), findsNothing); + expect(find.text('Free'), findsNothing); + expect(find.text('Four'), findsNothing); + expect(find.text('aardvark'), findsNothing); + expect(find.text('bobcat'), findsNothing); + expect(find.text('chameleon'), findsNothing); + + expect(find.text('Must make a selection.'), findsNothing); + expect(find.text("Can't be empty."), findsNothing); + expect(find.text('Nothing selected.'), findsNothing); + await tester.tap(find.text('Submit')); + await tester.pump(); + expect(find.text('Must make a selection.'), findsOneWidget); + expect(find.text("Can't be empty."), findsOneWidget); + expect(find.text('Nothing selected.'), findsOneWidget); + }); + + testWidgets('Form accepts valid inputs', (WidgetTester tester) async { + await tester.pumpWidget(const example.AutocompleteExampleApp()); + await tester.tap(find.byIcon(Icons.arrow_downward)); + await tester.pump(); + + expect(find.text('One'), findsOneWidget); + expect(find.text('Two'), findsOneWidget); + expect(find.text('Free'), findsOneWidget); + expect(find.text('Four'), findsOneWidget); + await tester.tap(find.text('Free')); + await tester.pump(); + expect(find.text('Two'), findsNothing); + expect(find.text('Free'), findsOneWidget); + + expect(find.text('This is a regular TextFormField'), findsOneWidget); + await tester.enterText( + find.ancestor( + of: find.text('This is a regular TextFormField'), + matching: find.byType(TextFormField), + ), + 'regular user input', + ); + + await tester.tap(find.ancestor( + of: find.text('This is a RawAutocomplete!'), + matching: find.byType(TextFormField), + )); + await tester.pump(); + expect(find.text('aardvark'), findsOneWidget); + expect(find.text('bobcat'), findsOneWidget); + expect(find.text('chameleon'), findsOneWidget); + await tester.tap(find.text('aardvark')); + await tester.pump(); + + expect(find.byType(AlertDialog), findsNothing); + await tester.tap(find.text('Submit')); + await tester.pump(); + expect(find.byType(AlertDialog), findsOneWidget); + expect(find.text('Successfully submitted'), findsOneWidget); + expect(find.text('DropdownButtonFormField: "Free"'), findsOneWidget); + expect(find.text('TextFormField: "regular user input"'), findsOneWidget); + expect(find.text('RawAutocomplete: "aardvark"'), findsOneWidget); + expect(find.text('Ok'), findsOneWidget); + + await tester.tap(find.text('Ok')); + await tester.pump(); + expect(find.byType(AlertDialog), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/autocomplete/raw_autocomplete.focus_node.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/autocomplete/raw_autocomplete.focus_node.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..36c097a4b1d3918d3ba9f22352a540862089aef5 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/autocomplete/raw_autocomplete.focus_node.0_test.dart @@ -0,0 +1,66 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/autocomplete/raw_autocomplete.focus_node.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Autocomplete example is visible', (WidgetTester tester) async { + await tester.pumpWidget(const example.AutocompleteExampleApp()); + expect(find.text('Split RawAutocomplete App'), findsOneWidget); + expect(find.byType(AppBar), findsOneWidget); + expect(find.byType(TextFormField), findsOneWidget); + expect( + find.descendant( + of: find.byType(AppBar), + matching: find.byType(TextFormField) + ), + findsOneWidget, + ); + + expect(find.byType(RawAutocomplete), findsOneWidget); + expect(find.text('aardvark'), findsNothing); + expect(find.text('bobcat'), findsNothing); + expect(find.text('chameleon'), findsNothing); + expect( + find.ancestor( + matching: find.byType(AppBar), + of: find.byType(RawAutocomplete) + ), + findsNothing, + ); + }); + + testWidgets('Options are shown correctly and selectable', (WidgetTester tester) async { + await tester.pumpWidget(const example.AutocompleteExampleApp()); + await tester.tap(find.byType(TextFormField)); + await tester.pump(); + + expect(find.byType(ListTile), findsNWidgets(3)); + expect(find.text('aardvark'), findsOneWidget); + expect(find.text('bobcat'), findsOneWidget); + expect(find.text('chameleon'), findsOneWidget); + + await tester.enterText(find.byType(TextFormField), 'b'); + await tester.pump(); + + expect(find.byType(ListTile), findsOneWidget); + expect(find.text('aardvark'), findsNothing); + expect(find.text('bobcat'), findsOneWidget); + expect(find.text('chameleon'), findsNothing); + + await tester.tap(find.text('bobcat')); + await tester.pump(); + + expect(find.byType(ListTile), findsNothing); + expect( + find.descendant( + of: find.byType(TextFormField), + matching: find.text('bobcat'), + ), + findsOneWidget, + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/basic/absorb_pointer.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/basic/absorb_pointer.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..eeaaf4e34e0807d637c5347a719cfbcbc9a71b1f --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/basic/absorb_pointer.0_test.dart @@ -0,0 +1,29 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; +import 'package:flutter_api_samples/widgets/basic/absorb_pointer.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('AbsorbPointer prevents hit testing on its child', (WidgetTester tester) async { + await tester.pumpWidget( + const example.AbsorbPointerApp(), + ); + + // Get the center of the stack. + final Offset center = tester.getCenter(find.byType(Stack).first); + + final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse, pointer: 1); + // Add the point to the center of the stack where the AbsorbPointer is. + await gesture.addPointer(location: center); + expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic); + + // Move the pointer to the left of the stack where the AbsorbPointer is not. + await gesture.moveTo(center + const Offset(-100, 0)); + expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.click); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/basic/aspect_ratio.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/basic/aspect_ratio.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..b7384521254654ba07632993d0aa04bf03f2a3d9 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/basic/aspect_ratio.0_test.dart @@ -0,0 +1,25 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/basic/aspect_ratio.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('AspectRatio applies 16 / 9 aspect ratio on its child', (WidgetTester tester) async { + const double height = 100.0; + + await tester.pumpWidget( + const example.AspectRatioApp(), + ); + + final Size parentContainer = tester.getSize(find.byType(Container).first); + expect(parentContainer.width, 800.0); + expect(parentContainer.height, height); + + final Size childContainer = tester.getSize(find.byType(Container).last); + expect(childContainer.width, height * 16 / 9); + expect(childContainer.height, height); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/basic/aspect_ratio.1_test.dart b/novelforge-project/flutter/examples/api/test/widgets/basic/aspect_ratio.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..e19d344938ee693354206c7616a1cb13c9d31ad9 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/basic/aspect_ratio.1_test.dart @@ -0,0 +1,23 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/basic/aspect_ratio.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('AspectRatio applies 2.0 aspect ratio on its child', (WidgetTester tester) async { + const Size containerSize = Size(100, 100); + + await tester.pumpWidget( + const example.AspectRatioApp(), + ); + + final Size parentContainer = tester.getSize(find.byType(Container).first); + expect(parentContainer, containerSize); + + final Size childContainer = tester.getSize(find.byType(Container).last); + expect(childContainer, Size(containerSize.height, containerSize.height / 2.0)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/basic/aspect_ratio.2_test.dart b/novelforge-project/flutter/examples/api/test/widgets/basic/aspect_ratio.2_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..cfd80da07b6caf74409ea7d567e58388fb2e5a6b --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/basic/aspect_ratio.2_test.dart @@ -0,0 +1,23 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/basic/aspect_ratio.2.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('AspectRatio applies 0.5 aspect ratio on its child', (WidgetTester tester) async { + const Size containerSize = Size(100, 100); + + await tester.pumpWidget( + const example.AspectRatioApp(), + ); + + final Size parentContainer = tester.getSize(find.byType(Container).first); + expect(parentContainer, containerSize); + + final Size childContainer = tester.getSize(find.byType(Container).last); + expect(childContainer, Size(containerSize.height * 0.5, containerSize.height)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/basic/clip_rrect.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/basic/clip_rrect.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..e62e24196a3c1ca4f47beced188333648f901d4b --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/basic/clip_rrect.0_test.dart @@ -0,0 +1,28 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/basic/clip_rrect.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('ClipRRect adds rounded corners to containers', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ClipRRectApp(), + ); + + final Finder clipRRectFinder = find.byType(ClipRRect); + final Finder containerFinder = find.byType(Container); + expect(clipRRectFinder, findsNWidgets(2)); + expect(containerFinder, findsNWidgets(3)); + + final Rect firstClipRect = tester.getRect(clipRRectFinder.first); + final Rect secondContainerRect = tester.getRect(containerFinder.at(1)); + expect(firstClipRect, equals(secondContainerRect)); + + final Rect secondClipRect = tester.getRect(clipRRectFinder.at(1)); + final Rect thirdContainerRect = tester.getRect(containerFinder.at(2)); + expect(secondClipRect, equals(thirdContainerRect)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/basic/clip_rrect.1_test.dart b/novelforge-project/flutter/examples/api/test/widgets/basic/clip_rrect.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..672ab5cff07322ad208bfeea8035c5e9862a7675 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/basic/clip_rrect.1_test.dart @@ -0,0 +1,24 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/basic/clip_rrect.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('ClipRRect fits to its child', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ClipRRectApp(), + ); + + final Finder clipRRectFinder = find.byType(ClipRRect); + final Finder logoFinder = find.byType(FlutterLogo); + expect(clipRRectFinder, findsOneWidget); + expect(logoFinder, findsOneWidget); + + final Rect clipRect = tester.getRect(clipRRectFinder); + final Rect containerRect = tester.getRect(logoFinder); + expect(clipRect, equals(containerRect)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/basic/custom_multi_child_layout.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/basic/custom_multi_child_layout.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..acd087ba8e4ae340ae0f45b4a5fac35a10638956 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/basic/custom_multi_child_layout.0_test.dart @@ -0,0 +1,59 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/basic/custom_multi_child_layout.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('has four containers', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: Scaffold( + body: example.CustomMultiChildLayoutApp(), + ), + ), + ); + final Finder containerFinder = find.byType(Container); + expect(containerFinder, findsNWidgets(4)); + }); + + testWidgets('containers are the same size', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: Scaffold( + body: example.CustomMultiChildLayoutExample(), + ), + ), + ); + final Finder containerFinder = find.byType(Container); + const Size expectedSize = Size(100, 100); + for (int i = 0; i < 4; i += 1) { + expect(tester.getSize(containerFinder.at(i)), equals(expectedSize)); + } + expect(containerFinder, findsNWidgets(4)); + }); + + testWidgets('containers are offset', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: Scaffold( + body: example.CustomMultiChildLayoutExample(), + ), + ), + ); + final Finder containerFinder = find.byType(Container); + Rect previousRect = tester.getRect(containerFinder.first); + for (int i = 1; i < 4; i += 1) { + expect( + tester.getRect(containerFinder.at(i)), + equals(previousRect.shift(const Offset(100, 70))), + reason: 'Rect $i not correct size', + ); + previousRect = tester.getRect(containerFinder.at(i)); + } + expect(containerFinder, findsNWidgets(4)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/basic/expanded.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/basic/expanded.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..66827372de0bbec88a3184ad4601e072ff4ed6be --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/basic/expanded.0_test.dart @@ -0,0 +1,37 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/basic/expanded.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Expanded widget in a Column', (WidgetTester tester) async { + const double totalHeight = 600; + const double appBarHeight = 56.0; + const double columnWidth = 100.0; + const double columnHeight = totalHeight - appBarHeight; + const double containerOneHeight = 100; + const double containerTwoHeight = columnHeight - 200; + const double containerThreeHeight = 100; + + await tester.pumpWidget( + const example.ExpandedApp(), + ); + + final Size column = tester.getSize(find.byType(Column)); + expect(column, const Size(columnWidth, columnHeight)); + + final Size containerOne = tester.getSize(find.byType(Container).at(0)); + expect(containerOne, const Size(columnWidth, containerOneHeight)); + + // This Container is wrapped in an Expanded widget, so it should take up + // the remaining space in the Column. + final Size containerTwo = tester.getSize(find.byType(Container).at(1)); + expect(containerTwo, const Size(columnWidth, containerTwoHeight)); + + final Size containerThree = tester.getSize(find.byType(Container).at(2)); + expect(containerThree, const Size(columnWidth, containerThreeHeight)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/basic/expanded.1_test.dart b/novelforge-project/flutter/examples/api/test/widgets/basic/expanded.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..6d1a5d7277fde3673e1ebf45b301361c77b8d717 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/basic/expanded.1_test.dart @@ -0,0 +1,37 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/basic/expanded.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Expanded widgets in a Row', (WidgetTester tester) async { + const double rowWidth = 800.0; + const double rowHeight = 100.0; + const double containerOneWidth = (rowWidth - 50) * 2 / 3; + const double containerTwoWidth = 50; + const double containerThreeWidth = (rowWidth - 50) * 1 / 3; + + await tester.pumpWidget( + const example.ExpandedApp(), + ); + + final Size row = tester.getSize(find.byType(Row)); + expect(row, const Size(rowWidth, rowHeight)); + + // This container is wrapped in an Expanded widget, so it should take up + // two thirds of the remaining space in the Row. + final Size containerOne = tester.getSize(find.byType(Container).at(0)); + expect(containerOne, const Size(containerOneWidth, rowHeight)); + + final Size containerTwo = tester.getSize(find.byType(Container).at(1)); + expect(containerTwo, const Size(containerTwoWidth, rowHeight)); + + // This container is wrapped in an Expanded widget, so it should take up + // one third of the remaining space in the Row. + final Size containerThree = tester.getSize(find.byType(Container).at(2)); + expect(containerThree, const Size(containerThreeWidth, rowHeight)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/basic/fitted_box.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/basic/fitted_box.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..adedfb222e10f6ca6a72617bca5e7f44c4e67f21 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/basic/fitted_box.0_test.dart @@ -0,0 +1,28 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:io'; + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/basic/fitted_box.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + setUpAll(() { + HttpOverrides.global = null; + }); + + testWidgets('FittedBox scales the image to fill the parent container', (WidgetTester tester) async { + await tester.pumpWidget( + const example.FittedBoxApp(), + ); + + final Size containerSize = tester.getSize(find.byType(Container)); + expect(containerSize, const Size(300, 400)); + + // FittedBox should scale the image to fill the parent container. + final FittedBox fittedBox = tester.widget(find.byType(FittedBox)); + expect(fittedBox.fit, BoxFit.fill); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/basic/flow.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/basic/flow.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..ef45b416c8e60a2637a8cabfbe36a4d15dd49bf2 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/basic/flow.0_test.dart @@ -0,0 +1,35 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/basic/flow.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Clicking on the menu icon opens the Flow menu', (WidgetTester tester) async { + await tester.pumpWidget( + const example.FlowApp(), + ); + + // The menu icon is in the top left corner of the screen. + Offset menuIcon = tester.getCenter(find.byIcon(Icons.menu)); + expect(menuIcon, const Offset(80.0, 144.0)); + + // The home icon is also in the top left corner of the screen. + Offset homeIcon = tester.getCenter(find.byIcon(Icons.home)); + expect(homeIcon, const Offset(80.0, 144.0)); + + // Tap the menu icon to open the flow menu. + await tester.tapAt(menuIcon); + await tester.pumpAndSettle(); + + // The home icon is still in the top left corner of the screen. + homeIcon = tester.getCenter(find.byIcon(Icons.home)); + expect(homeIcon, const Offset(80.0, 144.0)); + + // The menu icon is now in the top right corner of the screen. + menuIcon = tester.getCenter(find.byIcon(Icons.menu)); + expect(menuIcon, const Offset(720.0, 144.0)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/basic/fractionally_sized_box.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/basic/fractionally_sized_box.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..65e3d6742653f206d62bfee3567ace42b3d2fe18 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/basic/fractionally_sized_box.0_test.dart @@ -0,0 +1,27 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/basic/fractionally_sized_box.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('FractionallySizedBox sizes DecoratedBox', (WidgetTester tester) async { + const double appBarHeight = 56.0; + const double widthFactor = 0.5; + const double heightFactor = 0.5; + + await tester.pumpWidget( + const example.FractionallySizedBoxApp(), + ); + + final FractionallySizedBox fractionallySizedBox = tester.widget(find.byType(FractionallySizedBox)); + expect(fractionallySizedBox.widthFactor, widthFactor); + expect(fractionallySizedBox.heightFactor, heightFactor); + + final Size boxSize = tester.getSize(find.byType(DecoratedBox)); + expect(boxSize.width, 800 * widthFactor); + expect(boxSize.height, (600 - appBarHeight) * heightFactor); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/basic/ignore_pointer.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/basic/ignore_pointer.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..fa7583ec6ca8a1027c8ec3bcef3a87d272a53e1d --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/basic/ignore_pointer.0_test.dart @@ -0,0 +1,33 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/gestures.dart'; +import 'package:flutter/rendering.dart'; +import 'package:flutter_api_samples/widgets/basic/ignore_pointer.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('IgnorePointer ignores pointer on the ElevatedButton', (WidgetTester tester) async { + const String clickButtonText = 'Click me!'; + + await tester.pumpWidget( + const example.IgnorePointerApp(), + ); + + // The ElevatedButton is clickable. + expect(find.text('Ignoring: false'), findsOneWidget); + + final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse, pointer: 1); + await gesture.addPointer(location: tester.getCenter(find.text(clickButtonText))); + // On hovering the ElevatedButton, the cursor should be SystemMouseCursors.click. + expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.click); + + // Tap to set ignoring pointer to true. + await tester.tap(find.text('Set ignoring to true')); + await tester.pump(); + + // The ElevatedButton is not clickable so the cursor should be SystemMouseCursors.basic. + expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/basic/indexed_stack.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/basic/indexed_stack.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..c4f797d0a651c613c4fb9db2985d908e67a87ad1 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/basic/indexed_stack.0_test.dart @@ -0,0 +1,94 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/basic/indexed_stack.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('has correct forward rendering mechanism', (WidgetTester tester) async { + await tester.pumpWidget(const example.IndexedStackApp()); + + final Finder gesture2 = find.byKey(const Key('gesture2')); + final Element containerFinder = find.byKey(const Key('Dash'), skipOffstage: false).evaluate().first; + expect(containerFinder.renderObject!.debugNeedsPaint, false); + final Element containerFinder1 = find.byKey(const Key('John'), skipOffstage: false).evaluate().first; + expect(containerFinder1.renderObject!.debugNeedsPaint, true); + final Element containerFinder2 = find.byKey(const Key('Mary'), skipOffstage: false).evaluate().first; + expect(containerFinder2.renderObject!.debugNeedsPaint, true); + + await tester.tap(gesture2); + await tester.pump(); + expect(containerFinder.renderObject!.debugNeedsPaint, false); + expect(containerFinder1.renderObject!.debugNeedsPaint, false); + expect(containerFinder2.renderObject!.debugNeedsPaint, true); + + await tester.tap(gesture2); + await tester.pump(); + expect(containerFinder.renderObject!.debugNeedsPaint, false); + expect(containerFinder1.renderObject!.debugNeedsPaint, false); + expect(containerFinder2.renderObject!.debugNeedsPaint, false); + }); + testWidgets('has correct backward rendering mechanism', (WidgetTester tester) async { + await tester.pumpWidget(const example.IndexedStackApp()); + + final Finder gesture1 = find.byKey(const Key('gesture1')); + final Element containerFinder = find.byKey(const Key('Dash'), skipOffstage: false).evaluate().first; + final Element containerFinder1 = find.byKey(const Key('John'), skipOffstage: false).evaluate().first; + final Element containerFinder2 = find.byKey(const Key('Mary'), skipOffstage: false).evaluate().first; + + await tester.tap(gesture1); + await tester.pump(); + expect(containerFinder.renderObject!.debugNeedsPaint, false); + expect(containerFinder1.renderObject!.debugNeedsPaint, true); + expect(containerFinder2.renderObject!.debugNeedsPaint, false); + + await tester.tap(gesture1); + await tester.pump(); + expect(containerFinder.renderObject!.debugNeedsPaint, false); + expect(containerFinder1.renderObject!.debugNeedsPaint, false); + expect(containerFinder2.renderObject!.debugNeedsPaint, false); + }); + testWidgets('has correct element addition handling', (WidgetTester tester) async { + await tester.pumpWidget(const example.IndexedStackApp()); + + expect(find.byType(example.PersonTracker), findsOneWidget); + expect(find.byType(example.PersonTracker, skipOffstage: false), findsNWidgets(3)); + final Finder textField = find.byType(TextField); + await tester.enterText(textField, 'hello'); + await tester.testTextInput.receiveAction(TextInputAction.done); + await tester.pump(); + expect(find.byType(example.PersonTracker, skipOffstage: false), findsNWidgets(4)); + + await tester.enterText(textField, 'hello1'); + await tester.testTextInput.receiveAction(TextInputAction.done); + await tester.pump(); + expect(find.byType(example.PersonTracker, skipOffstage: false), findsNWidgets(5)); + }); + testWidgets('has state preservation', (WidgetTester tester) async { + await tester.pumpWidget(const example.IndexedStackApp()); + + final Finder gesture1 = find.byKey(const Key('gesture1')); + final Finder gesture2 = find.byKey(const Key('gesture2')); + final Finder containerFinder = find.byKey(const Key('Dash')); + final Finder incrementFinder = find.byKey(const Key('incrementDash')); + Finder counterFinder(int score) { + return find.descendant(of: containerFinder, matching: find.text('Score: $score')); + } + + expect(counterFinder(0), findsOneWidget); + await tester.tap(incrementFinder); + await tester.pump(); + + expect(counterFinder(1), findsOneWidget); + + await tester.tap(gesture2); + await tester.pump(); + await tester.tap(gesture1); + await tester.pump(); + + expect(counterFinder(1), findsOneWidget); + expect(counterFinder(0), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/basic/listener.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/basic/listener.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..40fb5d6b5cc833da0c18824dfa2506af2616206c --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/basic/listener.0_test.dart @@ -0,0 +1,34 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/basic/listener.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Listener detects press & release, and cursor location', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp(home: example.ListenerExample()), + ); + + expect(find.text('0 presses\n0 releases'), findsOneWidget); + expect(find.text('The cursor is here: (0.00, 0.00)'), findsOneWidget); + + final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); + await gesture.addPointer(); + await gesture.down(tester.getCenter(find.byType(ColoredBox))); + await tester.pump(); + + expect(find.text('1 presses\n0 releases'), findsOneWidget); + expect(find.text('The cursor is here: (400.00, 300.00)'), findsOneWidget); + + await gesture.up(); + await tester.pump(); + + expect(find.text('1 presses\n1 releases'), findsOneWidget); + expect(find.text('The cursor is here: (400.00, 300.00)'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/basic/mouse_region.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/basic/mouse_region.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..028210d862ca50eb03c0cd8d7f177dbae26ac11f --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/basic/mouse_region.0_test.dart @@ -0,0 +1,39 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/basic/mouse_region.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('MouseRegion detects mouse entries, exists, and location', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp(home: example.MouseRegionApp()), + ); + + expect(find.text('0 Entries\n0 Exits'), findsOneWidget); + expect(find.text('The cursor is here: (0.00, 0.00)'), findsOneWidget); + + final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); + await gesture.addPointer(); + await gesture.moveTo(tester.getCenter(find.byType(ColoredBox))); + await tester.pump(); + + expect(find.text('1 Entries\n0 Exits'), findsOneWidget); + expect(find.text('The cursor is here: (400.00, 328.00)'), findsOneWidget); + + await gesture.moveTo( + tester.getCenter(find.byType(ColoredBox)) + const Offset(50.0, 30.0), + ); + await tester.pump(); + + expect(find.text('The cursor is here: (450.00, 358.00)'), findsOneWidget); + + await gesture.moveTo(Offset.zero); + await tester.pump(); + + expect(find.text('1 Entries\n1 Exits'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/basic/mouse_region.on_exit.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/basic/mouse_region.on_exit.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..1f8ac60f0fa4d36e6f046fb8d0917cd67a9b4fcc --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/basic/mouse_region.on_exit.0_test.dart @@ -0,0 +1,27 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/basic/mouse_region.on_exit.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('MouseRegion detects mouse hover', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp(home: example.MouseRegionApp()), + ); + + Container container = tester.widget(find.byType(Container)); + expect(container.decoration, const BoxDecoration(color: Colors.blue)); + + final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); + await gesture.addPointer(); + await gesture.moveTo(tester.getCenter(find.byType(Container))); + await tester.pump(); + + container = tester.widget(find.byType(Container)); + expect(container.decoration, const BoxDecoration(color: Colors.yellow)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/basic/mouse_region.on_exit.1_test.dart b/novelforge-project/flutter/examples/api/test/widgets/basic/mouse_region.on_exit.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..6025575e32a7f005bbd436d845f01e5bdc2cf0dc --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/basic/mouse_region.on_exit.1_test.dart @@ -0,0 +1,30 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/basic/mouse_region.on_exit.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('MouseRegion update mouse hover with a delay', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp(home: example.MouseRegionApp()), + ); + + expect(find.text('Not hovering'), findsOneWidget); + + final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); + await gesture.addPointer(); + await gesture.moveTo(tester.getCenter(find.byType(Container))); + await tester.pump(); + + expect(find.text('Hovering'), findsOneWidget); + + await gesture.moveTo(Offset.zero); + await tester.pump(const Duration(seconds: 1)); + + expect(find.text('Not hovering'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/basic/offstage.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/basic/offstage.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..e459dee7e760eb097e6bc8f7ac103ebe0ede85b6 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/basic/offstage.0_test.dart @@ -0,0 +1,31 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/basic/offstage.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can off/on stage Flutter logo widget', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp(home: example.OffstageApp()), + ); + + // The Flutter logo is off stage and not visible. + expect(find.text('Flutter logo is offstage: true'), findsOneWidget); + + // Tap to get the Flutter logo size. + await tester.tap(find.text('Get Flutter Logo size')); + await tester.pumpAndSettle(); + + expect(find.text('Flutter Logo size is Size(150.0, 150.0)'), findsOneWidget); + + // Tap to toggle the offstage value. + await tester.tap(find.text('Toggle Offstage Value')); + await tester.pumpAndSettle(); + + // The Flutter logo is on stage and visible. + expect(find.text('Flutter logo is offstage: false'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/basic/overflowbox.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/basic/overflowbox.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..a3b86f8fb86262729d8bc6a7cf0296e502cd2cfa --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/basic/overflowbox.0_test.dart @@ -0,0 +1,31 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/basic/overflowbox.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('OverflowBox allows child widget to overflow parent container', (WidgetTester tester) async { + const Size containerSize = Size(100, 100); + const Size maxSize = Size(200, 200); + + await tester.pumpWidget( + const example.OverflowBoxApp(), + ); + + // The parent container has fixed width and height of 100 pixels. + expect(tester.getSize(find.byType(Container).first), containerSize); + + final OverflowBox overflowBox = tester.widget(find.byType(OverflowBox)); + // The OverflowBox imposes its own constraints of maxWidth and maxHeight of + // 200 on its child which allows the child to overflow the parent container. + expect(overflowBox.maxWidth, maxSize.width); + expect(overflowBox.maxHeight, maxSize.height); + + // The child widget overflows the parent container. + expect(tester.getSize(find.byType(FlutterLogo)), greaterThan(containerSize)); + expect(tester.getSize(find.byType(FlutterLogo)), maxSize); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/basic/physical_shape.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/basic/physical_shape.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..db6e9aea5379cdbcfb7399c71b1720c2157775c7 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/basic/physical_shape.0_test.dart @@ -0,0 +1,25 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/basic/physical_shape.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('PhysicalShape is an ancestor of the text widget', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp(home: example.PhysicalShapeApp()), + ); + + final PhysicalShape physicalShape = tester.widget( + find.ancestor( + of:find.text('Hello, World!'), + matching: find.byType(PhysicalShape), + ), + ); + expect(physicalShape.clipper, isNotNull); + expect(physicalShape.color, Colors.orange); + expect(physicalShape.elevation, 5.0); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/binding/widget_binding_observer.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/binding/widget_binding_observer.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..6da54447e5edd2a04831a968b4769e8dd7203b1d --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/binding/widget_binding_observer.0_test.dart @@ -0,0 +1,46 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; +import 'package:flutter_api_samples/widgets/binding/widget_binding_observer.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('App tracks lifecycle states', (WidgetTester tester) async { + Future setAppLifeCycleState(AppLifecycleState state) async { + final ByteData? message = + const StringCodec().encodeMessage(state.toString()); + await tester.binding.defaultBinaryMessenger.handlePlatformMessage( + 'flutter/lifecycle', message, (_) {}); + } + + await tester.pumpWidget( + const example.WidgetBindingObserverExampleApp(), + ); + + expect(find.text('There are no AppLifecycleStates to show.'), findsOneWidget); + + await setAppLifeCycleState(AppLifecycleState.resumed); + await tester.pumpAndSettle(); + expect(find.text('state is: AppLifecycleState.resumed'), findsOneWidget); + + await setAppLifeCycleState(AppLifecycleState.inactive); + await tester.pumpAndSettle(); + expect(find.text('state is: AppLifecycleState.inactive'), findsOneWidget); + + await setAppLifeCycleState(AppLifecycleState.paused); + await tester.pumpAndSettle(); + // Can't look for paused text here because rendering is paused. + + await setAppLifeCycleState(AppLifecycleState.inactive); + await tester.pumpAndSettle(); + expect(find.text('state is: AppLifecycleState.inactive'), findsNWidgets(2)); + + await setAppLifeCycleState(AppLifecycleState.resumed); + await tester.pumpAndSettle(); + expect(find.text('state is: AppLifecycleState.resumed'), findsNWidgets(2)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/dismissible/dismissible.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/dismissible/dismissible.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..9dcb809677601b0393746b2ca3174937220bfb32 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/dismissible/dismissible.0_test.dart @@ -0,0 +1,81 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/dismissible/dismissible.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + Future dismissHorizontally({ + required WidgetTester tester, + required Finder finder, + required AxisDirection direction, + }) async { + final double width = (tester.renderObject(finder) as RenderBox).size.width; + final double dx = width * 0.8; + + final Offset offset = switch (direction) { + AxisDirection.left => Offset(-dx, 0.0), + AxisDirection.right => Offset(dx, 0.0), + _ => throw ArgumentError('$direction is not supported'), + }; + + await tester.drag(finder, offset); + } + + testWidgets( + 'ListTiles can be dismissed from right to left', + (WidgetTester tester) async { + await tester.pumpWidget( + const example.DismissibleExampleApp(), + ); + + for (final int index in [0, 33, 66, 99]) { + final ValueKey key = ValueKey(index); + + await tester.scrollUntilVisible(find.byKey(key), 100); + + expect(find.byKey(key), findsOneWidget); + + await dismissHorizontally( + tester: tester, + finder: find.byKey(key), + direction: AxisDirection.left, + ); + + await tester.pumpAndSettle(); + + expect(find.byKey(key), findsNothing); + } + }, + ); + + testWidgets( + 'ListTiles can be dismissed from left to right', + (WidgetTester tester) async { + await tester.pumpWidget( + const example.DismissibleExampleApp(), + ); + + for (final int index in [0, 33, 66, 99]) { + final ValueKey key = ValueKey(index); + + await tester.scrollUntilVisible(find.byKey(key), 100); + + expect(find.byKey(key), findsOneWidget); + + await dismissHorizontally( + tester: tester, + finder: find.byKey(key), + direction: AxisDirection.right, + ); + + await tester.pumpAndSettle(); + + expect(find.byKey(key), findsNothing); + } + }, + ); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/drag_target/draggable.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/drag_target/draggable.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..6773ed2a73eb003e2287c895a3ca238dc57cace8 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/drag_target/draggable.0_test.dart @@ -0,0 +1,122 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/drag_target/draggable.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + Finder findContainerWith({ + required Finder child, + required Color color, + }) { + return find.ancestor( + of: child, + matching: find.byWidgetPredicate( + (Widget widget) => widget is Container && widget.color == color, + ), + ); + } + + testWidgets('Verify initial state', (WidgetTester tester) async { + await tester.pumpWidget( + const example.DraggableExampleApp(), + ); + + expect(find.text('Draggable Sample'), findsOneWidget); + + expect( + findContainerWith( + color: Colors.lightGreenAccent, + child: find.text('Draggable'), + ), + findsOneWidget, + ); + + expect( + findContainerWith( + color: Colors.cyan, + child: find.text('Value is updated to: 0'), + ), + findsOneWidget, + ); + }); + + testWidgets('Verify correct containers are displayed while dragging', (WidgetTester tester) async { + await tester.pumpWidget( + const example.DraggableExampleApp(), + ); + + final Finder idleContainer = findContainerWith( + color: Colors.lightGreenAccent, + child: find.text('Draggable'), + ); + final Finder draggingContainer = findContainerWith( + color: Colors.pinkAccent, + child: find.text('Child When Dragging'), + ); + final Finder feedbackContainer = findContainerWith( + color: Colors.deepOrange, + child: find.byIcon(Icons.directions_run), + ); + + expect(idleContainer, findsOneWidget); + expect(draggingContainer, findsNothing); + expect(feedbackContainer, findsNothing); + + final TestGesture gesture = await tester.startGesture( + tester.getCenter(idleContainer), + ); + await tester.pump(); + + expect(idleContainer, findsNothing); + expect(draggingContainer, findsOneWidget); + expect(feedbackContainer, findsOneWidget); + + await gesture.moveBy(const Offset(200, 0)); + await tester.pump(); + + expect(idleContainer, findsNothing); + expect(draggingContainer, findsOneWidget); + expect(feedbackContainer, findsOneWidget); + + await gesture.up(); + await tester.pump(); + + expect(idleContainer, findsOneWidget); + expect(draggingContainer, findsNothing); + expect(feedbackContainer, findsNothing); + }); + + testWidgets('Dropping Draggable over DragTarget updates the counter', (WidgetTester tester) async { + await tester.pumpWidget( + const example.DraggableExampleApp(), + ); + + final Finder draggable = find.byType(Draggable); + final Finder target = find.byType(DragTarget); + + int counter = 0; + + for (int i = 0; i < 5; i++) { + final TestGesture gesture = await tester.startGesture( + tester.getCenter(draggable), + ); + await gesture.moveTo(tester.getCenter(target)); + await gesture.up(); + await tester.pump(); + + counter += 10; + + expect( + findContainerWith( + color: Colors.cyan, + child: find.text('Value is updated to: $counter'), + ), + findsOneWidget, + ); + } + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/draggable_scrollable_sheet/draggable_scrollable_sheet.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/draggable_scrollable_sheet/draggable_scrollable_sheet.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..da365dc6cbe0490286fb2ab230fe852126665564 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/draggable_scrollable_sheet/draggable_scrollable_sheet.0_test.dart @@ -0,0 +1,63 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/draggable_scrollable_sheet/draggable_scrollable_sheet.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Test DraggableScrollableSheet initial state', (WidgetTester tester) async { + await tester.pumpWidget( + const example.DraggableScrollableSheetExampleApp(), + ); + + final Finder sheetFinder = find.byType(DraggableScrollableSheet); + + // Verify that DraggableScrollableSheet is initially present + expect(sheetFinder, findsOneWidget); + + // Verify that DraggableScrollableSheet is shown initially at 50% height + final DraggableScrollableSheet draggableSheet = tester.widget(sheetFinder); + expect(draggableSheet.initialChildSize, 0.5); + }); + + testWidgets('Test DraggableScrollableSheet drag behavior on mobile platforms', (WidgetTester tester) async { + await tester.pumpWidget( + const example.DraggableScrollableSheetExampleApp(), + ); + + // Verify that ListView is visible + final Finder listViewFinder = find.byType(ListView); + expect(listViewFinder, findsOneWidget); + + // Get the initial size of the ListView + final Size listViewInitialSize = tester.getSize(listViewFinder); + + // Drag the the sheet from anywhere inside the sheet to change the sheet position + await tester.drag(listViewFinder, const Offset(0.0, -100.0)); + await tester.pump(); + + // Verify that the ListView is expanded + final Size listViewCurrentSize = tester.getSize(listViewFinder); + expect(listViewCurrentSize.height, greaterThan(listViewInitialSize.height)); + }, variant: TargetPlatformVariant.mobile()); + + testWidgets('Test DraggableScrollableSheet drag behavior on desktop platforms', (WidgetTester tester) async { + await tester.pumpWidget( + const example.DraggableScrollableSheetExampleApp(), + ); + + // Verify that Grabber is visible + final Finder grabberFinder = find.byType(example.Grabber); + expect(grabberFinder, findsOneWidget); + + // Drag the Grabber to change the sheet position + await tester.drag(grabberFinder, const Offset(0.0, -100.0)); + await tester.pump(); + + // Verify that the DraggableScrollableSheet's initialChildSize is updated + final DraggableScrollableSheet draggableSheet = tester.widget(find.byType(DraggableScrollableSheet)); + expect(draggableSheet.initialChildSize, isNot(0.5)); + }, variant: TargetPlatformVariant.desktop()); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/editable_text/editable_text.on_changed.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/editable_text/editable_text.on_changed.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..6bb420d04f335d28d4371f5ee772d99093d1a6a4 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/editable_text/editable_text.on_changed.0_test.dart @@ -0,0 +1,68 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/editable_text/editable_text.on_changed.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Verify correct labels are displayed', (WidgetTester tester) async { + await tester.pumpWidget( + const example.OnChangedExampleApp(), + ); + + expect( + find.text('What number comes next in the sequence?'), + findsOneWidget, + ); + expect(find.text('1, 1, 2, 3, 5, 8...?'), findsOneWidget); + }); + + testWidgets('Does not show dialog when answer is not correct', (WidgetTester tester) async { + await tester.pumpWidget( + const example.OnChangedExampleApp(), + ); + + await tester.enterText(find.byType(TextField), '33'); + await tester.pumpAndSettle(); + + expect(find.byType(AlertDialog), findsNothing); + }); + + testWidgets('Shows dialog when answer is correct', (WidgetTester tester) async { + await tester.pumpWidget( + const example.OnChangedExampleApp(), + ); + + await tester.enterText(find.byType(TextField), '13'); + await tester.pumpAndSettle(); + + expect(find.byType(AlertDialog), findsOneWidget); + expect(find.text('That is correct!'), findsOneWidget); + expect(find.text('13 is the right answer.'), findsOneWidget); + expect(find.text('OK'), findsOneWidget); + }); + + testWidgets('Closes dialog on OK button tap', (WidgetTester tester) async { + await tester.pumpWidget( + const example.OnChangedExampleApp(), + ); + + await tester.enterText(find.byType(TextField), '13'); + await tester.pumpAndSettle(); + + expect(find.byType(AlertDialog), findsOneWidget); + + await tester.tap( + find.ancestor( + of: find.text('OK'), + matching: find.byType(TextButton), + ), + ); + await tester.pumpAndSettle(); + + expect(find.byType(AlertDialog), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/editable_text/editable_text.on_content_inserted.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/editable_text/editable_text.on_content_inserted.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..a3b76b30f06446a904c5d604ef2173e7a59a271b --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/editable_text/editable_text.on_content_inserted.0_test.dart @@ -0,0 +1,57 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_api_samples/widgets/editable_text/editable_text.on_content_inserted.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Image.memory displays inserted content', (WidgetTester tester) async { + await tester.pumpWidget( + const example.KeyboardInsertedContentApp(), + ); + + expect(find.text('Keyboard Inserted Content Sample'), findsOneWidget); + + await tester.tap(find.byType(EditableText)); + await tester.enterText(find.byType(EditableText), 'test'); + await tester.idle(); + + const String uri = 'content://com.google.android.inputmethod.latin.fileprovider/test.png'; + const List kBlueSquarePng = [ + 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, + 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x32, 0x08, 0x06, + 0x00, 0x00, 0x00, 0x1e, 0x3f, 0x88, 0xb1, 0x00, 0x00, 0x00, 0x48, 0x49, 0x44, + 0x41, 0x54, 0x78, 0xda, 0xed, 0xcf, 0x31, 0x0d, 0x00, 0x30, 0x08, 0x00, 0xb0, + 0x61, 0x63, 0x2f, 0xfe, 0x2d, 0x61, 0x05, 0x34, 0xf0, 0x92, 0xd6, 0x41, 0x23, + 0x7f, 0xf5, 0x3b, 0x20, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, + 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, + 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, + 0x44, 0x44, 0x44, 0x36, 0x06, 0x03, 0x6e, 0x69, 0x47, 0x12, 0x8e, 0xea, 0xaa, + 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, + ]; + final ByteData? messageBytes = const JSONMessageCodec().encodeMessage({ + 'args': [ + -1, + 'TextInputAction.commitContent', + jsonDecode('{"mimeType": "image/png", "data": $kBlueSquarePng, "uri": "$uri"}'), + ], + 'method': 'TextInputClient.performAction', + }); + + try { + await tester.binding.defaultBinaryMessenger.handlePlatformMessage( + 'flutter/textinput', + messageBytes, + (ByteData? _) {}, + ); + } catch (_) {} + + await tester.pumpAndSettle(); + expect(find.byType(Image), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/editable_text/text_editing_controller.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/editable_text/text_editing_controller.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..11737ed0240e7b37be1b5174cc6e1d6bf83f7c40 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/editable_text/text_editing_controller.0_test.dart @@ -0,0 +1,67 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/editable_text/text_editing_controller.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Forces text to be lower case', (WidgetTester tester) async { + await tester.pumpWidget( + const example.TextEditingControllerExampleApp(), + ); + + const String input = 'Almost Everything Is a WIDGET! 💙'; + + await tester.enterText(find.byType(TextFormField), input); + await tester.pump(); + + final TextFormField textField = tester.widget(find.byType(TextFormField)); + final TextEditingController controller = textField.controller!; + + expect(find.text(input.toLowerCase()), findsOneWidget); + expect(controller.text, input.toLowerCase()); + }); + + testWidgets('Keeps the caret at the end of the input', (WidgetTester tester) async { + await tester.pumpWidget( + const example.TextEditingControllerExampleApp(), + ); + + const String input = 'flutter'; + + await tester.enterText(find.byType(TextFormField), input); + await tester.pump(); + + expect(find.text(input), findsOneWidget); + + final TextFormField textField = tester.widget(find.byType(TextFormField)); + final TextEditingController controller = textField.controller!; + + // Verify that the caret positioned at the end of the input. + expect( + controller.selection, + const TextSelection.collapsed(offset: input.length), + ); + + final RenderBox box = tester.renderObject(find.byType(TextFormField)); + + // Calculate the center-left point of the field. + final Offset centerLeftPoint = box.localToGlobal( + Offset(0, box.size.height / 2), + ); + + // Tap on the center-left point of the field to try to change the caret + // position. + await tester.tapAt(centerLeftPoint); + await tester.pump(); + + // Verify that the caret position remains unchanged. + expect( + controller.selection, + const TextSelection.collapsed(offset: input.length), + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/editable_text/text_editing_controller.1_test.dart b/novelforge-project/flutter/examples/api/test/widgets/editable_text/text_editing_controller.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..c2b00d9ad9d890d9bda3aac370bdccb70f4a29de --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/editable_text/text_editing_controller.1_test.dart @@ -0,0 +1,21 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/editable_text/text_editing_controller.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Initial selection is collapsed at offset 0', (WidgetTester tester) async { + await tester.pumpWidget( + const example.TextEditingControllerExampleApp(), + ); + + final EditableText editableText = tester.widget(find.byType(EditableText)); + final TextEditingController controller = editableText.controller; + + expect(controller.text, 'Flutter'); + expect(controller.selection, const TextSelection.collapsed(offset: 0)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/focus_manager/focus_node.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/focus_manager/focus_node.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..bd017976f727dd12f36a61212b3a16855a9bd187 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/focus_manager/focus_node.0_test.dart @@ -0,0 +1,191 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_api_samples/widgets/focus_manager/focus_node.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets( + 'FocusNode gets focused and unfocused on ColorfulButton tap', + (WidgetTester tester) async { + await tester.pumpWidget( + const example.FocusNodeExampleApp(), + ); + + final Element button = tester.element( + find.byType(example.ColorfulButton), + ); + + expect( + tester.binding.focusManager.primaryFocus?.context, + isNot(equals(button)), + ); + + // Tapping on ColorfulButton to focus on FocusNode. + await tester.tap(find.byType(example.ColorfulButton)); + await tester.pump(); + + expect( + tester.binding.focusManager.primaryFocus?.context, + equals(button), + ); + + // Tapping on ColorfulButton to unfocus from FocusNode. + await tester.tap(find.byType(example.ColorfulButton)); + await tester.pump(); + + expect( + tester.binding.focusManager.primaryFocus?.context, + isNot(equals(button)), + ); + }, + ); + + testWidgets( + 'FocusNode updates the text label when focused or unfocused', + (WidgetTester tester) async { + await tester.pumpWidget( + const example.FocusNodeExampleApp(), + ); + + expect(find.text('Press to focus'), findsOneWidget); + expect(find.text("I'm in color! Press R,G,B!"), findsNothing); + + // Tapping on ColorfulButton to focus on FocusNode. + await tester.tap(find.byType(example.ColorfulButton)); + await tester.pump(); + + expect(find.text('Press to focus'), findsNothing); + expect(find.text("I'm in color! Press R,G,B!"), findsOneWidget); + + // Tapping on ColorfulButton to unfocus from FocusNode. + await tester.tap(find.byType(example.ColorfulButton)); + await tester.pump(); + + expect(find.text('Press to focus'), findsOneWidget); + expect(find.text("I'm in color! Press R,G,B!"), findsNothing); + }, + ); + + testWidgets( + 'FocusNode updates color of the Container according to the key events when focused', + (WidgetTester tester) async { + await tester.pumpWidget( + const example.FocusNodeExampleApp(), + ); + + // Tapping on ColorfulButton to focus on FocusNode. + await tester.tap(find.byType(example.ColorfulButton)); + await tester.pump(); + + final Finder containerFinder = find.descendant( + of: find.byType(example.ColorfulButton), + matching: find.byType(Container), + ); + + Container container = tester.widget(containerFinder); + expect(container.color, equals(Colors.white)); + + await tester.sendKeyEvent(LogicalKeyboardKey.keyR); + await tester.pump(); + + container = tester.widget(containerFinder); + expect(container.color, equals(Colors.red)); + + await tester.sendKeyEvent(LogicalKeyboardKey.keyG); + await tester.pump(); + + container = tester.widget(containerFinder); + expect(container.color, equals(Colors.green)); + + await tester.sendKeyEvent(LogicalKeyboardKey.keyB); + await tester.pump(); + + container = tester.widget(containerFinder); + expect(container.color, equals(Colors.blue)); + }, + ); + + testWidgets( + 'FocusNode does not listen to the key events when unfocused', + (WidgetTester tester) async { + await tester.pumpWidget( + const example.FocusNodeExampleApp(), + ); + + final Finder containerFinder = find.descendant( + of: find.byType(example.ColorfulButton), + matching: find.byType(Container), + ); + + Container container = tester.widget(containerFinder); + expect(container.color, equals(Colors.white)); + + await tester.sendKeyEvent(LogicalKeyboardKey.keyR); + await tester.pump(); + + container = tester.widget(containerFinder); + expect(container.color, equals(Colors.white)); + + await tester.sendKeyEvent(LogicalKeyboardKey.keyG); + await tester.pump(); + + container = tester.widget(containerFinder); + expect(container.color, equals(Colors.white)); + + await tester.sendKeyEvent(LogicalKeyboardKey.keyB); + await tester.pump(); + + container = tester.widget(containerFinder); + expect(container.color, equals(Colors.white)); + }, + ); + + testWidgets( + 'FocusNode sets color to the white when unfocused and sets it back to the selected one when focused', + (WidgetTester tester) async { + await tester.pumpWidget( + const example.FocusNodeExampleApp(), + ); + + final Finder containerFinder = find.descendant( + of: find.byType(example.ColorfulButton), + matching: find.byType(Container), + ); + + Container container = tester.widget(containerFinder); + expect(container.color, equals(Colors.white)); + + // Tapping on ColorfulButton to focus on FocusNode. + await tester.tap(find.byType(example.ColorfulButton)); + await tester.pump(); + + container = tester.widget(containerFinder); + expect(container.color, equals(Colors.white)); + + await tester.sendKeyEvent(LogicalKeyboardKey.keyR); + await tester.pump(); + + container = tester.widget(containerFinder); + expect(container.color, equals(Colors.red)); + + // Tapping on ColorfulButton to unfocus from FocusNode. + await tester.tap(find.byType(example.ColorfulButton)); + await tester.pump(); + + container = tester.widget(containerFinder); + expect(container.color, equals(Colors.white)); + + // Tapping on ColorfulButton to focus on FocusNode. + await tester.tap(find.byType(example.ColorfulButton)); + await tester.pump(); + + container = tester.widget(containerFinder); + expect(container.color, equals(Colors.red)); + }, + ); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/focus_scope/focus.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/focus_scope/focus.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..a42c3665e482ad143fe5142d8350bcb43af0d298 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/focus_scope/focus.0_test.dart @@ -0,0 +1,80 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_api_samples/widgets/focus_scope/focus.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('shows initial content', (WidgetTester tester) async { + await tester.pumpWidget(const example.FocusExampleApp()); + expect(find.byType(Scaffold), findsOneWidget); + expect(find.byType(AppBar), findsOneWidget); + expect(find.byType(FocusScope), findsAtLeastNWidgets(1)); + expect(find.text('Press to focus'), findsOneWidget); + expect(find.text('Focus Sample'), findsOneWidget); + expect(find.byType(Container), findsOneWidget); + + final Container container = + tester.widget(find.byType(Container)); + expect(container.color, Colors.white); + }); + + testWidgets('switches to focus mode', (WidgetTester tester) async { + await tester.pumpWidget(const example.FocusExampleApp()); + expect(find.text('Press to focus'), findsOneWidget); + expect(find.text("I'm in color! Press R,G,B!"), findsNothing); + await tester.tap(find.text('Press to focus')); + await tester.pumpAndSettle(); + expect(find.text('Press to focus'), findsNothing); + expect(find.text("I'm in color! Press R,G,B!"), findsOneWidget); + + expect(find.byType(Container), findsOneWidget); + final Container container = + tester.widget(find.byType(Container)); + expect(container.color, Colors.white); + + await tester.tap(find.text("I'm in color! Press R,G,B!")); + await tester.pumpAndSettle(); + expect(find.text('Press to focus'), findsOneWidget); + expect(find.text("I'm in color! Press R,G,B!"), findsNothing); + }); + + testWidgets('changes color according to key presses', (WidgetTester tester) async { + await tester.pumpWidget(const example.FocusExampleApp()); + expect(find.byType(Container), findsOneWidget); + expect(tester.widget(find.byType(Container)).color, Colors.white); + await tester.sendKeyEvent(LogicalKeyboardKey.keyR); + await tester.pumpAndSettle(); + expect(tester.widget(find.byType(Container)).color, Colors.white); + await tester.sendKeyEvent(LogicalKeyboardKey.keyG); + await tester.pumpAndSettle(); + expect(tester.widget(find.byType(Container)).color, Colors.white); + await tester.sendKeyEvent(LogicalKeyboardKey.keyB); + await tester.pumpAndSettle(); + expect(tester.widget(find.byType(Container)).color, Colors.white); + + expect(find.text('Press to focus'), findsOneWidget); + await tester.tap(find.text('Press to focus')); + await tester.pumpAndSettle(); + expect(find.byType(Container), findsOneWidget); + expect(tester.widget(find.byType(Container)).color, Colors.white); + await tester.sendKeyEvent(LogicalKeyboardKey.keyR); + await tester.pumpAndSettle(); + expect(tester.widget(find.byType(Container)).color, Colors.red); + await tester.sendKeyEvent(LogicalKeyboardKey.keyG); + await tester.pumpAndSettle(); + expect(tester.widget(find.byType(Container)).color, Colors.green); + await tester.sendKeyEvent(LogicalKeyboardKey.keyB); + await tester.pumpAndSettle(); + expect(tester.widget(find.byType(Container)).color, Colors.blue); + + expect(find.text("I'm in color! Press R,G,B!"), findsOneWidget); + await tester.tap(find.text("I'm in color! Press R,G,B!")); + await tester.pumpAndSettle(); + expect(tester.widget(find.byType(Container)).color, Colors.white); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/focus_scope/focus.1_test.dart b/novelforge-project/flutter/examples/api/test/widgets/focus_scope/focus.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..dcc7b83ed79c3472ccdba8933232aa4eefb4b0a5 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/focus_scope/focus.1_test.dart @@ -0,0 +1,100 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_api_samples/widgets/focus_scope/focus.1.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('FocusableText shows content and color depending on focus', + (WidgetTester tester) async { + await tester.pumpWidget(const MaterialApp( + home: Scaffold( + body: example.FocusableText( + 'Item 0', + autofocus: false, + ), + ), + )); + // Autofocus needs to check that no other node in the [FocusScope] is + // focused and can only request focus for the second frame. + await tester.pumpAndSettle(); + expect(find.descendant( + of: find.byType(example.FocusableText), + matching: find.byType(Focus), + ), findsOneWidget); + expect(find.text('Item 0'), findsOneWidget); + + expect(find.byType(Container), findsOneWidget); + final Container container1 = tester.widget( + find.byType(Container) + ); + expect(container1.color, Colors.white); + + await tester.pumpWidget(const MaterialApp( + home: Scaffold( + body: example.FocusableText( + 'Item 1', + autofocus: true, + ), + ), + )); + await tester.pumpAndSettle(); + + final Finder focusableTextFinder2 = find.ancestor( + of: find.text('Item 1'), + matching: find.byType(example.FocusableText), + ); + expect(tester.widget(find.descendant( + of: focusableTextFinder2, + matching: find.byType(Focus), + )).autofocus, isTrue); + final Container container2 = tester.widget(find.descendant( + of: focusableTextFinder2, + matching: find.byType(Container), + )); + expect(container2.color, Colors.red); + }); + + testWidgets('builds list showcasing focus traversal', + (WidgetTester tester) async { + await tester.pumpWidget(const example.FocusExampleApp()); + await tester.pumpAndSettle(); + + expect(find.byType(ListView), findsOneWidget); + + final Finder childFinder = find.descendant( + of: find.byType(ListView), + matching: find.byType(example.FocusableText), + ); + expect(childFinder, findsAtLeastNWidgets(2)); + + Container container0 = tester.widget(find.descendant( + of: childFinder.first, + matching: find.byType(Container), + )); + Container container1 = tester.widget(find.descendant( + of: childFinder.at(1), + matching: find.byType(Container), + )); + expect(container0.color, Colors.red); + expect(container1.color, Colors.white); + + await tester.sendKeyDownEvent(LogicalKeyboardKey.arrowDown); + await tester.pumpAndSettle(); + + container0 = tester.widget(find.descendant( + of: childFinder.first, + matching: find.byType(Container), + )); + container1 = tester.widget(find.descendant( + of: childFinder.at(1), + matching: find.byType(Container), + )); + expect(container0.color, Colors.white); + expect(container1.color, Colors.red); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/focus_scope/focus.2_test.dart b/novelforge-project/flutter/examples/api/test/widgets/focus_scope/focus.2_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..37c9f50f88675271aa26776eca7f99b52a220802 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/focus_scope/focus.2_test.dart @@ -0,0 +1,42 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/focus_scope/focus.2.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Adds children through button', (WidgetTester tester) async { + await tester.pumpWidget(const example.FocusExampleApp()); + expect(find.byIcon(Icons.add), findsOneWidget); + expect(find.text('CHILD 0'), findsOneWidget); + + for (int i = 1; i <= 20; i += 1) { + await tester.tap(find.byIcon(Icons.add)); + await tester.pumpAndSettle(); + expect(find.text('CHILD $i'), findsOneWidget); + expect(find.textContaining('CHILD '), findsNWidgets(i + 1)); + } + }); + + testWidgets('Inserts focus nodes', (WidgetTester tester) async { + await tester.pumpWidget(const example.FocusExampleApp()); + expect(find.byIcon(Icons.add), findsOneWidget); + + for (int i = 0; i <= 10; i += 1) { + expect(find.text('CHILD $i'), findsOneWidget); + final ActionChip chip = tester.widget(find.ancestor( + of: find.text('CHILD $i'), + matching: find.byType(ActionChip) + )); + expect(chip.focusNode, isNotNull); + expect(chip.focusNode!.hasPrimaryFocus, isTrue); + expect(chip.focusNode!.debugLabel, 'Child $i'); + + await tester.tap(find.byIcon(Icons.add)); + await tester.pumpAndSettle(); + } + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/form/form.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/form/form.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..0e51c6b30964a956273836e25c02627eaab3cfb5 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/form/form.0_test.dart @@ -0,0 +1,34 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/form/form.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Form Smoke Test', (WidgetTester tester) async { + await tester.pumpWidget( + const example.FormExampleApp(), + ); + expect(find.widgetWithText(AppBar, 'Form Sample'), findsOneWidget); + + final Finder textField = find.byType(TextField); + final Finder button = find.byType(ElevatedButton); + final TextField textFieldWidget = tester.widget(textField); + + expect(textField, findsOneWidget); + expect(button, findsOneWidget); + + expect(textFieldWidget.controller?.text, ''); + await tester.tap(button); + await tester.pumpAndSettle(); + expect(find.text('Please enter some text'), findsOneWidget); + + await tester.enterText(textField, 'Hello World'); + expect(textFieldWidget.controller?.text, 'Hello World'); + await tester.tap(button); + await tester.pumpAndSettle(); + expect(find.text('Please enter some text'), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/form/form.1_test.dart b/novelforge-project/flutter/examples/api/test/widgets/form/form.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..f9ccd71d521e8f6bfcba11795ea794a4171750ee --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/form/form.1_test.dart @@ -0,0 +1,37 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/form/form.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can go back when form is clean', (WidgetTester tester) async { + await tester.pumpWidget( + const example.FormApp(), + ); + + expect(find.text('Are you sure?'), findsNothing); + + await tester.tap(find.text('Go back')); + await tester.pumpAndSettle(); + + expect(find.text('Are you sure?'), findsNothing); + }); + + testWidgets('Cannot go back when form is dirty', (WidgetTester tester) async { + await tester.pumpWidget( + const example.FormApp(), + ); + + expect(find.text('Are you sure?'), findsNothing); + + await tester.enterText(find.byType(TextFormField), 'some new text'); + + await tester.tap(find.text('Go back')); + await tester.pumpAndSettle(); + + expect(find.text('Are you sure?'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/gesture_detector/gesture_detector.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/gesture_detector/gesture_detector.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..50cbe2b3f978b9c189195d654d4dc8a68ff7a4f5 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/gesture_detector/gesture_detector.0_test.dart @@ -0,0 +1,40 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/gesture_detector/gesture_detector.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets( + 'GestureDetector updates icon color and text on tap', + (WidgetTester tester) async { + await tester.pumpWidget( + const example.GestureDetectorExampleApp(), + ); + + Icon icon = tester.widget(find.byIcon(Icons.lightbulb_outline)); + + expect(find.text('TURN LIGHT ON'), findsOneWidget); + expect(icon.color, Colors.black); + + await tester.tap(find.byType(GestureDetector)); + await tester.pump(); + + icon = tester.widget(find.byIcon(Icons.lightbulb_outline)); + + expect(find.text('TURN LIGHT OFF'), findsOneWidget); + expect(icon.color, Colors.yellow.shade600); + + await tester.tap(find.byType(GestureDetector)); + await tester.pump(); + + icon = tester.widget(find.byIcon(Icons.lightbulb_outline)); + + expect(find.text('TURN LIGHT ON'), findsOneWidget); + expect(icon.color, Colors.black); + }, + ); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/gesture_detector/gesture_detector.1_test.dart b/novelforge-project/flutter/examples/api/test/widgets/gesture_detector/gesture_detector.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..bf3dc25f216f7f9c8276bb4ba9d89e1f336d251d --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/gesture_detector/gesture_detector.1_test.dart @@ -0,0 +1,52 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/gesture_detector/gesture_detector.1.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets( + 'GestureDetector updates Container color on tap', + (WidgetTester tester) async { + await tester.pumpWidget( + const example.GestureDetectorExampleApp(), + ); + + Container container = tester.widget( + find.ancestor( + of: find.byType(GestureDetector), + matching: find.byType(Container), + ), + ); + + expect(container.color, Colors.white); + + await tester.tap(find.byType(GestureDetector)); + await tester.pump(); + + container = tester.widget( + find.ancestor( + of: find.byType(GestureDetector), + matching: find.byType(Container), + ), + ); + + expect(container.color, Colors.yellow); + + await tester.tap(find.byType(GestureDetector)); + await tester.pump(); + + container = tester.widget( + find.ancestor( + of: find.byType(GestureDetector), + matching: find.byType(Container), + ), + ); + + expect(container.color, Colors.white); + }, + ); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/gesture_detector/gesture_detector.2_test.dart b/novelforge-project/flutter/examples/api/test/widgets/gesture_detector/gesture_detector.2_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..eb59b902eb876c475c0909e2dfe05bca0333f051 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/gesture_detector/gesture_detector.2_test.dart @@ -0,0 +1,94 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/gesture_detector/gesture_detector.2.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + + void expectBorders( + WidgetTester tester, { + required bool expectGreenHasBorder, + required bool expectYellowHasBorder, + }) { + final Finder containerFinder = find.byType(Container); + final Finder greenFinder = containerFinder.first; + final Finder yellowFinder = containerFinder.last; + + final Container greenContainer = tester.firstWidget(greenFinder); + final BoxDecoration? greenDecoration = greenContainer.decoration as BoxDecoration?; + expect(greenDecoration?.border, expectGreenHasBorder ? isNot(null) : null); + + final Container yellowContainer = tester.firstWidget(yellowFinder); + final BoxDecoration? yellowDecoration = yellowContainer.decoration as BoxDecoration?; + expect(yellowDecoration?.border, expectYellowHasBorder ? isNot(null) : null); + } + + void expectInnerGestureDetectorBehavior(WidgetTester tester, HitTestBehavior behavior) { + // There is a third GestureDetector added by Scaffold. + final Finder innerGestureDetectorFinder = find.byType(GestureDetector).at(1); + final GestureDetector innerGestureDetector = tester.firstWidget(innerGestureDetectorFinder); + expect(innerGestureDetector.behavior, behavior); + } + + testWidgets('Only the green Container shows a red border when tapped', (WidgetTester tester) async { + await tester.pumpWidget( + const example.NestedGestureDetectorsApp(), + ); + + final Finder greenFinder = find.byType(Container).first; + final Offset greenTopLeftCorner = tester.getTopLeft(greenFinder); + await tester.tapAt(greenTopLeftCorner); + await tester.pumpAndSettle(); + expectBorders(tester, expectGreenHasBorder: true, expectYellowHasBorder: false); + + // Tap on the button to toggle inner GestureDetector.behavior + final Finder toggleBehaviorFinder = find.byType(ElevatedButton).last; + await tester.tap(toggleBehaviorFinder); + await tester.pump(); + expectInnerGestureDetectorBehavior(tester, HitTestBehavior.translucent); + + // Tap again on the green container, expect nothing changed + await tester.tapAt(greenTopLeftCorner); + await tester.pump(); + expectBorders(tester, expectGreenHasBorder: true, expectYellowHasBorder: false); + + // Tap on the reset button + final Finder resetFinder = find.byType(ElevatedButton).first; + await tester.tap(resetFinder); + await tester.pump(); + expectInnerGestureDetectorBehavior(tester, HitTestBehavior.opaque); + }); + + testWidgets('Only the yellow Container shows a red border when tapped', (WidgetTester tester) async { + await tester.pumpWidget( + const example.NestedGestureDetectorsApp(), + ); + + final Finder yellowFinder = find.byType(Container).last; + final Offset yellowTopLeftCorner = tester.getTopLeft(yellowFinder); + await tester.tapAt(yellowTopLeftCorner); + await tester.pump(); + expectBorders(tester, expectGreenHasBorder: false, expectYellowHasBorder: true); + + // Tap on the button to toggle inner GestureDetector.behavior + final Finder toggleBehaviorFinder = find.byType(ElevatedButton).last; + await tester.tap(toggleBehaviorFinder); + await tester.pump(); + expectInnerGestureDetectorBehavior(tester, HitTestBehavior.translucent); + + // Tap again on the yellow container, expect nothing changed + await tester.tapAt(yellowTopLeftCorner); + await tester.pump(); + expectBorders(tester, expectGreenHasBorder: false, expectYellowHasBorder: true); + + // Tap on the reset button + final Finder resetFinder = find.byType(ElevatedButton).first; + await tester.tap(resetFinder); + await tester.pump(); + expectInnerGestureDetectorBehavior(tester, HitTestBehavior.opaque); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/hardware_keyboard/key_event_manager.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/hardware_keyboard/key_event_manager.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..513c760a621afab7a949fb18c21a41df62755316 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/hardware_keyboard/key_event_manager.0_test.dart @@ -0,0 +1,68 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_api_samples/widgets/hardware_keyboard/key_event_manager.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('App tracks lifecycle states', (WidgetTester tester) async { + Future getCapturedKey() async { + final Widget textWidget = tester.firstWidget( + find.textContaining('is not handled by shortcuts.')); + expect(textWidget, isA()); + return (textWidget as Text).data!.split(' ').first; + } + + await tester.pumpWidget( + const MaterialApp( + home: Scaffold( + body: Center( + child: example.FallbackDemo(), + ) + ), + ), + ); + + // Focus on the first text field. + await tester.tap(find.byType(TextField).first); + + // Press Q, which is taken as a text input, unhandled by the keyboard system. + await tester.sendKeyEvent(LogicalKeyboardKey.keyQ); + await tester.pump(); + expect(await getCapturedKey(), 'Q'); + + // Press Ctrl-A, which is taken as a text short cut, handled by the keyboard system. + await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft); + await tester.sendKeyEvent(LogicalKeyboardKey.keyA); + await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft); + expect(await getCapturedKey(), 'Q'); + + // Press A, which is taken as a text input, handled by the keyboard system. + await tester.sendKeyEvent(LogicalKeyboardKey.keyA); + await tester.pump(); + expect(await getCapturedKey(), 'A'); + + // Focus on the second text field. + await tester.tap(find.byType(TextField).last); + + // Press Q, which is taken as a stub shortcut, handled by the keyboard system. + await tester.sendKeyEvent(LogicalKeyboardKey.keyQ); + await tester.pump(); + expect(await getCapturedKey(), 'A'); + + // Press B, which is taken as a text input, unhandled by the keyboard system. + await tester.sendKeyEvent(LogicalKeyboardKey.keyB); + await tester.pump(); + expect(await getCapturedKey(), 'B'); + + // Press Ctrl-A, which is taken as a text short cut, handled by the keyboard system. + await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft); + await tester.sendKeyEvent(LogicalKeyboardKey.keyA); + await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft); + expect(await getCapturedKey(), 'B'); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/heroes/hero.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/heroes/hero.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..058436ddb0936a49203726dd1e9441010b074cc8 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/heroes/hero.0_test.dart @@ -0,0 +1,71 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/heroes/hero.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Has Hero animation', (WidgetTester tester) async { + await tester.pumpWidget( + const example.HeroApp(), + ); + + expect(find.text('Hero Sample'), findsOneWidget); + await tester.tap(find.byType(Container)); + await tester.pump(); + + Size heroSize = tester.getSize(find.byType(Container)); + + // Jump 25% into the transition (total length = 300ms) + await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms + heroSize = tester.getSize(find.byType(Container)); + expect(heroSize.width.roundToDouble(), 103.0); + expect(heroSize.height.roundToDouble(), 60.0); + + // Jump to 50% into the transition. + await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms + heroSize = tester.getSize(find.byType(Container)); + expect(heroSize.width.roundToDouble(), 189.0); + expect(heroSize.height.roundToDouble(), 146.0); + + // Jump to 75% into the transition. + await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms + heroSize = tester.getSize(find.byType(Container)); + expect(heroSize.width.roundToDouble(), 199.0); + expect(heroSize.height.roundToDouble(), 190.0); + + // Jump to 100% into the transition. + await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms + heroSize = tester.getSize(find.byType(Container)); + expect(heroSize, const Size(200.0, 200.0)); + + expect(find.byIcon(Icons.arrow_back), findsOneWidget); + await tester.tap(find.byIcon(Icons.arrow_back)); + await tester.pump(); + + // Jump 25% into the transition (total length = 300ms) + await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms + heroSize = tester.getSize(find.byType(Container)); + expect(heroSize.width.roundToDouble(), 199.0); + expect(heroSize.height.roundToDouble(), 190.0); + + // Jump to 50% into the transition. + await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms + heroSize = tester.getSize(find.byType(Container)); + expect(heroSize.width.roundToDouble(), 189.0); + expect(heroSize.height.roundToDouble(), 146.0); + + // Jump to 75% into the transition. + await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms + heroSize = tester.getSize(find.byType(Container)); + expect(heroSize.width.roundToDouble(), 103.0); + expect(heroSize.height.roundToDouble(), 60.0); + + // Jump to 100% into the transition. + await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms + heroSize = tester.getSize(find.byType(Container)); + expect(heroSize, const Size(50.0, 50.0)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/heroes/hero.1_test.dart b/novelforge-project/flutter/examples/api/test/widgets/heroes/hero.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..1fab344d82902734e12800cf88247f09deb33048 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/heroes/hero.1_test.dart @@ -0,0 +1,135 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/heroes/hero.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Hero flight animation with default rect tween', (WidgetTester tester) async { + await tester.pumpWidget( + const example.HeroApp(), + ); + + expect(find.text('Hero Sample'), findsOneWidget); + await tester.tap(find.byType(ElevatedButton)); + await tester.pump(); + + Size heroSize = tester.getSize(find.byType(Container).first); + expect(heroSize, const Size(50.0, 50.0)); + + // Jump 25% into the transition (total length = 300ms) + await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms + heroSize = tester.getSize(find.byType(Container).first); + expect(heroSize.width.roundToDouble(), 170.0); + expect(heroSize.height.roundToDouble(), 73.0); + + // Jump to 50% into the transition. + await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms + heroSize = tester.getSize(find.byType(Container).first); + expect(heroSize.width.roundToDouble(), 371.0); + expect(heroSize.height.roundToDouble(), 273.0); + + // Jump to 75% into the transition. + await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms + heroSize = tester.getSize(find.byType(Container).first); + expect(heroSize.width.roundToDouble(), 398.0); + expect(heroSize.height.roundToDouble(), 376.0); + + // Jump to 100% into the transition. + await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms + heroSize = tester.getSize(find.byType(Container).first); + expect(heroSize, const Size(400.0, 400.0)); + + expect(find.byIcon(Icons.arrow_back), findsOneWidget); + await tester.tap(find.byIcon(Icons.arrow_back)); + await tester.pump(); + + // Jump 25% into the transition (total length = 300ms) + await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms + heroSize = tester.getSize(find.byType(Container).first); + expect(heroSize.width.roundToDouble(), 398.0); + expect(heroSize.height.roundToDouble(), 376.0); + + // Jump to 50% into the transition. + await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms + heroSize = tester.getSize(find.byType(Container).first); + expect(heroSize.width.roundToDouble(), 371.0); + expect(heroSize.height.roundToDouble(), 273.0); + + // Jump to 75% into the transition. + await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms + heroSize = tester.getSize(find.byType(Container).first); + expect(heroSize.width.roundToDouble(), 170.0); + expect(heroSize.height.roundToDouble(), 73.0); + + // Jump to 100% into the transition. + await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms + heroSize = tester.getSize(find.byType(Container).first); + expect(heroSize, const Size(50.0, 50.0)); + }); + + testWidgets('Hero flight animation with custom rect tween', (WidgetTester tester) async { + await tester.pumpWidget( + const example.HeroApp(), + ); + + expect(find.text('Hero Sample'), findsOneWidget); + await tester.tap(find.byType(ElevatedButton)); + await tester.pump(); + + Size heroSize = tester.getSize(find.byType(Container).last); + expect(heroSize, const Size(50.0, 50.0)); + + // Jump 25% into the transition (total length = 300ms) + await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms + heroSize = tester.getSize(find.byType(Container).last); + expect(heroSize.width.roundToDouble(), 133.0); + expect(heroSize.height.roundToDouble(), 133.0); + + // Jump to 50% into the transition. + await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms + heroSize = tester.getSize(find.byType(Container).last); + expect(heroSize.width.roundToDouble(), 321.0); + expect(heroSize.height.roundToDouble(), 321.0); + + // Jump to 75% into the transition. + await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms + heroSize = tester.getSize(find.byType(Container).first); + expect(heroSize.width.roundToDouble(), 398.0); + expect(heroSize.height.roundToDouble(), 376.0); + + // Jump to 100% into the transition. + await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms + heroSize = tester.getSize(find.byType(Container).last); + expect(heroSize, const Size(400.0, 400.0)); + + expect(find.byIcon(Icons.arrow_back), findsOneWidget); + await tester.tap(find.byIcon(Icons.arrow_back)); + await tester.pump(); + + // Jump 25% into the transition (total length = 300ms) + await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms + heroSize = tester.getSize(find.byType(Container).last); + expect(heroSize.width.roundToDouble(), 386.0); + expect(heroSize.height.roundToDouble(), 386.0); + + // Jump to 50% into the transition. + await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms + heroSize = tester.getSize(find.byType(Container).last); + expect(heroSize.width.roundToDouble(), 321.0); + expect(heroSize.height.roundToDouble(), 321.0); + + // Jump to 75% into the transition. + await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms + heroSize = tester.getSize(find.byType(Container).last); + expect(heroSize.width.roundToDouble(), 133.0); + expect(heroSize.height.roundToDouble(), 133.0); + + // Jump to 100% into the transition. + await tester.pump(const Duration(milliseconds: 75)); // 25% of 300ms + heroSize = tester.getSize(find.byType(Container).last); + expect(heroSize, const Size(50.0, 50.0)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/image/image.error_builder.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/image/image.error_builder.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..fa2e41fffa875fff576cb0a4a0f48c36b4ed079f --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/image/image.error_builder.0_test.dart @@ -0,0 +1,49 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:io'; + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/image/image.error_builder.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + // The app being tested loads images via HTTP which the test + // framework defeats by default. + setUpAll(() { + HttpOverrides.global = null; + }); + + testWidgets('Has nonexistent url', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ErrorBuilderExampleApp(), + ); + await tester.pumpAndSettle(); + + final Image image = tester.widget(find.byType(Image)); + final NetworkImage imageProvider = image.image as NetworkImage; + + expect( + imageProvider.url, + equals('https://example.does.not.exist/image.jpg'), + ); + }); + + testWidgets('errorBuilder returns text with emoji', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ErrorBuilderExampleApp(), + ); + await tester.pumpAndSettle(); + + final Image image = tester.widget(find.byType(Image)); + final ImageErrorWidgetBuilder errorBuilder = image.errorBuilder!; + final BuildContext context = tester.element(find.byType(Image)); + + expect( + errorBuilder(context, const HttpException('oops'), StackTrace.empty), + isA().having((Text text) => text.data, 'data', equals('😢')), + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/implicit_animations/animated_align.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/implicit_animations/animated_align.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..80072b837234a970373076ac54af2b08e6c66b8f --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/implicit_animations/animated_align.0_test.dart @@ -0,0 +1,79 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/implicit_animations/animated_align.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('AnimatedAlign animates on tap', (WidgetTester tester) async { + await tester.pumpWidget( + const example.AnimatedAlignExampleApp(), + ); + + final Finder alignFinder = find.descendant( + of: find.byType(AnimatedAlign), + matching: find.byType(Align), + ); + + const Alignment beginAlignment = Alignment.bottomLeft; + const Alignment endAlignment = Alignment.topRight; + + Align align = tester.widget(alignFinder); + expect(align.alignment, beginAlignment); + + // Tap on the AnimatedAlignExample to start the forward animation. + await tester.tap(find.byType(example.AnimatedAlignExample)); + await tester.pump(); + + align = tester.widget(alignFinder); + expect(align.alignment, beginAlignment); + + // Advance animation to the middle. + await tester.pump(example.AnimatedAlignExampleApp.duration ~/ 2); + + align = tester.widget(alignFinder); + expect( + align.alignment, + Alignment.lerp( + beginAlignment, + endAlignment, + example.AnimatedAlignExampleApp.curve.transform(0.5), + ), + ); + + // Advance animation to the end. + await tester.pump(example.AnimatedAlignExampleApp.duration ~/ 2); + + align = tester.widget(alignFinder); + expect(align.alignment, endAlignment); + + // Tap on the AnimatedAlignExample again to start the reverse animation. + await tester.tap(find.byType(example.AnimatedAlignExample)); + await tester.pump(); + + align = tester.widget(alignFinder); + expect(align.alignment, endAlignment); + + // Advance animation to the middle. + await tester.pump(example.AnimatedAlignExampleApp.duration ~/ 2); + + align = tester.widget(alignFinder); + expect( + align.alignment, + Alignment.lerp( + endAlignment, + beginAlignment, + example.AnimatedAlignExampleApp.curve.transform(0.5), + ), + ); + + // Advance animation to the end. + await tester.pump(example.AnimatedAlignExampleApp.duration ~/ 2); + + align = tester.widget(alignFinder); + expect(align.alignment, beginAlignment); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/implicit_animations/animated_container.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/implicit_animations/animated_container.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..8a50895eef1f4a44379a7887c3ca5ed3d4bdcfb6 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/implicit_animations/animated_container.0_test.dart @@ -0,0 +1,71 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/implicit_animations/animated_container.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('AnimatedContainer updates on tap', (WidgetTester tester) async { + await tester.pumpWidget( + const example.AnimatedContainerExampleApp(), + ); + + Container container = tester.widget( + find.ancestor( + of: find.byType(AnimatedContainer), + matching: find.byType(Container), + ), + ); + expect( + (container.decoration! as BoxDecoration).color, + equals(Colors.blue), + ); + expect( + container.constraints, + equals(const BoxConstraints.tightFor(width: 100, height: 200)), + ); + expect(container.alignment, equals(Alignment.topCenter)); + + await tester.tap(find.byType(FlutterLogo)); + await tester.pump(); + + container = tester.widget( + find.ancestor( + of: find.byType(AnimatedContainer), + matching: find.byType(Container), + ), + ); + expect( + (container.decoration! as BoxDecoration).color, + equals(Colors.blue), + ); + expect( + container.constraints, + equals(const BoxConstraints.tightFor(width: 100, height: 200)), + ); + expect(container.alignment, equals(Alignment.topCenter)); + + // Advance animation to the end by the 2-second duration specified in + // the example app. + await tester.pump(const Duration(seconds: 2)); + + container = tester.widget( + find.ancestor( + of: find.byType(AnimatedContainer), + matching: find.byType(Container), + ), + ); + expect( + (container.decoration! as BoxDecoration).color, + equals(Colors.red), + ); + expect( + container.constraints, + equals(const BoxConstraints.tightFor(width: 200, height: 100)), + ); + expect(container.alignment, equals(Alignment.center)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/implicit_animations/animated_fractionally_sized_box.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/implicit_animations/animated_fractionally_sized_box.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..2a931a97b87d29b45b902c33ea811887c2decf1d --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/implicit_animations/animated_fractionally_sized_box.0_test.dart @@ -0,0 +1,125 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:ui'; + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/implicit_animations/animated_fractionally_sized_box.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets( + 'AnimatedFractionallySizedBox animates on tap', + (WidgetTester tester) async { + await tester.pumpWidget( + const example.AnimatedFractionallySizedBoxExampleApp(), + ); + + final Finder fractionallySizedBoxFinder = find.descendant( + of: find.byType(AnimatedFractionallySizedBox), + matching: find.byType(FractionallySizedBox), + ); + + const double beginWidthFactor = 0.75; + const double endWidthFactor = 0.25; + const double beginHeightFactor = 0.25; + const double endHeightFactor = 0.75; + const Alignment beginAlignment = Alignment.bottomRight; + const Alignment endAlignment = Alignment.topLeft; + + FractionallySizedBox fractionallySizedBox = tester.widget( + fractionallySizedBoxFinder, + ); + expect(fractionallySizedBox.widthFactor, beginWidthFactor); + expect(fractionallySizedBox.heightFactor, beginHeightFactor); + expect(fractionallySizedBox.alignment, beginAlignment); + + // Tap on the AnimatedFractionallySizedBoxExample to start the forward + // animation. + await tester.tap( + find.byType(example.AnimatedFractionallySizedBoxExample), + ); + await tester.pump(); + + fractionallySizedBox = tester.widget(fractionallySizedBoxFinder); + expect(fractionallySizedBox.widthFactor, beginWidthFactor); + expect(fractionallySizedBox.heightFactor, beginHeightFactor); + expect(fractionallySizedBox.alignment, beginAlignment); + + // Advance animation to the middle. + await tester.pump( + example.AnimatedFractionallySizedBoxExampleApp.duration ~/ 2, + ); + + final double t = + example.AnimatedFractionallySizedBoxExampleApp.curve.transform(0.5); + + fractionallySizedBox = tester.widget(fractionallySizedBoxFinder); + expect( + fractionallySizedBox.widthFactor, + lerpDouble(beginWidthFactor, endWidthFactor, t), + ); + expect( + fractionallySizedBox.heightFactor, + lerpDouble(beginHeightFactor, endHeightFactor, t), + ); + expect( + fractionallySizedBox.alignment, + Alignment.lerp(beginAlignment, endAlignment, t), + ); + + // Advance animation to the end. + await tester.pump( + example.AnimatedFractionallySizedBoxExampleApp.duration ~/ 2, + ); + + fractionallySizedBox = tester.widget(fractionallySizedBoxFinder); + expect(fractionallySizedBox.widthFactor, endWidthFactor); + expect(fractionallySizedBox.heightFactor, endHeightFactor); + expect(fractionallySizedBox.alignment, endAlignment); + + // Tap on the AnimatedFractionallySizedBoxExample again to start the + // reverse animation. + await tester.tap( + find.byType(example.AnimatedFractionallySizedBoxExample), + ); + await tester.pump(); + + fractionallySizedBox = tester.widget(fractionallySizedBoxFinder); + expect(fractionallySizedBox.widthFactor, endWidthFactor); + expect(fractionallySizedBox.heightFactor, endHeightFactor); + expect(fractionallySizedBox.alignment, endAlignment); + + // Advance animation to the middle. + await tester.pump( + example.AnimatedFractionallySizedBoxExampleApp.duration ~/ 2, + ); + + fractionallySizedBox = tester.widget(fractionallySizedBoxFinder); + expect( + fractionallySizedBox.widthFactor, + lerpDouble(endWidthFactor, beginWidthFactor, t), + ); + expect( + fractionallySizedBox.heightFactor, + lerpDouble(endHeightFactor, beginHeightFactor, t), + ); + expect( + fractionallySizedBox.alignment, + Alignment.lerp(endAlignment, beginAlignment, t), + ); + + // Advance animation to the end. + await tester.pump( + example.AnimatedFractionallySizedBoxExampleApp.duration ~/ 2, + ); + + fractionallySizedBox = tester.widget(fractionallySizedBoxFinder); + expect(fractionallySizedBox.widthFactor, beginWidthFactor); + expect(fractionallySizedBox.heightFactor, beginHeightFactor); + expect(fractionallySizedBox.alignment, beginAlignment); + }, + ); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/implicit_animations/animated_padding.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/implicit_animations/animated_padding.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..fa9d5a1d632b35ce4cdcbbe489dd5c460dad8909 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/implicit_animations/animated_padding.0_test.dart @@ -0,0 +1,50 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/implicit_animations/animated_padding.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets( + 'AnimatedPadding animates on ElevatedButton tap', + (WidgetTester tester) async { + await tester.pumpWidget( + const example.AnimatedPaddingExampleApp(), + ); + + Padding padding = tester.widget( + find.descendant( + of: find.byType(AnimatedPadding), + matching: find.byType(Padding), + ), + ); + expect(padding.padding, equals(EdgeInsets.zero)); + + await tester.tap(find.byType(ElevatedButton)); + await tester.pump(); + + padding = tester.widget( + find.descendant( + of: find.byType(AnimatedPadding), + matching: find.byType(Padding), + ), + ); + expect(padding.padding, equals(EdgeInsets.zero)); + + // Advance animation to the end by the 2-second duration specified in + // the example app. + await tester.pump(const Duration(seconds: 2)); + + padding = tester.widget( + find.descendant( + of: find.byType(AnimatedPadding), + matching: find.byType(Padding), + ), + ); + expect(padding.padding, equals(const EdgeInsets.all(100.0))); + }, + ); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/implicit_animations/animated_positioned.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/implicit_animations/animated_positioned.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..88654eb7e07b8392c65ac3ecf5c4afaa487c1c36 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/implicit_animations/animated_positioned.0_test.dart @@ -0,0 +1,91 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:ui'; + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/implicit_animations/animated_positioned.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets( + 'AnimatedPositioned animates on tap', + (WidgetTester tester) async { + await tester.pumpWidget( + const example.AnimatedPositionedExampleApp(), + ); + + final Finder positionedFinder = find.descendant( + of: find.byType(AnimatedPositioned), + matching: find.byType(Positioned), + ); + + const double beginWidth = 50.0; + const double endWidth = 200.0; + const double beginHeight = 200.0; + const double endHeight = 50.0; + const double beginTop = 150.0; + const double endTop = 50.0; + + Positioned positioned = tester.widget(positionedFinder); + expect(positioned.width, beginWidth); + expect(positioned.height, beginHeight); + expect(positioned.top, beginTop); + + // Tap on the 'Tap me' text to start the forward animation. + await tester.tap(find.text('Tap me')); + await tester.pump(); + + positioned = tester.widget(positionedFinder); + expect(positioned.width, beginWidth); + expect(positioned.height, beginHeight); + expect(positioned.top, beginTop); + + // Advance animation to the middle. + await tester.pump(example.AnimatedPositionedExampleApp.duration ~/ 2); + + final double t = + example.AnimatedPositionedExampleApp.curve.transform(0.5); + + positioned = tester.widget(positionedFinder); + expect(positioned.width, lerpDouble(beginWidth, endWidth, t)); + expect(positioned.height, lerpDouble(beginHeight, endHeight, t)); + expect(positioned.top, lerpDouble(beginTop, endTop, t)); + + // Advance animation to the end. + await tester.pump(example.AnimatedPositionedExampleApp.duration ~/ 2); + + positioned = tester.widget(positionedFinder); + expect(positioned.width, endWidth); + expect(positioned.height, endHeight); + expect(positioned.top, endTop); + + // Tap on the 'Tap me' text again to start the reverse animation. + await tester.tap(find.text('Tap me')); + await tester.pump(); + + positioned = tester.widget(positionedFinder); + expect(positioned.width, endWidth); + expect(positioned.height, endHeight); + expect(positioned.top, endTop); + + // Advance animation to the middle. + await tester.pump(example.AnimatedPositionedExampleApp.duration ~/ 2); + + positioned = tester.widget(positionedFinder); + expect(positioned.width, lerpDouble(endWidth, beginWidth, t)); + expect(positioned.height, lerpDouble(endHeight, beginHeight, t)); + expect(positioned.top, lerpDouble(endTop, beginTop, t)); + + // Advance animation to the end. + await tester.pump(example.AnimatedPositionedExampleApp.duration ~/ 2); + + positioned = tester.widget(positionedFinder); + expect(positioned.width, beginWidth); + expect(positioned.height, beginHeight); + expect(positioned.top, beginTop); + }, + ); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/implicit_animations/animated_slide.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/implicit_animations/animated_slide.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..10746def6f15650f11eaacb6c94236d85872fb52 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/implicit_animations/animated_slide.0_test.dart @@ -0,0 +1,37 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/implicit_animations/animated_slide.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Translate FlutterLogo using AnimatedSlide', (WidgetTester tester) async { + await tester.pumpWidget( + const example.AnimatedSlideApp(), + ); + + Offset logoOffset = tester.getCenter(find.byType(FlutterLogo)); + expect(logoOffset.dx, 376.0); + expect(logoOffset.dy, 304.0); + + // Test Y axis slider. + final Offset y = tester.getCenter(find.text('Y')); + await tester.tapAt(Offset(y.dx, y.dy + 100)); + await tester.pumpAndSettle(); + + logoOffset = tester.getCenter(find.byType(FlutterLogo)); + expect(logoOffset.dx.roundToDouble(), 376.0); + expect(logoOffset.dy.roundToDouble(), 137.0); + + // Test X axis slider. + final Offset x = tester.getCenter(find.text('X')); + await tester.tapAt(Offset(x.dx + 100, x.dy)); + await tester.pumpAndSettle(); + + logoOffset = tester.getCenter(find.byType(FlutterLogo)); + expect(logoOffset.dx.roundToDouble(), 178.0); + expect(logoOffset.dy.roundToDouble(), 137.0); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/implicit_animations/sliver_animated_opacity.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/implicit_animations/sliver_animated_opacity.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..8ac97867afc84edb9a7fbb0bcda9eb111485fe70 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/implicit_animations/sliver_animated_opacity.0_test.dart @@ -0,0 +1,84 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:ui'; + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/implicit_animations/sliver_animated_opacity.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets( + 'SilverAnimatedOpacity animates on FloatingActionButton tap', + (WidgetTester tester) async { + await tester.pumpWidget( + const example.SliverAnimatedOpacityExampleApp(), + ); + + final Finder fadeTransitionFinder = find.descendant( + of: find.byType(SliverAnimatedOpacity), + matching: find.byType(SliverFadeTransition), + ); + + const double beginOpacity = 1.0; + const double endOpacity = 0.0; + + SliverFadeTransition fadeTransition = tester.widget(fadeTransitionFinder); + expect(fadeTransition.opacity.value, beginOpacity); + + // Tap on the FloatingActionButton to start the forward animation. + await tester.tap(find.byType(FloatingActionButton)); + await tester.pump(); + + fadeTransition = tester.widget(fadeTransitionFinder); + expect(fadeTransition.opacity.value, beginOpacity); + + // Advance animation to the middle. + await tester.pump(example.SliverAnimatedOpacityExampleApp.duration ~/ 2); + + fadeTransition = tester.widget(fadeTransitionFinder); + expect( + fadeTransition.opacity.value, + lerpDouble( + beginOpacity, + endOpacity, + example.SliverAnimatedOpacityExampleApp.curve.transform(0.5), + ), + ); + + // Advance animation to the end. + await tester.pump(example.SliverAnimatedOpacityExampleApp.duration ~/ 2); + + fadeTransition = tester.widget(fadeTransitionFinder); + expect(fadeTransition.opacity.value, endOpacity); + + // Tap on the FloatingActionButton again to start the reverse animation. + await tester.tap(find.byType(FloatingActionButton)); + await tester.pump(); + + fadeTransition = tester.widget(fadeTransitionFinder); + expect(fadeTransition.opacity.value, endOpacity); + + // Advance animation to the middle. + await tester.pump(example.SliverAnimatedOpacityExampleApp.duration ~/ 2); + + fadeTransition = tester.widget(fadeTransitionFinder); + expect( + fadeTransition.opacity.value, + lerpDouble( + endOpacity, + beginOpacity, + example.SliverAnimatedOpacityExampleApp.curve.transform(0.5), + ), + ); + + // Advance animation to the end. + await tester.pump(example.SliverAnimatedOpacityExampleApp.duration ~/ 2); + + fadeTransition = tester.widget(fadeTransitionFinder); + expect(fadeTransition.opacity.value, beginOpacity); + }, + ); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/inherited_model/inherited_model.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/inherited_model/inherited_model.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..3f3f9a569efecde5b75700d156b2017dcf79b9f7 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/inherited_model/inherited_model.0_test.dart @@ -0,0 +1,34 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/inherited_model/inherited_model.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Rebuild widget using InheritedModel', (WidgetTester tester) async { + await tester.pumpWidget( + const example.InheritedModelApp(), + ); + + BoxDecoration? decoration = tester.widget( + find.byType(AnimatedContainer).first, + ).decoration as BoxDecoration?; + expect(decoration!.color, Colors.blue); + + await tester.tap(find.text('Update background')); + await tester.pumpAndSettle(); + decoration = tester.widget( + find.byType(AnimatedContainer).first, + ).decoration as BoxDecoration?; + expect(decoration!.color, Colors.red); + + double? size = tester.widget(find.byType(FlutterLogo)).size; + expect(size, 100.0); + await tester.tap(find.text('Resize Logo')); + await tester.pumpAndSettle(); + size = tester.widget(find.byType(FlutterLogo)).size; + expect(size, 200.0); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/inherited_notifier/inherited_notifier.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/inherited_notifier/inherited_notifier.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..34c4c8969297133f6e552b27b346e50be3cec795 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/inherited_notifier/inherited_notifier.0_test.dart @@ -0,0 +1,60 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:math' as math; + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/inherited_notifier/inherited_notifier.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('It rotates the spinners', (WidgetTester tester) async { + await tester.pumpWidget( + const example.InheritedNotifierExampleApp(), + ); + + final Iterable widgets = tester.widgetList( + find.ancestor( + of: find.text('Whee!'), + matching: find.byType(Transform), + ), + ); + + Matcher transformMatcher(Matrix4 matrix) { + return everyElement(isA().having((Transform widget) => widget.transform, 'transform', matrix)); + } + + expect(widgets, transformMatcher(Matrix4.identity())); + + await tester.pump(const Duration(seconds: 1)); + expect(widgets, transformMatcher(Matrix4.rotationZ(0.2 * math.pi))); + + await tester.pump(const Duration(seconds: 1)); + expect(widgets, transformMatcher(Matrix4.rotationZ(0.4 * math.pi))); + + await tester.pump(const Duration(seconds: 1)); + expect(widgets, transformMatcher(Matrix4.rotationZ(0.6 * math.pi))); + + await tester.pump(const Duration(seconds: 1)); + expect(widgets, transformMatcher(Matrix4.rotationZ(0.8 * math.pi))); + + await tester.pump(const Duration(seconds: 1)); + expect(widgets, transformMatcher(Matrix4.identity()..storage[0] = -1..storage[5] = -1)); + + await tester.pump(const Duration(seconds: 1)); + expect(widgets, transformMatcher(Matrix4.rotationZ(1.2 * math.pi))); + + await tester.pump(const Duration(seconds: 1)); + expect(widgets, transformMatcher(Matrix4.rotationZ(1.4 * math.pi))); + + await tester.pump(const Duration(seconds: 1)); + expect(widgets, transformMatcher(Matrix4.rotationZ(1.6 * math.pi))); + + await tester.pump(const Duration(seconds: 1)); + expect(widgets, transformMatcher(Matrix4.rotationZ(1.8 * math.pi))); + + await tester.pump(const Duration(seconds: 1)); + expect(widgets, transformMatcher(Matrix4.identity())); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/inherited_theme/inherited_theme.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/inherited_theme/inherited_theme.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..03067fb20e99e91afc786935db9800d92d59a7ae --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/inherited_theme/inherited_theme.0_test.dart @@ -0,0 +1,30 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/inherited_theme/inherited_theme.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('StreamBuilder listens to internal stream', (WidgetTester tester) async { + await tester.pumpWidget( + const example.InheritedThemeExampleApp(), + ); + + expect(find.byType(GestureDetector), findsOne); + expect(find.text('Tap Here'), findsOne); + + final DefaultTextStyle bodyDefaultTextStyle = DefaultTextStyle.of(tester.element(find.text('Tap Here'))); + expect(bodyDefaultTextStyle.style, const TextStyle(fontSize: 48, color: Colors.blue)); + + await tester.tap(find.text('Tap Here')); + await tester.pumpAndSettle(); + + expect(find.text('Hello World'), findsOne); + + final DefaultTextStyle routeDefaultTextStyle = DefaultTextStyle.of(tester.element(find.text('Hello World'))); + expect(routeDefaultTextStyle.style, const TextStyle(fontSize: 48, color: Colors.blue)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/interactive_viewer/interactive_viewer.builder.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/interactive_viewer/interactive_viewer.builder.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..4cfaa619894f60a47cc6dbd53e8282a771defdff --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/interactive_viewer/interactive_viewer.builder.0_test.dart @@ -0,0 +1,35 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/widgets.dart'; +import 'package:flutter_api_samples/widgets/interactive_viewer/interactive_viewer.builder.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('has correct items on screen', (WidgetTester tester) async { + await tester.pumpWidget( + const example.IVBuilderExampleApp(), + ); + + final Finder positionedFinder = find.byType(Positioned); + final Finder zeroFinder = find.text('0 x 0'); + final Finder nineFinder = find.text('0 x 9'); + + expect(positionedFinder, findsNWidgets(35)); + expect(zeroFinder, findsOneWidget); + expect(nineFinder, findsNothing); + + const Offset firstLocation = Offset(750.0, 100.0); + final TestGesture gesture = await tester.startGesture(firstLocation); + + const Offset secondLocation = Offset(50.0, 100.0); + await gesture.moveTo(secondLocation); + await tester.pump(); + + expect(positionedFinder, findsNWidgets(42)); + expect(nineFinder, findsOneWidget); + expect(zeroFinder, findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/layout_builder/layout_builder.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/layout_builder/layout_builder.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..c2c954ba56996d7de33b0abb7a8e9621c7cd024c --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/layout_builder/layout_builder.0_test.dart @@ -0,0 +1,29 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/widgets.dart'; +import 'package:flutter_api_samples/widgets/layout_builder/layout_builder.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('has two containers when wide', (WidgetTester tester) async { + await tester.pumpWidget( + const example.LayoutBuilderExampleApp(), + ); + + final Finder containerFinder = find.byType(Container); + expect(containerFinder, findsNWidgets(2)); + }); + testWidgets('has one container when narrow', (WidgetTester tester) async { + await tester.pumpWidget( + ConstrainedBox( + constraints: const BoxConstraints(maxWidth: 400), + child: const example.LayoutBuilderExampleApp(), + ), + ); + + final Finder containerFinder = find.byType(Container); + expect(containerFinder, findsNWidgets(2)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/magnifier/magnifier.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/magnifier/magnifier.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..75702af3da864c54527efa0ef5f1333b53abfcec --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/magnifier/magnifier.0_test.dart @@ -0,0 +1,56 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/magnifier/magnifier.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('should update magnifier position on drag', (WidgetTester tester) async { + await tester.pumpWidget(const example.MagnifierExampleApp()); + + Matcher isPositionedAt(Offset at) { + return isA().having( + (Positioned positioned) => Offset(positioned.left!, positioned.top!), + 'magnifier position', + at, + ); + } + + expect( + tester.widget(find.byType(Positioned)), + isPositionedAt(Offset.zero), + ); + + final Offset centerOfFlutterLogo = tester.getCenter(find.byType(Positioned)); + final Offset topLeftOfFlutterLogo = tester.getTopLeft(find.byType(FlutterLogo)); + + const Offset dragDistance = Offset(10, 10); + + await tester.dragFrom(centerOfFlutterLogo, dragDistance); + await tester.pump(); + + expect( + tester.widget(find.byType(Positioned)), + // Need to adjust by the topleft since the position is local. + isPositionedAt((centerOfFlutterLogo - topLeftOfFlutterLogo) + dragDistance), + ); + }); + + testWidgets('should match golden', (WidgetTester tester) async { + await tester.pumpWidget(const example.MagnifierExampleApp()); + + final Offset centerOfFlutterLogo = tester.getCenter(find.byType(Positioned)); + const Offset dragDistance = Offset(10, 10); + + await tester.dragFrom(centerOfFlutterLogo, dragDistance); + await tester.pump(); + + await expectLater( + find.byType(RepaintBoundary).last, + matchesGoldenFile('magnifier.0_test.png'), + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/navigator/navigator.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/navigator/navigator.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..58f93077041940f62994dfdd11d95319bcc89b06 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/navigator/navigator.0_test.dart @@ -0,0 +1,35 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_api_samples/widgets/navigator/navigator.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('It should show the home page', (WidgetTester tester) async { + await tester.pumpWidget( + const example.NavigatorExampleApp(), + ); + + expect(find.text('Home Page'), findsOne); + }); + + testWidgets('It should start from the sign up page and follow the flow to reach the home page', (WidgetTester tester) async { + tester.platformDispatcher.defaultRouteNameTestValue = '/signup'; + await tester.pumpWidget( + const example.NavigatorExampleApp(), + ); + + expect(find.text('Collect Personal Info Page'), findsOne); + + await tester.tap(find.text('Collect Personal Info Page')); + await tester.pumpAndSettle(); + + expect(find.text('Choose Credentials Page'), findsOne); + + await tester.tap(find.text('Choose Credentials Page')); + await tester.pumpAndSettle(); + + expect(find.text('Home Page'), findsOne); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/navigator_pop_handler/navigator_pop_handler.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/navigator_pop_handler/navigator_pop_handler.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..88f29223f60a40c9757d8026e7c6597358d63dbd --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/navigator_pop_handler/navigator_pop_handler.0_test.dart @@ -0,0 +1,48 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_api_samples/widgets/navigator_pop_handler/navigator_pop_handler.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +import '../navigator_utils.dart'; + +void main() { + testWidgets('Can go back with system back gesture', (WidgetTester tester) async { + await tester.pumpWidget( + const example.NavigatorPopHandlerApp(), + ); + + expect(find.text('Nested Navigators Example'), findsOneWidget); + expect(find.text('Nested Navigators Page One'), findsNothing); + expect(find.text('Nested Navigators Page Two'), findsNothing); + + await tester.tap(find.text('Nested Navigator route')); + await tester.pumpAndSettle(); + + expect(find.text('Nested Navigators Example'), findsNothing); + expect(find.text('Nested Navigators Page One'), findsOneWidget); + expect(find.text('Nested Navigators Page Two'), findsNothing); + + await tester.tap(find.text('Go to another route in this nested Navigator')); + await tester.pumpAndSettle(); + + expect(find.text('Nested Navigators Example'), findsNothing); + expect(find.text('Nested Navigators Page One'), findsNothing); + expect(find.text('Nested Navigators Page Two'), findsOneWidget); + + await simulateSystemBack(); + await tester.pumpAndSettle(); + + expect(find.text('Nested Navigators Example'), findsNothing); + expect(find.text('Nested Navigators Page One'), findsOneWidget); + expect(find.text('Nested Navigators Page Two'), findsNothing); + + await simulateSystemBack(); + await tester.pumpAndSettle(); + + expect(find.text('Nested Navigators Example'), findsOneWidget); + expect(find.text('Nested Navigators Page One'), findsNothing); + expect(find.text('Nested Navigators Page Two'), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/navigator_pop_handler/navigator_pop_handler.1_test.dart b/novelforge-project/flutter/examples/api/test/widgets/navigator_pop_handler/navigator_pop_handler.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..a6ea0ac82806f16f9ba51e55caecc198f911c2e3 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/navigator_pop_handler/navigator_pop_handler.1_test.dart @@ -0,0 +1,38 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_api_samples/widgets/navigator_pop_handler/navigator_pop_handler.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +import '../navigator_utils.dart'; + +void main() { + testWidgets("System back gesture operates on current tab's nested Navigator", (WidgetTester tester) async { + await tester.pumpWidget( + const example.NavigatorPopHandlerApp(), + ); + + expect(find.text('Bottom nav - tab Home Tab - route _TabPage.home'), findsOneWidget); + + // Go to the next route in this tab. + await tester.tap(find.text('Go to another route in this nested Navigator')); + await tester.pumpAndSettle(); + expect(find.text('Bottom nav - tab Home Tab - route _TabPage.one'), findsOneWidget); + + // Go to another tab. + await tester.tap(find.text('Go to One')); + await tester.pumpAndSettle(); + expect(find.text('Bottom nav - tab Tab One - route _TabPage.home'), findsOneWidget); + + // Return to the home tab. The navigation state is preserved. + await tester.tap(find.text('Go to Home')); + await tester.pumpAndSettle(); + expect(find.text('Bottom nav - tab Home Tab - route _TabPage.one'), findsOneWidget); + + // A back pops the navigation stack of the current tab's nested Navigator. + await simulateSystemBack(); + await tester.pumpAndSettle(); + expect(find.text('Bottom nav - tab Home Tab - route _TabPage.home'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/navigator_utils.dart b/novelforge-project/flutter/examples/api/test/widgets/navigator_utils.dart new file mode 100644 index 0000000000000000000000000000000000000000..46f1f9b1ac469b0b62969dcd47c1567b39fe227e --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/navigator_utils.dart @@ -0,0 +1,20 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; + +/// Simulates a system back, like a back gesture on Android. +/// +/// Sends the same platform channel message that the engine sends when it +/// receives a system back. +Future simulateSystemBack() { + return TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.handlePlatformMessage( + 'flutter/navigation', + const JSONMessageCodec().encodeMessage({ + 'method': 'popRoute', + }), + (ByteData? _) {}, + ); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/nested_scroll_view/nested_scroll_view.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/nested_scroll_view/nested_scroll_view.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..5a9ee19f792a20f72125732017e1aef67f1ccdb3 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/nested_scroll_view/nested_scroll_view.0_test.dart @@ -0,0 +1,44 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/nested_scroll_view/nested_scroll_view.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Shows all elements', (WidgetTester tester) async { + await tester.pumpWidget(const example.NestedScrollViewExampleApp()); + expect(find.byType(NestedScrollView), findsOneWidget); + expect(find.byType(SliverAppBar), findsOneWidget); + expect(find.byType(TabBarView), findsOneWidget); + expect(find.byType(Tab), findsNWidgets(2)); + expect(find.byType(CustomScrollView), findsAtLeast(1)); + expect(find.text('Books'), findsOneWidget); + expect(find.text('Tab 1'), findsOneWidget); + expect(find.text('Tab 2'), findsOneWidget); + expect(find.text('Item 0'), findsOneWidget); + expect(find.text('Item 14'), findsNothing); + expect(find.text('Item 14', skipOffstage: false), findsOneWidget); + expect(find.textContaining(RegExp(r'Item \d\d?'), skipOffstage: false), findsAtLeast(15)); + + await tester.tap(find.text('Tab 2')); + await tester.pumpAndSettle(); + expect(find.textContaining(RegExp(r'Item \d\d?'), skipOffstage: false), findsAtLeast(15)); + }); + + testWidgets('Shrinks app bar on scroll', (WidgetTester tester) async { + await tester.pumpWidget(const example.NestedScrollViewExampleApp()); + + final double initialAppBarHeight = tester.getTopLeft(find.byType(TabBarView)).dy; + expect(find.text('Item 1'), findsOneWidget); + await tester.ensureVisible(find.text('Item 14', skipOffstage: false)); + await tester.pump(); + expect(find.text('Item 1'), findsNothing); + + expect( + tester.getTopLeft(find.byType(TabBarView)).dy, + lessThan(initialAppBarHeight), + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/nested_scroll_view/nested_scroll_view.1_test.dart b/novelforge-project/flutter/examples/api/test/widgets/nested_scroll_view/nested_scroll_view.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..4b897b6bbc87cfe2e2ec72c4452739d6766ae64c --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/nested_scroll_view/nested_scroll_view.1_test.dart @@ -0,0 +1,23 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/nested_scroll_view/nested_scroll_view.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Hides app bar after scrolling down', (WidgetTester tester) async { + await tester.pumpWidget(const example.NestedScrollViewExampleApp()); + expect(find.text('Floating Nested SliverAppBar'), findsOneWidget); + expect(find.byType(NestedScrollView), findsOneWidget); + expect(find.text('Item 0'), findsOneWidget); + expect(find.text('Item 12'), findsNothing); + expect(find.text('Item 12', skipOffstage: false), findsOneWidget); + + await tester.ensureVisible(find.text('Item 12', skipOffstage: false)); + await tester.pump(); + expect(find.text('Item 0'), findsNothing); + expect(find.text('Floating Nested SliverAppBar'), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/nested_scroll_view/nested_scroll_view.2_test.dart b/novelforge-project/flutter/examples/api/test/widgets/nested_scroll_view/nested_scroll_view.2_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..86fbd9b563467d730d31c2c2e258b6b3d1504f54 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/nested_scroll_view/nested_scroll_view.2_test.dart @@ -0,0 +1,24 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/nested_scroll_view/nested_scroll_view.2.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Hides app bar after scrolling past first item', (WidgetTester tester) async { + await tester.pumpWidget(const example.NestedScrollViewExampleApp()); + expect(find.text('Snapping Nested SliverAppBar'), findsOneWidget); + expect(find.byType(NestedScrollView), findsOneWidget); + expect(find.text('Item 0'), findsOneWidget); + + while (find.text('Item 0').evaluate().isNotEmpty) { + await tester.sendEventToBinding(const PointerScrollEvent(scrollDelta: Offset(0.0, 1.0))); + await tester.pump(); + } + + expect(find.text('Snapping Nested SliverAppBar'), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/overflow_bar/overflow_bar.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/overflow_bar/overflow_bar.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..56d67ec8c5a7429e7b0f6355e944d0248eaf8e52 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/overflow_bar/overflow_bar.0_test.dart @@ -0,0 +1,28 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/overflow_bar/overflow_bar.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('OverflowBar displays buttons', (WidgetTester tester) async { + await tester.pumpWidget( + const example.OverflowBarExampleApp(), + ); + + // Creates a finder that matches widgets of the given + // `widgetType`, ensuring that the given widgets exist + // inside of an OverflowBar. + Finder buttonsFinder(Type widgetType) { + return find.descendant( + of: find.byType(OverflowBar), + matching: find.byType(widgetType), + ); + } + + expect(buttonsFinder(TextButton), findsNWidgets(2)); + expect(buttonsFinder(OutlinedButton), findsOne); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/overlay/overlay.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/overlay/overlay.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..c626fe17fee25190cfa0fa679cbd82004278a450 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/overlay/overlay.0_test.dart @@ -0,0 +1,41 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/overlay/overlay.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can use Overlay to highlight NavigationBar destination', (WidgetTester tester) async { + const String explorePage = 'Explore page'; + const String commutePage = 'Commute page'; + const String savedPage = 'Saved page'; + + await tester.pumpWidget( + const example.OverlayApp(), + ); + + expect(find.text(explorePage), findsNothing); + expect(find.text(commutePage), findsNothing); + expect(find.text(savedPage), findsNothing); + + await tester.tap(find.widgetWithText(ElevatedButton, 'Explore')); + await tester.pumpAndSettle(); + expect(find.text(explorePage), findsOneWidget); + + await tester.tap(find.widgetWithText(ElevatedButton, 'Commute')); + await tester.pumpAndSettle(); + expect(find.text(commutePage), findsOneWidget); + + await tester.tap(find.widgetWithText(ElevatedButton, 'Saved')); + await tester.pumpAndSettle(); + expect(find.text(savedPage), findsOneWidget); + + await tester.tap(find.widgetWithText(ElevatedButton, 'Remove Overlay')); + await tester.pumpAndSettle(); + expect(find.text(explorePage), findsNothing); + expect(find.text(commutePage), findsNothing); + expect(find.text(savedPage), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/overlay/overlay_portal.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/overlay/overlay_portal.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..2f104aff30afcad772eb7f85f5e8d98526f03280 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/overlay/overlay_portal.0_test.dart @@ -0,0 +1,44 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/rendering.dart'; +import 'package:flutter_api_samples/widgets/overlay/overlay_portal.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + const String tooltipText = 'tooltip'; + testWidgets('Tooltip is shown on press', (WidgetTester tester) async { + await tester.pumpWidget(const example.OverlayPortalExampleApp()); + expect(find.text(tooltipText), findsNothing); + + await tester.tap(find.byType(example.ClickableTooltipWidget)); + await tester.pump(); + expect(find.text(tooltipText), findsOneWidget); + + await tester.tap(find.byType(example.ClickableTooltipWidget)); + await tester.pump(); + expect(find.text(tooltipText), findsNothing); + }); + + testWidgets('Tooltip is shown at the right location', (WidgetTester tester) async { + await tester.pumpWidget(const example.OverlayPortalExampleApp()); + await tester.tap(find.byType(example.ClickableTooltipWidget)); + await tester.pump(); + + final Size canvasSize = tester.getSize(find.byType(example.OverlayPortalExampleApp)); + expect( + tester.getBottomRight(find.text(tooltipText)), + canvasSize - const Size(50, 50), + ); + }); + + testWidgets('Tooltip is shown with the right font size', (WidgetTester tester) async { + await tester.pumpWidget(const example.OverlayPortalExampleApp()); + await tester.tap(find.byType(example.ClickableTooltipWidget)); + await tester.pump(); + + final TextSpan textSpan = tester.renderObject(find.text(tooltipText)).text as TextSpan; + expect(textSpan.style?.fontSize, 50); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/page/page_can_pop.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/page/page_can_pop.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..c78205e34e9dd93dd8fc9234031c14c58ff24e48 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/page/page_can_pop.0_test.dart @@ -0,0 +1,54 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_api_samples/widgets/page/page_can_pop.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +import '../navigator_utils.dart'; + +void main() { + testWidgets('Can choose to stay on page', (WidgetTester tester) async { + await tester.pumpWidget( + const example.PageApiExampleApp(), + ); + + expect(find.text('Home'), findsOneWidget); + + await tester.tap(find.text('Go to details')); + await tester.pumpAndSettle(); + expect(find.text('Home'), findsNothing); + expect(find.text('Details'), findsOneWidget); + + await simulateSystemBack(); + await tester.pumpAndSettle(); + expect(find.text('Are you sure?'), findsOneWidget); + + await tester.tap(find.text('Cancel')); + await tester.pumpAndSettle(); + expect(find.text('Home'), findsNothing); + expect(find.text('Details'), findsOneWidget); + }); + + testWidgets('Can choose to go back', (WidgetTester tester) async { + await tester.pumpWidget( + const example.PageApiExampleApp(), + ); + + expect(find.text('Home'), findsOneWidget); + + await tester.tap(find.text('Go to details')); + await tester.pumpAndSettle(); + expect(find.text('Home'), findsNothing); + expect(find.text('Details'), findsOneWidget); + + await simulateSystemBack(); + await tester.pumpAndSettle(); + expect(find.text('Are you sure?'), findsOneWidget); + + await tester.tap(find.text('Confirm')); + await tester.pumpAndSettle(); + expect(find.text('Details'), findsNothing); + expect(find.text('Home'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/page_view/page_view.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/page_view/page_view.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..a994f22d0aa4d233dff97cafc838daca7ef6c3a5 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/page_view/page_view.0_test.dart @@ -0,0 +1,66 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/page_view/page_view.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('PageView swipe gestures on mobile platforms', (WidgetTester tester) async { + await tester.pumpWidget( + const example.PageViewExampleApp(), + ); + + // Verify that first page is shown initially. + expect(find.text('First Page'), findsOneWidget); + + // Swipe to the left. + await tester.fling(find.text('First Page'), const Offset(-300.0, 0.0), 3000); + await tester.pumpAndSettle(); + // Verify that the second page is shown. + expect(find.text('Second Page'), findsOneWidget); + + // Swipe back to the right. + await tester.fling(find.text('Second Page'), const Offset(300.0, 0.0), 3000); + await tester.pumpAndSettle(); + // Verify that first page is shown. + expect(find.text('First Page'), findsOneWidget); + }, variant: TargetPlatformVariant.mobile()); + + testWidgets('PageView navigation using forward/backward buttons on desktop platforms', (WidgetTester tester) async { + await tester.pumpWidget( + const example.PageViewExampleApp(), + ); + + // Verify that first page is shown along with forward/backward buttons in page indicator. + expect(find.text('First Page'), findsOneWidget); + expect(find.byType(TabPageSelector), findsOneWidget); + + // Tap forward button on page indicator area. + await tester.tap(find.byIcon(Icons.arrow_right_rounded)); + await tester.pumpAndSettle(); + // Verify that second page is shown. + expect(find.text('Second Page'), findsOneWidget); + + // Verify that page indicator index is updated. + final TabPageSelector pageIndicator = tester.widget(find.byType(TabPageSelector)); + expect(pageIndicator.controller?.index, 1); + + // Verify that page view index is also updated with same index to page indicator. + final PageView pageView = tester.widget(find.byType(PageView)); + expect(pageView.controller.page, 1); + + // Tap backward button on page indicator area. + await tester.tap(find.byIcon(Icons.arrow_left_rounded)); + await tester.pumpAndSettle(); + // Verify that first page is shown. + expect(find.text('First Page'), findsOneWidget); + + // Tap backward button one more time. + await tester.tap(find.byIcon(Icons.arrow_left_rounded)); + await tester.pumpAndSettle(); + // Verify that first page is still shown. + expect(find.text('First Page'), findsOneWidget); + }, variant: TargetPlatformVariant.desktop()); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/page_view/page_view.1_test.dart b/novelforge-project/flutter/examples/api/test/widgets/page_view/page_view.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..677a12e87e1ea5c66ba8a7ef10a21b60d66e85ea --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/page_view/page_view.1_test.dart @@ -0,0 +1,29 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/page_view/page_view.1.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets( + 'tapping Reverse button should reverse PageView', + (WidgetTester tester) async { + await tester.pumpWidget(const example.PageViewExampleApp()); + final Finder pageView = find.byType(PageView); + final Finder reverseFinder = find.text('Reverse items'); + final Finder firstItemFinder = find.byKey(const ValueKey('1')); + final Finder lastItemFinder = find.byKey(const ValueKey('5')); + expect(pageView, findsOneWidget); + expect(reverseFinder, findsOneWidget); + expect(firstItemFinder, findsOneWidget); + expect(lastItemFinder, findsNothing); + await tester.tap(reverseFinder); + await tester.pump(); + expect(firstItemFinder, findsNothing); + expect(lastItemFinder, findsOneWidget); + }, + ); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/pop_scope/pop_scope.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/pop_scope/pop_scope.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..ac334fc3222f24498221db38881ccf98952da509 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/pop_scope/pop_scope.0_test.dart @@ -0,0 +1,66 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_api_samples/widgets/pop_scope/pop_scope.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +import '../navigator_utils.dart'; + +void main() { + testWidgets('Can choose to stay on page', (WidgetTester tester) async { + await tester.pumpWidget( + const example.NavigatorPopHandlerApp(), + ); + + expect(find.text('Page One'), findsOneWidget); + expect(find.text('Page Two'), findsNothing); + expect(find.text('Are you sure?'), findsNothing); + + await tester.tap(find.text('Next page')); + await tester.pumpAndSettle(); + expect(find.text('Page One'), findsNothing); + expect(find.text('Page Two'), findsOneWidget); + expect(find.text('Are you sure?'), findsNothing); + + await simulateSystemBack(); + await tester.pumpAndSettle(); + expect(find.text('Page One'), findsNothing); + expect(find.text('Page Two'), findsOneWidget); + expect(find.text('Are you sure?'), findsOneWidget); + + await tester.tap(find.text('Nevermind')); + await tester.pumpAndSettle(); + expect(find.text('Page One'), findsNothing); + expect(find.text('Page Two'), findsOneWidget); + expect(find.text('Are you sure?'), findsNothing); + }); + + testWidgets('Can choose to go back', (WidgetTester tester) async { + await tester.pumpWidget( + const example.NavigatorPopHandlerApp(), + ); + + expect(find.text('Page One'), findsOneWidget); + expect(find.text('Page Two'), findsNothing); + expect(find.text('Are you sure?'), findsNothing); + + await tester.tap(find.text('Next page')); + await tester.pumpAndSettle(); + expect(find.text('Page One'), findsNothing); + expect(find.text('Page Two'), findsOneWidget); + expect(find.text('Are you sure?'), findsNothing); + + await simulateSystemBack(); + await tester.pumpAndSettle(); + expect(find.text('Page One'), findsNothing); + expect(find.text('Page Two'), findsOneWidget); + expect(find.text('Are you sure?'), findsOneWidget); + + await tester.tap(find.text('Leave')); + await tester.pumpAndSettle(); + expect(find.text('Page One'), findsOneWidget); + expect(find.text('Page Two'), findsNothing); + expect(find.text('Are you sure?'), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/pop_scope/pop_scope.1_test.dart b/novelforge-project/flutter/examples/api/test/widgets/pop_scope/pop_scope.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..14266af52147dc7eca5e591491933318b1afa407 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/pop_scope/pop_scope.1_test.dart @@ -0,0 +1,67 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/pop_scope/pop_scope.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +import '../navigator_utils.dart'; + +void main() { + testWidgets('Can choose to stay on page', (WidgetTester tester) async { + await tester.pumpWidget( + const example.NavigatorPopHandlerApp(), + ); + + expect(find.text('Page One'), findsOneWidget); + + await tester.tap(find.text('Next page')); + await tester.pumpAndSettle(); + expect(find.text('Page One'), findsNothing); + expect(find.text('Page Two'), findsOneWidget); + + await simulateSystemBack(); + await tester.pumpAndSettle(); + expect(find.text('Page One'), findsNothing); + expect(find.text('Page Two'), findsOneWidget); + expect(find.text('Are you sure?'), findsOneWidget); + + await tester.tap(find.text('Never mind')); + await tester.pumpAndSettle(); + expect(find.text('Page One'), findsNothing); + expect(find.text('Page Two'), findsOneWidget); + }); + + testWidgets('Can choose to go back with pop result', (WidgetTester tester) async { + await tester.pumpWidget( + const example.NavigatorPopHandlerApp(), + ); + + expect(find.text('Page One'), findsOneWidget); + expect(find.text('Page Two'), findsNothing); + + await tester.tap(find.text('Next page')); + await tester.pumpAndSettle(); + expect(find.text('Page One'), findsNothing); + expect(find.text('Page Two'), findsOneWidget); + + await tester.enterText(find.byType(TextFormField).first, 'John'); + await tester.pumpAndSettle(); + await tester.enterText(find.byType(TextFormField).last, 'Apple'); + await tester.pumpAndSettle(); + + await tester.tap(find.text('Go back')); + await tester.pumpAndSettle(); + expect(find.text('Page One'), findsNothing); + expect(find.text('Page Two'), findsOneWidget); + expect(find.text('Are you sure?'), findsOneWidget); + + await tester.tap(find.text('Leave')); + await tester.pumpAndSettle(); + expect(find.text('Page One'), findsOneWidget); + expect(find.text('Page Two'), findsNothing); + expect(find.text('Are you sure?'), findsNothing); + expect(find.text('Hello John, whose favorite food is Apple.'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/preferred_size/preferred_size.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/preferred_size/preferred_size.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..c6b1bb64df7d6c993f80ae650ac7c08c40001eba --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/preferred_size/preferred_size.0_test.dart @@ -0,0 +1,35 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/preferred_size/preferred_size.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets( + 'PreferredSize determines the height of AppBarContent', + (WidgetTester tester) async { + await tester.pumpWidget( + const example.PreferredSizeExampleApp(), + ); + + final PreferredSize preferredSize = tester.widget( + find.ancestor( + of: find.byType(example.AppBarContent), + matching: find.byType(PreferredSize), + ), + ); + + final RenderBox appBarContent = tester.renderObject( + find.byType(example.AppBarContent), + ) as RenderBox; + + expect( + preferredSize.preferredSize.height, + equals(appBarContent.size.height), + ); + }, + ); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/restoration_properties/restorable_value.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/restoration_properties/restorable_value.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..8c52ea8c5cfeea4b2a211624de68b058adf3c3d2 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/restoration_properties/restorable_value.0_test.dart @@ -0,0 +1,56 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/restoration_properties/restorable_value.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Increments answer on OutlinedButton tap', (WidgetTester tester) async { + await tester.pumpWidget( + const example.RestorableValueExampleApp(), + ); + + // Verify that the initial answer value in the example equals 42. + expect(find.text('42'), findsOneWidget); + + // Tap the button to increment the answer value by 1. + await tester.tap(find.byType(OutlinedButton)); + await tester.pump(); + + // Verify that the answer value increased by 1. + expect(find.text('43'), findsOneWidget); + }); + + testWidgets('Restores answer value after restart', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: RootRestorationScope( + restorationId: 'root', + child: example.RestorableValueExample(restorationId: 'child'), + ), + ), + ); + + // The initial answer value in the example equals 42. + expect(find.text('42'), findsOneWidget); + + // Tap the button 10 times to change the answer value. + for (int i = 0; i < 10; i++) { + await tester.tap(find.byType(OutlinedButton)); + await tester.pump(); + } + + // Verify that the answer value increased by 10. + expect(find.text('52'), findsOneWidget); + + // Simulate restoring the state of the widget tree after the application + // is restarted. + await tester.restartAndRestore(); + + // Verify that the answer value is restored correctly. + expect(find.text('52'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/routes/popup_route.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/routes/popup_route.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..9968cea88675ebe94eb55c2d1a67f5e6c337192f --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/routes/popup_route.0_test.dart @@ -0,0 +1,40 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_api_samples/widgets/routes/popup_route.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Dismiss dialog with tap on the scrim and escape key', (WidgetTester tester) async { + const String dialogText = 'Tap in the scrim or press escape key to dismiss.'; + + await tester.pumpWidget( + const example.PopupRouteApp(), + ); + + expect(find.text(dialogText), findsNothing); + + // Tap on the button to show the dialog. + await tester.tap(find.byType(OutlinedButton)); + await tester.pumpAndSettle(); + expect(find.text(dialogText), findsOneWidget); + + // Try to dismiss the dialog with a tap on the scrim. + await tester.tapAt(const Offset(10.0, 10.0)); + await tester.pumpAndSettle(); + expect(find.text(dialogText), findsNothing); + + // Open the dialog again. + await tester.tap(find.byType(OutlinedButton)); + await tester.pumpAndSettle(); + expect(find.text(dialogText), findsOneWidget); + + // Try to dismiss the dialog with the escape key. + await tester.sendKeyEvent(LogicalKeyboardKey.escape); + await tester.pumpAndSettle(); + expect(find.text(dialogText), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/routes/route_observer.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/routes/route_observer.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..7077c317eb0014854beead0e9836cf3b09b7a8a2 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/routes/route_observer.0_test.dart @@ -0,0 +1,41 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_api_samples/widgets/routes/route_observer.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('RouteObserver notifies RouteAware widget', (WidgetTester tester) async { + await tester.pumpWidget( + const example.RouteObserverApp(), + ); + + // Check the initial RouteObserver logs. + expect(find.text('didPush'), findsOneWidget); + + // Tap on the button to push a new route. + await tester.tap(find.text('Go to next page')); + await tester.pumpAndSettle(); + + // Tap on the button to go back to the previous route. + await tester.tap(find.text('Go back to RouteAware page')); + await tester.pumpAndSettle(); + + // Check the RouteObserver logs after the route is popped. + expect(find.text('didPush'), findsOneWidget); + expect(find.text('didPopNext'), findsOneWidget); + + // Tap on the button to push a new route again. + await tester.tap(find.text('Go to next page')); + await tester.pumpAndSettle(); + + // Tap on the button to go back to the previous route again. + await tester.tap(find.text('Go back to RouteAware page')); + await tester.pumpAndSettle(); + + // Check the RouteObserver logs after the route is popped again. + expect(find.text('didPush'), findsOneWidget); + expect(find.text('didPopNext'), findsNWidgets(2)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/routes/show_general_dialog.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/routes/show_general_dialog.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..f6c859977a9e841264f4e4ce06ee1a077001d03c --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/routes/show_general_dialog.0_test.dart @@ -0,0 +1,29 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/routes/show_general_dialog.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Open and dismiss general dialog', (WidgetTester tester) async { + const String dialogText = 'Alert!'; + + await tester.pumpWidget( + const example.GeneralDialogApp(), + ); + + expect(find.text(dialogText), findsNothing); + + // Tap on the button to show the dialog. + await tester.tap(find.byType(OutlinedButton)); + await tester.pumpAndSettle(); + expect(find.text(dialogText), findsOneWidget); + + // Try to dismiss the dialog with a tap on the scrim. + await tester.tapAt(const Offset(10.0, 10.0)); + await tester.pumpAndSettle(); + expect(find.text(dialogText), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/scroll_end_notification/scroll_end_notification.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/scroll_end_notification/scroll_end_notification.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..d3db5a363cfdd54ff7e3d1979792d6ea4317e5ea --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/scroll_end_notification/scroll_end_notification.0_test.dart @@ -0,0 +1,46 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/scroll_end_notification/scroll_end_notification.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('IsScrollingListenerApp smoke test', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ScrollEndNotificationApp(), + ); + + expect(find.byType(CustomScrollView), findsOneWidget); + expect(find.byType(Scrollbar), findsOneWidget); + + ScrollPosition getScrollPosition() { + return tester.widget(find.byType(CustomScrollView)).controller!.position; + } + + // Viewport is 600 pixels high, each item's height is 100, 6 items are visible. + expect(getScrollPosition().viewportDimension, 600); + expect(getScrollPosition().pixels, 0); + expect(find.text('Item 0'), findsOneWidget); + expect(find.text('Item 5'), findsOneWidget); + + // Small (< 100) scrolls don't trigger an auto-scroll + await tester.drag(find.byType(Scrollbar), const Offset(0, -20.0)); + await tester.pumpAndSettle(); + expect(getScrollPosition().pixels, 20); + expect(find.text('Item 0'), findsOneWidget); + + // Initial scroll is to 220: items 0,1 are scrolled off the top, + // the bottom 80 pixels of item 2 are visible, items 4-7 are + // completely visible, the first 20 pixels of item 8 are visible. + // After the auto-scroll, items 3-8 are completely visible. + await tester.drag(find.byType(Scrollbar), const Offset(0, -200.0)); + await tester.pumpAndSettle(); + expect(getScrollPosition().pixels, 300); + expect(find.text('Item 0'), findsNothing); + expect(find.text('Item 2'), findsNothing); + expect(find.text('Item 3'), findsOneWidget); + expect(find.text('Item 8'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/scroll_end_notification/scroll_end_notification.1_test.dart b/novelforge-project/flutter/examples/api/test/widgets/scroll_end_notification/scroll_end_notification.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..8f36c8fde5d7e2c1fdc90312f48f2a01fa0624d3 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/scroll_end_notification/scroll_end_notification.1_test.dart @@ -0,0 +1,52 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/scroll_end_notification/scroll_end_notification.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('SliverAutoScroll example', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SliverAutoScrollExampleApp(), + ); + + final double itemHeight = tester.getSize(find.widgetWithText(Card, 'Item 0.15')).height; + + // The scroll view is 600 pixels high and the big orange + // "AlignedItem" is precedeed by 15 regular items. Scroll up enough + // to make it partially visible. + await tester.drag(find.byType(CustomScrollView), Offset(0, 600 - 15.5 * itemHeight)); + await tester.pumpAndSettle(); + + final Finder alignedItem = find.widgetWithText(Card, 'Aligned Item'); + + // The "AlignedItem" is now bottom aligned. + expect(tester.getRect(alignedItem).bottom, 600); + + // Scrolling down a little (less then the big orange item's height) and no + // auto-scroll occurs. + await tester.drag(find.byType(CustomScrollView), Offset(0, itemHeight)); + await tester.pumpAndSettle(); + expect(tester.getRect(alignedItem).bottom, 600 + itemHeight); + + // Scroll up a little and the "AlignedItem" does not auto-scroll, because + // it's fully visible. + await tester.drag(find.byType(CustomScrollView), Offset(0, - 2 * itemHeight)); + await tester.pumpAndSettle(); + expect(tester.getRect(alignedItem).bottom, 600 - itemHeight); + + // Scroll up far enough to make the AlignedItem partially visible and to trigger + // an auto-scroll that aligns it with the top of the viewport. + await tester.drag(find.byType(CustomScrollView), Offset(0, -600 + itemHeight * 1.5)); + await tester.pumpAndSettle(); + expect(tester.getRect(alignedItem).top, 0); + + // Scroll down a little and the "AlignedItem" does not auto-scroll because + // it's fully visible. + await tester.drag(find.byType(CustomScrollView), Offset(0, itemHeight)); + await tester.pumpAndSettle(); + expect(tester.getRect(alignedItem).top, itemHeight); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/scroll_notification_observer/scroll_notification_observer.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/scroll_notification_observer/scroll_notification_observer.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..082897641793ad2d1ad1055d5749c6b62b58374f --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/scroll_notification_observer/scroll_notification_observer.0_test.dart @@ -0,0 +1,31 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/scroll_notification_observer/scroll_notification_observer.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Scroll to top buttons appears when scrolling down', (WidgetTester tester) async { + const String buttonText = 'Scroll to top'; + + await tester.pumpWidget( + const example.ScrollNotificationObserverApp(), + ); + + expect(find.byType(ScrollNotificationObserver), findsOneWidget); + expect(find.text(buttonText), findsNothing); + + // Scroll down. + await tester.drag(find.byType(ListView), const Offset(0.0, -300.0)); + await tester.pumpAndSettle(); + + expect(find.text(buttonText), findsOneWidget); + + await tester.tap(find.text(buttonText)); + await tester.pumpAndSettle(); + + expect(find.text(buttonText), findsNothing); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/scroll_position/is_scrolling_listener.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/scroll_position/is_scrolling_listener.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..6016039f81aa21aefb289a5bbbfd8e9a80fa6d04 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/scroll_position/is_scrolling_listener.0_test.dart @@ -0,0 +1,46 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/scroll_position/is_scrolling_listener.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('IsScrollingListenerApp smoke test', (WidgetTester tester) async { + await tester.pumpWidget( + const example.IsScrollingListenerApp(), + ); + + expect(find.byType(CustomScrollView), findsOneWidget); + expect(find.byType(Scrollbar), findsOneWidget); + + ScrollPosition getScrollPosition() { + return tester.widget(find.byType(CustomScrollView)).controller!.position; + } + + // Viewport is 600 pixels high, each item's height is 100, 6 items are visible. + expect(getScrollPosition().viewportDimension, 600); + expect(getScrollPosition().pixels, 0); + expect(find.text('Item 0'), findsOneWidget); + expect(find.text('Item 5'), findsOneWidget); + + // Small (< 100) scrolls don't trigger an auto-scroll + await tester.drag(find.byType(Scrollbar), const Offset(0, -20.0)); + await tester.pumpAndSettle(); + expect(getScrollPosition().pixels, 20); + expect(find.text('Item 0'), findsOneWidget); + + // Initial scroll is to 220: items 0,1 are scrolled off the top, + // the bottom 80 pixels of item 2 are visible, items 4-7 are + // completely visible, the first 20 pixels of item 8 are visible. + // After the auto-scroll, items 3-8 are completely visible. + await tester.drag(find.byType(Scrollbar), const Offset(0, -200.0)); + await tester.pumpAndSettle(); + expect(getScrollPosition().pixels, 300); + expect(find.text('Item 0'), findsNothing); + expect(find.text('Item 2'), findsNothing); + expect(find.text('Item 3'), findsOneWidget); + expect(find.text('Item 8'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/scroll_position/scroll_controller_notification.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/scroll_position/scroll_controller_notification.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..1eec63095da25eaf7da3fa26be7e6281655505e6 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/scroll_position/scroll_controller_notification.0_test.dart @@ -0,0 +1,32 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/scroll_position/scroll_controller_notification.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can toggle between scroll notification types', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ScrollNotificationDemo(), + ); + + expect(find.byType(CustomScrollView), findsOneWidget); + expect(find.text('Last notification: Null'), findsNothing); + + // Toggle to use NotificationListener + await tester.tap( + find.byWidgetPredicate((Widget widget) { + return widget is Radio && !widget.value; + }) + ); + await tester.pumpAndSettle(); + + expect(find.text('Last notification: Null'), findsOneWidget); + await tester.drag(find.byType(CustomScrollView), const Offset(20.0, 20.0)); + await tester.pumpAndSettle(); + expect(find.text('Last notification: UserScrollNotification'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/scroll_position/scroll_controller_on_attach.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/scroll_position/scroll_controller_on_attach.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..1c7d307317212bf181aa1b9d259d6fd156c87617 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/scroll_position/scroll_controller_on_attach.0_test.dart @@ -0,0 +1,47 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/scroll_position/scroll_controller_on_attach.0.dart' +as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can toggle between scroll notification types', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ScrollControllerDemo(), + ); + + expect(find.byType(CustomScrollView), findsOneWidget); + expect(find.text('Not Scrolling'), findsOneWidget); + Material appBarMaterial = tester.widget( + find.descendant( + of: find.byType(AppBar), + matching: find.byType(Material), + ), + ); + expect(appBarMaterial.color, Colors.redAccent[700]!.withOpacity(.85)); + final TestGesture gesture = await tester.startGesture(tester.getCenter(find.byType(CustomScrollView))); + await gesture.moveBy(const Offset(10.0, 10.0)); + await tester.pump(); + expect(find.text('Scrolling'), findsOneWidget); + appBarMaterial = tester.widget( + find.descendant( + of: find.byType(AppBar), + matching: find.byType(Material), + ), + ); + expect(appBarMaterial.color, Colors.green[800]!.withOpacity(.85)); + await gesture.up(); + await tester.pumpAndSettle(); + + expect(find.text('Not Scrolling'), findsOneWidget); + appBarMaterial = tester.widget( + find.descendant( + of: find.byType(AppBar), + matching: find.byType(Material), + ), + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/scroll_view/grid_view.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/scroll_view/grid_view.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..9368a091d3b3833175de5845d32e09272ca184a0 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/scroll_view/grid_view.0_test.dart @@ -0,0 +1,32 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/rendering.dart'; +import 'package:flutter_api_samples/widgets/scroll_view/grid_view.0.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('$CustomGridLayout', (WidgetTester tester) async { + const CustomGridLayout layout = CustomGridLayout( + crossAxisCount: 2, + fullRowPeriod: 3, + dimension: 100, + ); + final List scrollOffsets = List.generate(10, (int i) => layout.computeMaxScrollOffset(i)); + expect(scrollOffsets, [0.0, 0.0, 100.0, 100.0, 200.0, 300.0, 300.0, 400.0, 400.0, 500.0]); + final List minOffsets = List.generate(10, (int i) => layout.getMinChildIndexForScrollOffset(i * 80.0)); + expect(minOffsets, [0, 0, 2, 4, 5, 7, 7, 9, 10, 12]); + final List maxOffsets = List.generate(10, (int i) => layout.getMaxChildIndexForScrollOffset(i * 80.0)); + expect(maxOffsets, [1, 1, 3, 4, 6, 8, 8, 9, 11, 13]); + final List offsets = List.generate(20, (int i) => layout.getGeometryForChildIndex(i)); + offsets.reduce((SliverGridGeometry a, SliverGridGeometry b) { + if (a.scrollOffset == b.scrollOffset) { + expect(a.crossAxisOffset, lessThan(b.crossAxisOffset)); + } else { + expect(a.scrollOffset, lessThan(b.scrollOffset)); + } + return b; + }); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/scroll_view/list_view.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/scroll_view/list_view.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..1515492e5678088dd525b49e4db4f715afea3004 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/scroll_view/list_view.0_test.dart @@ -0,0 +1,74 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/scroll_view/list_view.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('long press ListTile should enable edit mode', + (WidgetTester tester) async { + await tester.pumpWidget( + const example.ListViewExampleApp(), + ); + + final Finder listView = find.byType(ListView); + final Finder selectAllFinder = find.text('select all'); + final Finder checkBoxFinder = find.byType(Checkbox); + expect(listView, findsWidgets); + expect(selectAllFinder, findsNothing); + expect(checkBoxFinder, findsNothing); + await tester.longPress(listView.first); + await tester.pump(); + expect(selectAllFinder, findsOneWidget); + expect(checkBoxFinder, findsWidgets); + }); + + testWidgets('Pressing cross button should disable edit mode', + (WidgetTester tester) async { + await tester.pumpWidget( + const example.ListViewExampleApp(), + ); + + final Finder listView = find.byType(ListView); + final Finder crossIconFinder = find.byIcon(Icons.close); + expect(listView, findsWidgets); + expect(crossIconFinder, findsNothing); + + /// enable edit mode + await tester.longPress(listView.first); + await tester.pump(); + + expect(crossIconFinder, findsOneWidget); + await tester.tap(crossIconFinder); + await tester.pump(); + final Finder selectAllFinder = find.text('select all'); + expect(selectAllFinder, findsNothing); + expect(crossIconFinder, findsNothing); + }); + + testWidgets('tapping ListTile or checkBox should toggle ListTile state', + (WidgetTester tester) async { + await tester.pumpWidget( + const example.ListViewExampleApp(), + ); + + final Finder listView = find.byType(ListView); + final Finder selectAllFinder = find.text('select all'); + expect(listView, findsWidgets); + + /// enable edit mode + await tester.longPress(listView.first); + await tester.pump(); + + final Finder checkBoxFinder = find.byType(Checkbox).first; + expect(selectAllFinder, findsOneWidget); + expect(checkBoxFinder, findsOneWidget); + expect(tester.widget(checkBoxFinder).value, false); + await tester.tap(checkBoxFinder); + await tester.pump(); + expect(tester.widget(checkBoxFinder).value, true); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/scroll_view/list_view.1_test.dart b/novelforge-project/flutter/examples/api/test/widgets/scroll_view/list_view.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..0a9e5defbb3eb5aa0d337c374e4d31554172df8c --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/scroll_view/list_view.1_test.dart @@ -0,0 +1,28 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/scroll_view/list_view.1.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets( + 'tapping Reverse button should reverse ListView', + (WidgetTester tester) async { + await tester.pumpWidget(const example.ListViewExampleApp()); + final Finder listView = find.byType(ListView); + final Finder reverseFinder = find.text('Reverse items'); + expect(listView, findsOneWidget); + expect(reverseFinder, findsOneWidget); + final Finder keepAliveItemFinder = find.byType(example.KeepAliveItem); + example.KeepAliveItem firstWidget = tester.firstWidget(keepAliveItemFinder); + expect(firstWidget.data, '1'); + await tester.tap(reverseFinder); + await tester.pump(); + firstWidget = tester.firstWidget(keepAliveItemFinder); + expect(firstWidget.data, '5'); + }, + ); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/scrollbar/raw_scrollbar.desktop.0.dart b/novelforge-project/flutter/examples/api/test/widgets/scrollbar/raw_scrollbar.desktop.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..f05964b559c4a96c753d162312eecc51fa2d2ece --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/scrollbar/raw_scrollbar.desktop.0.dart @@ -0,0 +1,20 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/scrollbar/raw_scrollbar.desktop.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can hide default scrollbar on desktop', (WidgetTester tester) async { + + await tester.pumpWidget( + const example.ScrollbarApp(), + ); + + // Two from left list view where scroll configuration is not set. + // One from right list view where scroll configuration is set. + expect(find.byType(Scrollbar), findsNWidgets(3)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/shared_app_data/shared_app_data.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/shared_app_data/shared_app_data.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..c84cb862084841535c86062ec5f01e7126cad278 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/shared_app_data/shared_app_data.0_test.dart @@ -0,0 +1,100 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/shared_app_data/shared_app_data.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Verify correct labels are displayed', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SharedAppDataExampleApp(), + ); + + expect(find.text('SharedAppData Sample'), findsOneWidget); + expect(find.text('foo: initial'), findsOneWidget); + expect(find.text('bar: initial'), findsOneWidget); + expect(find.text('change foo'), findsOneWidget); + expect(find.text('change bar'), findsOneWidget); + }); + + testWidgets('foo value can be updated', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SharedAppDataExampleApp(), + ); + + int counter = 0; + + while (counter < 10) { + counter++; + + await tester.tap(find.ancestor( + of: find.text('change foo'), + matching: find.byType(ElevatedButton), + )); + await tester.pump(); + + expect(find.text('foo: FOO $counter'), findsOneWidget); + } + }); + + testWidgets('bar value can be updated', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SharedAppDataExampleApp(), + ); + + int counter = 0; + + while (counter < 10) { + counter++; + + await tester.tap(find.ancestor( + of: find.text('change bar'), + matching: find.byType(ElevatedButton), + )); + await tester.pump(); + + expect(find.text('bar: BAR $counter'), findsOneWidget); + } + }); + + testWidgets('foo and bar values update independently of one another', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SharedAppDataExampleApp(), + ); + + int fooCounter = 0; + int barCounter = 0; + + for (int i = 0; i < 20; i++) { + if (i.isEven) { + fooCounter++; + } else { + barCounter++; + } + + await tester.tap( + find.ancestor( + of: i.isEven ? find.text('change foo') : find.text('change bar'), + matching: find.byType(ElevatedButton), + ), + ); + await tester.pump(); + + expect( + find.text( + 'foo: ${fooCounter == 0 ? 'initial' : 'FOO $fooCounter'}', + ), + findsOneWidget, + ); + expect( + find.text( + 'bar: ${barCounter == 0 ? 'initial' : 'BAR $barCounter'}', + ), + findsOneWidget, + ); + } + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/shared_app_data/shared_app_data.1_test.dart b/novelforge-project/flutter/examples/api/test/widgets/shared_app_data/shared_app_data.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..4ada24bddd3a421d3ae49b0be1d41ce6e3e196fd --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/shared_app_data/shared_app_data.1_test.dart @@ -0,0 +1,48 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/shared_app_data/shared_app_data.1.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + example.SharedObject getSharedObject(WidgetTester tester) { + final BuildContext context = tester.element( + find.byType(example.CustomWidget), + ); + return example.SharedObject.of(context); + } + + testWidgets('Verify correct labels are displayed', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SharedAppDataExampleApp(), + ); + + final example.SharedObject sharedObject = getSharedObject(tester); + + expect(find.text('SharedAppData Sample'), findsOneWidget); + expect(find.text('Replace $sharedObject'), findsOneWidget); + }); + + testWidgets('Button tap resets SharedObject', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SharedAppDataExampleApp(), + ); + + for (int i = 0; i < 10; i++) { + final example.SharedObject sharedObject = getSharedObject(tester); + + final Finder buttonFinder = find.ancestor( + of: find.text('Replace $sharedObject'), + matching: find.byType(ElevatedButton), + ); + + expect(buttonFinder, findsOneWidget); + + await tester.tap(buttonFinder); + await tester.pump(); + } + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/shortcuts/callback_shortcuts.0.dart b/novelforge-project/flutter/examples/api/test/widgets/shortcuts/callback_shortcuts.0.dart new file mode 100644 index 0000000000000000000000000000000000000000..f0ac673ce677f0bfd4ac700c668733c7aeefe16a --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/shortcuts/callback_shortcuts.0.dart @@ -0,0 +1,29 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/services.dart'; +import 'package:flutter_api_samples/widgets/shortcuts/callback_shortcuts.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('CallbackShortcutsApp increments and decrements', (WidgetTester tester) async { + await tester.pumpWidget( + const example.CallbackShortcutsApp(), + ); + + expect(find.text('count: 0'), findsOneWidget); + + // Increment the counter. + await tester.sendKeyEvent(LogicalKeyboardKey.arrowUp); + await tester.pump(); + + expect(find.text('count: 1'), findsOneWidget); + + // Decrement the counter. + await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown); + await tester.pump(); + + expect(find.text('count: 0'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/shortcuts/callback_shortcuts.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/shortcuts/callback_shortcuts.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..d65ecccfc17be38cdbe8f9ce6a4ca3bc9a8382f0 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/shortcuts/callback_shortcuts.0_test.dart @@ -0,0 +1,55 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/services.dart'; +import 'package:flutter_api_samples/widgets/shortcuts/callback_shortcuts.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Verify correct labels are displayed', (WidgetTester tester) async { + await tester.pumpWidget( + const example.CallbackShortcutsApp(), + ); + + expect(find.text('CallbackShortcuts Sample'), findsOneWidget); + expect( + find.text('Press the up arrow key to add to the counter'), + findsOneWidget, + ); + expect( + find.text('Press the down arrow key to subtract from the counter'), + findsOneWidget, + ); + expect(find.text('count: 0'), findsOneWidget); + }); + + testWidgets('Up and down arrow press updates counter', (WidgetTester tester) async { + await tester.pumpWidget( + const example.CallbackShortcutsApp(), + ); + + int counter = 0; + + while (counter < 10) { + expect(find.text('count: $counter'), findsOneWidget); + + // Increment the counter. + await tester.sendKeyEvent(LogicalKeyboardKey.arrowUp); + await tester.pump(); + + counter++; + } + + while (counter >= 0) { + expect(find.text('count: $counter'), findsOneWidget); + + // Decrement the counter. + await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown); + await tester.pump(); + + counter--; + } + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/shortcuts/character_activator.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/shortcuts/character_activator.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..fda1dccc21a90d476862d89e8a7cf71a6ddded8e --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/shortcuts/character_activator.0_test.dart @@ -0,0 +1,53 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_api_samples/widgets/shortcuts/character_activator.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + group('CharacterActivatorExampleApp', () { + testWidgets('displays correct labels', (WidgetTester tester) async { + await tester.pumpWidget( + const example.CharacterActivatorExampleApp(), + ); + + expect(find.text('CharacterActivator Sample'), findsOneWidget); + expect(find.text('Press question mark for help'), findsOneWidget); + }); + + testWidgets( + 'shows snack bar on question key pressed', + (WidgetTester tester) async { + await tester.pumpWidget( + const example.CharacterActivatorExampleApp(), + ); + + final Finder snackBarFinder = find.ancestor( + of: find.text('Keep calm and carry on!'), + matching: find.byType(SnackBar), + ); + + expect(snackBarFinder, findsNothing); + + await tester.sendKeyEvent(LogicalKeyboardKey.slash, character: '?'); + + // Advance the SnackBar entrance animation to the end. + await tester.pumpAndSettle(); + + expect(snackBarFinder, findsOneWidget); + + // Advance time by default SnackBar display duration. + await tester.pump(const Duration(milliseconds: 4000)); + + // Advance the SnackBar exit animation to the end. + await tester.pumpAndSettle(); + + expect(snackBarFinder, findsNothing); + }, + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/shortcuts/logical_key_set.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/shortcuts/logical_key_set.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..8c6c0a766d2d1ce2e2ba9b0c1fcd6681e3adeb39 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/shortcuts/logical_key_set.0_test.dart @@ -0,0 +1,118 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/services.dart'; +import 'package:flutter_api_samples/widgets/shortcuts/logical_key_set.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + Future sendKeyCombination( + WidgetTester tester, + List keys, + ) async { + for (final LogicalKeyboardKey key in keys) { + await tester.sendKeyDownEvent(key); + } + for (final LogicalKeyboardKey key in keys.reversed) { + await tester.sendKeyUpEvent(key); + } + } + + testWidgets('Verify correct labels are displayed', (WidgetTester tester) async { + await tester.pumpWidget( + const example.LogicalKeySetExampleApp(), + ); + + expect(find.text('LogicalKeySet Sample'), findsOneWidget); + expect( + find.text('Add to the counter by pressing Ctrl+C'), + findsOneWidget, + ); + expect(find.text('count: 0'), findsOneWidget); + }); + + testWidgets('CtrlLeft+C or C+CtrlLeft key combination updates counter', (WidgetTester tester) async { + await tester.pumpWidget( + const example.LogicalKeySetExampleApp(), + ); + + for (int counter = 0; counter < 10; counter++) { + expect(find.text('count: $counter'), findsOneWidget); + + await sendKeyCombination( + tester, + counter.isEven + ? [ + LogicalKeyboardKey.controlLeft, + LogicalKeyboardKey.keyC, + ] + : [ + LogicalKeyboardKey.keyC, + LogicalKeyboardKey.controlLeft, + ], + ); + await tester.pump(); + } + }); + + testWidgets('CtrlRight+C key combination updates counter', (WidgetTester tester) async { + await tester.pumpWidget( + const example.LogicalKeySetExampleApp(), + ); + + for (int counter = 0; counter < 10; counter++) { + expect(find.text('count: $counter'), findsOneWidget); + + await sendKeyCombination( + tester, + [ + LogicalKeyboardKey.controlRight, + LogicalKeyboardKey.keyC, + ], + ); + await tester.pump(); + } + }); + + testWidgets('CtrlLeft+A+C key combination does not update counter', (WidgetTester tester) async { + await tester.pumpWidget( + const example.LogicalKeySetExampleApp(), + ); + + for (int counter = 0; counter < 10; counter++) { + expect(find.text('count: 0'), findsOneWidget); + + await sendKeyCombination( + tester, + [ + LogicalKeyboardKey.controlLeft, + LogicalKeyboardKey.keyA, + LogicalKeyboardKey.keyC, + ], + ); + await tester.pump(); + } + }); + + testWidgets('CtrlRight+A+C key combination does not update counter', (WidgetTester tester) async { + await tester.pumpWidget( + const example.LogicalKeySetExampleApp(), + ); + + for (int counter = 0; counter < 10; counter++) { + expect(find.text('count: 0'), findsOneWidget); + + await sendKeyCombination( + tester, + [ + LogicalKeyboardKey.controlRight, + LogicalKeyboardKey.keyA, + LogicalKeyboardKey.keyC, + ], + ); + await tester.pump(); + } + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/shortcuts/shortcuts.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/shortcuts/shortcuts.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..0a9275140614ad82d529882c5da65193bbb7a611 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/shortcuts/shortcuts.0_test.dart @@ -0,0 +1,55 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/services.dart'; +import 'package:flutter_api_samples/widgets/shortcuts/shortcuts.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Verify correct labels are displayed', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ShortcutsExampleApp(), + ); + + expect(find.text('Shortcuts Sample'), findsOneWidget); + expect( + find.text('Add to the counter by pressing the up arrow key'), + findsOneWidget, + ); + expect( + find.text('Subtract from the counter by pressing the down arrow key'), + findsOneWidget, + ); + expect(find.text('count: 0'), findsOneWidget); + }); + + testWidgets('Up and down arrow press updates counter', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ShortcutsExampleApp(), + ); + + int counter = 0; + + while (counter < 10) { + expect(find.text('count: $counter'), findsOneWidget); + + // Increment the counter. + await tester.sendKeyEvent(LogicalKeyboardKey.arrowUp); + await tester.pump(); + + counter++; + } + + while (counter >= 0) { + expect(find.text('count: $counter'), findsOneWidget); + + // Decrement the counter. + await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown); + await tester.pump(); + + counter--; + } + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/shortcuts/shortcuts.1_test.dart b/novelforge-project/flutter/examples/api/test/widgets/shortcuts/shortcuts.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..17a2155739d6851f108f393383238be845cb601a --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/shortcuts/shortcuts.1_test.dart @@ -0,0 +1,55 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/services.dart'; +import 'package:flutter_api_samples/widgets/shortcuts/shortcuts.1.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Verify correct labels are displayed', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ShortcutsExampleApp(), + ); + + expect(find.text('Shortcuts Sample'), findsOneWidget); + expect( + find.text('Add to the counter by pressing the up arrow key'), + findsOneWidget, + ); + expect( + find.text('Subtract from the counter by pressing the down arrow key'), + findsOneWidget, + ); + expect(find.text('count: 0'), findsOneWidget); + }); + + testWidgets('Up and down arrow press updates counter', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ShortcutsExampleApp(), + ); + + int counter = 0; + + while (counter <= 10) { + expect(find.text('count: $counter'), findsOneWidget); + + // Increment the counter. + await tester.sendKeyEvent(LogicalKeyboardKey.arrowUp); + await tester.pump(); + + counter += 2; + } + + while (counter >= 0) { + expect(find.text('count: $counter'), findsOneWidget); + + // Decrement the counter. + await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown); + await tester.pump(); + + counter -= 2; + } + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/shortcuts/single_activator.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/shortcuts/single_activator.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..2be8c32126155a86b14707142605090be0d5ad0d --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/shortcuts/single_activator.0_test.dart @@ -0,0 +1,47 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/services.dart'; +import 'package:flutter_api_samples/widgets/shortcuts/single_activator.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + Future pressControlC(WidgetTester tester) async { + await tester.sendKeyDownEvent(LogicalKeyboardKey.control); + await tester.sendKeyDownEvent(LogicalKeyboardKey.keyC); + await tester.sendKeyUpEvent(LogicalKeyboardKey.keyC); + await tester.sendKeyUpEvent(LogicalKeyboardKey.control); + } + + group('SingleActivatorExampleApp', () { + testWidgets('displays correct labels', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SingleActivatorExampleApp(), + ); + + expect( + find.text('Add to the counter by pressing Ctrl+C'), + findsOneWidget, + ); + expect(find.text('count: 0'), findsOneWidget); + }); + + testWidgets( + 'updates counter when Ctrl-C combination pressed', + (WidgetTester tester) async { + await tester.pumpWidget( + const example.SingleActivatorExampleApp(), + ); + + for (int counter = 0; counter < 10; counter++) { + expect(find.text('count: $counter'), findsOneWidget); + + await pressControlC(tester); + await tester.pump(); + } + }, + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/sliver/decorated_sliver.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/sliver/decorated_sliver.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..6298215aca67cc05f0c49c5ef5f07c84c73a7226 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/sliver/decorated_sliver.0_test.dart @@ -0,0 +1,74 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/sliver/decorated_sliver.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Verify the texts are displayed', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SliverDecorationExampleApp(), + ); + + final Finder moonText = find.text('A moon on a night sky'); + expect(moonText, findsOneWidget); + + final Finder blueSkyText = find.text('A blue sky'); + expect(blueSkyText, findsOneWidget); + }); + + testWidgets('Verify the sliver with key `radial-gradient` has a RadialGradient', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SliverDecorationExampleApp(), + ); + + final DecoratedSliver radialDecoratedSliver = tester.widget( + find.byKey(const ValueKey('radial-gradient')), + ); + expect( + radialDecoratedSliver.decoration, + const BoxDecoration( + gradient: RadialGradient( + center: Alignment(-0.5, -0.6), + radius: 0.15, + colors: [ + Color(0xFFEEEEEE), + Color(0xFF111133), + ], + stops: [0.4, 0.8], + ), + ), + ); + }); + + testWidgets('Verify that the sliver with key `linear-gradient` has a LinearGradient', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SliverDecorationExampleApp(), + ); + + final DecoratedSliver linearDecoratedSliver = tester.widget( + find.byKey(const ValueKey('linear-gradient')), + ); + expect( + linearDecoratedSliver.decoration, + const BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [ + Color(0xFF111133), + Color(0xFF1A237E), + Color(0xFF283593), + Color(0xFF3949AB), + Color(0xFF3F51B5), + Color(0xFF1976D2), + Color(0xFF1E88E5), + Color(0xFF42A5F5), + ], + ), + ), + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/sliver/pinned_header_sliver.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/sliver/pinned_header_sliver.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..ac5dfbcacd113618c782d72ee2c91d3aeb27534f --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/sliver/pinned_header_sliver.0_test.dart @@ -0,0 +1,21 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/sliver/pinned_header_sliver.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('PinnedHeaderSliver example', (WidgetTester tester) async { + await tester.pumpWidget( + const example.PinnedHeaderSliverApp(), + ); + + expect(find.text('PinnedHeaderSliver'), findsOneWidget); + + await tester.tap(find.byType(FloatingActionButton)); + await tester.pumpAndSettle(); + expect(find.text('Alternative Title\nWith Two Lines'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/sliver/sliver_constrained_cross_axis.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/sliver/sliver_constrained_cross_axis.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..32f7093cdf3b2fa55c6323db7e142c754e334f4c --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/sliver/sliver_constrained_cross_axis.0_test.dart @@ -0,0 +1,20 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; +import 'package:flutter_api_samples/widgets/sliver/sliver_constrained_cross_axis.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('SliverConstrainedCrossAxis example', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SliverConstrainedCrossAxisExampleApp(), + ); + + final RenderSliverList renderSliverList = tester.renderObject(find.byType(SliverList)); + expect(renderSliverList.constraints.crossAxisExtent, equals(200)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/sliver/sliver_cross_axis_group.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/sliver/sliver_cross_axis_group.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..d49b6f5935b9e125aff4bd09af8d398312e23fac --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/sliver/sliver_cross_axis_group.0_test.dart @@ -0,0 +1,43 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; +import 'package:flutter_api_samples/widgets/sliver/sliver_cross_axis_group.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('SliverCrossAxisGroup example', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SliverCrossAxisGroupExampleApp(), + ); + + final RenderSliverCrossAxisGroup renderSliverGroup = tester.renderObject(find.byType(SliverCrossAxisGroup)); + expect(renderSliverGroup, isNotNull); + + final double crossAxisExtent = renderSliverGroup.constraints.crossAxisExtent; + + final List renderSliverLists = tester.renderObjectList(find.byType(SliverList)).toList(); + final RenderSliverList firstList = renderSliverLists[0]; + final RenderSliverList secondList = renderSliverLists[1]; + final RenderSliverList thirdList = renderSliverLists[2]; + + final double expectedFirstExtent = (crossAxisExtent - 200) / 3; + const double expectedSecondExtent = 200; + final double expectedThirdExtent = 2 * (crossAxisExtent - 200) / 3; + expect(firstList.constraints.crossAxisExtent, equals(expectedFirstExtent)); + expect(secondList.constraints.crossAxisExtent, equals(expectedSecondExtent)); + expect(thirdList.constraints.crossAxisExtent, equals(expectedThirdExtent)); + + // Also check that the paint offsets are correct. + final RenderSliverConstrainedCrossAxis renderConstrained = tester.renderObject( + find.byType(SliverConstrainedCrossAxis) + ); + + expect((firstList.parentData! as SliverPhysicalParentData).paintOffset.dx, equals(0)); + expect((renderConstrained.parentData! as SliverPhysicalParentData).paintOffset.dx, equals(expectedFirstExtent)); + expect((thirdList.parentData! as SliverPhysicalParentData).paintOffset.dx, equals(expectedFirstExtent + expectedSecondExtent)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/sliver/sliver_main_axis_group.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/sliver/sliver_main_axis_group.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..563b54739d843a7bf8af6ff3552cc675492b546e --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/sliver/sliver_main_axis_group.0_test.dart @@ -0,0 +1,30 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; +import 'package:flutter_api_samples/widgets/sliver/sliver_main_axis_group.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('SliverMainAxisGroup example', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SliverMainAxisGroupExampleApp(), + ); + + final RenderSliverMainAxisGroup renderSliverGroup = tester.renderObject(find.byType(SliverMainAxisGroup)); + expect(renderSliverGroup, isNotNull); + + final RenderSliverPersistentHeader renderAppBar = tester.renderObject(find.byType(SliverAppBar)); + final RenderSliverList renderSliverList = tester.renderObject(find.byType(SliverList)); + final RenderSliverToBoxAdapter renderSliverAdapter = tester.renderObject(find.byType(SliverToBoxAdapter)); + + // renderAppBar, renderSliverList, and renderSliverAdapter1 are part of the same sliver group. + expect(renderAppBar.geometry!.scrollExtent, equals(70.0)); + expect(renderSliverList.geometry!.scrollExtent, equals(100.0 * 5)); + expect(renderSliverAdapter.geometry!.scrollExtent, equals(100.0)); + expect(renderSliverGroup.geometry!.scrollExtent, equals(70.0 + 100.0 * 5 + 100.0)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/sliver/sliver_opacity.1_test.dart b/novelforge-project/flutter/examples/api/test/widgets/sliver/sliver_opacity.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..3c72f5ef3dfc1b65d66d4e941d5f2ca31c546026 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/sliver/sliver_opacity.1_test.dart @@ -0,0 +1,23 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/sliver/sliver_opacity.1.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('SliverOpacity example', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SliverOpacityExampleApp(), + ); + + final Finder button = find.byType(FloatingActionButton); + final Finder opacity = find.byType(SliverOpacity); + expect((tester.widget(opacity) as SliverOpacity).opacity, 1.0); + await tester.tap(button); + await tester.pump(); + expect((tester.widget(opacity) as SliverOpacity).opacity, 0.0); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/sliver/sliver_resizing_header.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/sliver/sliver_resizing_header.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..70a5a5ef1354f878a419cd183982f39663f8acc5 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/sliver/sliver_resizing_header.0_test.dart @@ -0,0 +1,26 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/sliver/sliver_resizing_header.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('SliverResizingHeader example', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SliverResizingHeaderApp(), + ); + + final Finder headerMaterial = find.text('SliverResizingHeader\nWith Two Optional\nLines of Text'); + final double initialHeight = tester.getSize(headerMaterial).height; + + await tester.drag(find.byType(CustomScrollView), const Offset(0, -200)); + await tester.pumpAndSettle(); + expect(tester.getSize(headerMaterial).height, lessThan(initialHeight / 2)); + + await tester.drag(find.byType(CustomScrollView), const Offset(0, 200)); + await tester.pumpAndSettle(); + expect(tester.getSize(headerMaterial).height, initialHeight); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/sliver/sliver_tree.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/sliver/sliver_tree.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..46d77c06f3bd2fa5cdb83db4bac299d3646bb7c4 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/sliver/sliver_tree.0_test.dart @@ -0,0 +1,21 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_api_samples/widgets/sliver/sliver_tree.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can toggle nodes in TreeSliver', (WidgetTester tester) async { + await tester.pumpWidget( + const example.TreeSliverExampleApp(), + ); + expect(find.text('Second'), findsOneWidget); + expect(find.text('alpha'), findsNothing); + // Toggle tree node. + await tester.tap(find.text('Second')); + await tester.pumpAndSettle(); + expect(find.text('alpha'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/sliver/sliver_tree.1_test.dart b/novelforge-project/flutter/examples/api/test/widgets/sliver/sliver_tree.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..d54f839c6bcd1a979b75615b98a1249a02838d81 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/sliver/sliver_tree.1_test.dart @@ -0,0 +1,21 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_api_samples/widgets/sliver/sliver_tree.1.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can toggle nodes in TreeSliver', (WidgetTester tester) async { + await tester.pumpWidget( + const example.TreeSliverExampleApp(), + ); + expect(find.text('lib'), findsOneWidget); + expect(find.text('src'), findsNothing); + // Toggle tree node. + await tester.tap(find.text('lib')); + await tester.pumpAndSettle(); + expect(find.text('src'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/sliver_fill/sliver_fill_remaining.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/sliver_fill/sliver_fill_remaining.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..cb60dc3bf9f93d7da17d83a979fc7a72b96a977a --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/sliver_fill/sliver_fill_remaining.0_test.dart @@ -0,0 +1,42 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/sliver_fill/sliver_fill_remaining.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('shows how SliverFillRemaining takes up remaining space', (WidgetTester tester) async { + await tester.pumpWidget(const example.SliverFillRemainingExampleApp()); + expect(find.text('SliverFillRemaining Sample'), findsOneWidget); + expect(find.byType(CustomScrollView), findsOneWidget); + + expect(find.descendant( + of: find.byType(SliverToBoxAdapter), + matching: find.byType(Container)), findsOneWidget); + final Container upperContainer = tester.widget(find.descendant( + of: find.byType(SliverToBoxAdapter), + matching: find.byType(Container))); + expect(upperContainer.color, Colors.amber[300]); + + expect(find.byType(SliverFillRemaining), findsOneWidget); + expect(find.descendant( + of: find.byType(SliverFillRemaining), + matching: find.byType(Container)), findsOneWidget); + expect(find.byIcon(Icons.sentiment_very_satisfied), findsOneWidget); + final Icon lowerIcon = tester.widget(find.descendant( + of: find.byType(SliverFillRemaining), + matching: find.byType(Icon))); + expect(lowerIcon.color, Colors.blue[900]); + + final double total = tester.getSize(find.byType(CustomScrollView)).height; + final double upperHeight = tester.getSize(find.descendant( + of: find.byType(SliverToBoxAdapter), + matching: find.byType(Container))).height; + final double lowerHeight = tester.getSize(find.descendant( + of: find.byType(SliverFillRemaining), + matching: find.byType(Icon))).height; + expect(upperHeight + lowerHeight, equals(total)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/sliver_fill/sliver_fill_remaining.1_test.dart b/novelforge-project/flutter/examples/api/test/widgets/sliver_fill/sliver_fill_remaining.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..de66a3ea692af06a7a6270a5fda416c84689cc46 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/sliver_fill/sliver_fill_remaining.1_test.dart @@ -0,0 +1,43 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/sliver_fill/sliver_fill_remaining.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Shows all elements', (WidgetTester tester) async { + await tester.pumpWidget(const example.SliverFillRemainingExampleApp()); + expect(find.text('SliverFillRemaining Sample'), findsOneWidget); + expect(find.byType(CustomScrollView), findsOneWidget); + expect(find.byWidgetPredicate((Widget widget) => (widget is Container) + && widget.color == Colors.amber[200]), + findsNWidgets(2)); + expect(find.byWidgetPredicate((Widget widget) => (widget is Container) + && widget.color == Colors.blue[200]), + findsOneWidget); + expect(find.byWidgetPredicate((Widget widget) => (widget is Container) + && widget.color == Colors.orange[300]), + findsOneWidget); + expect(find.byType(SliverFixedExtentList), findsOneWidget); + expect(find.byType(SliverFillRemaining), findsOneWidget); + expect(find.byType(FlutterLogo), findsOneWidget); + }); + + testWidgets('Fills up all available space', (WidgetTester tester) async { + await tester.pumpWidget(const example.SliverFillRemainingExampleApp()); + + final double listSpace = tester.getSize(find.byType(CustomScrollView)).height; + double contentHeight = 0.0; + for (final Widget widget in tester.widgetList(find.byWidgetPredicate( + (Widget widget) => + (widget is Container) + && [Colors.orange[300]!, Colors.blue[200]!, Colors.amber[200]!] + .contains(widget.color))) + ) { + contentHeight += tester.getSize(find.byWidget(widget)).height; + } + expectLater(contentHeight, equals(listSpace)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/sliver_fill/sliver_fill_remaining.2_test.dart b/novelforge-project/flutter/examples/api/test/widgets/sliver_fill/sliver_fill_remaining.2_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..5d3a5535de5f05b9a3fc9c123f4a850edfa240ca --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/sliver_fill/sliver_fill_remaining.2_test.dart @@ -0,0 +1,31 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/sliver_fill/sliver_fill_remaining.2.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Shows all elements', (WidgetTester tester) async { + await tester.pumpWidget(const example.SliverFillRemainingExampleApp()); + expect(find.text('SliverFillRemaining Sample'), findsOneWidget); + expect(find.byType(CustomScrollView), findsOneWidget); + expect(find.byType(SliverFixedExtentList), findsOneWidget); + + expect(find.byWidgetPredicate((Widget widget) => (widget is Container) + && widget.color == Colors.indigo[200], + skipOffstage: false, + ), findsNWidgets(3)); + expect(find.byWidgetPredicate((Widget widget) => (widget is Container) + && widget.color == Colors.orange[200] + ), findsNWidgets(2)); + expect(find.byType(Container, skipOffstage: false,), findsNWidgets(5)); + + expect(find.byType(SliverFillRemaining), findsNothing); + await tester.scrollUntilVisible(find.byType(SliverFillRemaining), 20); + expect(find.byType(SliverFillRemaining), findsOneWidget); + expect(find.byIcon(Icons.pan_tool), findsOneWidget); + expect(tester.widget(find.byIcon(Icons.pan_tool)).color, Colors.blueGrey); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/sliver_fill/sliver_fill_remaining.3_test.dart b/novelforge-project/flutter/examples/api/test/widgets/sliver_fill/sliver_fill_remaining.3_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..fbd88e9f1f330a66c1ae1ca5172020cf97c18ee6 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/sliver_fill/sliver_fill_remaining.3_test.dart @@ -0,0 +1,33 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/sliver_fill/sliver_fill_remaining.3.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Shows all elements', (WidgetTester tester) async { + await tester.pumpWidget(const example.SliverFillRemainingExampleApp()); + expect(find.text('SliverFillRemaining Sample'), findsOneWidget); + expect(find.byType(ElevatedButton), findsOneWidget); + expect(find.text('Bottom Pinned Button!'), findsOneWidget); + expect(find.byType(CustomScrollView), findsOneWidget); + final CustomScrollView scroll = tester.widget(find.byType(CustomScrollView)); + expect(scroll.physics, isA(). + having((BouncingScrollPhysics bsp) => bsp.parent, 'parent', isA())); + + expect(find.byWidgetPredicate((Widget widget) => (widget is Container) + && widget.color == Colors.tealAccent[700], + ), findsOneWidget); + expect(find.byWidgetPredicate((Widget widget) => (widget is Container) + && widget.color == Colors.teal[100] + ), findsOneWidget); + expect(find.byType(Container), findsNWidgets(2)); + + expect(find.byType(SliverFillRemaining), findsOneWidget); + final SliverFillRemaining fill = tester.widget(find.byType(SliverFillRemaining)); + expect(fill.hasScrollBody, false); + expect(fill.fillOverscroll, true); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/slotted_render_object_widget/slotted_multi_child_render_object_widget_mixin.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/slotted_render_object_widget/slotted_multi_child_render_object_widget_mixin.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..150d9e57fd1a3dde0860809337f922a4472f4fd5 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/slotted_render_object_widget/slotted_multi_child_render_object_widget_mixin.0_test.dart @@ -0,0 +1,41 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/widgets.dart'; +import 'package:flutter_api_samples/widgets/slotted_render_object_widget/slotted_multi_child_render_object_widget_mixin.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('shows two widgets arranged diagonally', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ExampleWidget(), + ); + + expect(find.text('topLeft'), findsOneWidget); + expect(find.text('bottomRight'), findsOneWidget); + + expect( + tester.getBottomRight(findContainerWithText('topLeft')), + tester.getTopLeft(findContainerWithText('bottomRight')), + ); + + expect( + tester.getSize(findContainerWithText('topLeft')), + const Size(200, 100), + ); + expect( + tester.getSize(findContainerWithText('bottomRight')), + const Size(30, 60), + ); + + expect( + tester.getSize(find.byType(example.Diagonal)), + const Size(200 + 30, 100 + 60), + ); + }); +} + +Finder findContainerWithText(String text) { + return find.ancestor(of: find.text(text), matching: find.byType(Container)); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/system_context_menu/system_context_menu.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/system_context_menu/system_context_menu.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..f8052e500b920f7bfc4b1df617bc6995a0b18c14 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/system_context_menu/system_context_menu.0_test.dart @@ -0,0 +1,67 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/system_context_menu/system_context_menu.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('only shows the system context menu on iOS when MediaQuery says it is supported', (WidgetTester tester) async { + await tester.pumpWidget( + Builder( + builder: (BuildContext context) { + final MediaQueryData mediaQueryData = MediaQuery.of(context); + return MediaQuery( + data: mediaQueryData.copyWith( + // Faking this value, which is usually set to true only on + // devices running iOS 16+. + supportsShowingSystemContextMenu: defaultTargetPlatform == TargetPlatform.iOS, + ), + child: const example.SystemContextMenuExampleApp(), + ); + }, + ), + ); + + expect(find.byType(SystemContextMenu), findsNothing); + + // Show the context menu. + final Finder textFinder = find.byType(EditableText); + await tester.longPress(textFinder); + tester.state(textFinder).showToolbar(); + await tester.pumpAndSettle(); + + switch (defaultTargetPlatform) { + case TargetPlatform.iOS: + expect(find.byType(SystemContextMenu), findsOneWidget); + expect(find.byType(AdaptiveTextSelectionToolbar), findsNothing); + case TargetPlatform.android: + case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.macOS: + case TargetPlatform.windows: + expect(find.byType(AdaptiveTextSelectionToolbar), findsOneWidget); + expect(find.byType(SystemContextMenu), findsNothing); + } + }, variant: TargetPlatformVariant.all(), skip: kIsWeb); // [intended] + + testWidgets('does not show the system context menu when not supported', (WidgetTester tester) async { + await tester.pumpWidget( + // By default, MediaQueryData.supportsShowingSystemContextMenu is false. + const example.SystemContextMenuExampleApp(), + ); + + expect(find.byType(SystemContextMenu), findsNothing); + + // Show the context menu. + final Finder textFinder = find.byType(EditableText); + await tester.longPress(textFinder); + tester.state(textFinder).showToolbar(); + await tester.pumpAndSettle(); + + expect(find.byType(AdaptiveTextSelectionToolbar), findsOneWidget); + expect(find.byType(SystemContextMenu), findsNothing); + }, variant: TargetPlatformVariant.all(), skip: kIsWeb); // [intended] +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/table/table.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/table/table.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..869fd605e684b4730b0561ab3ba6896c972765ff --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/table/table.0_test.dart @@ -0,0 +1,39 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/table/table.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Table has expected arrangement', (WidgetTester tester) async { + await tester.pumpWidget(const example.TableExampleApp()); + + final Table table = tester.widget(find.byType(Table)); + + // Check the defined columnWidths. + expect(table.columnWidths, const { + 0: IntrinsicColumnWidth(), + 1: FlexColumnWidth(), + 2: FixedColumnWidth(64), + }); + + // The table has two rows. + expect(table.children.length, 2); + + for (int i = 0; i < table.children.length; i++) { + // Each row has three containers. + expect(table.children[i].children.length, 3); + + // Returns the width of given widget. + double getWidgetWidth(Widget widget) { + return tester.getSize(find.byWidget(widget)).width; + } + + // Check table row container width. + expect(getWidgetWidth(table.children[i].children.first), equals(128)); + expect(getWidgetWidth(table.children[i].children[2]), equals(64)); + } + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/tap_region/text_field_tap_region.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/tap_region/text_field_tap_region.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..bd1e91f9a5becdd7e5bf59ef590ab25ef6aa57ee --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/tap_region/text_field_tap_region.0_test.dart @@ -0,0 +1,100 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/tap_region/text_field_tap_region.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('shows a text field with a zero count, and the spinner buttons', (WidgetTester tester) async { + await tester.pumpWidget( + const example.TapRegionApp(), + ); + + expect(find.byType(TextField), findsOneWidget); + expect(getFieldValue(tester).text, equals('0')); + expect(find.byIcon(Icons.add), findsOneWidget); + expect(find.byIcon(Icons.remove), findsOneWidget); + }); + + testWidgets('tapping increment/decrement works', (WidgetTester tester) async { + await tester.pumpWidget( + const example.TapRegionApp(), + ); + await tester.pump(); + + expect(getFieldValue(tester).text, equals('0')); + expect( + getFieldValue(tester).selection, + equals(const TextSelection.collapsed(offset: 1)), + ); + + await tester.tap(find.byIcon(Icons.add)); + await tester.pumpAndSettle(); + + expect(getFieldValue(tester).text, equals('1')); + expect( + getFieldValue(tester).selection, + equals(const TextSelection(baseOffset: 0, extentOffset: 1)), + ); + + await tester.tap(find.byIcon(Icons.remove)); + await tester.pumpAndSettle(); + await tester.tap(find.byIcon(Icons.remove)); + await tester.pumpAndSettle(); + + expect(getFieldValue(tester).text, equals('-1')); + expect( + getFieldValue(tester).selection, + equals(const TextSelection(baseOffset: 0, extentOffset: 2)), + ); + }); + + testWidgets('entering text and then incrementing/decrementing works', (WidgetTester tester) async { + await tester.pumpWidget( + const example.TapRegionApp(), + ); + await tester.pump(); + + await tester.tap(find.byIcon(Icons.add)); + await tester.pumpAndSettle(); + + expect(getFieldValue(tester).text, equals('1')); + expect( + getFieldValue(tester).selection, + equals(const TextSelection(baseOffset: 0, extentOffset: 1)), + ); + + await tester.enterText(find.byType(TextField), '123'); + await tester.pumpAndSettle(); + expect(getFieldValue(tester).text, equals('123')); + expect( + getFieldValue(tester).selection, + equals(const TextSelection.collapsed(offset: 3)), + ); + + await tester.tap(find.byIcon(Icons.remove)); + await tester.pumpAndSettle(); + await tester.tap(find.byIcon(Icons.remove)); + await tester.pumpAndSettle(); + + expect(getFieldValue(tester).text, equals('121')); + expect( + getFieldValue(tester).selection, + equals(const TextSelection(baseOffset: 0, extentOffset: 3)), + ); + final FocusNode textFieldFocusNode = Focus.of( + tester.element( + find.byWidgetPredicate((Widget widget) { + return widget.runtimeType.toString() == '_Editable'; + }), + ), + ); + expect(textFieldFocusNode.hasPrimaryFocus, isTrue); + }); +} + +TextEditingValue getFieldValue(WidgetTester tester) { + return (tester.widget(find.byType(TextField)) as TextField).controller!.value; +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/text/text.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/text/text.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..a854bb3af25baedbf2d40e013c3a0f719af560e4 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/text/text.0_test.dart @@ -0,0 +1,26 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/text/text.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('WidgetsApp test', (WidgetTester tester) async { + await tester.pumpWidget( + const example.DefaultTextStyleApp(), + ); + + expect(find.text('Flutter'), findsOneWidget); + + final RichText text = tester.firstWidget(find.byType(RichText)); + expect(text.text.style!.fontSize, 24); + expect(text.text.style!.fontWeight, FontWeight.bold); + + // Because this example uses Material 3 and a light brightness, the text color + // should be the color scheme `onSurface` color. + final Color textColor = ColorScheme.fromSeed(seedColor: Colors.purple).onSurface; + expect(text.text.style!.color, textColor); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/text_magnifier/text_magnifier.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/text_magnifier/text_magnifier.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..9d94d9373b4a494a450bcb43826f9459fa3916a0 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/text_magnifier/text_magnifier.0_test.dart @@ -0,0 +1,111 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; +import 'package:flutter_api_samples/widgets/text_magnifier/text_magnifier.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +List _globalize( + Iterable points, RenderBox box) { + return points.map((TextSelectionPoint point) { + return TextSelectionPoint( + box.localToGlobal(point.point), + point.direction, + ); + }).toList(); +} + +RenderEditable _findRenderEditable>(WidgetTester tester) { + return (tester.state(find.byType(TextField)) + as TextSelectionGestureDetectorBuilderDelegate) + .editableTextKey + .currentState! + .renderEditable; +} + +Offset _textOffsetToPosition>(WidgetTester tester, int offset) { + final RenderEditable renderEditable = _findRenderEditable(tester); + + final List endpoints = renderEditable + .getEndpointsForSelection( + TextSelection.collapsed(offset: offset), + ) + .map((TextSelectionPoint point) => TextSelectionPoint( + renderEditable.localToGlobal(point.point), + point.direction, + )) + .toList(); + + return endpoints[0].point + const Offset(0.0, -2.0); +} + +void main() { + const Duration durationBetweenActions = Duration(milliseconds: 20); + const String defaultText = 'I am a magnifier, fear me!'; + + Future showMagnifier(WidgetTester tester, String characterToTapOn) async { + final Offset tapOffset = _textOffsetToPosition(tester, defaultText.indexOf(characterToTapOn)); + + // Double tap 'Magnifier' word to show the selection handles. + final TestGesture testGesture = await tester.startGesture(tapOffset); + await tester.pump(durationBetweenActions); + await testGesture.up(); + await tester.pump(durationBetweenActions); + await testGesture.down(tapOffset); + await tester.pump(durationBetweenActions); + await testGesture.up(); + await tester.pumpAndSettle(); + + final TextSelection selection = tester + .firstWidget(find.byType(TextField)) + .controller! + .selection; + + final RenderEditable renderEditable = _findRenderEditable(tester); + final List endpoints = _globalize( + renderEditable.getEndpointsForSelection(selection), + renderEditable, + ); + + final Offset handlePos = endpoints.last.point + const Offset(10.0, 10.0); + + final TestGesture gesture = await tester.startGesture(handlePos); + + await gesture.moveTo( + _textOffsetToPosition( + tester, + defaultText.length - 2, + ), + ); + await tester.pump(); + } + + testWidgets('should show custom magnifier on drag', (WidgetTester tester) async { + await tester.pumpWidget(const example.TextMagnifierExampleApp(text: defaultText)); + + await showMagnifier(tester, 'e'); + expect(find.byType(example.CustomMagnifier), findsOneWidget); + + await expectLater( + find.byType(example.TextMagnifierExampleApp), + matchesGoldenFile('text_magnifier.0_test.png'), + ); + }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.android })); + + + for (final TextDirection textDirection in TextDirection.values) { + testWidgets('should show custom magnifier in $textDirection', (WidgetTester tester) async { + final String text = textDirection == TextDirection.rtl ? 'أثارت زر' : defaultText; + final String textToTapOn = textDirection == TextDirection.rtl ? 'ت' : 'e'; + + await tester.pumpWidget(example.TextMagnifierExampleApp(textDirection: textDirection, text: text)); + + await showMagnifier(tester, textToTapOn); + + expect(find.byType(example.CustomMagnifier), findsOneWidget); + }); + } +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/transitions/align_transition.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/transitions/align_transition.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..f321592de37ab9f4d3845f3963baf6230fc7f3a8 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/transitions/align_transition.0_test.dart @@ -0,0 +1,49 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/transitions/align_transition.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Shows flutter logo in transition', (WidgetTester tester) async { + await tester.pumpWidget(const example.AlignTransitionExampleApp()); + expect(find.byType(ColoredBox), findsOneWidget); + expect( + find.byWidgetPredicate((Widget padding) => padding is Padding + && padding.padding == const EdgeInsets.all(8.0)), + findsOneWidget, + ); + expect(find.byType(FlutterLogo), findsOneWidget); + expect(find.byType(AlignTransition), findsOneWidget); + }); + + testWidgets('Animates repeatedly every 2 seconds', (WidgetTester tester) async { + await tester.pumpWidget(const example.AlignTransitionExampleApp()); + final Finder paddingFinder = find.byWidgetPredicate( + (Widget padding) => padding is Padding + && padding.padding == const EdgeInsets.all(8.0)); + + expect( + tester.getBottomLeft(paddingFinder), + tester.getBottomLeft(find.byType(AlignTransition)), + ); + + await tester.pump(const Duration(seconds: 2)); + await tester.pump(); + + expect( + tester.getCenter(paddingFinder), + tester.getCenter(find.byType(AlignTransition)), + ); + + await tester.pump(const Duration(seconds: 2)); + await tester.pump(); + + expect( + tester.getBottomLeft(paddingFinder), + tester.getBottomLeft(find.byType(AlignTransition)), + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/transitions/animated_builder.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/transitions/animated_builder.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..84735c358ce0f1ca196a44f27790745621fc623c --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/transitions/animated_builder.0_test.dart @@ -0,0 +1,30 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:math' as math; + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/transitions/animated_builder.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Rotates text and container', (WidgetTester tester) async { + await tester.pumpWidget(const example.AnimatedBuilderExampleApp()); + expect(find.text('Whee!'), findsOneWidget); + expect(find.byType(Container), findsOneWidget); + expect(tester.widget(find.byType(Container)), isA() + .having((Container container) => container.color, 'color', Colors.green)); + + expect(find.byWidgetPredicate((Widget widget) => widget is Transform + && widget.transform == Transform.rotate(angle: 0.0).transform), + findsOneWidget); + + await tester.pump(const Duration(seconds: 5)); + await tester.pump(); + + expect(find.byWidgetPredicate((Widget widget) => widget is Transform + && widget.transform == Transform.rotate(angle: math.pi).transform), + findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/transitions/animated_widget.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/transitions/animated_widget.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..46b6de6efcfd5fb9f8824fa11c00b9c1ff95b602 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/transitions/animated_widget.0_test.dart @@ -0,0 +1,29 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:math' as math; + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/transitions/animated_widget.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Rotates green container', (WidgetTester tester) async { + await tester.pumpWidget(const example.AnimatedWidgetExampleApp()); + expect(find.byType(Container), findsOneWidget); + expect(tester.widget(find.byType(Container)), isA() + .having((Container container) => container.color, 'color', Colors.green)); + + expect(find.byWidgetPredicate((Widget widget) => widget is Transform + && widget.transform == Transform.rotate(angle: 0.0).transform), + findsOneWidget); + + await tester.pump(const Duration(seconds: 5)); + await tester.pump(); + + expect(find.byWidgetPredicate((Widget widget) => widget is Transform + && widget.transform == Transform.rotate(angle: math.pi).transform), + findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/transitions/decorated_box_transition.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/transitions/decorated_box_transition.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..95b26ee0e034a32d6939b14e28a6d8a2f5547f9b --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/transitions/decorated_box_transition.0_test.dart @@ -0,0 +1,66 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/transitions/decorated_box_transition.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Shows container in 3 second loop', (WidgetTester tester) async { + await tester.pumpWidget(const example.DecoratedBoxTransitionExampleApp()); + expect(find.byType(FlutterLogo), findsOneWidget); + expect(find.byType(Center), findsOneWidget); + expect(find.descendant( + of: find.byType(Center), + matching: find.byType(FlutterLogo) + ), findsOneWidget); + expect(find.ancestor( + of: find.byType(FlutterLogo), + matching: find.byType(Container) + ), findsAtLeast(1)); + expect(find.byType(DecoratedBoxTransition), findsOneWidget); + + expect( + tester.widget(find.byType(DecoratedBoxTransition)), + isA() + .having( + (DecoratedBoxTransition transition) => transition.decoration.value, + 'decoration', + BoxDecoration( + color: const Color(0xFFFFFFFF), + border: Border.all(style: BorderStyle.none), + borderRadius: BorderRadius.circular(60.0), + boxShadow: const [ + BoxShadow( + color: Color(0x66666666), + blurRadius: 10.0, + spreadRadius: 3.0, + offset: Offset(0, 6.0), + ), + ], + ), + ), + ); + + await tester.pump(const Duration(seconds: 3)); + await tester.pump(); + + expect( + tester.widget(find.byType(DecoratedBoxTransition)), + isA() + .having( + (DecoratedBoxTransition transition) => transition.decoration.value, + 'decoration', + BoxDecoration( + color: const Color(0xFFFFFFFF), + border: Border.all( + style: BorderStyle.none, + ), + borderRadius: BorderRadius.zero, + // No shadow. + ), + ), + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/transitions/default_text_style_transition.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/transitions/default_text_style_transition.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..f31d4f10392cc98ecc868bc5b9144b2131a82797 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/transitions/default_text_style_transition.0_test.dart @@ -0,0 +1,56 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/transitions/default_text_style_transition.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Transforms text style periodically', (WidgetTester tester) async { + await tester.pumpWidget(const example.DefaultTextStyleTransitionExampleApp()); + expect(find.byType(Center), findsOneWidget); + expect(find.byType(Text), findsOneWidget); + expect(find.text('Flutter'), findsOneWidget); + expect( + find.descendant( + of: find.byType(Center), + matching: find.byType(Text) + ), + findsOneWidget, + ); + expect(find.byType(DefaultTextStyleTransition), findsOneWidget); + expect(tester.widget(find.byType(DefaultTextStyleTransition)), + isA() + .having( + (DefaultTextStyleTransition transition) => transition.style.value, + 'style', + const TextStyle(fontSize: 50, color: Colors.blue, fontWeight: FontWeight.w900), + ), + ); + + await tester.pump(const Duration(seconds: 2)); + await tester.pump(); + + expect(tester.widget(find.byType(DefaultTextStyleTransition)), + isA() + .having( + (DefaultTextStyleTransition transition) => transition.style.value, + 'style', + const TextStyle(fontSize: 50, color: Colors.red, fontWeight: FontWeight.w100), + ), + ); + + await tester.pump(const Duration(seconds: 2)); + await tester.pump(); + + expect(tester.widget(find.byType(DefaultTextStyleTransition)), + isA() + .having( + (DefaultTextStyleTransition transition) => transition.style.value, + 'style', + const TextStyle(fontSize: 50, color: Colors.blue, fontWeight: FontWeight.w900), + ), + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/transitions/fade_transition.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/transitions/fade_transition.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..1bed187a93fe8e46ed378d7e00a51a6126888519 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/transitions/fade_transition.0_test.dart @@ -0,0 +1,83 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:ui'; + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/transitions/fade_transition.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Shows FlutterLogo inside a FadeTransition', (WidgetTester tester) async { + await tester.pumpWidget( + const example.FadeTransitionExampleApp(), + ); + + expect( + find.ancestor( + of: find.byType(FlutterLogo), + matching: find.byType(FadeTransition), + ), + findsOneWidget, + ); + }); + + testWidgets('FadeTransition animates', (WidgetTester tester) async { + await tester.pumpWidget( + const example.FadeTransitionExampleApp(), + ); + + final Finder fadeTransitionFinder = find.ancestor( + of: find.byType(FlutterLogo), + matching: find.byType(FadeTransition), + ); + + const double beginOpacity = 0.0; + const double endOpacity = 1.0; + + FadeTransition fadeTransition = tester.widget(fadeTransitionFinder); + expect(fadeTransition.opacity.value, equals(beginOpacity)); + + // Advance animation to the middle. + await tester.pump( + example.FadeTransitionExampleApp.duration ~/ 2, + ); + + final double t = example.FadeTransitionExampleApp.curve.transform(0.5); + + fadeTransition = tester.widget(fadeTransitionFinder); + expect( + fadeTransition.opacity.value, + equals(lerpDouble(beginOpacity, endOpacity, t)), + ); + + // Advance animation to the end. + await tester.pump( + example.FadeTransitionExampleApp.duration ~/ 2, + ); + + fadeTransition = tester.widget(fadeTransitionFinder); + expect(fadeTransition.opacity.value, equals(endOpacity)); + + // Advance animation to the middle. + await tester.pump( + example.FadeTransitionExampleApp.duration ~/ 2, + ); + + fadeTransition = tester.widget(fadeTransitionFinder); + expect( + fadeTransition.opacity.value, + equals(lerpDouble(beginOpacity, endOpacity, t)), + ); + + // Advance animation to the end. + await tester.pump( + example.FadeTransitionExampleApp.duration ~/ 2, + ); + + fadeTransition = tester.widget(fadeTransitionFinder); + expect(fadeTransition.opacity.value, equals(beginOpacity)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/transitions/listenable_builder.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/transitions/listenable_builder.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..68e38c0c90ebaddd8967d31fcc19db5c6c376091 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/transitions/listenable_builder.0_test.dart @@ -0,0 +1,43 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/transitions/listenable_builder.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Changing focus changes border', (WidgetTester tester) async { + await tester.pumpWidget(const example.ListenableBuilderExample()); + + Finder findContainer() => find.descendant(of: find.byType(example.FocusListenerContainer), matching: find.byType(Container)).first; + Finder findChild() => find.descendant(of: findContainer(), matching: find.byType(Column)).first; + bool childHasFocus() => Focus.of(tester.element(findChild())).hasFocus; + Container getContainer() => tester.widget(findContainer()) as Container; + ShapeDecoration getDecoration() => getContainer().decoration! as ShapeDecoration; + OutlinedBorder getBorder() => getDecoration().shape as OutlinedBorder; + + expect(find.text('Company'), findsOneWidget); + expect(find.text('First Name'), findsOneWidget); + expect(find.text('Last Name'), findsOneWidget); + + await tester.tap(find.byType(TextField).first); + await tester.pumpAndSettle(); + expect(childHasFocus(), isFalse); + expect(getBorder().side.width, equals(1)); + expect(getContainer().color, isNull); + expect(getDecoration().color, isNull); + + await tester.tap(find.byType(TextField).at(1)); + await tester.pumpAndSettle(); + expect(childHasFocus(), isTrue); + expect(getBorder().side.width, equals(4)); + expect(getDecoration().color, equals(Colors.blue.shade50)); + + await tester.tap(find.byType(TextField).at(2)); + await tester.pumpAndSettle(); + expect(childHasFocus(), isTrue); + expect(getBorder().side.width, equals(4)); + expect(getDecoration().color, equals(Colors.blue.shade50)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/transitions/listenable_builder.1_test.dart b/novelforge-project/flutter/examples/api/test/widgets/transitions/listenable_builder.1_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..00f18d1c28b12fec9c68b64f7b08df05d11a4831 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/transitions/listenable_builder.1_test.dart @@ -0,0 +1,24 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/transitions/listenable_builder.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Tapping FAB increments counter', (WidgetTester tester) async { + await tester.pumpWidget(const example.ListenableBuilderExample()); + + String getCount() => (tester.widget(find.descendant(of: find.byType(ListenableBuilder), matching: find.byType(Text))) as Text).data!; + + expect(find.text('Current counter value:'), findsOneWidget); + expect(find.text('0'), findsOneWidget); + expect(find.byIcon(Icons.add), findsOneWidget); + expect(getCount(), equals('0')); + + await tester.tap(find.byType(FloatingActionButton).first); + await tester.pumpAndSettle(); + expect(getCount(), equals('1')); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/transitions/listenable_builder.2_test.dart b/novelforge-project/flutter/examples/api/test/widgets/transitions/listenable_builder.2_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..60b6e22d1acb3c7b47672e9735a473db8e7a95fc --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/transitions/listenable_builder.2_test.dart @@ -0,0 +1,34 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/transitions/listenable_builder.2.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Increments counter', (WidgetTester tester) async { + await tester.pumpWidget(const example.ListenableBuilderExample()); + expect(find.text('ListenableBuilder Example'), findsOneWidget); + expect(find.text('Current counter value:'), findsOneWidget); + expect(find.byIcon(Icons.add), findsOneWidget); + expect(find.descendant( + of: find.byType(FloatingActionButton), + matching: find.byIcon(Icons.add) + ), findsOneWidget); + + + expect(find.text('0'), findsOneWidget); + expect(find.text('1'), findsNothing); + await tester.tap(find.byIcon(Icons.add)); + await tester.pump(); + expect(find.text('0'), findsNothing); + expect(find.text('1'), findsOneWidget); + + for (int i = 0; i < 4; i++) { + await tester.tap(find.byIcon(Icons.add)); + } + await tester.pump(); + expect(find.text('5'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/transitions/listenable_builder.3_test.dart b/novelforge-project/flutter/examples/api/test/widgets/transitions/listenable_builder.3_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..a618a4999b207351d101a5c386fb3ff5e970fbc8 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/transitions/listenable_builder.3_test.dart @@ -0,0 +1,34 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/transitions/listenable_builder.3.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Tapping FAB adds to values', (WidgetTester tester) async { + await tester.pumpWidget(const example.ListenableBuilderExample()); + + final Finder listContent = find.byWidgetPredicate((Widget widget) => widget is example.ListBody); + + expect(find.text('Current values:'), findsOneWidget); + expect(find.byIcon(Icons.add), findsOneWidget); + expect( + (tester.widget(listContent) as example.ListBody).listNotifier.values.isEmpty, + isTrue, + ); + + await tester.tap(find.byType(FloatingActionButton).first); + await tester.pumpAndSettle(); + expect( + (tester.widget(listContent) as example.ListBody).listNotifier.values.isEmpty, + isFalse, + ); + expect( + (tester.widget(listContent) as example.ListBody).listNotifier.values, + [1464685455], + ); + expect(find.text('1464685455'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/transitions/matrix_transition.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/transitions/matrix_transition.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..afa0ddabf6ba394ee3ce5f951b3ed160c1ca8ddd --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/transitions/matrix_transition.0_test.dart @@ -0,0 +1,56 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/transitions/matrix_transition.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Shows Flutter logo inside a MatrixTransition', (WidgetTester tester) async { + await tester.pumpWidget( + const example.MatrixTransitionExampleApp(), + ); + + final Finder transformFinder = find.ancestor( + of: find.byType(FlutterLogo), + matching: find.byType(MatrixTransition), + ); + expect(transformFinder, findsOneWidget); + }); + + testWidgets('MatrixTransition animates', (WidgetTester tester) async { + await tester.pumpWidget( + const example.MatrixTransitionExampleApp(), + ); + + final Finder transformFinder = find.ancestor( + of: find.byType(FlutterLogo), + matching: find.byType(Transform), + ); + + Transform transformBox = tester.widget(transformFinder); + Matrix4 actualTransform = transformBox.transform; + + // Check initial transform. + expect(actualTransform, Matrix4.fromList([ + 1.0, 0.0, 0.0, 0.0, + 0.0, 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, 0.0, + 0.0, 0.0, 0.004, 1.0, + ])..transpose()); + + // Animate half way. + await tester.pump(const Duration(seconds: 1)); + transformBox = tester.widget(transformFinder); + actualTransform = transformBox.transform; + + // The transform should be updated. + expect(actualTransform, isNot(Matrix4.fromList([ + 1.0, 0.0, 0.0, 0.0, + 0.0, 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, 0.0, + 0.0, 0.0, 0.004, 1.0, + ])..transpose())); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/transitions/positioned_transition.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/transitions/positioned_transition.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..94945e8576ec9d97c199145db9a81e5d5ed073ae --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/transitions/positioned_transition.0_test.dart @@ -0,0 +1,42 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/transitions/positioned_transition.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Shows flutter logo in transition', (WidgetTester tester) async { + await tester.pumpWidget(const example.PositionedTransitionExampleApp()); + expect(find.byType(FlutterLogo), findsOneWidget); + expect(find.byType(Padding), findsAtLeast(1)); + expect(find.byType(PositionedTransition), findsOneWidget); + }); + + testWidgets('Animates repeatedly every 2 seconds', (WidgetTester tester) async { + await tester.pumpWidget(const example.PositionedTransitionExampleApp()); + + expect(tester.getSize(find.byType(FlutterLogo)), const Size(100.0 - 2.0 * 8.0, 100.0 - 2.0 * 8.0)); + expect(tester.getTopLeft(find.byType(FlutterLogo)), const Offset(8.0, 8.0)); + + await tester.pump(const Duration(seconds: 2)); + await tester.pump(); + + final Size canvasSize = tester.getSize(find.byType(LayoutBuilder)); + expect(tester.getSize(find.byType(FlutterLogo)), const Size(200.0 - 2.0 * 8.0, 200.0 - 2.0 * 8.0)); + expect(tester.getBottomRight(find.byType(FlutterLogo)), Offset(canvasSize.width - 8.0, canvasSize.height - 8.0)); + + await tester.pump(const Duration(seconds: 2)); + await tester.pump(); + + expect(tester.getSize(find.byType(FlutterLogo)), const Size(100.0 - 2.0 * 8.0, 100.0 - 2.0 * 8.0)); + expect(tester.getTopLeft(find.byType(FlutterLogo)), const Offset(8.0, 8.0)); + + await tester.pump(const Duration(seconds: 2)); + await tester.pump(); + + expect(tester.getSize(find.byType(FlutterLogo)), const Size(200.0 - 2.0 * 8.0, 200.0 - 2.0 * 8.0)); + expect(tester.getBottomRight(find.byType(FlutterLogo)), Offset(canvasSize.width - 8.0, canvasSize.height - 8.0)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/transitions/relative_positioned_transition.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/transitions/relative_positioned_transition.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..0cd06b3219810305dec3e994978743c942332859 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/transitions/relative_positioned_transition.0_test.dart @@ -0,0 +1,42 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/transitions/relative_positioned_transition.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Shows flutter logo in transition', (WidgetTester tester) async { + await tester.pumpWidget(const example.RelativePositionedTransitionExampleApp()); + expect(find.byType(FlutterLogo), findsOneWidget); + expect(find.byType(Padding), findsAtLeast(1)); + expect(find.byType(RelativePositionedTransition), findsOneWidget); + }); + + testWidgets('Animates repeatedly every 2 seconds', (WidgetTester tester) async { + await tester.pumpWidget(const example.RelativePositionedTransitionExampleApp()); + + expect(tester.getSize(find.byType(FlutterLogo)), const Size(200.0 - 2.0 * 8.0, 200.0 - 2.0 * 8.0)); + expect(tester.getTopLeft(find.byType(FlutterLogo)), const Offset(8.0, 8.0)); + + await tester.pump(const Duration(seconds: 2)); + await tester.pump(); + + final Size canvasSize = tester.getSize(find.byType(LayoutBuilder)); + expect(tester.getSize(find.byType(FlutterLogo)), const Size(100.0 - 2.0 * 8.0, 100.0 - 2.0 * 8.0)); + expect(tester.getBottomRight(find.byType(FlutterLogo)), Offset(canvasSize.width - 8.0, canvasSize.height - 8.0)); + + await tester.pump(const Duration(seconds: 2)); + await tester.pump(); + + expect(tester.getSize(find.byType(FlutterLogo)), const Size(200.0 - 2.0 * 8.0, 200.0 - 2.0 * 8.0)); + expect(tester.getTopLeft(find.byType(FlutterLogo)), const Offset(8.0, 8.0)); + + await tester.pump(const Duration(seconds: 2)); + await tester.pump(); + + expect(tester.getSize(find.byType(FlutterLogo)), const Size(100.0 - 2.0 * 8.0, 100.0 - 2.0 * 8.0)); + expect(tester.getBottomRight(find.byType(FlutterLogo)), Offset(canvasSize.width - 8.0, canvasSize.height - 8.0)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/transitions/rotation_transition.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/transitions/rotation_transition.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..5cd269aeb7e672edc285d190f2b67efe50fb1365 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/transitions/rotation_transition.0_test.dart @@ -0,0 +1,46 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/transitions/rotation_transition.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Shows flutter logo in rotation transition', (WidgetTester tester) async { + await tester.pumpWidget(const example.RotationTransitionExampleApp()); + expect( + find.byWidgetPredicate((Widget widget) => widget is RotationTransition + && widget.turns is CurvedAnimation + && (widget.turns as CurvedAnimation).curve == Curves.elasticOut, + ), findsOneWidget); + expect(find.byType(FlutterLogo), findsOneWidget); + expect(find.byType(Padding), findsAtLeast(1)); + expect( + find.descendant( + of: find.byType(Center), + matching: find.byType(FlutterLogo) + ), + findsOneWidget, + ); + + expect( + find.byWidgetPredicate((Widget widget) => widget is RotationTransition + && widget.turns is CurvedAnimation + && widget.turns.value == 0.0 + && widget.turns.status == AnimationStatus.forward + ), findsOneWidget); + + await tester.pump(); + await tester.pump(const Duration(seconds: 3)); + await tester.pump(); + + expect( + find.byWidgetPredicate((Widget widget) => widget is RotationTransition + && widget.turns is CurvedAnimation + && (widget.turns as CurvedAnimation).parent is AnimationController + && ((widget.turns as CurvedAnimation).parent as AnimationController).value == 0.5 + && widget.turns.status == AnimationStatus.reverse + ), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/transitions/scale_transition.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/transitions/scale_transition.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..785058ed3c7cd7a8232426adb0600de80ba41d94 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/transitions/scale_transition.0_test.dart @@ -0,0 +1,47 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/transitions/scale_transition.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Shows flutter logo in transition', (WidgetTester tester) async { + await tester.pumpWidget(const example.ScaleTransitionExampleApp()); + expect(find.byType(FlutterLogo), findsOneWidget); + expect(find.byType(Center), findsOneWidget); + expect(find.descendant( + of: find.byType(Center), + matching: find.byType(ScaleTransition) + ), findsOneWidget); + expect( + find.byWidgetPredicate((Widget widget) => widget is ScaleTransition + && widget.scale is CurvedAnimation + && (widget.scale as CurvedAnimation).curve == Curves.fastOutSlowIn, + ), findsOneWidget); + }); + + testWidgets('Scales every 2 seconds', (WidgetTester tester) async { + await tester.pumpWidget(const example.ScaleTransitionExampleApp()); + final Finder transformFinder = find.descendant( + of: find.byType(Center), + matching: find.byType(Transform) + ); + + Transform transform = tester.widget(transformFinder); + expect(transform.transform[0], 0); + + await tester.pump(const Duration(seconds: 2)); + await tester.pump(); + + transform = tester.widget(transformFinder); + expect(transform.transform[0], 1.0); + + await tester.pump(const Duration(seconds: 2)); + await tester.pump(); + + transform = tester.widget(transformFinder); + expect(transform.transform[0], 0); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/transitions/size_transition.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/transitions/size_transition.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..d3228e20db9fea40b0f03a7794b1ffa5d13f4574 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/transitions/size_transition.0_test.dart @@ -0,0 +1,32 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/transitions/size_transition.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Shows flutter logo in transition', (WidgetTester tester) async { + await tester.pumpWidget(const example.SizeTransitionExampleApp()); + expect(find.byType(FlutterLogo), findsOneWidget); + expect(find.byType(Center), findsOneWidget); + expect(find.descendant( + of: find.byType(Center), + matching: find.byType(FlutterLogo) + ), findsOneWidget); + expect(find.byType(SizeTransition), findsOneWidget); + + expect( + tester.widget(find.byType(SizeTransition)), + isA() + .having((SizeTransition transition) => transition.axis, 'axis', Axis.horizontal) + .having((SizeTransition transition) => transition.axisAlignment, 'axis alignment', -1) + .having((SizeTransition transition) => transition.sizeFactor, 'factor', isA() + .having((CurvedAnimation animation) => animation.curve, 'curve', Curves.fastOutSlowIn) + .having((CurvedAnimation animation) => animation.parent, 'paren', isA() + .having((AnimationController controller) => controller.duration, 'duration', const Duration(seconds: 3))) + ) + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/transitions/slide_transition.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/transitions/slide_transition.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..a637caca8a531a963ede66e896306863fe671988 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/transitions/slide_transition.0_test.dart @@ -0,0 +1,44 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/transitions/slide_transition.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Shows flutter logo in transition', (WidgetTester tester) async { + await tester.pumpWidget(const example.SlideTransitionExampleApp()); + expect(find.text('SlideTransition Sample'), findsOneWidget); + expect(find.byType(Center), findsOneWidget); + expect(find.byType(FlutterLogo), findsOneWidget); + expect(find.byType(Padding), findsAtLeast(1)); + expect(find.byType(SlideTransition), findsOneWidget); + }); + + testWidgets('Animates repeatedly every 2 seconds', (WidgetTester tester) async { + await tester.pumpWidget(const example.SlideTransitionExampleApp()); + + expect( + tester.getCenter(find.byType(FlutterLogo)), + tester.getCenter(find.byType(Center)), + ); + + await tester.pump(const Duration(seconds: 2)); + await tester.pump(); + + final double width = tester.getSize(find.byType(FlutterLogo)).width + 2 * 8.0; + expect( + tester.getCenter(find.byType(FlutterLogo)).dx, + tester.getCenter(find.byType(Center)).dx + 1.5 * width, + ); + + await tester.pump(const Duration(seconds: 2)); + await tester.pump(); + + expect( + tester.getCenter(find.byType(FlutterLogo)), + tester.getCenter(find.byType(Center)), + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/transitions/sliver_fade_transition.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/transitions/sliver_fade_transition.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..e766e3f96e209aa058667d469db53deffdf6f088 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/transitions/sliver_fade_transition.0_test.dart @@ -0,0 +1,44 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; +import 'package:flutter_api_samples/widgets/transitions/sliver_fade_transition.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Shows color list in transition', (WidgetTester tester) async { + await tester.pumpWidget(const example.SliverFadeTransitionExampleApp()); + expect(find.text('SliverFadeTransition Sample'), findsOneWidget); + expect(find.byType(SliverFadeTransition), findsOneWidget); + expect(find.byType(CustomScrollView), findsOneWidget); + expect(find.byWidgetPredicate( + (Widget widget) => widget is Container && + widget.color == Colors.indigo[200] + ), findsNWidgets(3)); + expect(find.byWidgetPredicate( + (Widget widget) => widget is Container && + widget.color == Colors.orange[200] + ), findsNWidgets(2)); + }); + + testWidgets('Animates repeatedly every second', (WidgetTester tester) async { + await tester.pumpWidget(const example.SliverFadeTransitionExampleApp()); + + expect( + tester.renderObject(find.byType(SliverFadeTransition)), + isA() + .having((RenderSliverAnimatedOpacity obj) => obj.opacity.value, 'opacity', 0.0) + ); + + await tester.pump(const Duration(seconds: 1)); + await tester.pump(); + + expect( + tester.renderObject(find.byType(SliverFadeTransition)), + isA() + .having((RenderSliverAnimatedOpacity obj) => obj.opacity.value, 'opacity', 1.0) + ); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/tween_animation_builder/tween_animation_builder.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/tween_animation_builder/tween_animation_builder.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..6a2c67a1d888886dc6faa879e7ba5ce65d449739 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/tween_animation_builder/tween_animation_builder.0_test.dart @@ -0,0 +1,160 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:ui'; + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/tween_animation_builder/tween_animation_builder.0.dart' + as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Animates icon size on first build', (WidgetTester tester) async { + await tester.pumpWidget( + const example.TweenAnimationBuilderExampleApp(), + ); + + // The animation duration defined in the example app. + const Duration animationDuration = Duration(seconds: 1); + + const double beginSize = 0.0; + const double endSize = 24.0; + + final Finder iconButtonFinder = find.byType(IconButton); + + IconButton iconButton = tester.widget(iconButtonFinder); + expect(iconButton.iconSize, equals(beginSize)); + + // Advance animation to the middle. + await tester.pump(animationDuration ~/ 2); + + iconButton = tester.widget(iconButtonFinder); + expect( + iconButton.iconSize, + equals(lerpDouble(beginSize, endSize, 0.5)), + ); + + // Advance animation to the end. + await tester.pump(animationDuration ~/ 2); + + iconButton = tester.widget(iconButtonFinder); + expect(iconButton.iconSize, equals(endSize)); + }); + + testWidgets('Animates icon size on IconButton tap', (WidgetTester tester) async { + await tester.pumpWidget( + const example.TweenAnimationBuilderExampleApp(), + ); + await tester.pumpAndSettle(); + + // The animation duration defined in the example app. + const Duration animationDuration = Duration(seconds: 1); + + const double beginSize = 24.0; + const double endSize = 48.0; + + final Finder iconButtonFinder = find.byType(IconButton); + + IconButton iconButton = tester.widget(iconButtonFinder); + expect(iconButton.iconSize, equals(beginSize)); + + // Tap on the IconButton to start the forward animation. + await tester.tap(iconButtonFinder); + await tester.pump(); + + iconButton = tester.widget(iconButtonFinder); + expect(iconButton.iconSize, equals(beginSize)); + + // Advance animation to the middle. + await tester.pump(animationDuration ~/ 2); + + iconButton = tester.widget(iconButtonFinder); + expect( + iconButton.iconSize, + equals(lerpDouble(beginSize, endSize, 0.5)), + ); + + // Advance animation to the end. + await tester.pump(animationDuration ~/ 2); + + iconButton = tester.widget(iconButtonFinder); + expect(iconButton.iconSize, equals(endSize)); + + // Tap on the IconButton to start the reverse animation. + await tester.tap(iconButtonFinder); + await tester.pump(); + + iconButton = tester.widget(iconButtonFinder); + expect(iconButton.iconSize, equals(endSize)); + + // Advance animation to the middle. + await tester.pump(animationDuration ~/ 2); + + iconButton = tester.widget(iconButtonFinder); + expect( + iconButton.iconSize, + equals(lerpDouble(endSize, beginSize, 0.5)), + ); + + // Advance animation to the end. + await tester.pump(animationDuration ~/ 2); + + iconButton = tester.widget(iconButtonFinder); + expect(iconButton.iconSize, equals(beginSize)); + }); + + testWidgets('Animation target can be updated during the animation', (WidgetTester tester) async { + await tester.pumpWidget( + const example.TweenAnimationBuilderExampleApp(), + ); + await tester.pumpAndSettle(); + + // The animation duration defined in the example app. + const Duration animationDuration = Duration(seconds: 1); + + const double beginSize = 24.0; + const double endSize = 48.0; + final double middleSize = lerpDouble(beginSize, endSize, 0.5)!; + + final Finder iconButtonFinder = find.byType(IconButton); + + IconButton iconButton = tester.widget(iconButtonFinder); + expect(iconButton.iconSize, equals(beginSize)); + + // Tap on the IconButton to start the forward animation. + await tester.tap(iconButtonFinder); + await tester.pump(); + + iconButton = tester.widget(iconButtonFinder); + expect(iconButton.iconSize, equals(beginSize)); + + // Advance animation to the middle. + await tester.pump(animationDuration ~/ 2); + + iconButton = tester.widget(iconButtonFinder); + expect(iconButton.iconSize, equals(middleSize)); + + // Tap on the IconButton to start the backward animation. + await tester.tap(iconButtonFinder); + await tester.pump(); + + iconButton = tester.widget(iconButtonFinder); + expect(iconButton.iconSize, equals(middleSize)); + + // Advance animation to the middle. + await tester.pump(animationDuration ~/ 2); + + iconButton = tester.widget(iconButtonFinder); + expect( + iconButton.iconSize, + equals(lerpDouble(middleSize, beginSize, 0.5)), + ); + + // Advance animation to the end. + await tester.pump(animationDuration ~/ 2); + + iconButton = tester.widget(iconButtonFinder); + expect(iconButton.iconSize, equals(beginSize)); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/undo_history/undo_history_controller.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/undo_history/undo_history_controller.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..91422a29f3cc56ebb2c403f40b40a5d56b2f1ae4 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/undo_history/undo_history_controller.0_test.dart @@ -0,0 +1,50 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/undo_history/undo_history_controller.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('The undo history controller should undo and redo the history changes', (WidgetTester tester) async { + await tester.pumpWidget( + const example.UndoHistoryControllerExampleApp(), + ); + + // Equals to UndoHistoryState._kThrottleDuration. + const Duration kThrottleDuration = Duration(milliseconds: 500); + + expect(find.byType(TextField), findsOne); + expect(find.widgetWithText(TextButton, 'Undo'), findsOne); + expect(find.widgetWithText(TextButton, 'Redo'), findsOne); + + await tester.enterText(find.byType(TextField), '1st change'); + await tester.pump(kThrottleDuration); + expect(find.text('1st change'), findsOne); + + await tester.enterText(find.byType(TextField), '2nd change'); + await tester.pump(kThrottleDuration); + expect(find.text('2nd change'), findsOne); + + await tester.enterText(find.byType(TextField), '3rd change'); + await tester.pump(kThrottleDuration); + expect(find.text('3rd change'), findsOne); + + await tester.tap(find.text('Undo')); + await tester.pump(); + expect(find.text('2nd change'), findsOne); + + await tester.tap(find.text('Undo')); + await tester.pump(); + expect(find.text('1st change'), findsOne); + + await tester.tap(find.text('Redo')); + await tester.pump(); + expect(find.text('2nd change'), findsOne); + + await tester.tap(find.text('Redo')); + await tester.pump(); + expect(find.text('3rd change'), findsOne); + }); +} diff --git a/novelforge-project/flutter/examples/api/test/widgets/value_listenable_builder/value_listenable_builder.0_test.dart b/novelforge-project/flutter/examples/api/test/widgets/value_listenable_builder/value_listenable_builder.0_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..b31e616230cccf9cebb4e1e37b3fe56be9707b42 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test/widgets/value_listenable_builder/value_listenable_builder.0_test.dart @@ -0,0 +1,35 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/widgets/value_listenable_builder/value_listenable_builder.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Tapping FAB increments counter', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: example.ValueListenableBuilderExample(), + ), + ); + + String getCount() { + return (tester.widget( + find.descendant( + of: find.byType(example.CountDisplay), + matching: find.byType(Text), + ), + ) as Text).data!; + } + + expect(find.text('You have pushed the button this many times:'), findsOneWidget); + expect(find.text('0'), findsOneWidget); + expect(find.byIcon(Icons.plus_one), findsOneWidget); + expect(getCount(), equals('0')); + + await tester.tap(find.byType(FloatingActionButton).first); + await tester.pumpAndSettle(); + expect(getCount(), equals('1')); + }); +} diff --git a/novelforge-project/flutter/examples/api/test_driver/integration_test.dart b/novelforge-project/flutter/examples/api/test_driver/integration_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..600bdc8828881377d5b401cdda5d7b59337292f1 --- /dev/null +++ b/novelforge-project/flutter/examples/api/test_driver/integration_test.dart @@ -0,0 +1,7 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:integration_test/integration_test_driver.dart'; + +Future main() => integrationDriver(); diff --git a/novelforge-project/flutter/examples/api/web/favicon.png b/novelforge-project/flutter/examples/api/web/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..8aaa46ac1ae21512746f852a42ba87e4165dfdd1 Binary files /dev/null and b/novelforge-project/flutter/examples/api/web/favicon.png differ diff --git a/novelforge-project/flutter/examples/api/web/icons/Icon-192.png b/novelforge-project/flutter/examples/api/web/icons/Icon-192.png new file mode 100644 index 0000000000000000000000000000000000000000..b749bfef07473333cf1dd31e9eed89862a5d52aa Binary files /dev/null and b/novelforge-project/flutter/examples/api/web/icons/Icon-192.png differ diff --git a/novelforge-project/flutter/examples/api/web/icons/Icon-512.png b/novelforge-project/flutter/examples/api/web/icons/Icon-512.png new file mode 100644 index 0000000000000000000000000000000000000000..88cfd48dff1169879ba46840804b412fe02fefd6 Binary files /dev/null and b/novelforge-project/flutter/examples/api/web/icons/Icon-512.png differ diff --git a/novelforge-project/flutter/examples/api/web/index.html b/novelforge-project/flutter/examples/api/web/index.html new file mode 100644 index 0000000000000000000000000000000000000000..f84a455ae9a60c12736ffb7fae6574d99eb6d49f --- /dev/null +++ b/novelforge-project/flutter/examples/api/web/index.html @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + Flutter API Sample + + + + + + + diff --git a/novelforge-project/flutter/examples/api/web/manifest.json b/novelforge-project/flutter/examples/api/web/manifest.json new file mode 100644 index 0000000000000000000000000000000000000000..ff5d87af91d1ed783c90fb3f282ffbcdf9ccd18c --- /dev/null +++ b/novelforge-project/flutter/examples/api/web/manifest.json @@ -0,0 +1,35 @@ +{ + "name": "flutter_api_samples", + "short_name": "flutter_api_samples", + "start_url": ".", + "display": "standalone", + "background_color": "#0175C2", + "theme_color": "#0175C2", + "description": "A temporary code sample for Curve2D", + "orientation": "portrait-primary", + "prefer_related_applications": false, + "icons": [ + { + "src": "icons/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + }, + { + "src": "icons/Icon-maskable-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "icons/Icon-maskable-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ] +} diff --git a/novelforge-project/flutter/examples/api/windows/CMakeLists.txt b/novelforge-project/flutter/examples/api/windows/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..8d3590ee41cb0b64bb7aae325dafbc4dbcee19d3 --- /dev/null +++ b/novelforge-project/flutter/examples/api/windows/CMakeLists.txt @@ -0,0 +1,95 @@ +cmake_minimum_required(VERSION 3.14) +project(dartpad_curve2_d_0 LANGUAGES CXX) + +set(BINARY_NAME "dartpad_curve2_d_0") + +cmake_policy(VERSION 3.14...3.25) + +set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") + +# Configure build options. +get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(IS_MULTICONFIG) + set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" + CACHE STRING "" FORCE) +else() + if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") + endif() +endif() + +set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") +set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") +set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") +set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") + +# Use Unicode for all projects. +add_definitions(-DUNICODE -D_UNICODE) + +# Compilation settings that should be applied to most targets. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_17) + target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") + target_compile_options(${TARGET} PRIVATE /EHsc) + target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") + target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") +endfunction() + +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") + +# Flutter library and tool build rules. +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# Application build +add_subdirectory("runner") + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# Support files are copied into place next to the executable, so that it can +# run in place. This is done instead of making a separate bundle (as on Linux) +# so that building and running from within Visual Studio will work. +set(BUILD_BUNDLE_DIR "$") +# Make the "install" step default, as it's required to run. +set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +if(PLUGIN_BUNDLED_LIBRARIES) + install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + CONFIGURATIONS Profile;Release + COMPONENT Runtime) diff --git a/novelforge-project/flutter/examples/api/windows/flutter/CMakeLists.txt b/novelforge-project/flutter/examples/api/windows/flutter/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..903f4899d6fced0eb941e159f7322b21b320c40c --- /dev/null +++ b/novelforge-project/flutter/examples/api/windows/flutter/CMakeLists.txt @@ -0,0 +1,109 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.14) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. +set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") + +# Set fallback configurations for older versions of the flutter tool. +if (NOT DEFINED FLUTTER_TARGET_PLATFORM) + set(FLUTTER_TARGET_PLATFORM "windows-x64") +endif() + +# === Flutter Library === +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "flutter_export.h" + "flutter_windows.h" + "flutter_messenger.h" + "flutter_plugin_registrar.h" + "flutter_texture_registrar.h" +) +list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") +add_dependencies(flutter flutter_assemble) + +# === Wrapper === +list(APPEND CPP_WRAPPER_SOURCES_CORE + "core_implementations.cc" + "standard_codec.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_PLUGIN + "plugin_registrar.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_APP + "flutter_engine.cc" + "flutter_view_controller.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") + +# Wrapper sources needed for a plugin. +add_library(flutter_wrapper_plugin STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} +) +apply_standard_settings(flutter_wrapper_plugin) +set_target_properties(flutter_wrapper_plugin PROPERTIES + POSITION_INDEPENDENT_CODE ON) +set_target_properties(flutter_wrapper_plugin PROPERTIES + CXX_VISIBILITY_PRESET hidden) +target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) +target_include_directories(flutter_wrapper_plugin PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_plugin flutter_assemble) + +# Wrapper sources needed for the runner. +add_library(flutter_wrapper_app STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_APP} +) +apply_standard_settings(flutter_wrapper_app) +target_link_libraries(flutter_wrapper_app PUBLIC flutter) +target_include_directories(flutter_wrapper_app PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_app flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") +set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} + ${PHONY_OUTPUT} + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" + ${FLUTTER_TARGET_PLATFORM} $ + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} +) diff --git a/novelforge-project/flutter/examples/api/windows/runner/CMakeLists.txt b/novelforge-project/flutter/examples/api/windows/runner/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..17411a8ab8eb7a538e7dfa59b33869832f6f0269 --- /dev/null +++ b/novelforge-project/flutter/examples/api/windows/runner/CMakeLists.txt @@ -0,0 +1,39 @@ +cmake_minimum_required(VERSION 3.14) +project(runner LANGUAGES CXX) + +# Define the application target. To change its name, change BINARY_NAME in the +# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer +# work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} WIN32 + "flutter_window.cpp" + "main.cpp" + "utils.cpp" + "win32_window.cpp" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" + "Runner.rc" + "runner.exe.manifest" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add preprocessor definitions for the build version. +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") + +# Disable Windows macros that collide with C++ standard library functions. +target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") + +# Add dependency libraries and include directories. Add any application-specific +# dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) +target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) diff --git a/novelforge-project/flutter/examples/api/windows/runner/Runner.rc b/novelforge-project/flutter/examples/api/windows/runner/Runner.rc new file mode 100644 index 0000000000000000000000000000000000000000..8d46438b8901b01335eb2078b09d90b4254809c7 --- /dev/null +++ b/novelforge-project/flutter/examples/api/windows/runner/Runner.rc @@ -0,0 +1,121 @@ +// Microsoft Visual C++ generated resource script. +// +#pragma code_page(65001) +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +// IDI_APP_ICON ICON "resources\\app_icon.ico" + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) +#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD +#else +#define VERSION_AS_NUMBER 1,0,0,0 +#endif + +#if defined(FLUTTER_VERSION) +#define VERSION_AS_STRING FLUTTER_VERSION +#else +#define VERSION_AS_STRING "1.0.0" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION VERSION_AS_NUMBER + PRODUCTVERSION VERSION_AS_NUMBER + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904e4" + BEGIN + VALUE "CompanyName", "The Flutter Authors" "\0" + VALUE "FileDescription", "A sample application demonstrating Flutter APIs." "\0" + VALUE "FileVersion", VERSION_AS_STRING "\0" + VALUE "InternalName", "Flutter API Sample" "\0" + VALUE "LegalCopyright", "Copyright 2014 The Flutter Authors. All rights reserved." "\0" + VALUE "OriginalFilename", "flutter_api_samples.exe" "\0" + VALUE "ProductName", "Flutter API Sample" "\0" + VALUE "ProductVersion", VERSION_AS_STRING "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED diff --git a/novelforge-project/flutter/examples/api/windows/runner/flutter_window.cpp b/novelforge-project/flutter/examples/api/windows/runner/flutter_window.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9cbd3109c3fee7d0af8ac9fc3554f6140a581532 --- /dev/null +++ b/novelforge-project/flutter/examples/api/windows/runner/flutter_window.cpp @@ -0,0 +1,65 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "flutter_window.h" + +#include + +#include "flutter/generated_plugin_registrant.h" + +FlutterWindow::FlutterWindow(const flutter::DartProject& project) + : project_(project) {} + +FlutterWindow::~FlutterWindow() {} + +bool FlutterWindow::OnCreate() { + if (!Win32Window::OnCreate()) { + return false; + } + + RECT frame = GetClientArea(); + + // The size here must match the window dimensions to avoid unnecessary surface + // creation / destruction in the startup path. + flutter_controller_ = std::make_unique( + frame.right - frame.left, frame.bottom - frame.top, project_); + // Ensure that basic setup of the controller was successful. + if (!flutter_controller_->engine() || !flutter_controller_->view()) { + return false; + } + RegisterPlugins(flutter_controller_->engine()); + SetChildContent(flutter_controller_->view()->GetNativeWindow()); + return true; +} + +void FlutterWindow::OnDestroy() { + if (flutter_controller_) { + flutter_controller_ = nullptr; + } + + Win32Window::OnDestroy(); +} + +LRESULT +FlutterWindow::MessageHandler(HWND hwnd, UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + // Give Flutter, including plugins, an opportunity to handle window messages. + if (flutter_controller_) { + std::optional result = + flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, + lparam); + if (result) { + return *result; + } + } + + switch (message) { + case WM_FONTCHANGE: + flutter_controller_->engine()->ReloadSystemFonts(); + break; + } + + return Win32Window::MessageHandler(hwnd, message, wparam, lparam); +} diff --git a/novelforge-project/flutter/examples/api/windows/runner/flutter_window.h b/novelforge-project/flutter/examples/api/windows/runner/flutter_window.h new file mode 100644 index 0000000000000000000000000000000000000000..bbc5836c018a235235e8094ab411d98e1c5443fa --- /dev/null +++ b/novelforge-project/flutter/examples/api/windows/runner/flutter_window.h @@ -0,0 +1,37 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef RUNNER_FLUTTER_WINDOW_H_ +#define RUNNER_FLUTTER_WINDOW_H_ + +#include +#include + +#include + +#include "win32_window.h" + +// A window that does nothing but host a Flutter view. +class FlutterWindow : public Win32Window { + public: + // Creates a new FlutterWindow hosting a Flutter view running |project|. + explicit FlutterWindow(const flutter::DartProject& project); + virtual ~FlutterWindow(); + + protected: + // Win32Window: + bool OnCreate() override; + void OnDestroy() override; + LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, + LPARAM const lparam) noexcept override; + + private: + // The project to run. + flutter::DartProject project_; + + // The Flutter instance hosted by this window. + std::unique_ptr flutter_controller_; +}; + +#endif // RUNNER_FLUTTER_WINDOW_H_ diff --git a/novelforge-project/flutter/examples/api/windows/runner/main.cpp b/novelforge-project/flutter/examples/api/windows/runner/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d1f23e5b8047f93b6ce14d7ff9ad354d3afddeab --- /dev/null +++ b/novelforge-project/flutter/examples/api/windows/runner/main.cpp @@ -0,0 +1,47 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include +#include +#include + +#include "flutter_window.h" +#include "utils.h" + +int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, + _In_ wchar_t *command_line, _In_ int show_command) { + // Attach to console when present (e.g., 'flutter run') or create a + // new console when running with a debugger. + if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { + CreateAndAttachConsole(); + } + + // Initialize COM, so that it is available for use in the library and/or + // plugins. + ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); + + flutter::DartProject project(L"data"); + + std::vector command_line_arguments = + GetCommandLineArguments(); + + project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); + + FlutterWindow window(project); + Win32Window::Point origin(10, 10); + Win32Window::Size size(1280, 720); + if (!window.CreateAndShow(L"flutter_api_samples", origin, size)) { + return EXIT_FAILURE; + } + window.SetQuitOnClose(true); + + ::MSG msg; + while (::GetMessage(&msg, nullptr, 0, 0)) { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + + ::CoUninitialize(); + return EXIT_SUCCESS; +} diff --git a/novelforge-project/flutter/examples/api/windows/runner/resource.h b/novelforge-project/flutter/examples/api/windows/runner/resource.h new file mode 100644 index 0000000000000000000000000000000000000000..c245ff19cb5805345a3d3265122298cb01b9d71f --- /dev/null +++ b/novelforge-project/flutter/examples/api/windows/runner/resource.h @@ -0,0 +1,20 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Runner.rc +// +#define IDI_APP_ICON 101 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/novelforge-project/flutter/examples/api/windows/runner/runner.exe.manifest b/novelforge-project/flutter/examples/api/windows/runner/runner.exe.manifest new file mode 100644 index 0000000000000000000000000000000000000000..a42ea7687cb67e55af955dc8874a072e087ce3ed --- /dev/null +++ b/novelforge-project/flutter/examples/api/windows/runner/runner.exe.manifest @@ -0,0 +1,20 @@ + + + + + PerMonitorV2 + + + + + + + + + + + + + + + diff --git a/novelforge-project/flutter/examples/api/windows/runner/utils.cpp b/novelforge-project/flutter/examples/api/windows/runner/utils.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b849ce2c32702dc4b1f35161e794e7dcc5a81ef8 --- /dev/null +++ b/novelforge-project/flutter/examples/api/windows/runner/utils.cpp @@ -0,0 +1,68 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "utils.h" + +#include +#include +#include +#include + +#include + +void CreateAndAttachConsole() { + if (::AllocConsole()) { + FILE *unused; + if (freopen_s(&unused, "CONOUT$", "w", stdout)) { + _dup2(_fileno(stdout), 1); + } + if (freopen_s(&unused, "CONOUT$", "w", stderr)) { + _dup2(_fileno(stdout), 2); + } + std::ios::sync_with_stdio(); + FlutterDesktopResyncOutputStreams(); + } +} + +std::vector GetCommandLineArguments() { + // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. + int argc; + wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); + if (argv == nullptr) { + return std::vector(); + } + + std::vector command_line_arguments; + + // Skip the first argument as it's the binary name. + for (int i = 1; i < argc; i++) { + command_line_arguments.push_back(Utf8FromUtf16(argv[i])); + } + + ::LocalFree(argv); + + return command_line_arguments; +} + +std::string Utf8FromUtf16(const wchar_t* utf16_string) { + if (utf16_string == nullptr) { + return std::string(); + } + int target_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + -1, nullptr, 0, nullptr, nullptr) + -1; // remove the trailing null character + std::string utf8_string; + if (target_length <= 0 || target_length > utf8_string.max_size()) { + return utf8_string; + } + utf8_string.resize(target_length); + int converted_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + -1, utf8_string.data(), target_length, nullptr, nullptr); + if (converted_length == 0) { + return std::string(); + } + return utf8_string; +} diff --git a/novelforge-project/flutter/examples/api/windows/runner/utils.h b/novelforge-project/flutter/examples/api/windows/runner/utils.h new file mode 100644 index 0000000000000000000000000000000000000000..54414c989ba716f78f3640e5407dd8ac74284aef --- /dev/null +++ b/novelforge-project/flutter/examples/api/windows/runner/utils.h @@ -0,0 +1,23 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef RUNNER_UTILS_H_ +#define RUNNER_UTILS_H_ + +#include +#include + +// Creates a console for the process, and redirects stdout and stderr to +// it for both the runner and the Flutter library. +void CreateAndAttachConsole(); + +// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string +// encoded in UTF-8. Returns an empty std::string on failure. +std::string Utf8FromUtf16(const wchar_t* utf16_string); + +// Gets the command line arguments passed in as a std::vector, +// encoded in UTF-8. Returns an empty std::vector on failure. +std::vector GetCommandLineArguments(); + +#endif // RUNNER_UTILS_H_ diff --git a/novelforge-project/flutter/examples/api/windows/runner/win32_window.cpp b/novelforge-project/flutter/examples/api/windows/runner/win32_window.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8fef19b0fbfd42ed35473b73ded3f6e1d70910e0 --- /dev/null +++ b/novelforge-project/flutter/examples/api/windows/runner/win32_window.cpp @@ -0,0 +1,249 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "win32_window.h" + +#include + +#include "resource.h" + +namespace { + +constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; + +// The number of Win32Window objects that currently exist. +static int g_active_window_count = 0; + +using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); + +// Scale helper to convert logical scaler values to physical using passed in +// scale factor +int Scale(int source, double scale_factor) { + return static_cast(source * scale_factor); +} + +// Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. +// This API is only needed for PerMonitor V1 awareness mode. +void EnableFullDpiSupportIfAvailable(HWND hwnd) { + HMODULE user32_module = LoadLibraryA("User32.dll"); + if (!user32_module) { + return; + } + auto enable_non_client_dpi_scaling = + reinterpret_cast( + GetProcAddress(user32_module, "EnableNonClientDpiScaling")); + if (enable_non_client_dpi_scaling != nullptr) { + enable_non_client_dpi_scaling(hwnd); + } + FreeLibrary(user32_module); +} + +} // namespace + +// Manages the Win32Window's window class registration. +class WindowClassRegistrar { + public: + ~WindowClassRegistrar() = default; + + // Returns the singleton registrar instance. + static WindowClassRegistrar* GetInstance() { + if (!instance_) { + instance_ = new WindowClassRegistrar(); + } + return instance_; + } + + // Returns the name of the window class, registering the class if it hasn't + // previously been registered. + const wchar_t* GetWindowClass(); + + // Unregisters the window class. Should only be called if there are no + // instances of the window. + void UnregisterWindowClass(); + + private: + WindowClassRegistrar() = default; + + static WindowClassRegistrar* instance_; + + bool class_registered_ = false; +}; + +WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; + +const wchar_t* WindowClassRegistrar::GetWindowClass() { + if (!class_registered_) { + WNDCLASS window_class{}; + window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); + window_class.lpszClassName = kWindowClassName; + window_class.style = CS_HREDRAW | CS_VREDRAW; + window_class.cbClsExtra = 0; + window_class.cbWndExtra = 0; + window_class.hInstance = GetModuleHandle(nullptr); + window_class.hIcon = + LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); + window_class.hbrBackground = 0; + window_class.lpszMenuName = nullptr; + window_class.lpfnWndProc = Win32Window::WndProc; + RegisterClass(&window_class); + class_registered_ = true; + } + return kWindowClassName; +} + +void WindowClassRegistrar::UnregisterWindowClass() { + UnregisterClass(kWindowClassName, nullptr); + class_registered_ = false; +} + +Win32Window::Win32Window() { + ++g_active_window_count; +} + +Win32Window::~Win32Window() { + --g_active_window_count; + Destroy(); +} + +bool Win32Window::CreateAndShow(const std::wstring& title, + const Point& origin, + const Size& size) { + Destroy(); + + const wchar_t* window_class = + WindowClassRegistrar::GetInstance()->GetWindowClass(); + + const POINT target_point = {static_cast(origin.x), + static_cast(origin.y)}; + HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); + UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); + double scale_factor = dpi / 96.0; + + HWND window = CreateWindow( + window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE, + Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), + Scale(size.width, scale_factor), Scale(size.height, scale_factor), + nullptr, nullptr, GetModuleHandle(nullptr), this); + + if (!window) { + return false; + } + + return OnCreate(); +} + +// static +LRESULT CALLBACK Win32Window::WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + if (message == WM_NCCREATE) { + auto window_struct = reinterpret_cast(lparam); + SetWindowLongPtr(window, GWLP_USERDATA, + reinterpret_cast(window_struct->lpCreateParams)); + + auto that = static_cast(window_struct->lpCreateParams); + EnableFullDpiSupportIfAvailable(window); + that->window_handle_ = window; + } else if (Win32Window* that = GetThisFromHandle(window)) { + return that->MessageHandler(window, message, wparam, lparam); + } + + return DefWindowProc(window, message, wparam, lparam); +} + +LRESULT +Win32Window::MessageHandler(HWND hwnd, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + switch (message) { + case WM_DESTROY: + window_handle_ = nullptr; + Destroy(); + if (quit_on_close_) { + PostQuitMessage(0); + } + return 0; + + case WM_DPICHANGED: { + auto newRectSize = reinterpret_cast(lparam); + LONG newWidth = newRectSize->right - newRectSize->left; + LONG newHeight = newRectSize->bottom - newRectSize->top; + + SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, + newHeight, SWP_NOZORDER | SWP_NOACTIVATE); + + return 0; + } + case WM_SIZE: { + RECT rect = GetClientArea(); + if (child_content_ != nullptr) { + // Size and position the child window. + MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, + rect.bottom - rect.top, TRUE); + } + return 0; + } + + case WM_ACTIVATE: + if (child_content_ != nullptr) { + SetFocus(child_content_); + } + return 0; + } + + return DefWindowProc(window_handle_, message, wparam, lparam); +} + +void Win32Window::Destroy() { + OnDestroy(); + + if (window_handle_) { + DestroyWindow(window_handle_); + window_handle_ = nullptr; + } + if (g_active_window_count == 0) { + WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); + } +} + +Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { + return reinterpret_cast( + GetWindowLongPtr(window, GWLP_USERDATA)); +} + +void Win32Window::SetChildContent(HWND content) { + child_content_ = content; + SetParent(content, window_handle_); + RECT frame = GetClientArea(); + + MoveWindow(content, frame.left, frame.top, frame.right - frame.left, + frame.bottom - frame.top, true); + + SetFocus(child_content_); +} + +RECT Win32Window::GetClientArea() { + RECT frame; + GetClientRect(window_handle_, &frame); + return frame; +} + +HWND Win32Window::GetHandle() { + return window_handle_; +} + +void Win32Window::SetQuitOnClose(bool quit_on_close) { + quit_on_close_ = quit_on_close; +} + +bool Win32Window::OnCreate() { + // No-op; provided for subclasses. + return true; +} + +void Win32Window::OnDestroy() { + // No-op; provided for subclasses. +} diff --git a/novelforge-project/flutter/examples/api/windows/runner/win32_window.h b/novelforge-project/flutter/examples/api/windows/runner/win32_window.h new file mode 100644 index 0000000000000000000000000000000000000000..33786ecd6f0b9bfeb539621c8f53fa415038fbad --- /dev/null +++ b/novelforge-project/flutter/examples/api/windows/runner/win32_window.h @@ -0,0 +1,102 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef RUNNER_WIN32_WINDOW_H_ +#define RUNNER_WIN32_WINDOW_H_ + +#include + +#include +#include +#include + +// A class abstraction for a high DPI-aware Win32 Window. Intended to be +// inherited from by classes that wish to specialize with custom +// rendering and input handling +class Win32Window { + public: + struct Point { + unsigned int x; + unsigned int y; + Point(unsigned int x, unsigned int y) : x(x), y(y) {} + }; + + struct Size { + unsigned int width; + unsigned int height; + Size(unsigned int width, unsigned int height) + : width(width), height(height) {} + }; + + Win32Window(); + virtual ~Win32Window(); + + // Creates and shows a win32 window with |title| and position and size using + // |origin| and |size|. New windows are created on the default monitor. Window + // sizes are specified to the OS in physical pixels, hence to ensure a + // consistent size to will treat the width height passed in to this function + // as logical pixels and scale to appropriate for the default monitor. Returns + // true if the window was created successfully. + bool CreateAndShow(const std::wstring& title, + const Point& origin, + const Size& size); + + // Release OS resources associated with window. + void Destroy(); + + // Inserts |content| into the window tree. + void SetChildContent(HWND content); + + // Returns the backing Window handle to enable clients to set icon and other + // window properties. Returns nullptr if the window has been destroyed. + HWND GetHandle(); + + // If true, closing this window will quit the application. + void SetQuitOnClose(bool quit_on_close); + + // Return a RECT representing the bounds of the current client area. + RECT GetClientArea(); + + protected: + // Processes and route salient window messages for mouse handling, + // size change and DPI. Delegates handling of these to member overloads that + // inheriting classes can handle. + virtual LRESULT MessageHandler(HWND window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Called when CreateAndShow is called, allowing subclass window-related + // setup. Subclasses should return false if setup fails. + virtual bool OnCreate(); + + // Called when Destroy is called. + virtual void OnDestroy(); + + private: + friend class WindowClassRegistrar; + + // OS callback called by message pump. Handles the WM_NCCREATE message which + // is passed when the non-client area is being created and enables automatic + // non-client DPI scaling so that the non-client area automatically + // responds to changes in DPI. All other messages are handled by + // MessageHandler. + static LRESULT CALLBACK WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Retrieves a class instance pointer for |window| + static Win32Window* GetThisFromHandle(HWND const window) noexcept; + + bool quit_on_close_ = false; + + // window handle for top level window. + HWND window_handle_ = nullptr; + + // window handle for hosted content. + HWND child_content_ = nullptr; +}; + +#endif // RUNNER_WIN32_WINDOW_H_ diff --git a/novelforge-project/flutter/examples/flutter_view/android/app/build.gradle b/novelforge-project/flutter/examples/flutter_view/android/app/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..ecbe93db92f92b9e1c758126739e16d594f9bfa7 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/android/app/build.gradle @@ -0,0 +1,64 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +apply plugin: 'com.android.application' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +android { + namespace "com.example.view" + compileSdk flutter.compileSdkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + defaultConfig { + applicationId "io.flutter.examples.flutter_view" + minSdkVersion flutter.minSdkVersion + targetSdkVersion flutter.targetSdkVersion + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} + +dependencies { + implementation 'androidx.appcompat:appcompat:1.1.0' + implementation 'com.google.android.material:material:1.0.0' +} diff --git a/novelforge-project/flutter/examples/flutter_view/android/app/src/main/AndroidManifest.xml b/novelforge-project/flutter/examples/flutter_view/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000000000000000000000000000000000000..f45c7021b5d21cb3389695aa258de4010d57d971 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/novelforge-project/flutter/examples/flutter_view/android/app/src/main/java/com/example/view/MainActivity.java b/novelforge-project/flutter/examples/flutter_view/android/app/src/main/java/com/example/view/MainActivity.java new file mode 100644 index 0000000000000000000000000000000000000000..3c53005f354249a8bf4e66a0f030aa2e71f5e2c0 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/android/app/src/main/java/com/example/view/MainActivity.java @@ -0,0 +1,128 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package com.example.view; + +import android.content.Intent; +import android.os.Bundle; +import android.view.View; +import android.widget.TextView; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; +import com.google.android.material.floatingactionbutton.FloatingActionButton; +import io.flutter.embedding.android.FlutterView; +import io.flutter.embedding.engine.FlutterEngine; +import io.flutter.embedding.engine.dart.DartExecutor; +import io.flutter.embedding.engine.dart.DartExecutor.DartEntrypoint; +import io.flutter.plugin.common.BasicMessageChannel; +import io.flutter.plugin.common.BasicMessageChannel.MessageHandler; +import io.flutter.plugin.common.BasicMessageChannel.Reply; +import io.flutter.plugin.common.StringCodec; +import java.util.ArrayList; + +public class MainActivity extends AppCompatActivity { + private static FlutterEngine flutterEngine; + + private FlutterView flutterView; + private int counter; + private static final String CHANNEL = "increment"; + private static final String EMPTY_MESSAGE = ""; + private static final String PING = "ping"; + private BasicMessageChannel messageChannel; + + private String[] getArgsFromIntent(Intent intent) { + // Before adding more entries to this list, consider that arbitrary + // Android applications can generate intents with extra data and that + // there are many security-sensitive args in the binary. + ArrayList args = new ArrayList<>(); + if (intent.getBooleanExtra("trace-startup", false)) { + args.add("--trace-startup"); + } + if (intent.getBooleanExtra("start-paused", false)) { + args.add("--start-paused"); + } + if (intent.getBooleanExtra("enable-dart-profiling", false)) { + args.add("--enable-dart-profiling"); + } + if (!args.isEmpty()) { + String[] argsArray = new String[args.size()]; + return args.toArray(argsArray); + } + return null; + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + String[] args = getArgsFromIntent(getIntent()); + if (flutterEngine == null) { + flutterEngine = new FlutterEngine(this, args); + flutterEngine.getDartExecutor().executeDartEntrypoint( + DartEntrypoint.createDefault() + ); + } + setContentView(R.layout.flutter_view_layout); + ActionBar supportActionBar = getSupportActionBar(); + if (supportActionBar != null) { + supportActionBar.hide(); + } + + flutterView = findViewById(R.id.flutter_view); + flutterView.attachToFlutterEngine(flutterEngine); + + messageChannel = new BasicMessageChannel<>(flutterEngine.getDartExecutor(), CHANNEL, StringCodec.INSTANCE); + messageChannel. + setMessageHandler(new MessageHandler() { + @Override + public void onMessage(String s, Reply reply) { + onFlutterIncrement(); + reply.reply(EMPTY_MESSAGE); + } + }); + + FloatingActionButton fab = findViewById(R.id.button); + fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + sendAndroidIncrement(); + } + }); + } + + private void sendAndroidIncrement() { + messageChannel.send(PING); + } + + private void onFlutterIncrement() { + counter++; + TextView textView = findViewById(R.id.button_tap); + String value = "Flutter button tapped " + counter + (counter == 1 ? " time" : " times"); + textView.setText(value); + } + + @Override + protected void onResume() { + super.onResume(); + flutterEngine.getLifecycleChannel().appIsResumed(); + } + + @Override + protected void onPause() { + super.onPause(); + flutterEngine.getLifecycleChannel().appIsInactive(); + } + + @Override + protected void onStop() { + super.onStop(); + flutterEngine.getLifecycleChannel().appIsPaused(); + } + + @Override + protected void onDestroy() { + flutterView.detachFromFlutterEngine(); + super.onDestroy(); + } +} diff --git a/novelforge-project/flutter/examples/flutter_view/android/app/src/main/res/color/fab_ripple_color.xml b/novelforge-project/flutter/examples/flutter_view/android/app/src/main/res/color/fab_ripple_color.xml new file mode 100644 index 0000000000000000000000000000000000000000..ea2ccbdc35c9cb841a0e93d44b8c92443ed41528 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/android/app/src/main/res/color/fab_ripple_color.xml @@ -0,0 +1,9 @@ + + + + + + + diff --git a/novelforge-project/flutter/examples/flutter_view/android/app/src/main/res/drawable/ic_add_black_24dp.xml b/novelforge-project/flutter/examples/flutter_view/android/app/src/main/res/drawable/ic_add_black_24dp.xml new file mode 100644 index 0000000000000000000000000000000000000000..f99c4c64f65c169034105c526ea7c011d4ac418f --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/android/app/src/main/res/drawable/ic_add_black_24dp.xml @@ -0,0 +1,13 @@ + + + + + diff --git a/novelforge-project/flutter/examples/flutter_view/android/app/src/main/res/layout/flutter_view_layout.xml b/novelforge-project/flutter/examples/flutter_view/android/app/src/main/res/layout/flutter_view_layout.xml new file mode 100644 index 0000000000000000000000000000000000000000..ba7e253a949f97d050bbd9a1d470d4fb16367501 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/android/app/src/main/res/layout/flutter_view_layout.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/novelforge-project/flutter/examples/flutter_view/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/novelforge-project/flutter/examples/flutter_view/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..db77bb4b7b0906d62b1847e87f15cdcacf6a4f29 Binary files /dev/null and b/novelforge-project/flutter/examples/flutter_view/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/novelforge-project/flutter/examples/flutter_view/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/novelforge-project/flutter/examples/flutter_view/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..17987b79bb8a35cc66c3c1fd44f5a5526c1b78be Binary files /dev/null and b/novelforge-project/flutter/examples/flutter_view/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/novelforge-project/flutter/examples/flutter_view/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/novelforge-project/flutter/examples/flutter_view/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..09d4391482be68e9e4a07fab769b5de337d16eb1 Binary files /dev/null and b/novelforge-project/flutter/examples/flutter_view/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/novelforge-project/flutter/examples/flutter_view/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/novelforge-project/flutter/examples/flutter_view/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..d5f1c8d34e7a88e3f88bea192c3a370d44689c3c Binary files /dev/null and b/novelforge-project/flutter/examples/flutter_view/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/novelforge-project/flutter/examples/flutter_view/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/novelforge-project/flutter/examples/flutter_view/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..4d6372eebdb28e45604e46eeda8dd24651419bc0 Binary files /dev/null and b/novelforge-project/flutter/examples/flutter_view/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/novelforge-project/flutter/examples/flutter_view/android/app/src/main/res/values/colors.xml b/novelforge-project/flutter/examples/flutter_view/android/app/src/main/res/values/colors.xml new file mode 100644 index 0000000000000000000000000000000000000000..07f7af62e7fbc2e93aa4b5897bec3a16c8b4b478 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/android/app/src/main/res/values/colors.xml @@ -0,0 +1,8 @@ + + + + #9E9E9E + #FFFFFF + diff --git a/novelforge-project/flutter/examples/flutter_view/android/app/src/main/res/values/dimens.xml b/novelforge-project/flutter/examples/flutter_view/android/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000000000000000000000000000000000000..1078837b05261f699ed602ea685aad09dd1b0827 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/android/app/src/main/res/values/dimens.xml @@ -0,0 +1,11 @@ + + + + 16dp + 6dp + 12dp + 17sp + 30sp + diff --git a/novelforge-project/flutter/examples/flutter_view/android/app/src/main/res/values/strings.xml b/novelforge-project/flutter/examples/flutter_view/android/app/src/main/res/values/strings.xml new file mode 100644 index 0000000000000000000000000000000000000000..53353042f3f46e8ca29d067e440580bdd1a88381 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/android/app/src/main/res/values/strings.xml @@ -0,0 +1,10 @@ + + + + Flutter View + Flutter Application + Flutter button tapped 0 times. + Android + diff --git a/novelforge-project/flutter/examples/flutter_view/android/gradle/wrapper/gradle-wrapper.properties b/novelforge-project/flutter/examples/flutter_view/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000000000000000000000000000000000000..e1ca574ef017c1bc00556b96ea372e2c07948771 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Flutter/AppFrameworkInfo.plist b/novelforge-project/flutter/examples/flutter_view/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 0000000000000000000000000000000000000000..8c6e56146e23c84aa60ea78f20bc3a7b3d8ef259 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + MinimumOSVersion + 12.0 + + diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Flutter/Debug.xcconfig b/novelforge-project/flutter/examples/flutter_view/ios/Flutter/Debug.xcconfig new file mode 100644 index 0000000000000000000000000000000000000000..592ceee85b89bd111b779db6116b130509ab6d4b --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/ios/Flutter/Debug.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Flutter/Release.xcconfig b/novelforge-project/flutter/examples/flutter_view/ios/Flutter/Release.xcconfig new file mode 100644 index 0000000000000000000000000000000000000000..592ceee85b89bd111b779db6116b130509ab6d4b --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/ios/Flutter/Release.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Runner.xcodeproj/project.pbxproj b/novelforge-project/flutter/examples/flutter_view/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000000000000000000000000000000000000..dceb2bab06811aa2984d09529e3c4361f909654f --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,477 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXBuildFile section */ + 2D4B11271E55A15A00FF14DB /* NativeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D4B11261E55A15A00FF14DB /* NativeViewController.m */; }; + 2DD8945F1E5B87AF0010574F /* ic_add.png in Resources */ = {isa = PBXBuildFile; fileRef = 2DD8945E1E5B87AF0010574F /* ic_add.png */; }; + 2DE332E71E55C6D800393FD5 /* MainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2DE332E61E55C6D800393FD5 /* MainViewController.m */; }; + 3B3967051E83383D004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967041E83383D004F5970 /* AppFrameworkInfo.plist */; }; + 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; + 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; }; + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 2D4B11261E55A15A00FF14DB /* NativeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NativeViewController.m; sourceTree = ""; }; + 2D4B11281E55A31800FF14DB /* NativeViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NativeViewController.h; sourceTree = ""; }; + 2DD8945E1E5B87AF0010574F /* ic_add.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ic_add.png; sourceTree = ""; }; + 2DE332E61E55C6D800393FD5 /* MainViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainViewController.m; sourceTree = ""; }; + 2DE332E81E55C6F100393FD5 /* MainViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MainViewController.h; sourceTree = ""; }; + 3B3967041E83383D004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; + 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; + 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 3B3967041E83383D004F5970 /* AppFrameworkInfo.plist */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + 97C146EF1CF9000F007C117D /* Products */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + ); + name = Products; + sourceTree = ""; + }; + 97C146F01CF9000F007C117D /* Runner */ = { + isa = PBXGroup; + children = ( + 2DD8945E1E5B87AF0010574F /* ic_add.png */, + 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */, + 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */, + 2DE332E81E55C6F100393FD5 /* MainViewController.h */, + 2DE332E61E55C6D800393FD5 /* MainViewController.m */, + 2D4B11261E55A15A00FF14DB /* NativeViewController.m */, + 2D4B11281E55A31800FF14DB /* NativeViewController.h */, + 97C146FA1CF9000F007C117D /* Main.storyboard */, + 97C146FD1CF9000F007C117D /* Assets.xcassets */, + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, + 97C147021CF9000F007C117D /* Info.plist */, + 97C146F11CF9000F007C117D /* Supporting Files */, + ); + path = Runner; + sourceTree = ""; + }; + 97C146F11CF9000F007C117D /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 97C146F21CF9000F007C117D /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 97C146ED1CF9000F007C117D /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 9740EEB61CF901F6004384FC /* Run Script */, + 97C146EA1CF9000F007C117D /* Sources */, + 97C146EB1CF9000F007C117D /* Frameworks */, + 97C146EC1CF9000F007C117D /* Resources */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Runner; + productName = Runner; + productReference = 97C146EE1CF9000F007C117D /* Runner.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 97C146E61CF9000F007C117D /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1510; + ORGANIZATIONNAME = "The Flutter Authors"; + TargetAttributes = { + 97C146ED1CF9000F007C117D = { + CreatedOnToolsVersion = 7.3.1; + LastSwiftMigration = 0820; + }; + }; + }; + buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 97C146E51CF9000F007C117D; + productRefGroup = 97C146EF1CF9000F007C117D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 97C146ED1CF9000F007C117D /* Runner */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 97C146EC1CF9000F007C117D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2DD8945F1E5B87AF0010574F /* ic_add.png in Resources */, + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, + 3B3967051E83383D004F5970 /* AppFrameworkInfo.plist in Resources */, + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin\n"; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build\n"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */, + 97C146F31CF9000F007C117D /* main.m in Sources */, + 2D4B11271E55A15A00FF14DB /* NativeViewController.m in Sources */, + 2DE332E71E55C6D800393FD5 /* MainViewController.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 97C146FA1CF9000F007C117D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C146FB1CF9000F007C117D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C147001CF9000F007C117D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 2418C3BA21828D0400D8F514 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Profile; + }; + 2418C3BB21828D0400D8F514 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.flutterView; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Profile; + }; + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 97C147041CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 97C147061CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.flutterView; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 97C147071CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.flutterView; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147031CF9000F007C117D /* Debug */, + 97C147041CF9000F007C117D /* Release */, + 2418C3BA21828D0400D8F514 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147061CF9000F007C117D /* Debug */, + 97C147071CF9000F007C117D /* Release */, + 2418C3BB21828D0400D8F514 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 97C146E61CF9000F007C117D /* Project object */; +} diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/novelforge-project/flutter/examples/flutter_view/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000000000000000000000000000000000000..919434a6254f0e9651f402737811be6634a03e9c --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/novelforge-project/flutter/examples/flutter_view/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000000000000000000000000000000000000..18d981003d68d0546c4804ac2ff47dd97c6e7921 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/novelforge-project/flutter/examples/flutter_view/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000000000000000000000000000000000000..e67b2808af02f9ec16f2d72b7961aefdf844afa5 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Runner.xcworkspace/contents.xcworkspacedata b/novelforge-project/flutter/examples/flutter_view/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000000000000000000000000000000000000..1d526a16ed0f1cd0c2409d848bf489b93fefa3b2 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/novelforge-project/flutter/examples/flutter_view/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000000000000000000000000000000000000..18d981003d68d0546c4804ac2ff47dd97c6e7921 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Runner/AppDelegate.h b/novelforge-project/flutter/examples/flutter_view/ios/Runner/AppDelegate.h new file mode 100644 index 0000000000000000000000000000000000000000..a78a945cd2ef8f832f90683ed5b29c97fcd8600b --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/ios/Runner/AppDelegate.h @@ -0,0 +1,10 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import +#import + +@interface AppDelegate : FlutterAppDelegate + +@end diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Runner/AppDelegate.m b/novelforge-project/flutter/examples/flutter_view/ios/Runner/AppDelegate.m new file mode 100644 index 0000000000000000000000000000000000000000..b3fa342f04a00ba7851bf0d19ca384b7bda2a425 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/ios/Runner/AppDelegate.m @@ -0,0 +1,15 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import "AppDelegate.h" +#import + +@implementation AppDelegate + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + // Override point for customization after application launch. + return YES; +} + +@end diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000000000000000000000000000000000000..13929fcb3b24a87bd89e677407c6e378bec9bf46 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,130 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@3x.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@3x.png", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@1x.png", + "scale" : "1x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@1x.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@2x.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "Icon-App-83.5x83.5@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@1x.png", + "scale" : "1x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@1x.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 0000000000000000000000000000000000000000..4cde12118dda48d71e01fcb589a74d069c5d7cb5 Binary files /dev/null and b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..d0ef06e7edb86cdfe0d15b4b0d98334a86163658 Binary files /dev/null and b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..dcdc2306c28505ebc0b6c3a359c4d252bf626b9f Binary files /dev/null and b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png new file mode 100644 index 0000000000000000000000000000000000000000..2ccbfd967d9697cd4b83225558af2911e9571c9b Binary files /dev/null and b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..c8f9ed8f5cee1c98386d13b17e89f719e83555b2 Binary files /dev/null and b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..a6d6b8609df07bf62e5100a53a01510388bd2b22 Binary files /dev/null and b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@1x.png b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@1x.png new file mode 100644 index 0000000000000000000000000000000000000000..f091b6b0bca859a3f474b03065bef75ba58a9e4c Binary files /dev/null and b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@1x.png differ diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..a6d6b8609df07bf62e5100a53a01510388bd2b22 Binary files /dev/null and b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..75b2d164a5a98e212cca15ea7bf2ab5de5108680 Binary files /dev/null and b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 0000000000000000000000000000000000000000..c4df70d39da7941ef3f6dcb7f06a192d8dcb308d Binary files /dev/null and b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..6a84f41e14e27f4b11f16f9ee39279ac98f8d5ac Binary files /dev/null and b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@3x.png b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..5d2bad850374720926b6d2d1126b3e2ef5e122ac Binary files /dev/null and b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@3x.png differ diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..d0e1f58536026aebc4f1f70e481f6993c9ff088d Binary files /dev/null and b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Runner/Base.lproj/LaunchScreen.storyboard b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000000000000000000000000000000000000..656380ca52560caca56d90fccf2e2568073d3d97 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Runner/Base.lproj/Main.storyboard b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 0000000000000000000000000000000000000000..76c8ca383cb9400b1347ce2047257ea9137da2a5 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,161 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Runner/Info.plist b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Info.plist new file mode 100644 index 0000000000000000000000000000000000000000..e8267951bd6ecc77fdffd1c3ea2933f126c15cce --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/ios/Runner/Info.plist @@ -0,0 +1,47 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + flutter_view + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + CADisableMinimumFrameDurationOnPhone + + UIApplicationSupportsIndirectInputEvents + + + diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Runner/MainViewController.h b/novelforge-project/flutter/examples/flutter_view/ios/Runner/MainViewController.h new file mode 100644 index 0000000000000000000000000000000000000000..2560f829607a31f038600823de43c934e0fc2037 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/ios/Runner/MainViewController.h @@ -0,0 +1,17 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef MainViewController_h +#define MainViewController_h + +#endif /* MainViewController_h */ + +#import +#import +#import "NativeViewController.h" + +@protocol NativeViewControllerDelegate; + +@interface MainViewController : UIViewController +@end diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Runner/MainViewController.m b/novelforge-project/flutter/examples/flutter_view/ios/Runner/MainViewController.m new file mode 100644 index 0000000000000000000000000000000000000000..895d92acc333eb810e99b17abcb8c29e8c819c55 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/ios/Runner/MainViewController.m @@ -0,0 +1,53 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import + +#import "MainViewController.h" +#import "NativeViewController.h" + +@interface MainViewController () + +@property (nonatomic) NativeViewController* nativeViewController; +@property (nonatomic) FlutterViewController* flutterViewController; +@property (nonatomic) FlutterBasicMessageChannel* messageChannel; +@end + +static NSString* const emptyString = @""; +static NSString* const ping = @"ping"; +static NSString* const channel = @"increment"; + +@implementation MainViewController + +- (NSString*) messageName { + return channel; +} + +- (void)prepareForSegue:(UIStoryboardSegue*)segue sender:(id)sender { + + if ([segue.identifier isEqualToString: @"NativeViewControllerSegue"]) { + self.nativeViewController = segue.destinationViewController; + self.nativeViewController.delegate = self; + } + + if ([segue.identifier isEqualToString:@"FlutterViewControllerSegue"]) { + self.flutterViewController = segue.destinationViewController; + + self.messageChannel = [FlutterBasicMessageChannel messageChannelWithName:channel + binaryMessenger:self.flutterViewController + codec:[FlutterStringCodec sharedInstance]]; + + MainViewController* __weak weakSelf = self; + [self.messageChannel setMessageHandler:^(id message, FlutterReply reply) { + [weakSelf.nativeViewController didReceiveIncrement]; + reply(emptyString); + }]; + } +} + +- (void)didTapIncrementButton { + [self.messageChannel sendMessage:ping]; +} + +@end diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Runner/NativeViewController.h b/novelforge-project/flutter/examples/flutter_view/ios/Runner/NativeViewController.h new file mode 100644 index 0000000000000000000000000000000000000000..279f80dcf589adff9822f62c39dec39e9ec7c572 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/ios/Runner/NativeViewController.h @@ -0,0 +1,17 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import + + +@protocol NativeViewControllerDelegate + +- (void)didTapIncrementButton; + +@end + +@interface NativeViewController: UIViewController +@property (strong, nonatomic) id delegate; +- (void) didReceiveIncrement; +@end diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Runner/NativeViewController.m b/novelforge-project/flutter/examples/flutter_view/ios/Runner/NativeViewController.m new file mode 100644 index 0000000000000000000000000000000000000000..e82375aa9b0b5a06bd6f2fc1d4145132ece767d6 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/ios/Runner/NativeViewController.m @@ -0,0 +1,34 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import + +#import "NativeViewController.h" + +@interface NativeViewController () +@property int counter; +@property (weak, nonatomic) IBOutlet UILabel* incrementLabel; +@end + +@implementation NativeViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + self.counter = 0; +} + +- (IBAction)handleIncrement:(id)sender { + [self.delegate didTapIncrementButton]; +} + +- (void)didReceiveIncrement { + self.counter++; + + NSString* text = [NSString stringWithFormat:@"Flutter button tapped %d %@.", + self.counter, + (self.counter == 1)? @"time" : @"times"]; + self.incrementLabel.text = text; +} + +@end diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Runner/ic_add.png b/novelforge-project/flutter/examples/flutter_view/ios/Runner/ic_add.png new file mode 100644 index 0000000000000000000000000000000000000000..23bf119211e02b139ad2e0961bc71662ce1caf1e Binary files /dev/null and b/novelforge-project/flutter/examples/flutter_view/ios/Runner/ic_add.png differ diff --git a/novelforge-project/flutter/examples/flutter_view/ios/Runner/main.m b/novelforge-project/flutter/examples/flutter_view/ios/Runner/main.m new file mode 100644 index 0000000000000000000000000000000000000000..86070722733949a969321315b3d1ad7ed69711bc --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/ios/Runner/main.m @@ -0,0 +1,14 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, + NSStringFromClass([AppDelegate class])); + } +} diff --git a/novelforge-project/flutter/examples/flutter_view/macos/Runner.xcodeproj/project.pbxproj b/novelforge-project/flutter/examples/flutter_view/macos/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000000000000000000000000000000000000..81495df5b9f433d68474af387ab7faa28eade0bc --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/macos/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,585 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXAggregateTarget section */ + 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = { + isa = PBXAggregateTarget; + buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */; + buildPhases = ( + 33CC111E2044C6BF0003C045 /* ShellScript */, + ); + dependencies = ( + ); + name = "Flutter Assemble"; + productName = FLX; + }; +/* End PBXAggregateTarget section */ + +/* Begin PBXBuildFile section */ + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; + F38F092928CC0D6C009892F7 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F38F092828CC0D6C009892F7 /* Main.storyboard */; }; + F38F092B28CC0F0F009892F7 /* NativeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F38F092A28CC0F0F009892F7 /* NativeViewController.swift */; }; + F38F092D28CC0FC7009892F7 /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F38F092C28CC0FC7009892F7 /* MainViewController.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC111A2044C6BA0003C045; + remoteInfo = FLX; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 33CC110E2044A8840003C045 /* Bundle Framework */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Bundle Framework"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; + 33CC10ED2044A3C60003C045 /* flutter_view.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = flutter_view.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; + 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; + 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; }; + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; }; + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; + 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; + 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; + 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; + F38F092828CC0D6C009892F7 /* Main.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = ""; }; + F38F092A28CC0F0F009892F7 /* NativeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NativeViewController.swift; sourceTree = ""; }; + F38F092C28CC0FC7009892F7 /* MainViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainViewController.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 33CC10EA2044A3C60003C045 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 33BA886A226E78AF003329D5 /* Configs */ = { + isa = PBXGroup; + children = ( + 33E5194F232828860026EE4D /* AppInfo.xcconfig */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */, + ); + path = Configs; + sourceTree = ""; + }; + 33CC10E42044A3C60003C045 = { + isa = PBXGroup; + children = ( + 33FAB671232836740065AC1E /* Runner */, + 33CEB47122A05771004F2AC0 /* Flutter */, + 33CC10EE2044A3C60003C045 /* Products */, + D73912EC22F37F3D000D13A0 /* Frameworks */, + ); + sourceTree = ""; + }; + 33CC10EE2044A3C60003C045 /* Products */ = { + isa = PBXGroup; + children = ( + 33CC10ED2044A3C60003C045 /* flutter_view.app */, + ); + name = Products; + sourceTree = ""; + }; + 33CC11242044D66E0003C045 /* Resources */ = { + isa = PBXGroup; + children = ( + 33CC10F22044A3C60003C045 /* Assets.xcassets */, + 33CC10F42044A3C60003C045 /* MainMenu.xib */, + F38F092828CC0D6C009892F7 /* Main.storyboard */, + 33CC10F72044A3C60003C045 /* Info.plist */, + ); + name = Resources; + path = ..; + sourceTree = ""; + }; + 33CEB47122A05771004F2AC0 /* Flutter */ = { + isa = PBXGroup; + children = ( + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */, + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, + ); + path = Flutter; + sourceTree = ""; + }; + 33FAB671232836740065AC1E /* Runner */ = { + isa = PBXGroup; + children = ( + 33CC10F02044A3C60003C045 /* AppDelegate.swift */, + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */, + F38F092C28CC0FC7009892F7 /* MainViewController.swift */, + F38F092A28CC0F0F009892F7 /* NativeViewController.swift */, + 33E51913231747F40026EE4D /* DebugProfile.entitlements */, + 33E51914231749380026EE4D /* Release.entitlements */, + 33CC11242044D66E0003C045 /* Resources */, + 33BA886A226E78AF003329D5 /* Configs */, + ); + path = Runner; + sourceTree = ""; + }; + D73912EC22F37F3D000D13A0 /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 33CC10EC2044A3C60003C045 /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 33CC10E92044A3C60003C045 /* Sources */, + 33CC10EA2044A3C60003C045 /* Frameworks */, + 33CC10EB2044A3C60003C045 /* Resources */, + 33CC110E2044A8840003C045 /* Bundle Framework */, + 3399D490228B24CF009A79C7 /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + 33CC11202044C79F0003C045 /* PBXTargetDependency */, + ); + name = Runner; + productName = Runner; + productReference = 33CC10ED2044A3C60003C045 /* flutter_view.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 33CC10E52044A3C60003C045 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0920; + LastUpgradeCheck = 1510; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 33CC10EC2044A3C60003C045 = { + CreatedOnToolsVersion = 9.2; + LastSwiftMigration = 1100; + ProvisioningStyle = Automatic; + SystemCapabilities = { + com.apple.Sandbox = { + enabled = 1; + }; + }; + }; + 33CC111A2044C6BA0003C045 = { + CreatedOnToolsVersion = 9.2; + ProvisioningStyle = Manual; + }; + }; + }; + buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 33CC10E42044A3C60003C045; + productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 33CC10EC2044A3C60003C045 /* Runner */, + 33CC111A2044C6BA0003C045 /* Flutter Assemble */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 33CC10EB2044A3C60003C045 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + F38F092928CC0D6C009892F7 /* Main.storyboard in Resources */, + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3399D490228B24CF009A79C7 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; + }; + 33CC111E2044C6BF0003C045 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + Flutter/ephemeral/FlutterInputs.xcfilelist, + ); + inputPaths = ( + Flutter/ephemeral/tripwire, + ); + outputFileListPaths = ( + Flutter/ephemeral/FlutterOutputs.xcfilelist, + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 33CC10E92044A3C60003C045 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */, + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */, + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */, + F38F092B28CC0F0F009892F7 /* NativeViewController.swift in Sources */, + F38F092D28CC0FC7009892F7 /* MainViewController.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 33CC11202044C79F0003C045 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */; + targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 33CC10F42044A3C60003C045 /* MainMenu.xib */ = { + isa = PBXVariantGroup; + children = ( + 33CC10F52044A3C60003C045 /* Base */, + ); + name = MainMenu.xib; + path = Runner; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 338D0CE9231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Profile; + }; + 338D0CEA231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Profile; + }; + 338D0CEB231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Profile; + }; + 33CC10F92044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 33CC10FA2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + 33CC10FC2044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 33CC10FD2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 33CC111C2044C6BA0003C045 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 33CC111D2044C6BA0003C045 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10F92044A3C60003C045 /* Debug */, + 33CC10FA2044A3C60003C045 /* Release */, + 338D0CE9231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10FC2044A3C60003C045 /* Debug */, + 33CC10FD2044A3C60003C045 /* Release */, + 338D0CEA231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC111C2044C6BA0003C045 /* Debug */, + 33CC111D2044C6BA0003C045 /* Release */, + 338D0CEB231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 33CC10E52044A3C60003C045 /* Project object */; +} diff --git a/novelforge-project/flutter/examples/flutter_view/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/novelforge-project/flutter/examples/flutter_view/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000000000000000000000000000000000000..18d981003d68d0546c4804ac2ff47dd97c6e7921 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/novelforge-project/flutter/examples/flutter_view/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/novelforge-project/flutter/examples/flutter_view/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000000000000000000000000000000000000..a7d8ce3a9a3c7de5d02135759c45aebc9d871c72 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/novelforge-project/flutter/examples/flutter_view/macos/Runner.xcworkspace/contents.xcworkspacedata b/novelforge-project/flutter/examples/flutter_view/macos/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000000000000000000000000000000000000..1d526a16ed0f1cd0c2409d848bf489b93fefa3b2 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/macos/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/novelforge-project/flutter/examples/flutter_view/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/novelforge-project/flutter/examples/flutter_view/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000000000000000000000000000000000000..18d981003d68d0546c4804ac2ff47dd97c6e7921 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/novelforge-project/flutter/examples/flutter_view/macos/Runner/Base.lproj/MainMenu.xib b/novelforge-project/flutter/examples/flutter_view/macos/Runner/Base.lproj/MainMenu.xib new file mode 100644 index 0000000000000000000000000000000000000000..ed58e810a587fb9189d68aabcd859e304dd47105 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/macos/Runner/Base.lproj/MainMenu.xib @@ -0,0 +1,344 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/novelforge-project/flutter/examples/flutter_view/macos/Runner/Configs/AppInfo.xcconfig b/novelforge-project/flutter/examples/flutter_view/macos/Runner/Configs/AppInfo.xcconfig new file mode 100644 index 0000000000000000000000000000000000000000..48e3350e08638e204ddacb19dfa8e6e3d3c9d955 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/macos/Runner/Configs/AppInfo.xcconfig @@ -0,0 +1,14 @@ +// Application-level settings for the Runner target. +// +// This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the +// future. If not, the values below would default to using the project name when this becomes a +// 'flutter create' template. + +// The application's name. By default this is also the title of the Flutter window. +PRODUCT_NAME = flutter_view + +// The application's bundle identifier +PRODUCT_BUNDLE_IDENTIFIER = io.flutter.examples.flutterView + +// The copyright displayed in application information +PRODUCT_COPYRIGHT = Copyright © 2022 io.flutter.examples. All rights reserved. diff --git a/novelforge-project/flutter/examples/flutter_view/macos/Runner/Configs/Debug.xcconfig b/novelforge-project/flutter/examples/flutter_view/macos/Runner/Configs/Debug.xcconfig new file mode 100644 index 0000000000000000000000000000000000000000..36b0fd9464f45b33f482e64bea579787e142affa --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/macos/Runner/Configs/Debug.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Debug.xcconfig" +#include "Warnings.xcconfig" diff --git a/novelforge-project/flutter/examples/flutter_view/macos/Runner/Configs/Release.xcconfig b/novelforge-project/flutter/examples/flutter_view/macos/Runner/Configs/Release.xcconfig new file mode 100644 index 0000000000000000000000000000000000000000..dff4f49561c816f70eaea557d889d31cf63447ac --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/macos/Runner/Configs/Release.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Release.xcconfig" +#include "Warnings.xcconfig" diff --git a/novelforge-project/flutter/examples/flutter_view/macos/Runner/Configs/Warnings.xcconfig b/novelforge-project/flutter/examples/flutter_view/macos/Runner/Configs/Warnings.xcconfig new file mode 100644 index 0000000000000000000000000000000000000000..42bcbf4780b187e80025b7917058bcb882012aa1 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/macos/Runner/Configs/Warnings.xcconfig @@ -0,0 +1,13 @@ +WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings +GCC_WARN_UNDECLARED_SELECTOR = YES +CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES +CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE +CLANG_WARN__DUPLICATE_METHOD_MATCH = YES +CLANG_WARN_PRAGMA_PACK = YES +CLANG_WARN_STRICT_PROTOTYPES = YES +CLANG_WARN_COMMA = YES +GCC_WARN_STRICT_SELECTOR_MATCH = YES +CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES +CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES +GCC_WARN_SHADOW = YES +CLANG_WARN_UNREACHABLE_CODE = YES diff --git a/novelforge-project/flutter/examples/flutter_view/macos/Runner/Info.plist b/novelforge-project/flutter/examples/flutter_view/macos/Runner/Info.plist new file mode 100644 index 0000000000000000000000000000000000000000..4789daa6a443eefa7f3f729164a18351e06e9800 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/macos/Runner/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + $(PRODUCT_COPYRIGHT) + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/novelforge-project/flutter/examples/flutter_view/macos/Runner/MainFlutterWindow.swift b/novelforge-project/flutter/examples/flutter_view/macos/Runner/MainFlutterWindow.swift new file mode 100644 index 0000000000000000000000000000000000000000..80fdda0b735ddc40706120ac103fa56c1019a869 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/macos/Runner/MainFlutterWindow.swift @@ -0,0 +1,25 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import Cocoa +import FlutterMacOS + +/** +The window that is automatically generated when `flutter create --target=macos` +on a project. `MainFlutterWindow` uses a FlutterViewController as it's content +view controller by default. +*/ +class MainFlutterWindow: NSWindow { + override func awakeFromNib() { + let windowFrame = self.frame + let storyboard = NSStoryboard(name: NSStoryboard.Name("Main"), bundle: Bundle.main) + // `flutter create --target=macos` uses this class (`self`) as an entrypoint + // for drawing on a surface. The line below intercepts that and uses + // the storyboard from `Main.storyboard`. + self.contentViewController = storyboard.instantiateController(withIdentifier: "MainViewController") as! NSViewController + self.setFrame(windowFrame, display: true) + + super.awakeFromNib() + } +} diff --git a/novelforge-project/flutter/examples/flutter_view/macos/Runner/MainViewController.swift b/novelforge-project/flutter/examples/flutter_view/macos/Runner/MainViewController.swift new file mode 100644 index 0000000000000000000000000000000000000000..9585090f6ee4e21408ecbb9586db6cafe7849ff1 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/macos/Runner/MainViewController.swift @@ -0,0 +1,69 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import Foundation +import AppKit +import FlutterMacOS + +/** +The code behind a storyboard view which splits a flutter view and a macOS view. +*/ +class MainViewController: NSViewController, NativeViewControllerDelegate { + static let emptyString: String = "" + static let ping: String = "ping" + static let channel: String = "increment" + + var nativeViewController: NativeViewController? + var flutterViewController: FlutterViewController? + var messageChannel: FlutterBasicMessageChannel? + + override func viewDidLoad() { + super.viewDidLoad() + } + + override func prepare(for segue: NSStoryboardSegue, sender: Any?) { + if segue.identifier == "NativeViewControllerSegue" { + self.nativeViewController = segue.destinationController as? NativeViewController + + // Since`MainViewController` owns the platform channel, but not the + // UI elements that trigger an action, those UI elements need a reference + // to this controller to send messages on the platform channel. + self.nativeViewController?.delegate = self + } + + if segue.identifier == "FlutterViewControllerSegue" { + self.flutterViewController = segue.destinationController as? FlutterViewController + + RegisterMethodChannel(registry: self.flutterViewController!) + + weak var weakSelf = self + messageChannel?.setMessageHandler({ (message, reply) in + + // Dispatch an event, incrementing the counter in this case, when *any* + // message is received. + + // Depending on the order of initialization, the nativeViewController + // might not be initialized until this point. + weakSelf?.nativeViewController?.didReceiveIncrement() + reply(MainViewController.emptyString) + }) + } + } + + func RegisterMethodChannel(registry: FlutterPluginRegistry) { + let registrar = registry.registrar(forPlugin: "") + messageChannel = FlutterBasicMessageChannel( + name: MainViewController.channel, + binaryMessenger: registrar.messenger, + codec: FlutterStringCodec.sharedInstance()) + } + + // Call in any instance where `ping` is to be sent through the `increment` + // channel. + + func didTapIncrementButton() { + self.messageChannel?.sendMessage(MainViewController.ping) + } + +} diff --git a/novelforge-project/flutter/examples/flutter_view/macos/Runner/NativeViewController.swift b/novelforge-project/flutter/examples/flutter_view/macos/Runner/NativeViewController.swift new file mode 100644 index 0000000000000000000000000000000000000000..cf791a15e4b011ade8d9f4f91a23db45e9174065 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/macos/Runner/NativeViewController.swift @@ -0,0 +1,50 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import Foundation +import AppKit + +protocol NativeViewControllerDelegate: NSObjectProtocol { + func didTapIncrementButton() +} + +/** +The code behind a native view to be displayed in the `MainFlutterViewController` +as an embed segue. If any storyboard view inherits from this class definition, +it should contain a function to handle for `handleIncrement` +*/ +class NativeViewController: NSViewController { + + var count: Int? + + var labelText: String { + get { + let count = self.count ?? 0 + return "Flutter button tapped \(count) time\(count == 1 ? "" : "s")" + } + } + + var delegate: NativeViewControllerDelegate? + + @IBOutlet weak var incrementLabel: NSTextField! + + @IBAction func handleIncrement(_ sender: Any) { + self.delegate?.didTapIncrementButton() + } + + override func viewDidLoad() { + super.viewDidLoad() + setState(for: 0) + } + + func didReceiveIncrement() { + setState(for: (self.count ?? 0) + 1) + } + + func setState(for count: Int) { + self.count = count + self.incrementLabel.stringValue = labelText + } + +} diff --git a/novelforge-project/flutter/examples/flutter_view/macos/Runner/Release.entitlements b/novelforge-project/flutter/examples/flutter_view/macos/Runner/Release.entitlements new file mode 100644 index 0000000000000000000000000000000000000000..852fa1a4728ae4789e3bca55dd07caef3b41f2a5 --- /dev/null +++ b/novelforge-project/flutter/examples/flutter_view/macos/Runner/Release.entitlements @@ -0,0 +1,8 @@ + + + + + com.apple.security.app-sandbox + + + diff --git a/novelforge-project/flutter/examples/hello_world/android/build.gradle b/novelforge-project/flutter/examples/hello_world/android/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..a38857e025b8d21aa747461529ead078874202ac --- /dev/null +++ b/novelforge-project/flutter/examples/hello_world/android/build.gradle @@ -0,0 +1,50 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This file is auto generated. +// To update all the build.gradle files in the Flutter repo, +// See dev/tools/bin/generate_gradle_lockfiles.dart. + +buildscript { + ext.kotlin_version = '1.9.0' + repositories { + google() + mavenCentral() + } + + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } + + configurations.classpath { + resolutionStrategy.activateDependencyLocking() + } +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = '../build' + +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(':app') + dependencyLocking { + ignoredDependencies.add('io.flutter:*') + lockFile = file("${rootProject.projectDir}/project-${project.name}.lockfile") + if (!project.hasProperty('local-engine-repo')) { + lockAllConfigurations() + } + } +} + +tasks.register("clean", Delete) { + delete rootProject.buildDir +} diff --git a/novelforge-project/flutter/examples/hello_world/android/build.gradle.kts b/novelforge-project/flutter/examples/hello_world/android/build.gradle.kts new file mode 100644 index 0000000000000000000000000000000000000000..e7755cd5f8d4372dda99ff012db8599d7d2cc487 --- /dev/null +++ b/novelforge-project/flutter/examples/hello_world/android/build.gradle.kts @@ -0,0 +1,34 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Contents of this file should be generated automatically by +// dev/tools/bin/generate_gradle_lockfiles.dart, but currently are not. +// See #141540. + +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = file("../build") + +subprojects { + project.buildDir = file("${rootProject.buildDir}/${project.name}") +} +subprojects { + project.evaluationDependsOn(":app") + dependencyLocking { + ignoredDependencies.add("io.flutter:*") + lockFile = file("${rootProject.projectDir}/project-${project.name}.lockfile") + if (!project.hasProperty("local-engine-repo")) { + lockAllConfigurations() + } + } +} + +tasks.register("clean") { + delete(rootProject.buildDir) +} diff --git a/novelforge-project/flutter/examples/hello_world/android/buildscript-gradle.lockfile b/novelforge-project/flutter/examples/hello_world/android/buildscript-gradle.lockfile new file mode 100644 index 0000000000000000000000000000000000000000..14350adbcb4575031503358df422a1ab7096a7ab --- /dev/null +++ b/novelforge-project/flutter/examples/hello_world/android/buildscript-gradle.lockfile @@ -0,0 +1,29 @@ +# This is a Gradle generated file for dependency locking. +# Manual edits can break the build and are not advised. +# This file is expected to be part of source control. +org.jetbrains.intellij.deps:trove4j:1.0.20200330=classpath +org.jetbrains.kotlin:kotlin-android-extensions:1.9.0=classpath +org.jetbrains.kotlin:kotlin-build-tools-api:1.9.0=classpath +org.jetbrains.kotlin:kotlin-compiler-embeddable:1.9.0=classpath +org.jetbrains.kotlin:kotlin-compiler-runner:1.9.0=classpath +org.jetbrains.kotlin:kotlin-daemon-client:1.9.0=classpath +org.jetbrains.kotlin:kotlin-daemon-embeddable:1.9.0=classpath +org.jetbrains.kotlin:kotlin-gradle-plugin-annotations:1.9.0=classpath +org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.9.0=classpath +org.jetbrains.kotlin:kotlin-gradle-plugin-idea-proto:1.9.0=classpath +org.jetbrains.kotlin:kotlin-gradle-plugin-idea:1.9.0=classpath +org.jetbrains.kotlin:kotlin-gradle-plugin-model:1.9.0=classpath +org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0=classpath +org.jetbrains.kotlin:kotlin-gradle-plugins-bom:1.9.0=classpath +org.jetbrains.kotlin:kotlin-klib-commonizer-api:1.9.0=classpath +org.jetbrains.kotlin:kotlin-native-utils:1.9.0=classpath +org.jetbrains.kotlin:kotlin-project-model:1.9.0=classpath +org.jetbrains.kotlin:kotlin-scripting-common:1.9.0=classpath +org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.9.0=classpath +org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.9.0=classpath +org.jetbrains.kotlin:kotlin-scripting-jvm:1.9.0=classpath +org.jetbrains.kotlin:kotlin-tooling-core:1.9.0=classpath +org.jetbrains.kotlin:kotlin-util-io:1.9.0=classpath +org.jetbrains.kotlin:kotlin-util-klib:1.9.0=classpath +org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.0=classpath +empty= diff --git a/novelforge-project/flutter/examples/hello_world/android/gradle.properties b/novelforge-project/flutter/examples/hello_world/android/gradle.properties new file mode 100644 index 0000000000000000000000000000000000000000..598d13fee446372f156ecc38527b54c7cdcc8e3b --- /dev/null +++ b/novelforge-project/flutter/examples/hello_world/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx4G +android.useAndroidX=true +android.enableJetifier=true diff --git a/novelforge-project/flutter/examples/hello_world/android/project-app.lockfile b/novelforge-project/flutter/examples/hello_world/android/project-app.lockfile new file mode 100644 index 0000000000000000000000000000000000000000..0d87887fa38ec4e6f3bee73be248e003d7c37a4f --- /dev/null +++ b/novelforge-project/flutter/examples/hello_world/android/project-app.lockfile @@ -0,0 +1,118 @@ +# This is a Gradle generated file for dependency locking. +# Manual edits can break the build and are not advised. +# This file is expected to be part of source control. +androidx.activity:activity:1.0.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.annotation:annotation-experimental:1.1.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.annotation:annotation:1.2.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.arch.core:core-common:2.1.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.arch.core:core-runtime:2.0.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.collection:collection:1.1.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.core:core:1.6.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.customview:customview:1.0.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.fragment:fragment:1.1.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.lifecycle:lifecycle-common-java8:2.2.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.lifecycle:lifecycle-common:2.2.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.lifecycle:lifecycle-livedata-core:2.0.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.lifecycle:lifecycle-livedata:2.0.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.lifecycle:lifecycle-runtime:2.2.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.lifecycle:lifecycle-viewmodel:2.1.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.loader:loader:1.0.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.savedstate:savedstate:1.0.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.tracing:tracing:1.0.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.versionedparcelable:versionedparcelable:1.1.1=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.viewpager:viewpager:1.0.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.window:window-java:1.0.0-beta04=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.window:window:1.0.0-beta04=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +com.android.tools.analytics-library:protos:27.1.3=lintClassPath +com.android.tools.analytics-library:shared:27.1.3=lintClassPath +com.android.tools.analytics-library:tracker:27.1.3=lintClassPath +com.android.tools.build:aapt2-proto:4.1.0-alpha01-6193524=lintClassPath +com.android.tools.build:aapt2:4.1.3-6503028=_internal_aapt2_binary +com.android.tools.build:apksig:4.1.3=lintClassPath +com.android.tools.build:apkzlib:4.1.3=lintClassPath +com.android.tools.build:builder-model:4.1.3=lintClassPath +com.android.tools.build:builder-test-api:4.1.3=lintClassPath +com.android.tools.build:builder:4.1.3=lintClassPath +com.android.tools.build:gradle-api:4.1.3=lintClassPath +com.android.tools.build:manifest-merger:27.1.3=lintClassPath +com.android.tools.ddms:ddmlib:27.1.3=lintClassPath +com.android.tools.external.com-intellij:intellij-core:27.1.3=lintClassPath +com.android.tools.external.com-intellij:kotlin-compiler:27.1.3=lintClassPath +com.android.tools.external.org-jetbrains:uast:27.1.3=lintClassPath +com.android.tools.layoutlib:layoutlib-api:27.1.3=lintClassPath +com.android.tools.lint:lint-api:27.1.3=lintClassPath +com.android.tools.lint:lint-checks:27.1.3=lintClassPath +com.android.tools.lint:lint-gradle-api:27.1.3=lintClassPath +com.android.tools.lint:lint-gradle:27.1.3=lintClassPath +com.android.tools.lint:lint-model:27.1.3=lintClassPath +com.android.tools.lint:lint:27.1.3=lintClassPath +com.android.tools:annotations:27.1.3=lintClassPath +com.android.tools:common:27.1.3=lintClassPath +com.android.tools:dvlib:27.1.3=lintClassPath +com.android.tools:repository:27.1.3=lintClassPath +com.android.tools:sdk-common:27.1.3=lintClassPath +com.android.tools:sdklib:27.1.3=lintClassPath +com.android:signflinger:4.1.3=lintClassPath +com.android:zipflinger:4.1.3=lintClassPath +com.google.code.findbugs:jsr305:3.0.2=lintClassPath +com.google.code.gson:gson:2.8.5=lintClassPath +com.google.errorprone:error_prone_annotations:2.3.2=lintClassPath +com.google.guava:failureaccess:1.0.1=lintClassPath +com.google.guava:guava:28.1-jre=lintClassPath +com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=lintClassPath +com.google.j2objc:j2objc-annotations:1.3=lintClassPath +com.google.jimfs:jimfs:1.1=lintClassPath +com.google.protobuf:protobuf-java:3.10.0=lintClassPath +com.googlecode.json-simple:json-simple:1.1=lintClassPath +com.squareup:javawriter:2.5.0=lintClassPath +com.sun.activation:javax.activation:1.2.0=lintClassPath +com.sun.istack:istack-commons-runtime:3.0.7=lintClassPath +com.sun.xml.fastinfoset:FastInfoset:1.2.15=lintClassPath +commons-codec:commons-codec:1.10=lintClassPath +commons-logging:commons-logging:1.2=lintClassPath +it.unimi.dsi:fastutil:7.2.0=lintClassPath +javax.activation:javax.activation-api:1.2.0=lintClassPath +javax.inject:javax.inject:1=lintClassPath +javax.xml.bind:jaxb-api:2.3.1=lintClassPath +net.sf.jopt-simple:jopt-simple:4.9=lintClassPath +net.sf.kxml:kxml2:2.3.0=lintClassPath +org.apache.commons:commons-compress:1.12=lintClassPath +org.apache.httpcomponents:httpclient:4.5.6=lintClassPath +org.apache.httpcomponents:httpcore:4.4.10=lintClassPath +org.apache.httpcomponents:httpmime:4.5.6=lintClassPath +org.bouncycastle:bcpkix-jdk15on:1.56=lintClassPath +org.bouncycastle:bcprov-jdk15on:1.56=lintClassPath +org.checkerframework:checker-qual:2.8.1=lintClassPath +org.codehaus.groovy:groovy-all:2.4.15=lintClassPath +org.codehaus.mojo:animal-sniffer-annotations:1.18=lintClassPath +org.glassfish.jaxb:jaxb-runtime:2.3.1=lintClassPath +org.glassfish.jaxb:txw2:2.3.1=lintClassPath +org.jacoco:org.jacoco.agent:0.8.8=androidJacocoAnt +org.jacoco:org.jacoco.ant:0.8.8=androidJacocoAnt +org.jacoco:org.jacoco.core:0.8.8=androidJacocoAnt +org.jacoco:org.jacoco.report:0.8.8=androidJacocoAnt +org.jetbrains.kotlin:kotlin-reflect:1.3.72=lintClassPath +org.jetbrains.kotlin:kotlin-stdlib-common:1.3.72=lintClassPath +org.jetbrains.kotlin:kotlin-stdlib-common:1.5.31=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.72=lintClassPath +org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.30=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72=lintClassPath +org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.30=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +org.jetbrains.kotlin:kotlin-stdlib:1.3.72=lintClassPath +org.jetbrains.kotlin:kotlin-stdlib:1.5.31=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.2=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +org.jetbrains.trove4j:trove4j:20160824=lintClassPath +org.jetbrains:annotations:13.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,lintClassPath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +org.jvnet.staxex:stax-ex:1.8=lintClassPath +org.ow2.asm:asm-analysis:7.0=lintClassPath +org.ow2.asm:asm-analysis:9.2=androidJacocoAnt +org.ow2.asm:asm-commons:7.0=lintClassPath +org.ow2.asm:asm-commons:9.2=androidJacocoAnt +org.ow2.asm:asm-tree:7.0=lintClassPath +org.ow2.asm:asm-tree:9.2=androidJacocoAnt +org.ow2.asm:asm-util:7.0=lintClassPath +org.ow2.asm:asm:7.0=lintClassPath +org.ow2.asm:asm:9.2=androidJacocoAnt +empty=androidApis,androidJdkImage,androidTestUtil,compile,coreLibraryDesugaring,debugAndroidTestAnnotationProcessorClasspath,debugAndroidTestRuntimeClasspath,debugAnnotationProcessorClasspath,debugReverseMetadataValues,debugUnitTestAnnotationProcessorClasspath,debugWearBundling,lintChecks,lintPublish,profileAnnotationProcessorClasspath,profileReverseMetadataValues,profileUnitTestAnnotationProcessorClasspath,profileWearBundling,releaseAnnotationProcessorClasspath,releaseReverseMetadataValues,releaseUnitTestAnnotationProcessorClasspath,releaseWearBundling,testCompile diff --git a/novelforge-project/flutter/examples/hello_world/android/settings.gradle b/novelforge-project/flutter/examples/hello_world/android/settings.gradle new file mode 100644 index 0000000000000000000000000000000000000000..cfecca12d3aa940bddebf93e1179e5700a7000ec --- /dev/null +++ b/novelforge-project/flutter/examples/hello_world/android/settings.gradle @@ -0,0 +1,34 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This file is auto generated. +// To update all the settings.gradle files in the Flutter repo, +// See dev/tools/bin/generate_gradle_lockfiles.dart. + +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + } + settings.ext.flutterSdkPath = flutterSdkPath() + + // Flutter Gradle Plugin ships together with the Flutter SDK + includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle") + + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + +plugins { + id "dev.flutter.flutter-plugin-loader" version "1.0.0" + id "com.android.application" version "7.4.2" apply false +} + +include ':app' diff --git a/novelforge-project/flutter/examples/hello_world/android/settings.gradle.kts b/novelforge-project/flutter/examples/hello_world/android/settings.gradle.kts new file mode 100644 index 0000000000000000000000000000000000000000..b1a0c7d3234c425a54e9dd4d27ff431450dd4e2e --- /dev/null +++ b/novelforge-project/flutter/examples/hello_world/android/settings.gradle.kts @@ -0,0 +1,41 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Contents of this file should be generated automatically by +// dev/tools/bin/generate_gradle_lockfiles.dart, but currently are not. +// See #141540. + +pluginManagement { + val flutterSdkPath = + run { + val properties = java.util.Properties() + file("local.properties").inputStream().use { properties.load(it) } + val flutterSdkPath = properties.getProperty("flutter.sdk") + require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" } + flutterSdkPath + } + + includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") + + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + +buildscript { + dependencyLocking { + lockFile = file("${rootProject.projectDir}/buildscript-gradle.lockfile") + lockAllConfigurations() + } +} + +plugins { + id("dev.flutter.flutter-plugin-loader") version "1.0.0" + id("com.android.application") version "7.4.2" apply false + id("org.jetbrains.kotlin.android") version "1.7.10" apply false +} + +include(":app") diff --git a/novelforge-project/flutter/examples/hello_world/lib/arabic.dart b/novelforge-project/flutter/examples/hello_world/lib/arabic.dart new file mode 100644 index 0000000000000000000000000000000000000000..8b5bae33230da9224e70e676571089d01fbf8ac2 --- /dev/null +++ b/novelforge-project/flutter/examples/hello_world/lib/arabic.dart @@ -0,0 +1,7 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/widgets.dart'; + +void main() => runApp(const Center(child: Text('برنامج أهلا بالعالم', textDirection: TextDirection.rtl))); diff --git a/novelforge-project/flutter/examples/hello_world/lib/main.dart b/novelforge-project/flutter/examples/hello_world/lib/main.dart new file mode 100644 index 0000000000000000000000000000000000000000..3fcab6a389483b7498bd8a23501ef72846f109b6 --- /dev/null +++ b/novelforge-project/flutter/examples/hello_world/lib/main.dart @@ -0,0 +1,16 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/widgets.dart'; + +void main() => + runApp( + const Center( + child: + Text('Hello, world!', + key: Key('title'), + textDirection: TextDirection.ltr, + ), + ), + ); diff --git a/novelforge-project/flutter/examples/hello_world/linux/CMakeLists.txt b/novelforge-project/flutter/examples/hello_world/linux/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..a50a4b5dcd04aa3df6ffebbf6d5722e5e4fe9732 --- /dev/null +++ b/novelforge-project/flutter/examples/hello_world/linux/CMakeLists.txt @@ -0,0 +1,138 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.10) +project(runner LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "hello_world") +# The unique GTK application identifier for this application. See: +# https://wiki.gnome.org/HowDoI/ChooseApplicationID +set(APPLICATION_ID "io.flutter.examples.hello_world") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(SET CMP0063 NEW) + +# Load bundled libraries from the lib/ directory relative to the binary. +set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") + +# Root filesystem for cross-building. +if(FLUTTER_TARGET_PLATFORM_SYSROOT) + set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif() + +# Define build configuration options. +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") +endif() + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_14) + target_compile_options(${TARGET} PRIVATE -Wall -Werror) + target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") + target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) + +add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") + +# Define the application target. To change its name, change BINARY_NAME above, +# not the value here, or `flutter run` will no longer work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} + "main.cc" + "my_application.cc" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add dependency libraries. Add any application-specific dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter) +target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) + +# Only the install-generated bundle's copy of the executable will launch +# correctly, since the resources must in the right relative locations. To avoid +# people trying to run the unbundled copy, put it in a subdirectory instead of +# the default top-level location. +set_target_properties(${BINARY_NAME} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" +) + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# By default, "installing" just makes a relocatable bundle in the build +# directory. +set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +# Start with a clean build bundle directory every time. +install(CODE " + file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") + " COMPONENT Runtime) + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) + install(FILES "${bundled_library}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endforeach(bundled_library) + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() diff --git a/novelforge-project/flutter/examples/hello_world/linux/main.cc b/novelforge-project/flutter/examples/hello_world/linux/main.cc new file mode 100644 index 0000000000000000000000000000000000000000..281a29e16b599a95421e7a35112eda77900ff549 --- /dev/null +++ b/novelforge-project/flutter/examples/hello_world/linux/main.cc @@ -0,0 +1,10 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "my_application.h" + +int main(int argc, char** argv) { + g_autoptr(MyApplication) app = my_application_new(); + return g_application_run(G_APPLICATION(app), argc, argv); +} diff --git a/novelforge-project/flutter/examples/hello_world/linux/my_application.cc b/novelforge-project/flutter/examples/hello_world/linux/my_application.cc new file mode 100644 index 0000000000000000000000000000000000000000..5297953716ebe8edc5bc69e2f7372ee68f5a01e6 --- /dev/null +++ b/novelforge-project/flutter/examples/hello_world/linux/my_application.cc @@ -0,0 +1,111 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "my_application.h" + +#include +#ifdef GDK_WINDOWING_X11 +#include +#endif + +#include "flutter/generated_plugin_registrant.h" + +struct _MyApplication { + GtkApplication parent_instance; + char** dart_entrypoint_arguments; +}; + +G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) + +// Implements GApplication::activate. +static void my_application_activate(GApplication* application) { + MyApplication* self = MY_APPLICATION(application); + GtkWindow* window = + GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); + + // Use a header bar when running in GNOME as this is the common style used + // by applications and is the setup most users will be using (e.g. Ubuntu + // desktop). + // If running on X and not using GNOME then just use a traditional title bar + // in case the window manager does more exotic layout, e.g. tiling. + // If running on Wayland assume the header bar will work (may need changing + // if future cases occur). + gboolean use_header_bar = TRUE; +#ifdef GDK_WINDOWING_X11 + GdkScreen* screen = gtk_window_get_screen(window); + if (GDK_IS_X11_SCREEN(screen)) { + const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); + if (g_strcmp0(wm_name, "GNOME Shell") != 0) { + use_header_bar = FALSE; + } + } +#endif + if (use_header_bar) { + GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); + gtk_widget_show(GTK_WIDGET(header_bar)); + gtk_header_bar_set_title(header_bar, "hello_world"); + gtk_header_bar_set_show_close_button(header_bar, TRUE); + gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); + } else { + gtk_window_set_title(window, "hello_world"); + } + + gtk_window_set_default_size(window, 1280, 720); + gtk_widget_show(GTK_WIDGET(window)); + + g_autoptr(FlDartProject) project = fl_dart_project_new(); + fl_dart_project_set_dart_entrypoint_arguments( + project, self->dart_entrypoint_arguments); + + FlView* view = fl_view_new(project); + gtk_widget_show(GTK_WIDGET(view)); + gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); + + fl_register_plugins(FL_PLUGIN_REGISTRY(view)); + + gtk_widget_grab_focus(GTK_WIDGET(view)); +} + +// Implements GApplication::local_command_line. +static gboolean my_application_local_command_line(GApplication* application, + gchar*** arguments, + int* exit_status) { + MyApplication* self = MY_APPLICATION(application); + // Strip out the first argument as it is the binary name. + self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); + + g_autoptr(GError) error = nullptr; + if (!g_application_register(application, nullptr, &error)) { + g_warning("Failed to register: %s", error->message); + *exit_status = 1; + return TRUE; + } + + g_application_activate(application); + *exit_status = 0; + + return TRUE; +} + +// Implements GObject::dispose. +static void my_application_dispose(GObject* object) { + MyApplication* self = MY_APPLICATION(object); + g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); + G_OBJECT_CLASS(my_application_parent_class)->dispose(object); +} + +static void my_application_class_init(MyApplicationClass* klass) { + G_APPLICATION_CLASS(klass)->activate = my_application_activate; + G_APPLICATION_CLASS(klass)->local_command_line = + my_application_local_command_line; + G_OBJECT_CLASS(klass)->dispose = my_application_dispose; +} + +static void my_application_init(MyApplication* self) {} + +MyApplication* my_application_new() { + return MY_APPLICATION(g_object_new(my_application_get_type(), + "application-id", APPLICATION_ID, "flags", + G_APPLICATION_NON_UNIQUE, nullptr)); +} diff --git a/novelforge-project/flutter/examples/hello_world/linux/my_application.h b/novelforge-project/flutter/examples/hello_world/linux/my_application.h new file mode 100644 index 0000000000000000000000000000000000000000..8c66ec485434d1f922c9915bdaefcb8969cdfec9 --- /dev/null +++ b/novelforge-project/flutter/examples/hello_world/linux/my_application.h @@ -0,0 +1,22 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef FLUTTER_MY_APPLICATION_H_ +#define FLUTTER_MY_APPLICATION_H_ + +#include + +G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, + GtkApplication) + +/** + * my_application_new: + * + * Creates a new Flutter-based application. + * + * Returns: a new #MyApplication. + */ +MyApplication* my_application_new(); + +#endif // FLUTTER_MY_APPLICATION_H_ diff --git a/novelforge-project/flutter/examples/hello_world/test/hello_test.dart b/novelforge-project/flutter/examples/hello_world/test/hello_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..46c361c9b53076b2958e22d948827375e496f157 --- /dev/null +++ b/novelforge-project/flutter/examples/hello_world/test/hello_test.dart @@ -0,0 +1,15 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_test/flutter_test.dart'; +import 'package:hello_world/main.dart' as hello_world; + +void main() { + testWidgets('Hello world smoke test', (WidgetTester tester) async { + hello_world.main(); // builds the app and schedules a frame but doesn't trigger one + await tester.pump(); // triggers a frame + + expect(find.text('Hello, world!'), findsOneWidget); + }); +} diff --git a/novelforge-project/flutter/examples/hello_world/test_driver/smoke_web_engine.dart b/novelforge-project/flutter/examples/hello_world/test_driver/smoke_web_engine.dart new file mode 100644 index 0000000000000000000000000000000000000000..6155684e1272f1ae4f6080adf06e05efa19fca06 --- /dev/null +++ b/novelforge-project/flutter/examples/hello_world/test_driver/smoke_web_engine.dart @@ -0,0 +1,12 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_driver/driver_extension.dart'; +import 'package:hello_world/main.dart' as app; + +void main() { + enableFlutterDriverExtension(); + + app.main(); +} diff --git a/novelforge-project/flutter/examples/hello_world/test_driver/smoke_web_engine_test.dart b/novelforge-project/flutter/examples/hello_world/test_driver/smoke_web_engine_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..c7dcaa0873b8c9cbec387b31f036a7e1ad6ced21 --- /dev/null +++ b/novelforge-project/flutter/examples/hello_world/test_driver/smoke_web_engine_test.dart @@ -0,0 +1,48 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; + +import 'package:flutter_driver/flutter_driver.dart'; +import 'package:test/test.dart'; +import 'package:webdriver/async_io.dart'; + +// TODO(web): Migrate this test to a normal integration_test with a WidgetTester. + +/// The following test is used as a simple smoke test for verifying Flutter +/// Framework and Flutter Web Engine integration. +void main() { + group('Hello World App', () { + final SerializableFinder titleFinder = find.byValueKey('title'); + + late FlutterDriver driver; + + // Connect to the Flutter driver before running any tests. + setUpAll(() async { + driver = await FlutterDriver.connect(); + }); + + // Close the connection to the driver after the tests have completed. + tearDownAll(() async { + driver.close(); + }); + + test('title is correct', () async { + expect(await driver.getText(titleFinder), 'Hello, world!'); + }); + + test('enable accessibility', () async { + await driver.setSemantics(true); + + // TODO(ianh): this delay violates our style guide. We should instead wait for a triggering event. + await Future.delayed(const Duration(seconds: 2)); + + final WebElement? fltSemantics = await driver.webDriver.execute( + 'return document.querySelector("flt-semantics")', + [], + ) as WebElement?; + expect(fltSemantics, isNotNull); + }); + }); +} diff --git a/novelforge-project/flutter/examples/hello_world/web/flutter_bootstrap.js b/novelforge-project/flutter/examples/hello_world/web/flutter_bootstrap.js new file mode 100644 index 0000000000000000000000000000000000000000..be78d93ce8c6a5019c16a6c2b13d466745f7dc1a --- /dev/null +++ b/novelforge-project/flutter/examples/hello_world/web/flutter_bootstrap.js @@ -0,0 +1,12 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +{{flutter_js}} +{{flutter_build_config}} +_flutter.loader.load({ + config: { + // Use the local CanvasKit bundle instead of the CDN to reduce test flakiness. + canvasKitBaseUrl: "/canvaskit/", + }, +}); diff --git a/novelforge-project/flutter/examples/hello_world/web/index.html b/novelforge-project/flutter/examples/hello_world/web/index.html new file mode 100644 index 0000000000000000000000000000000000000000..a856086c8ee988a3c27b67aae4f14f19bf709c37 --- /dev/null +++ b/novelforge-project/flutter/examples/hello_world/web/index.html @@ -0,0 +1,12 @@ + + + + + Hello, World + + + + + diff --git a/novelforge-project/flutter/examples/hello_world/windows/CMakeLists.txt b/novelforge-project/flutter/examples/hello_world/windows/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..51ca9d1db750fb9e3fe20a37f951285c983fbdac --- /dev/null +++ b/novelforge-project/flutter/examples/hello_world/windows/CMakeLists.txt @@ -0,0 +1,101 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.14) +project(hello_world LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "hello_world") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(VERSION 3.14...3.25) + +# Define build configuration option. +get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(IS_MULTICONFIG) + set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" + CACHE STRING "" FORCE) +else() + if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") + endif() +endif() +# Define settings for the Profile build mode. +set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") +set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") +set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") +set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") + +# Use Unicode for all projects. +add_definitions(-DUNICODE -D_UNICODE) + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_17) + target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") + target_compile_options(${TARGET} PRIVATE /EHsc) + target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") + target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# Application build; see runner/CMakeLists.txt. +add_subdirectory("runner") + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# Support files are copied into place next to the executable, so that it can +# run in place. This is done instead of making a separate bundle (as on Linux) +# so that building and running from within Visual Studio will work. +set(BUILD_BUNDLE_DIR "$") +# Make the "install" step default, as it's required to run. +set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +if(PLUGIN_BUNDLED_LIBRARIES) + install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + CONFIGURATIONS Profile;Release + COMPONENT Runtime) diff --git a/novelforge-project/flutter/examples/hello_world/windows/flutter/CMakeLists.txt b/novelforge-project/flutter/examples/hello_world/windows/flutter/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..903f4899d6fced0eb941e159f7322b21b320c40c --- /dev/null +++ b/novelforge-project/flutter/examples/hello_world/windows/flutter/CMakeLists.txt @@ -0,0 +1,109 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.14) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. +set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") + +# Set fallback configurations for older versions of the flutter tool. +if (NOT DEFINED FLUTTER_TARGET_PLATFORM) + set(FLUTTER_TARGET_PLATFORM "windows-x64") +endif() + +# === Flutter Library === +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "flutter_export.h" + "flutter_windows.h" + "flutter_messenger.h" + "flutter_plugin_registrar.h" + "flutter_texture_registrar.h" +) +list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") +add_dependencies(flutter flutter_assemble) + +# === Wrapper === +list(APPEND CPP_WRAPPER_SOURCES_CORE + "core_implementations.cc" + "standard_codec.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_PLUGIN + "plugin_registrar.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_APP + "flutter_engine.cc" + "flutter_view_controller.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") + +# Wrapper sources needed for a plugin. +add_library(flutter_wrapper_plugin STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} +) +apply_standard_settings(flutter_wrapper_plugin) +set_target_properties(flutter_wrapper_plugin PROPERTIES + POSITION_INDEPENDENT_CODE ON) +set_target_properties(flutter_wrapper_plugin PROPERTIES + CXX_VISIBILITY_PRESET hidden) +target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) +target_include_directories(flutter_wrapper_plugin PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_plugin flutter_assemble) + +# Wrapper sources needed for the runner. +add_library(flutter_wrapper_app STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_APP} +) +apply_standard_settings(flutter_wrapper_app) +target_link_libraries(flutter_wrapper_app PUBLIC flutter) +target_include_directories(flutter_wrapper_app PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_app flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") +set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} + ${PHONY_OUTPUT} + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" + ${FLUTTER_TARGET_PLATFORM} $ + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} +) diff --git a/novelforge-project/flutter/examples/hello_world/windows/runner/CMakeLists.txt b/novelforge-project/flutter/examples/hello_world/windows/runner/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..394917c053a04daa76d8b94f0a02db0bd99e1034 --- /dev/null +++ b/novelforge-project/flutter/examples/hello_world/windows/runner/CMakeLists.txt @@ -0,0 +1,40 @@ +cmake_minimum_required(VERSION 3.14) +project(runner LANGUAGES CXX) + +# Define the application target. To change its name, change BINARY_NAME in the +# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer +# work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} WIN32 + "flutter_window.cpp" + "main.cpp" + "utils.cpp" + "win32_window.cpp" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" + "Runner.rc" + "runner.exe.manifest" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add preprocessor definitions for the build version. +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") + +# Disable Windows macros that collide with C++ standard library functions. +target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") + +# Add dependency libraries and include directories. Add any application-specific +# dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) +target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") +target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) diff --git a/novelforge-project/flutter/examples/image_list/android/app/build.gradle b/novelforge-project/flutter/examples/image_list/android/app/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..2670aafd6e76c18a3e58b87085bb5ada08ea1138 --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/android/app/build.gradle @@ -0,0 +1,60 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +apply plugin: 'com.android.application' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +android { + namespace "com.example.image_list" + compileSdk flutter.compileSdkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId "com.example.image_list" + minSdkVersion flutter.minSdkVersion + targetSdkVersion flutter.targetSdkVersion + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} diff --git a/novelforge-project/flutter/examples/image_list/android/app/src/main/AndroidManifest.xml b/novelforge-project/flutter/examples/image_list/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000000000000000000000000000000000000..9943200ec1752ed748c4ee7510a4bc6879eb3e49 --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/novelforge-project/flutter/examples/image_list/android/app/src/main/res/drawable/launch_background.xml b/novelforge-project/flutter/examples/image_list/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 0000000000000000000000000000000000000000..bb6811b2ee10d9304d3c94e1d43db4b7892827a9 --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,15 @@ + + + + + + + + + diff --git a/novelforge-project/flutter/examples/image_list/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/novelforge-project/flutter/examples/image_list/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..db77bb4b7b0906d62b1847e87f15cdcacf6a4f29 Binary files /dev/null and b/novelforge-project/flutter/examples/image_list/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/novelforge-project/flutter/examples/image_list/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/novelforge-project/flutter/examples/image_list/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..17987b79bb8a35cc66c3c1fd44f5a5526c1b78be Binary files /dev/null and b/novelforge-project/flutter/examples/image_list/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/novelforge-project/flutter/examples/image_list/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/novelforge-project/flutter/examples/image_list/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..09d4391482be68e9e4a07fab769b5de337d16eb1 Binary files /dev/null and b/novelforge-project/flutter/examples/image_list/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/novelforge-project/flutter/examples/image_list/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/novelforge-project/flutter/examples/image_list/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..d5f1c8d34e7a88e3f88bea192c3a370d44689c3c Binary files /dev/null and b/novelforge-project/flutter/examples/image_list/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/novelforge-project/flutter/examples/image_list/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/novelforge-project/flutter/examples/image_list/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..4d6372eebdb28e45604e46eeda8dd24651419bc0 Binary files /dev/null and b/novelforge-project/flutter/examples/image_list/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/novelforge-project/flutter/examples/image_list/android/app/src/main/res/values/styles.xml b/novelforge-project/flutter/examples/image_list/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000000000000000000000000000000000000..223593b1718388a43e0041b2a221f658dfc1a503 --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/android/app/src/main/res/values/styles.xml @@ -0,0 +1,11 @@ + + + + + diff --git a/novelforge-project/flutter/examples/image_list/android/build.gradle b/novelforge-project/flutter/examples/image_list/android/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..2de20623576a82c3115eca8b1bdb56fd5b5051cb --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/android/build.gradle @@ -0,0 +1,51 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This file is auto generated. +// To update all the build.gradle files in the Flutter repo, +// See dev/tools/bin/generate_gradle_lockfiles.dart. + +buildscript { + ext.kotlin_version = '1.5.31' + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:7.2.0' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } + + configurations.classpath { + resolutionStrategy.activateDependencyLocking() + } +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = '../build' + +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(':app') + dependencyLocking { + ignoredDependencies.add('io.flutter:*') + lockFile = file("${rootProject.projectDir}/project-${project.name}.lockfile") + if (!project.hasProperty('local-engine-repo')) { + lockAllConfigurations() + } + } +} + +tasks.register("clean", Delete) { + delete rootProject.buildDir +} diff --git a/novelforge-project/flutter/examples/image_list/android/buildscript-gradle.lockfile b/novelforge-project/flutter/examples/image_list/android/buildscript-gradle.lockfile new file mode 100644 index 0000000000000000000000000000000000000000..efe13277310ee8fef3c9d7f6f8a2cbbe601d110f --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/android/buildscript-gradle.lockfile @@ -0,0 +1,163 @@ +# This is a Gradle generated file for dependency locking. +# Manual edits can break the build and are not advised. +# This file is expected to be part of source control. +androidx.databinding:databinding-common:7.2.0=classpath +androidx.databinding:databinding-compiler-common:7.2.0=classpath +com.android.databinding:baseLibrary:7.2.0=classpath +com.android.tools.analytics-library:crash:30.2.0=classpath +com.android.tools.analytics-library:protos:30.2.0=classpath +com.android.tools.analytics-library:shared:30.2.0=classpath +com.android.tools.analytics-library:tracker:30.2.0=classpath +com.android.tools.build.jetifier:jetifier-core:1.0.0-beta09=classpath +com.android.tools.build.jetifier:jetifier-processor:1.0.0-beta09=classpath +com.android.tools.build:aapt2-proto:7.2.0-7984345=classpath +com.android.tools.build:aaptcompiler:7.2.0=classpath +com.android.tools.build:apksig:7.2.0=classpath +com.android.tools.build:apkzlib:7.2.0=classpath +com.android.tools.build:builder-model:7.2.0=classpath +com.android.tools.build:builder-test-api:7.2.0=classpath +com.android.tools.build:builder:7.2.0=classpath +com.android.tools.build:bundletool:1.8.2=classpath +com.android.tools.build:gradle-api:7.2.0=classpath +com.android.tools.build:gradle:7.2.0=classpath +com.android.tools.build:manifest-merger:30.2.0=classpath +com.android.tools.build:transform-api:2.0.0-deprecated-use-gradle-api=classpath +com.android.tools.ddms:ddmlib:30.2.0=classpath +com.android.tools.layoutlib:layoutlib-api:30.2.0=classpath +com.android.tools.lint:lint-model:30.2.0=classpath +com.android.tools.lint:lint-typedef-remover:30.2.0=classpath +com.android.tools.utp:android-device-provider-ddmlib-proto:30.2.0=classpath +com.android.tools.utp:android-device-provider-gradle-proto:30.2.0=classpath +com.android.tools.utp:android-test-plugin-host-additional-test-output-proto:30.2.0=classpath +com.android.tools.utp:android-test-plugin-host-coverage-proto:30.2.0=classpath +com.android.tools.utp:android-test-plugin-host-retention-proto:30.2.0=classpath +com.android.tools.utp:android-test-plugin-result-listener-gradle-proto:30.2.0=classpath +com.android.tools:annotations:30.2.0=classpath +com.android.tools:common:30.2.0=classpath +com.android.tools:dvlib:30.2.0=classpath +com.android.tools:repository:30.2.0=classpath +com.android.tools:sdk-common:30.2.0=classpath +com.android.tools:sdklib:30.2.0=classpath +com.android:signflinger:7.2.0=classpath +com.android:zipflinger:7.2.0=classpath +com.fasterxml.jackson.core:jackson-annotations:2.11.1=classpath +com.fasterxml.jackson.core:jackson-core:2.11.1=classpath +com.fasterxml.jackson.core:jackson-databind:2.11.1=classpath +com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.11.1=classpath +com.fasterxml.jackson.module:jackson-module-jaxb-annotations:2.11.1=classpath +com.fasterxml.jackson.module:jackson-module-kotlin:2.11.1=classpath +com.fasterxml.woodstox:woodstox-core:6.2.1=classpath +com.github.gundy:semver4j:0.16.4=classpath +com.google.android:annotations:4.1.1.4=classpath +com.google.api.grpc:proto-google-common-protos:1.12.0=classpath +com.google.auto.value:auto-value-annotations:1.6.2=classpath +com.google.code.findbugs:jsr305:3.0.2=classpath +com.google.code.gson:gson:2.8.6=classpath +com.google.crypto.tink:tink:1.3.0-rc2=classpath +com.google.dagger:dagger:2.28.3=classpath +com.google.errorprone:error_prone_annotations:2.3.4=classpath +com.google.flatbuffers:flatbuffers-java:1.12.0=classpath +com.google.guava:failureaccess:1.0.1=classpath +com.google.guava:guava:30.1-jre=classpath +com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=classpath +com.google.j2objc:j2objc-annotations:1.3=classpath +com.google.jimfs:jimfs:1.1=classpath +com.google.protobuf:protobuf-java-util:3.10.0=classpath +com.google.protobuf:protobuf-java:3.10.0=classpath +com.google.testing.platform:core-proto:0.0.8-alpha07=classpath +com.googlecode.json-simple:json-simple:1.1=classpath +com.googlecode.juniversalchardet:juniversalchardet:1.0.3=classpath +com.squareup:javapoet:1.10.0=classpath +com.squareup:javawriter:2.5.0=classpath +com.sun.activation:javax.activation:1.2.0=classpath +com.sun.istack:istack-commons-runtime:3.0.8=classpath +com.sun.xml.fastinfoset:FastInfoset:1.2.16=classpath +commons-codec:commons-codec:1.11=classpath +commons-io:commons-io:2.4=classpath +commons-logging:commons-logging:1.2=classpath +de.undercouch:gradle-download-task:4.1.1=classpath +io.grpc:grpc-api:1.21.1=classpath +io.grpc:grpc-context:1.21.1=classpath +io.grpc:grpc-core:1.21.1=classpath +io.grpc:grpc-netty:1.21.1=classpath +io.grpc:grpc-protobuf-lite:1.21.1=classpath +io.grpc:grpc-protobuf:1.21.1=classpath +io.grpc:grpc-stub:1.21.1=classpath +io.netty:netty-buffer:4.1.34.Final=classpath +io.netty:netty-codec-http2:4.1.34.Final=classpath +io.netty:netty-codec-http:4.1.34.Final=classpath +io.netty:netty-codec-socks:4.1.34.Final=classpath +io.netty:netty-codec:4.1.34.Final=classpath +io.netty:netty-common:4.1.34.Final=classpath +io.netty:netty-handler-proxy:4.1.34.Final=classpath +io.netty:netty-handler:4.1.34.Final=classpath +io.netty:netty-resolver:4.1.34.Final=classpath +io.netty:netty-transport:4.1.34.Final=classpath +io.opencensus:opencensus-api:0.21.0=classpath +io.opencensus:opencensus-contrib-grpc-metrics:0.21.0=classpath +it.unimi.dsi:fastutil:8.4.0=classpath +jakarta.activation:jakarta.activation-api:1.2.1=classpath +jakarta.xml.bind:jakarta.xml.bind-api:2.3.2=classpath +javax.inject:javax.inject:1=classpath +net.java.dev.jna:jna-platform:5.6.0=classpath +net.java.dev.jna:jna:5.6.0=classpath +net.sf.jopt-simple:jopt-simple:4.9=classpath +net.sf.kxml:kxml2:2.3.0=classpath +org.apache.commons:commons-compress:1.20=classpath +org.apache.httpcomponents:httpclient:4.5.9=classpath +org.apache.httpcomponents:httpcore:4.4.11=classpath +org.apache.httpcomponents:httpmime:4.5.6=classpath +org.bitbucket.b_c:jose4j:0.7.0=classpath +org.bouncycastle:bcpkix-jdk15on:1.56=classpath +org.bouncycastle:bcprov-jdk15on:1.56=classpath +org.checkerframework:checker-qual:3.5.0=classpath +org.codehaus.mojo:animal-sniffer-annotations:1.17=classpath +org.codehaus.woodstox:stax2-api:4.2.1=classpath +org.glassfish.jaxb:jaxb-runtime:2.3.2=classpath +org.glassfish.jaxb:txw2:2.3.2=classpath +org.jdom:jdom2:2.0.6=classpath +org.jetbrains.dokka:dokka-core:1.4.32=classpath +org.jetbrains.intellij.deps:trove4j:1.0.20181211=classpath +org.jetbrains.kotlin:kotlin-android-extensions:1.5.31=classpath +org.jetbrains.kotlin:kotlin-annotation-processing-gradle:1.5.31=classpath +org.jetbrains.kotlin:kotlin-build-common:1.5.31=classpath +org.jetbrains.kotlin:kotlin-compiler-embeddable:1.5.31=classpath +org.jetbrains.kotlin:kotlin-compiler-runner:1.5.31=classpath +org.jetbrains.kotlin:kotlin-daemon-client:1.5.31=classpath +org.jetbrains.kotlin:kotlin-daemon-embeddable:1.5.31=classpath +org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.5.31=classpath +org.jetbrains.kotlin:kotlin-gradle-plugin-model:1.5.31=classpath +org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31=classpath +org.jetbrains.kotlin:kotlin-klib-commonizer-api:1.5.31=classpath +org.jetbrains.kotlin:kotlin-native-utils:1.5.31=classpath +org.jetbrains.kotlin:kotlin-project-model:1.5.31=classpath +org.jetbrains.kotlin:kotlin-reflect:1.5.31=classpath +org.jetbrains.kotlin:kotlin-scripting-common:1.5.31=classpath +org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.5.31=classpath +org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.5.31=classpath +org.jetbrains.kotlin:kotlin-scripting-jvm:1.5.31=classpath +org.jetbrains.kotlin:kotlin-stdlib-common:1.5.31=classpath +org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.31=classpath +org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.31=classpath +org.jetbrains.kotlin:kotlin-stdlib:1.5.31=classpath +org.jetbrains.kotlin:kotlin-tooling-metadata:1.5.31=classpath +org.jetbrains.kotlin:kotlin-util-io:1.5.31=classpath +org.jetbrains.kotlin:kotlin-util-klib:1.5.31=classpath +org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.0=classpath +org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0=classpath +org.jetbrains:annotations:13.0=classpath +org.jetbrains:markdown-jvm:0.2.1=classpath +org.jetbrains:markdown:0.2.1=classpath +org.json:json:20180813=classpath +org.jsoup:jsoup:1.13.1=classpath +org.jvnet.staxex:stax-ex:1.8.1=classpath +org.ow2.asm:asm-analysis:9.1=classpath +org.ow2.asm:asm-commons:9.1=classpath +org.ow2.asm:asm-tree:9.1=classpath +org.ow2.asm:asm-util:9.1=classpath +org.ow2.asm:asm:9.1=classpath +org.slf4j:slf4j-api:1.7.30=classpath +org.tensorflow:tensorflow-lite-metadata:0.1.0-rc2=classpath +xerces:xercesImpl:2.12.0=classpath +xml-apis:xml-apis:1.4.01=classpath +empty= diff --git a/novelforge-project/flutter/examples/image_list/android/gradle.properties b/novelforge-project/flutter/examples/image_list/android/gradle.properties new file mode 100644 index 0000000000000000000000000000000000000000..598d13fee446372f156ecc38527b54c7cdcc8e3b --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx4G +android.useAndroidX=true +android.enableJetifier=true diff --git a/novelforge-project/flutter/examples/image_list/android/gradle/wrapper/gradle-wrapper.properties b/novelforge-project/flutter/examples/image_list/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000000000000000000000000000000000000..e1ca574ef017c1bc00556b96ea372e2c07948771 --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip diff --git a/novelforge-project/flutter/examples/image_list/android/project-app.lockfile b/novelforge-project/flutter/examples/image_list/android/project-app.lockfile new file mode 100644 index 0000000000000000000000000000000000000000..e160a81ffd42a36bca35a414c624786fdac26bc3 --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/android/project-app.lockfile @@ -0,0 +1,118 @@ +# This is a Gradle generated file for dependency locking. +# Manual edits can break the build and are not advised. +# This file is expected to be part of source control. +androidx.activity:activity:1.0.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.annotation:annotation-experimental:1.1.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.annotation:annotation:1.2.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.arch.core:core-common:2.1.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.arch.core:core-runtime:2.0.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.collection:collection:1.1.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.core:core:1.6.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.customview:customview:1.0.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.fragment:fragment:1.1.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.lifecycle:lifecycle-common-java8:2.2.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.lifecycle:lifecycle-common:2.2.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.lifecycle:lifecycle-livedata-core:2.0.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.lifecycle:lifecycle-livedata:2.0.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.lifecycle:lifecycle-runtime:2.2.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.lifecycle:lifecycle-viewmodel:2.1.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.loader:loader:1.0.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.savedstate:savedstate:1.0.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.tracing:tracing:1.0.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.versionedparcelable:versionedparcelable:1.1.1=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.viewpager:viewpager:1.0.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.window:window-java:1.0.0-beta04=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +androidx.window:window:1.0.0-beta04=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +com.android.tools.analytics-library:protos:27.1.3=lintClassPath +com.android.tools.analytics-library:shared:27.1.3=lintClassPath +com.android.tools.analytics-library:tracker:27.1.3=lintClassPath +com.android.tools.build:aapt2-proto:4.1.0-alpha01-6193524=lintClassPath +com.android.tools.build:aapt2:4.1.3-6503028=_internal_aapt2_binary +com.android.tools.build:apksig:4.1.3=lintClassPath +com.android.tools.build:apkzlib:4.1.3=lintClassPath +com.android.tools.build:builder-model:4.1.3=lintClassPath +com.android.tools.build:builder-test-api:4.1.3=lintClassPath +com.android.tools.build:builder:4.1.3=lintClassPath +com.android.tools.build:gradle-api:4.1.3=lintClassPath +com.android.tools.build:manifest-merger:27.1.3=lintClassPath +com.android.tools.ddms:ddmlib:27.1.3=lintClassPath +com.android.tools.external.com-intellij:intellij-core:27.1.3=lintClassPath +com.android.tools.external.com-intellij:kotlin-compiler:27.1.3=lintClassPath +com.android.tools.external.org-jetbrains:uast:27.1.3=lintClassPath +com.android.tools.layoutlib:layoutlib-api:27.1.3=lintClassPath +com.android.tools.lint:lint-api:27.1.3=lintClassPath +com.android.tools.lint:lint-checks:27.1.3=lintClassPath +com.android.tools.lint:lint-gradle-api:27.1.3=lintClassPath +com.android.tools.lint:lint-gradle:27.1.3=lintClassPath +com.android.tools.lint:lint-model:27.1.3=lintClassPath +com.android.tools.lint:lint:27.1.3=lintClassPath +com.android.tools:annotations:27.1.3=lintClassPath +com.android.tools:common:27.1.3=lintClassPath +com.android.tools:dvlib:27.1.3=lintClassPath +com.android.tools:repository:27.1.3=lintClassPath +com.android.tools:sdk-common:27.1.3=lintClassPath +com.android.tools:sdklib:27.1.3=lintClassPath +com.android:signflinger:4.1.3=lintClassPath +com.android:zipflinger:4.1.3=lintClassPath +com.google.code.findbugs:jsr305:3.0.2=lintClassPath +com.google.code.gson:gson:2.8.5=lintClassPath +com.google.errorprone:error_prone_annotations:2.3.2=lintClassPath +com.google.guava:failureaccess:1.0.1=lintClassPath +com.google.guava:guava:28.1-jre=lintClassPath +com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=lintClassPath +com.google.j2objc:j2objc-annotations:1.3=lintClassPath +com.google.jimfs:jimfs:1.1=lintClassPath +com.google.protobuf:protobuf-java:3.10.0=lintClassPath +com.googlecode.json-simple:json-simple:1.1=lintClassPath +com.squareup:javawriter:2.5.0=lintClassPath +com.sun.activation:javax.activation:1.2.0=lintClassPath +com.sun.istack:istack-commons-runtime:3.0.7=lintClassPath +com.sun.xml.fastinfoset:FastInfoset:1.2.15=lintClassPath +commons-codec:commons-codec:1.10=lintClassPath +commons-logging:commons-logging:1.2=lintClassPath +it.unimi.dsi:fastutil:7.2.0=lintClassPath +javax.activation:javax.activation-api:1.2.0=lintClassPath +javax.inject:javax.inject:1=lintClassPath +javax.xml.bind:jaxb-api:2.3.1=lintClassPath +net.sf.jopt-simple:jopt-simple:4.9=lintClassPath +net.sf.kxml:kxml2:2.3.0=lintClassPath +org.apache.commons:commons-compress:1.12=lintClassPath +org.apache.httpcomponents:httpclient:4.5.6=lintClassPath +org.apache.httpcomponents:httpcore:4.4.10=lintClassPath +org.apache.httpcomponents:httpmime:4.5.6=lintClassPath +org.bouncycastle:bcpkix-jdk15on:1.56=lintClassPath +org.bouncycastle:bcprov-jdk15on:1.56=lintClassPath +org.checkerframework:checker-qual:2.8.1=lintClassPath +org.codehaus.groovy:groovy-all:2.4.15=lintClassPath +org.codehaus.mojo:animal-sniffer-annotations:1.18=lintClassPath +org.glassfish.jaxb:jaxb-runtime:2.3.1=lintClassPath +org.glassfish.jaxb:txw2:2.3.1=lintClassPath +org.jacoco:org.jacoco.agent:0.8.7=androidJacocoAnt +org.jacoco:org.jacoco.ant:0.8.7=androidJacocoAnt +org.jacoco:org.jacoco.core:0.8.7=androidJacocoAnt +org.jacoco:org.jacoco.report:0.8.7=androidJacocoAnt +org.jetbrains.kotlin:kotlin-reflect:1.3.72=lintClassPath +org.jetbrains.kotlin:kotlin-stdlib-common:1.3.72=lintClassPath +org.jetbrains.kotlin:kotlin-stdlib-common:1.5.31=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.72=lintClassPath +org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.30=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72=lintClassPath +org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.30=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +org.jetbrains.kotlin:kotlin-stdlib:1.3.72=lintClassPath +org.jetbrains.kotlin:kotlin-stdlib:1.5.31=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.2=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +org.jetbrains.trove4j:trove4j:20160824=lintClassPath +org.jetbrains:annotations:13.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,lintClassPath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath +org.jvnet.staxex:stax-ex:1.8=lintClassPath +org.ow2.asm:asm-analysis:7.0=lintClassPath +org.ow2.asm:asm-analysis:9.1=androidJacocoAnt +org.ow2.asm:asm-commons:7.0=lintClassPath +org.ow2.asm:asm-commons:9.1=androidJacocoAnt +org.ow2.asm:asm-tree:7.0=lintClassPath +org.ow2.asm:asm-tree:9.1=androidJacocoAnt +org.ow2.asm:asm-util:7.0=lintClassPath +org.ow2.asm:asm:7.0=lintClassPath +org.ow2.asm:asm:9.1=androidJacocoAnt +empty=androidApis,androidJdkImage,androidTestUtil,compile,coreLibraryDesugaring,debugAndroidTestAnnotationProcessorClasspath,debugAndroidTestRuntimeClasspath,debugAnnotationProcessorClasspath,debugReverseMetadataValues,debugUnitTestAnnotationProcessorClasspath,debugWearBundling,lintChecks,lintPublish,profileAnnotationProcessorClasspath,profileReverseMetadataValues,profileUnitTestAnnotationProcessorClasspath,profileWearBundling,releaseAnnotationProcessorClasspath,releaseReverseMetadataValues,releaseUnitTestAnnotationProcessorClasspath,releaseWearBundling,testCompile diff --git a/novelforge-project/flutter/examples/image_list/android/settings.gradle b/novelforge-project/flutter/examples/image_list/android/settings.gradle new file mode 100644 index 0000000000000000000000000000000000000000..03ae72d135c01f849e6812b36575b62b14fee791 --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/android/settings.gradle @@ -0,0 +1,21 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This file is auto generated. +// To update all the settings.gradle files in the Flutter repo, +// See dev/tools/bin/generate_gradle_lockfiles.dart. + +include ':app' + +enableFeaturePreview('ONE_LOCKFILE_PER_PROJECT') + +def localPropertiesFile = new File(rootProject.projectDir, "local.properties") +def properties = new Properties() + +assert localPropertiesFile.exists() +localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + +def flutterSdkPath = properties.getProperty("flutter.sdk") +assert flutterSdkPath != null, "flutter.sdk not set in local.properties" +apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/novelforge-project/flutter/examples/image_list/images/coast.jpg b/novelforge-project/flutter/examples/image_list/images/coast.jpg new file mode 100644 index 0000000000000000000000000000000000000000..2a5e7a0f3493de6e7962bc4f91e5fb5b3dbac165 --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/images/coast.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:da957fd30c51b8d27d74c2c918692dc4d3c5c99bb00f0d6b5ebb30395a6ede82 +size 202344 diff --git a/novelforge-project/flutter/examples/image_list/ios/Flutter/AppFrameworkInfo.plist b/novelforge-project/flutter/examples/image_list/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 0000000000000000000000000000000000000000..8c6e56146e23c84aa60ea78f20bc3a7b3d8ef259 --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + MinimumOSVersion + 12.0 + + diff --git a/novelforge-project/flutter/examples/image_list/ios/Flutter/Debug.xcconfig b/novelforge-project/flutter/examples/image_list/ios/Flutter/Debug.xcconfig new file mode 100644 index 0000000000000000000000000000000000000000..592ceee85b89bd111b779db6116b130509ab6d4b --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/ios/Flutter/Debug.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/novelforge-project/flutter/examples/image_list/ios/Flutter/Release.xcconfig b/novelforge-project/flutter/examples/image_list/ios/Flutter/Release.xcconfig new file mode 100644 index 0000000000000000000000000000000000000000..592ceee85b89bd111b779db6116b130509ab6d4b --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/ios/Flutter/Release.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/novelforge-project/flutter/examples/image_list/ios/Runner.xcodeproj/project.pbxproj b/novelforge-project/flutter/examples/image_list/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000000000000000000000000000000000000..38ca950598f36cac06a0eb7d82b95ccbcd8b9dec --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,468 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXBuildFile section */ + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; + 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; }; + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; + 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; + 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + 97C146EF1CF9000F007C117D /* Products */, + CF3B75C9A7D2FA2A4C99F110 /* Frameworks */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + ); + name = Products; + sourceTree = ""; + }; + 97C146F01CF9000F007C117D /* Runner */ = { + isa = PBXGroup; + children = ( + 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */, + 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */, + 97C146FA1CF9000F007C117D /* Main.storyboard */, + 97C146FD1CF9000F007C117D /* Assets.xcassets */, + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, + 97C147021CF9000F007C117D /* Info.plist */, + 97C146F11CF9000F007C117D /* Supporting Files */, + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, + ); + path = Runner; + sourceTree = ""; + }; + 97C146F11CF9000F007C117D /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 97C146F21CF9000F007C117D /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 97C146ED1CF9000F007C117D /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 9740EEB61CF901F6004384FC /* Run Script */, + 97C146EA1CF9000F007C117D /* Sources */, + 97C146EB1CF9000F007C117D /* Frameworks */, + 97C146EC1CF9000F007C117D /* Resources */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Runner; + productName = Runner; + productReference = 97C146EE1CF9000F007C117D /* Runner.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 97C146E61CF9000F007C117D /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1510; + ORGANIZATIONNAME = "The Flutter Authors"; + TargetAttributes = { + 97C146ED1CF9000F007C117D = { + CreatedOnToolsVersion = 7.3.1; + }; + }; + }; + buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 97C146E51CF9000F007C117D; + productRefGroup = 97C146EF1CF9000F007C117D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 97C146ED1CF9000F007C117D /* Runner */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 97C146EC1CF9000F007C117D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */, + 97C146F31CF9000F007C117D /* main.m in Sources */, + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 97C146FA1CF9000F007C117D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C146FB1CF9000F007C117D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C147001CF9000F007C117D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 249021D3217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Profile; + }; + 249021D4217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = S8QB4VV633; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.example.imageLoading; + PRODUCT_NAME = "$(TARGET_NAME)"; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Profile; + }; + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 97C147041CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 97C147061CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.example.imageLoading; + PRODUCT_NAME = "$(TARGET_NAME)"; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Debug; + }; + 97C147071CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.example.imageLoading; + PRODUCT_NAME = "$(TARGET_NAME)"; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147031CF9000F007C117D /* Debug */, + 97C147041CF9000F007C117D /* Release */, + 249021D3217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147061CF9000F007C117D /* Debug */, + 97C147071CF9000F007C117D /* Release */, + 249021D4217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 97C146E61CF9000F007C117D /* Project object */; +} diff --git a/novelforge-project/flutter/examples/image_list/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/novelforge-project/flutter/examples/image_list/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000000000000000000000000000000000000..919434a6254f0e9651f402737811be6634a03e9c --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/novelforge-project/flutter/examples/image_list/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/novelforge-project/flutter/examples/image_list/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000000000000000000000000000000000000..a00db7a9e12a704a72a09581cfe235a7f58061ec --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/novelforge-project/flutter/examples/image_list/ios/Runner.xcworkspace/contents.xcworkspacedata b/novelforge-project/flutter/examples/image_list/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000000000000000000000000000000000000..1d526a16ed0f1cd0c2409d848bf489b93fefa3b2 --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/novelforge-project/flutter/examples/image_list/ios/Runner/AppDelegate.h b/novelforge-project/flutter/examples/image_list/ios/Runner/AppDelegate.h new file mode 100644 index 0000000000000000000000000000000000000000..7d5bcd37fc850c239f7df54ed38c02bab4ed30d3 --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/ios/Runner/AppDelegate.h @@ -0,0 +1,10 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import +#import + +@interface AppDelegate : FlutterAppDelegate + +@end diff --git a/novelforge-project/flutter/examples/image_list/ios/Runner/AppDelegate.m b/novelforge-project/flutter/examples/image_list/ios/Runner/AppDelegate.m new file mode 100644 index 0000000000000000000000000000000000000000..df796d6a9e498cf59a39da034ab151620b033be6 --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/ios/Runner/AppDelegate.m @@ -0,0 +1,17 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import "AppDelegate.h" +#import "GeneratedPluginRegistrant.h" + +@implementation AppDelegate + +- (BOOL)application:(UIApplication *)application + didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + [GeneratedPluginRegistrant registerWithRegistry:self]; + // Override point for customization after application launch. + return [super application:application didFinishLaunchingWithOptions:launchOptions]; +} + +@end diff --git a/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000000000000000000000000000000000000..d36b1fab2d9dea668a4f83df94d525897d9e68dd --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,122 @@ +{ + "images" : [ + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@3x.png", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@3x.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@3x.png", + "scale" : "3x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@1x.png", + "scale" : "1x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@1x.png", + "scale" : "1x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@1x.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@2x.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "Icon-App-83.5x83.5@2x.png", + "scale" : "2x" + }, + { + "size" : "1024x1024", + "idiom" : "ios-marketing", + "filename" : "Icon-App-1024x1024@1x.png", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png new file mode 100644 index 0000000000000000000000000000000000000000..3d43d11e66f4de3da27ed045ca4fe38ad8b48094 Binary files /dev/null and b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ diff --git a/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 0000000000000000000000000000000000000000..28c6bf03016f6c994b70f38d1b7346e5831b531f Binary files /dev/null and b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..2ccbfd967d9697cd4b83225558af2911e9571c9b Binary files /dev/null and b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..f091b6b0bca859a3f474b03065bef75ba58a9e4c Binary files /dev/null and b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 0000000000000000000000000000000000000000..4cde12118dda48d71e01fcb589a74d069c5d7cb5 Binary files /dev/null and b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..d0ef06e7edb86cdfe0d15b4b0d98334a86163658 Binary files /dev/null and b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..dcdc2306c28505ebc0b6c3a359c4d252bf626b9f Binary files /dev/null and b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png new file mode 100644 index 0000000000000000000000000000000000000000..2ccbfd967d9697cd4b83225558af2911e9571c9b Binary files /dev/null and b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..c8f9ed8f5cee1c98386d13b17e89f719e83555b2 Binary files /dev/null and b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..a6d6b8609df07bf62e5100a53a01510388bd2b22 Binary files /dev/null and b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..a6d6b8609df07bf62e5100a53a01510388bd2b22 Binary files /dev/null and b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..75b2d164a5a98e212cca15ea7bf2ab5de5108680 Binary files /dev/null and b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 0000000000000000000000000000000000000000..c4df70d39da7941ef3f6dcb7f06a192d8dcb308d Binary files /dev/null and b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..6a84f41e14e27f4b11f16f9ee39279ac98f8d5ac Binary files /dev/null and b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..d0e1f58536026aebc4f1f70e481f6993c9ff088d Binary files /dev/null and b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json new file mode 100644 index 0000000000000000000000000000000000000000..0bedcf2fd46788ae3a01a423467513ff59b5c120 --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "LaunchImage.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png new file mode 100644 index 0000000000000000000000000000000000000000..9da19eacad3b03bb08bbddbbf4ac48dd78b3d838 Binary files /dev/null and b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png differ diff --git a/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..9da19eacad3b03bb08bbddbbf4ac48dd78b3d838 Binary files /dev/null and b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png differ diff --git a/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..9da19eacad3b03bb08bbddbbf4ac48dd78b3d838 Binary files /dev/null and b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png differ diff --git a/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md new file mode 100644 index 0000000000000000000000000000000000000000..89c2725b70f1882be97f5214fafe22d27a0ec01e --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md @@ -0,0 +1,5 @@ +# Launch Screen Assets + +You can customize the launch screen with your own desired assets by replacing the image files in this directory. + +You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. \ No newline at end of file diff --git a/novelforge-project/flutter/examples/image_list/ios/Runner/Base.lproj/LaunchScreen.storyboard b/novelforge-project/flutter/examples/image_list/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000000000000000000000000000000000000..f2e259c7c9390ff69a6bbe1e0907e6dc366848e7 --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/novelforge-project/flutter/examples/image_list/ios/Runner/Base.lproj/Main.storyboard b/novelforge-project/flutter/examples/image_list/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 0000000000000000000000000000000000000000..f3c28516fb38e64d88cfcf5fb1791175df078f2f --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/novelforge-project/flutter/examples/image_list/ios/Runner/Info.plist b/novelforge-project/flutter/examples/image_list/ios/Runner/Info.plist new file mode 100644 index 0000000000000000000000000000000000000000..2f1b82c8bada59ea0ce724343f55be8a201392c6 --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/ios/Runner/Info.plist @@ -0,0 +1,47 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + image_list + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + CADisableMinimumFrameDurationOnPhone + + UIApplicationSupportsIndirectInputEvents + + + diff --git a/novelforge-project/flutter/examples/image_list/ios/Runner/main.m b/novelforge-project/flutter/examples/image_list/ios/Runner/main.m new file mode 100644 index 0000000000000000000000000000000000000000..736a65aa5e1ab250f8353bfd31c4bfd9ab01339c --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/ios/Runner/main.m @@ -0,0 +1,13 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import +#import +#import "AppDelegate.h" + +int main(int argc, char* argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/novelforge-project/flutter/examples/image_list/lib/main.dart b/novelforge-project/flutter/examples/image_list/lib/main.dart new file mode 100644 index 0000000000000000000000000000000000000000..5c7522263baf37f5d7fba819e8a65c3e06625042 --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/lib/main.dart @@ -0,0 +1,244 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; +import 'dart:io'; +import 'dart:math'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +/// An example that sets up local http server for serving single +/// image, creates single flutter widget with five copies of requested +/// image and prints how long the loading took. +/// +/// This is used in [$FH/flutter/devicelab/bin/tasks/image_list_reported_duration.dart] test. +/// +/// +/// To generate new certificate: +/// +/// $ openssl req -new -out image_list.csr +/// Generating a 2048 bit RSA private key +/// Enter PEM pass phrase: +/// ... +/// Common Name (eg, fully qualified host name) []:localhost +/// +/// Copy content of the privateKey below into image_list.key file, then +/// $ openssl x509 -req -sha256 -days 3650 -in image_list.csr -signkey image_list.key -out image_list.crt +/// +/// Copy content of the image_list.crt into certificate string below. +String certificate = ''' +-----BEGIN CERTIFICATE----- +MIICpDCCAYwCCQD1kfAz8IhbazANBgkqhkiG9w0BAQsFADAUMRIwEAYDVQQDDAls +b2NhbGhvc3QwHhcNMjAwODI0MjE1MTUwWhcNMzAwODIyMjE1MTUwWjAUMRIwEAYD +VQQDDAlsb2NhbGhvc3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCi +/fmozdYuCIZbJS7y4zYPp2NRboLXrpUcUzzvzz+24k/TYUPNeRvf6wiNXHvr1ijM +g1j3wQP72RphxI7cY7XCwzRiM5QeQy3EtRz4ETYBzOev3mHLLEgZ9RnSq/u42siS +S9CNjoz97liPyQUq8h37/09qhYG0hR/2pRN+YB9g7sNYoGe2B7zkh3azRS0/Ltgl +tXwHUId7QzJc15W9Q7adsNVTpOCo7dOj2KWz6sEtFGkYfwLV5uiTslRdWCCOUD9i +ZjCtlPqALkGnWyhNiFJESLbVNC6MURyMngcALW0JTMwc2oDjMxtdNkMl0cdzPlhX +MDKIKpY9bWbRKUUdsfOnAgMBAAEwDQYJKoZIhvcNAQELBQADggEBAHZo/Io7hE9P +jDhSSP+4iSwx6xjnkRjBHReoea+XwSCv1s9Alwe1Nub6u5jUBhCpGCyU4diKFV1W +zhunXKY+zRGGtr09nYoN9UVizS5fAFb+h2x3Tw8lsxs4JpPQeWTbGK9Ci+jyfuZu +xPvdU8I8oxiTRPoWa1KpPm6UVvcrjyftvbqJ4l7cZ8KZN4JNSZlphX8lIM14xR4H +12sFFTcYWPNDTqO1A9MSflG4OkG59LDHV36JAEqB61pP8hipowVp48+rzD2DVpqb +r/Mw+0x0HENUTMVExSA5rj/3fxNMggUSl2YsujVJjkb1LiQNPORX7rBndcjknAMt +TvaTkrwwZA4= +-----END CERTIFICATE----- +'''; + +String privateKey = ''' +-----BEGIN PRIVATE KEY----- +MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCi/fmozdYuCIZb +JS7y4zYPp2NRboLXrpUcUzzvzz+24k/TYUPNeRvf6wiNXHvr1ijMg1j3wQP72Rph +xI7cY7XCwzRiM5QeQy3EtRz4ETYBzOev3mHLLEgZ9RnSq/u42siSS9CNjoz97liP +yQUq8h37/09qhYG0hR/2pRN+YB9g7sNYoGe2B7zkh3azRS0/LtgltXwHUId7QzJc +15W9Q7adsNVTpOCo7dOj2KWz6sEtFGkYfwLV5uiTslRdWCCOUD9iZjCtlPqALkGn +WyhNiFJESLbVNC6MURyMngcALW0JTMwc2oDjMxtdNkMl0cdzPlhXMDKIKpY9bWbR +KUUdsfOnAgMBAAECggEADUStiS9Qayjofwz02HLkmLugmyVq41Hj841XHZJ6dlHP ++74kPdrJCR5h8NgBgn5JjfR3TpvYziyrOCA/HPPE/RjU79WRDjGbzTKNLCiCg/0B +M1DgFyEAsZRBSOQVNsQgpcAkNxHOqnE3pmTP1eIlzLjI5zv9Bgv8QSDJCHWcuFA2 +NrvGudq3dlFnZwjipx0k0E1hCsaClqLsi5jEXIBA6TX7RTeeXjC+j2/DlmTpBxo0 +c34o/sSoCl+mfJDQ3QApXLFuycBl7nauO0M+VsUWrKYqHHr4NIcgoIpIX28QjWc/ +Y2+iooMSBO1ToK2nPD8hZQwNDF8xz6Xf7QNkTOpnqQKBgQDNgfNYkEvgWxhSMmW7 +cK06supZC/isj2JfQmlJc80JcAvf8rpynZLi4XWZWRo0PykM4szI91h3YHTG27VX +YVHSsFs+6FwP7fLAHR7FYn65p/bwTuqpWGjcmQhc0HWx7y45HRIoSK/m+Z7lNA/J +QxnCp1khTmhPqCNglo+38vZSzQKBgQDLCeBhji0K/BOmCrhNxRxrCvHYEd6gqRtC ++rKhco6mMrxma/UmggRKoGXg0yMcya3199y3pDkumHSlcMdUb+I9b+3j8R6ivoqN +TI1ned5K1uq3FyZpD0dZQWuunVeqYXuUQw5y5GxvK7haohbVpUG6lC3qYq2ubiYC +D0ENUfNoQwKBgEGucOozZCzWsJVEykL4JkWGfWPscZQlV5l+jkwNmNCVYRY4a+LJ +/fJJgN58HeXo8ePOcQkiFMJCr9AG1JSS5CXke6VFencU4+sG45jOfBY2WrQ/ZLyv +JwSqXIPdlGBEQ4+5fN4nLSEzUteKpij7KzaNae09NBWRdY0fUdvG6XdZAoGAf02S +/TfKsB97JlmEU2aqOcdj+WjC4JMG/8j2JVoRbM1U6Rb5X4qXrD7DgeKAGnWteBJP +tmjmXXvDb1O19xArlv/N9WRiJAI6FvwPkPiNUvlLsz51m9uzjZgCLzqCE9cJR91/ +erQT9ORBs7n7fTsfah+sZlA2u65ecF4mGHbwmccCgYAqHNRHnx1iHrYfr97cmXc9 +fNjJ7e1NHhVdgpGjaOiBSKj2rHNRy6iwCNbs5wjmRWlgqnFEM5r0VfFn9L0PvcQK +7iExMTm/PkSqHUntpy82Q8zRWmhw0G5p9DYyIPtaeW1NIKpIlCw6dTlf750BiGkr +mhBKvYQc85gja0s1c+1VXA== +-----END PRIVATE KEY----- +'''; + +class MyHttpOverrides extends HttpOverrides { + @override + HttpClient createHttpClient(SecurityContext? context) { + return super.createHttpClient( + (context ?? SecurityContext())..setTrustedCertificatesBytes(certificate.codeUnits), + ); + } +} + +Future main() async { + HttpOverrides.global = MyHttpOverrides(); + + final SecurityContext serverContext = SecurityContext() + ..useCertificateChainBytes(certificate.codeUnits) + ..usePrivateKeyBytes(privateKey.codeUnits); + + final HttpServer httpServer = + await HttpServer.bindSecure('localhost', 0, serverContext); + final int port = httpServer.port; + debugPrint('Listening on port $port.'); + + // Initializes bindings before using any platform channels. + WidgetsFlutterBinding.ensureInitialized(); + final ByteData byteData = await rootBundle.load('images/coast.jpg'); + httpServer.listen((HttpRequest request) async { + const int chunk_size = 2048; + int offset = byteData.offsetInBytes; + while (offset < byteData.lengthInBytes) { + final int length = min(byteData.lengthInBytes - offset, chunk_size); + final Uint8List bytes = byteData.buffer.asUint8List(offset, length); + offset += length; + request.response.add(bytes); + // Let other isolates and microtasks to run. + await Future.delayed(Duration.zero); + } + request.response.close(); + }); + + runApp(MyApp(port)); +} + +const int images = 50; + +@immutable +class MyApp extends StatelessWidget { + const MyApp(this.port, {super.key}); + + final int port; + + @override + Widget build(BuildContext context) { + return MaterialApp( + title: 'Flutter Demo', + theme: ThemeData( + primarySwatch: Colors.blue, + ), + home: MyHomePage(title: 'Flutter Demo Home Page', port: port), + ); + } +} + +class MyHomePage extends StatefulWidget { + const MyHomePage({super.key, required this.title, required this.port}); + final String title; + final int port; + + @override + State createState() => _MyHomePageState(); +} + +class _MyHomePageState extends State with TickerProviderStateMixin { + int _counter = 0; + + void _incrementCounter() { + setState(() { + _counter++; + }); + } + + Widget createImage(final int index, final Completer completer) { + return Image.network( + 'https://localhost:${widget.port}/${_counter * images + index}', + frameBuilder: ( + BuildContext context, + Widget child, + int? frame, + bool wasSynchronouslyLoaded, + ) { + if (frame == 0 && !completer.isCompleted) { + completer.complete(true); + } + return child; + }, + ); + } + + @override + Widget build(BuildContext context) { + final List controllers = [ + for (int i = 0; i < images; i++) + AnimationController( + duration: const Duration(milliseconds: 3600), + vsync: this, + )..repeat(), + ]; + final List> completers = >[ + for (int i = 0; i < images; i++) + Completer(), + ]; + final List> futures = completers.map( + (Completer completer) => completer.future, + ).toList(); + final DateTime started = DateTime.now(); + Future.wait(futures).then((_) { + debugPrint( + '===image_list=== all loaded in ${DateTime.now().difference(started).inMilliseconds}ms.', + ); + }); + return Scaffold( + appBar: AppBar( + title: Text(widget.title), + ), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Row(children: createImageList(images, completers, controllers)), + const Text( + 'You have pushed the button this many times:', + ), + Text( + '$_counter', + style: Theme.of(context).textTheme.headlineMedium, + ), + ], + ), + ), + floatingActionButton: FloatingActionButton( + onPressed: _incrementCounter, + tooltip: 'Increment', + child: const Icon(Icons.add), + ), + ); + } + + List createImageList( + int count, + List> completers, + List controllers, + ) { + final List list = []; + for (int i = 0; i < count; i++) { + list.add(Flexible( + fit: FlexFit.tight, + flex: i + 1, + child: RotationTransition( + turns: controllers[i], + child: createImage(i + 1, completers[i]), + ), + )); + } + return list; + } +} diff --git a/novelforge-project/flutter/examples/image_list/macos/Flutter/Flutter-Debug.xcconfig b/novelforge-project/flutter/examples/image_list/macos/Flutter/Flutter-Debug.xcconfig new file mode 100644 index 0000000000000000000000000000000000000000..c2efd0b608ba84712fb3e1d01122468a50c7fba1 --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/macos/Flutter/Flutter-Debug.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/novelforge-project/flutter/examples/image_list/macos/Flutter/Flutter-Release.xcconfig b/novelforge-project/flutter/examples/image_list/macos/Flutter/Flutter-Release.xcconfig new file mode 100644 index 0000000000000000000000000000000000000000..c2efd0b608ba84712fb3e1d01122468a50c7fba1 --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/macos/Flutter/Flutter-Release.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/novelforge-project/flutter/examples/image_list/macos/Runner.xcodeproj/project.pbxproj b/novelforge-project/flutter/examples/image_list/macos/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000000000000000000000000000000000000..c89cdb61399482c842452cb781173e73d918524f --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/macos/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,573 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXAggregateTarget section */ + 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = { + isa = PBXAggregateTarget; + buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */; + buildPhases = ( + 33CC111E2044C6BF0003C045 /* ShellScript */, + ); + dependencies = ( + ); + name = "Flutter Assemble"; + productName = FLX; + }; +/* End PBXAggregateTarget section */ + +/* Begin PBXBuildFile section */ + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC111A2044C6BA0003C045; + remoteInfo = FLX; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 33CC110E2044A8840003C045 /* Bundle Framework */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Bundle Framework"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; + 33CC10ED2044A3C60003C045 /* image_list.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "image_list.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; + 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; + 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; }; + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; }; + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; + 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; + 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; + 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 33CC10EA2044A3C60003C045 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 33BA886A226E78AF003329D5 /* Configs */ = { + isa = PBXGroup; + children = ( + 33E5194F232828860026EE4D /* AppInfo.xcconfig */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */, + ); + path = Configs; + sourceTree = ""; + }; + 33CC10E42044A3C60003C045 = { + isa = PBXGroup; + children = ( + 33FAB671232836740065AC1E /* Runner */, + 33CEB47122A05771004F2AC0 /* Flutter */, + 33CC10EE2044A3C60003C045 /* Products */, + D73912EC22F37F3D000D13A0 /* Frameworks */, + ); + sourceTree = ""; + }; + 33CC10EE2044A3C60003C045 /* Products */ = { + isa = PBXGroup; + children = ( + 33CC10ED2044A3C60003C045 /* image_list.app */, + ); + name = Products; + sourceTree = ""; + }; + 33CC11242044D66E0003C045 /* Resources */ = { + isa = PBXGroup; + children = ( + 33CC10F22044A3C60003C045 /* Assets.xcassets */, + 33CC10F42044A3C60003C045 /* MainMenu.xib */, + 33CC10F72044A3C60003C045 /* Info.plist */, + ); + name = Resources; + path = ..; + sourceTree = ""; + }; + 33CEB47122A05771004F2AC0 /* Flutter */ = { + isa = PBXGroup; + children = ( + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */, + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, + ); + path = Flutter; + sourceTree = ""; + }; + 33FAB671232836740065AC1E /* Runner */ = { + isa = PBXGroup; + children = ( + 33CC10F02044A3C60003C045 /* AppDelegate.swift */, + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */, + 33E51913231747F40026EE4D /* DebugProfile.entitlements */, + 33E51914231749380026EE4D /* Release.entitlements */, + 33CC11242044D66E0003C045 /* Resources */, + 33BA886A226E78AF003329D5 /* Configs */, + ); + path = Runner; + sourceTree = ""; + }; + D73912EC22F37F3D000D13A0 /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 33CC10EC2044A3C60003C045 /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 33CC10E92044A3C60003C045 /* Sources */, + 33CC10EA2044A3C60003C045 /* Frameworks */, + 33CC10EB2044A3C60003C045 /* Resources */, + 33CC110E2044A8840003C045 /* Bundle Framework */, + 3399D490228B24CF009A79C7 /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + 33CC11202044C79F0003C045 /* PBXTargetDependency */, + ); + name = Runner; + productName = Runner; + productReference = 33CC10ED2044A3C60003C045 /* image_list.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 33CC10E52044A3C60003C045 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0920; + LastUpgradeCheck = 1510; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 33CC10EC2044A3C60003C045 = { + CreatedOnToolsVersion = 9.2; + LastSwiftMigration = 1100; + ProvisioningStyle = Automatic; + SystemCapabilities = { + com.apple.Sandbox = { + enabled = 1; + }; + }; + }; + 33CC111A2044C6BA0003C045 = { + CreatedOnToolsVersion = 9.2; + ProvisioningStyle = Manual; + }; + }; + }; + buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 33CC10E42044A3C60003C045; + productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 33CC10EC2044A3C60003C045 /* Runner */, + 33CC111A2044C6BA0003C045 /* Flutter Assemble */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 33CC10EB2044A3C60003C045 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3399D490228B24CF009A79C7 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; + }; + 33CC111E2044C6BF0003C045 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + Flutter/ephemeral/FlutterInputs.xcfilelist, + ); + inputPaths = ( + Flutter/ephemeral/tripwire, + ); + outputFileListPaths = ( + Flutter/ephemeral/FlutterOutputs.xcfilelist, + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 33CC10E92044A3C60003C045 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */, + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */, + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 33CC11202044C79F0003C045 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */; + targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 33CC10F42044A3C60003C045 /* MainMenu.xib */ = { + isa = PBXVariantGroup; + children = ( + 33CC10F52044A3C60003C045 /* Base */, + ); + name = MainMenu.xib; + path = Runner; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 338D0CE9231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Profile; + }; + 338D0CEA231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Profile; + }; + 338D0CEB231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Profile; + }; + 33CC10F92044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 33CC10FA2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + 33CC10FC2044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 33CC10FD2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 33CC111C2044C6BA0003C045 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 33CC111D2044C6BA0003C045 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10F92044A3C60003C045 /* Debug */, + 33CC10FA2044A3C60003C045 /* Release */, + 338D0CE9231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10FC2044A3C60003C045 /* Debug */, + 33CC10FD2044A3C60003C045 /* Release */, + 338D0CEA231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC111C2044C6BA0003C045 /* Debug */, + 33CC111D2044C6BA0003C045 /* Release */, + 338D0CEB231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 33CC10E52044A3C60003C045 /* Project object */; +} diff --git a/novelforge-project/flutter/examples/image_list/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/novelforge-project/flutter/examples/image_list/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000000000000000000000000000000000000..18d981003d68d0546c4804ac2ff47dd97c6e7921 --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/novelforge-project/flutter/examples/image_list/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/novelforge-project/flutter/examples/image_list/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000000000000000000000000000000000000..95ef0b61381557625e5a00317f32a70dd41a73d3 --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/novelforge-project/flutter/examples/image_list/macos/Runner.xcworkspace/contents.xcworkspacedata b/novelforge-project/flutter/examples/image_list/macos/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000000000000000000000000000000000000..1d526a16ed0f1cd0c2409d848bf489b93fefa3b2 --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/macos/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/novelforge-project/flutter/examples/image_list/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/novelforge-project/flutter/examples/image_list/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000000000000000000000000000000000000..18d981003d68d0546c4804ac2ff47dd97c6e7921 --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/novelforge-project/flutter/examples/image_list/macos/Runner/AppDelegate.swift b/novelforge-project/flutter/examples/image_list/macos/Runner/AppDelegate.swift new file mode 100644 index 0000000000000000000000000000000000000000..d080d41951d3506a861ceadcf4354bbbb609a562 --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/macos/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import Cocoa +import FlutterMacOS + +@NSApplicationMain +class AppDelegate: FlutterAppDelegate { + override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { + return true + } +} diff --git a/novelforge-project/flutter/examples/image_list/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/novelforge-project/flutter/examples/image_list/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000000000000000000000000000000000000..a2ec33f19f110ebff51a23342d7bc29ec9a1aaa6 --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images" : [ + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_16.png", + "scale" : "1x" + }, + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "2x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "1x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_64.png", + "scale" : "2x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_128.png", + "scale" : "1x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "2x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "1x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "2x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "1x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_1024.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/novelforge-project/flutter/examples/image_list/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png b/novelforge-project/flutter/examples/image_list/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png new file mode 100644 index 0000000000000000000000000000000000000000..3c4935a7ca84f0976aca34b7f2895d65fb94d1ea Binary files /dev/null and b/novelforge-project/flutter/examples/image_list/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png differ diff --git a/novelforge-project/flutter/examples/image_list/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png b/novelforge-project/flutter/examples/image_list/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png new file mode 100644 index 0000000000000000000000000000000000000000..ed4cc16421680a50164ba74381b4b35ceaa0ccfc Binary files /dev/null and b/novelforge-project/flutter/examples/image_list/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png differ diff --git a/novelforge-project/flutter/examples/image_list/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png b/novelforge-project/flutter/examples/image_list/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png new file mode 100644 index 0000000000000000000000000000000000000000..483be61389733f2e5331c08db8ca245268610ccb Binary files /dev/null and b/novelforge-project/flutter/examples/image_list/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png differ diff --git a/novelforge-project/flutter/examples/image_list/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png b/novelforge-project/flutter/examples/image_list/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png new file mode 100644 index 0000000000000000000000000000000000000000..bcbf36df2f2aaaa0a63c7dabc94e600184229d0d Binary files /dev/null and b/novelforge-project/flutter/examples/image_list/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png differ diff --git a/novelforge-project/flutter/examples/image_list/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png b/novelforge-project/flutter/examples/image_list/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png new file mode 100644 index 0000000000000000000000000000000000000000..9c0a652864769b250ed58097f2f6270b393f751f Binary files /dev/null and b/novelforge-project/flutter/examples/image_list/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png differ diff --git a/novelforge-project/flutter/examples/image_list/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png b/novelforge-project/flutter/examples/image_list/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png new file mode 100644 index 0000000000000000000000000000000000000000..e71a726136a47ed24125c7efc79d68a4a01961b4 Binary files /dev/null and b/novelforge-project/flutter/examples/image_list/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png differ diff --git a/novelforge-project/flutter/examples/image_list/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png b/novelforge-project/flutter/examples/image_list/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png new file mode 100644 index 0000000000000000000000000000000000000000..8a31fe2dd3f91d79cab6e0390356bb3c1a355f94 Binary files /dev/null and b/novelforge-project/flutter/examples/image_list/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png differ diff --git a/novelforge-project/flutter/examples/image_list/macos/Runner/Base.lproj/MainMenu.xib b/novelforge-project/flutter/examples/image_list/macos/Runner/Base.lproj/MainMenu.xib new file mode 100644 index 0000000000000000000000000000000000000000..537341abf994b3b9c5fd0a42fa6ffe6b5ed01aae --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/macos/Runner/Base.lproj/MainMenu.xib @@ -0,0 +1,339 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/novelforge-project/flutter/examples/image_list/macos/Runner/Configs/AppInfo.xcconfig b/novelforge-project/flutter/examples/image_list/macos/Runner/Configs/AppInfo.xcconfig new file mode 100644 index 0000000000000000000000000000000000000000..55939c7dca21e857ffd653bb6881e91f17220204 --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/macos/Runner/Configs/AppInfo.xcconfig @@ -0,0 +1,14 @@ +// Application-level settings for the Runner target. +// +// This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the +// future. If not, the values below would default to using the project name when this becomes a +// 'flutter create' template. + +// The application's name. By default this is also the title of the Flutter window. +PRODUCT_NAME = image_list + +// The application's bundle identifier +PRODUCT_BUNDLE_IDENTIFIER = com.example.imageList + +// The copyright displayed in application information +PRODUCT_COPYRIGHT = Copyright © 2021 com.example. All rights reserved. diff --git a/novelforge-project/flutter/examples/image_list/macos/Runner/Configs/Debug.xcconfig b/novelforge-project/flutter/examples/image_list/macos/Runner/Configs/Debug.xcconfig new file mode 100644 index 0000000000000000000000000000000000000000..36b0fd9464f45b33f482e64bea579787e142affa --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/macos/Runner/Configs/Debug.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Debug.xcconfig" +#include "Warnings.xcconfig" diff --git a/novelforge-project/flutter/examples/image_list/macos/Runner/Configs/Release.xcconfig b/novelforge-project/flutter/examples/image_list/macos/Runner/Configs/Release.xcconfig new file mode 100644 index 0000000000000000000000000000000000000000..dff4f49561c816f70eaea557d889d31cf63447ac --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/macos/Runner/Configs/Release.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Release.xcconfig" +#include "Warnings.xcconfig" diff --git a/novelforge-project/flutter/examples/image_list/macos/Runner/Configs/Warnings.xcconfig b/novelforge-project/flutter/examples/image_list/macos/Runner/Configs/Warnings.xcconfig new file mode 100644 index 0000000000000000000000000000000000000000..42bcbf4780b187e80025b7917058bcb882012aa1 --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/macos/Runner/Configs/Warnings.xcconfig @@ -0,0 +1,13 @@ +WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings +GCC_WARN_UNDECLARED_SELECTOR = YES +CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES +CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE +CLANG_WARN__DUPLICATE_METHOD_MATCH = YES +CLANG_WARN_PRAGMA_PACK = YES +CLANG_WARN_STRICT_PROTOTYPES = YES +CLANG_WARN_COMMA = YES +GCC_WARN_STRICT_SELECTOR_MATCH = YES +CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES +CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES +GCC_WARN_SHADOW = YES +CLANG_WARN_UNREACHABLE_CODE = YES diff --git a/novelforge-project/flutter/examples/image_list/macos/Runner/DebugProfile.entitlements b/novelforge-project/flutter/examples/image_list/macos/Runner/DebugProfile.entitlements new file mode 100644 index 0000000000000000000000000000000000000000..dddb8a30c851e7ef5b16a9108934bd1217b6b43f --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/macos/Runner/DebugProfile.entitlements @@ -0,0 +1,12 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.cs.allow-jit + + com.apple.security.network.server + + + diff --git a/novelforge-project/flutter/examples/image_list/macos/Runner/Info.plist b/novelforge-project/flutter/examples/image_list/macos/Runner/Info.plist new file mode 100644 index 0000000000000000000000000000000000000000..4789daa6a443eefa7f3f729164a18351e06e9800 --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/macos/Runner/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + $(PRODUCT_COPYRIGHT) + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/novelforge-project/flutter/examples/image_list/macos/Runner/MainFlutterWindow.swift b/novelforge-project/flutter/examples/image_list/macos/Runner/MainFlutterWindow.swift new file mode 100644 index 0000000000000000000000000000000000000000..a6a6b9af83072d4765fb492f05ebc05671f9924e --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/macos/Runner/MainFlutterWindow.swift @@ -0,0 +1,19 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import Cocoa +import FlutterMacOS + +class MainFlutterWindow: NSWindow { + override func awakeFromNib() { + let flutterViewController = FlutterViewController() + let windowFrame = self.frame + self.contentViewController = flutterViewController + self.setFrame(windowFrame, display: true) + + RegisterGeneratedPlugins(registry: flutterViewController) + + super.awakeFromNib() + } +} diff --git a/novelforge-project/flutter/examples/image_list/macos/Runner/Release.entitlements b/novelforge-project/flutter/examples/image_list/macos/Runner/Release.entitlements new file mode 100644 index 0000000000000000000000000000000000000000..852fa1a4728ae4789e3bca55dd07caef3b41f2a5 --- /dev/null +++ b/novelforge-project/flutter/examples/image_list/macos/Runner/Release.entitlements @@ -0,0 +1,8 @@ + + + + + com.apple.security.app-sandbox + + + diff --git a/novelforge-project/flutter/examples/layers/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/novelforge-project/flutter/examples/layers/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..09d4391482be68e9e4a07fab769b5de337d16eb1 Binary files /dev/null and b/novelforge-project/flutter/examples/layers/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/novelforge-project/flutter/examples/layers/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/novelforge-project/flutter/examples/layers/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..d5f1c8d34e7a88e3f88bea192c3a370d44689c3c Binary files /dev/null and b/novelforge-project/flutter/examples/layers/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/novelforge-project/flutter/examples/layers/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/novelforge-project/flutter/examples/layers/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..4d6372eebdb28e45604e46eeda8dd24651419bc0 Binary files /dev/null and b/novelforge-project/flutter/examples/layers/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ