mirror of
https://github.com/flutter/samples.git
synced 2026-06-07 23:09:51 +00:00
added Type Jam puzzle app for review (#1554)
* added Type Jam puzzle app for review * pr round 2 prep * updated ci scripts for varfont_shader_puzzle * resolved unused and minor variable naming issues * rotator tiles row and col are final vars now * removed unused import and print from production * made constructors const where needed * pages_flow export refactored to directly come from that file * removed old api commented out section from FragmentShaded * updated pubspec yaml to correct project name * dart min version updated; removed unnecessary commented out dependencies from pubspec.yaml * updated pubspec.yaml min flutter version to ensure FragmentShader support * added/edited comments for explanation, esp on var fonts; removed obsolete comments * trailing newline added to pubspec.yaml eof
This commit is contained in:
@@ -0,0 +1,174 @@
|
||||
// Copyright 2023 The Flutter team. 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';
|
||||
import '../page_content/wallpapers_flow.dart';
|
||||
import '../components/components.dart';
|
||||
import 'pages.dart';
|
||||
|
||||
class PagesFlow extends StatefulWidget {
|
||||
const PagesFlow({Key? key}) : super(key: key);
|
||||
|
||||
static const pageScrollDuration = 400;
|
||||
|
||||
@override
|
||||
State<PagesFlow> createState() => _PagesFlowState();
|
||||
}
|
||||
|
||||
class _PagesFlowState extends State<PagesFlow> {
|
||||
late PageController pageController = PageController();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final double screenWidth = MediaQuery.of(context).size.width;
|
||||
final double screenHeight = MediaQuery.of(context).size.height;
|
||||
bool narrowView = screenWidth * 1.8 < screenHeight ? true : false;
|
||||
double puzzleSize =
|
||||
narrowView ? screenWidth * 1 : min(screenHeight * 0.6, screenWidth);
|
||||
double topBottomMargin = (screenHeight - puzzleSize) * 0.5;
|
||||
double wonkyCharLargeSize = topBottomMargin * 1.0;
|
||||
double wonkyCharSmallSize = wonkyCharLargeSize * 0.5;
|
||||
PageConfig pageConfig = PageConfig(
|
||||
screenWidth: screenWidth,
|
||||
screenHeight: screenHeight,
|
||||
narrowView: narrowView,
|
||||
puzzleSize: puzzleSize,
|
||||
pageController: pageController,
|
||||
wonkyCharLargeSize: wonkyCharLargeSize,
|
||||
wonkyCharSmallSize: wonkyCharSmallSize,
|
||||
);
|
||||
|
||||
return PageView(
|
||||
controller: pageController,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
scrollDirection: Axis.vertical,
|
||||
children: [
|
||||
PageNarrativePre(
|
||||
pageConfig: pageConfig,
|
||||
),
|
||||
PageWeight(
|
||||
pageConfig: pageConfig,
|
||||
),
|
||||
PageAscenderDescender(
|
||||
pageConfig: pageConfig,
|
||||
),
|
||||
PageOpticalSize(
|
||||
pageConfig: pageConfig,
|
||||
),
|
||||
PageWidth(
|
||||
pageConfig: pageConfig,
|
||||
),
|
||||
PageNarrativePost(
|
||||
pageConfig: pageConfig,
|
||||
),
|
||||
const WallpapersFlow(),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class PageConfig {
|
||||
final double screenWidth;
|
||||
final double screenHeight;
|
||||
final bool narrowView;
|
||||
final double puzzleSize;
|
||||
final PageController pageController;
|
||||
final double wonkyCharLargeSize;
|
||||
final double wonkyCharSmallSize;
|
||||
static double baseWeight = 800;
|
||||
const PageConfig({
|
||||
Key? key,
|
||||
required this.screenWidth,
|
||||
required this.screenHeight,
|
||||
required this.narrowView,
|
||||
required this.puzzleSize,
|
||||
required this.pageController,
|
||||
required this.wonkyCharLargeSize,
|
||||
required this.wonkyCharSmallSize,
|
||||
});
|
||||
}
|
||||
|
||||
class SinglePage extends StatefulWidget {
|
||||
final PageConfig pageConfig;
|
||||
const SinglePage({
|
||||
Key? key,
|
||||
required this.pageConfig,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<SinglePage> createState() => SinglePageState();
|
||||
}
|
||||
|
||||
class SinglePageState extends State<SinglePage> with TickerProviderStateMixin {
|
||||
List<Widget> buildWonkyChars() {
|
||||
return <Widget>[];
|
||||
}
|
||||
|
||||
Widget createPuzzle() {
|
||||
return Container();
|
||||
}
|
||||
|
||||
Widget createTopicIntro() {
|
||||
return LightboxedPanel(
|
||||
pageConfig: widget.pageConfig,
|
||||
content: const [],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<Widget> c = [];
|
||||
c.add(createPuzzle());
|
||||
c += buildWonkyChars();
|
||||
c.add(createTopicIntro());
|
||||
return Stack(
|
||||
children: c,
|
||||
);
|
||||
}
|
||||
|
||||
void puzzleDone() {}
|
||||
}
|
||||
|
||||
class NarrativePage extends StatefulWidget {
|
||||
final PageConfig pageConfig;
|
||||
const NarrativePage({
|
||||
Key? key,
|
||||
required this.pageConfig,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<NarrativePage> createState() => NarrativePageState();
|
||||
}
|
||||
|
||||
class NarrativePageState extends State<NarrativePage>
|
||||
with TickerProviderStateMixin {
|
||||
int panelIndex = 0;
|
||||
List<LightboxedPanel> panels = [];
|
||||
|
||||
void handleIntroDismiss() {
|
||||
Future.delayed(const Duration(milliseconds: 50), () {
|
||||
setState(() {
|
||||
if (panelIndex == panels.length - 1) {
|
||||
widget.pageConfig.pageController.nextPage(
|
||||
duration:
|
||||
const Duration(milliseconds: PagesFlow.pageScrollDuration),
|
||||
curve: Curves.easeOut,
|
||||
);
|
||||
} else {
|
||||
panelIndex++;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
switch (panelIndex) {
|
||||
default:
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
|
||||
void puzzleDone() {}
|
||||
}
|
||||
Reference in New Issue
Block a user