Compare commits
No commits in common. "lab_2" and "master" have entirely different histories.
@ -1,4 +1,4 @@
|
|||||||
# identity
|
# mobilefl
|
||||||
|
|
||||||
A new Flutter project.
|
A new Flutter project.
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace = "com.example.identity"
|
namespace = "com.example.mobilefl"
|
||||||
compileSdk = flutter.compileSdkVersion
|
compileSdk = flutter.compileSdkVersion
|
||||||
ndkVersion = flutter.ndkVersion
|
ndkVersion = flutter.ndkVersion
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ android {
|
|||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||||
applicationId = "com.example.identity"
|
applicationId = "com.example.mobilefl"
|
||||||
// You can update the following values to match your application needs.
|
// You can update the following values to match your application needs.
|
||||||
// For more information, see: https://flutter.dev/to/review-gradle-config.
|
// For more information, see: https://flutter.dev/to/review-gradle-config.
|
||||||
minSdk = flutter.minSdkVersion
|
minSdk = flutter.minSdkVersion
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<application
|
<application
|
||||||
android:label="identity"
|
android:label="mobilefl"
|
||||||
android:name="${applicationName}"
|
android:name="${applicationName}"
|
||||||
android:icon="@mipmap/ic_launcher">
|
android:icon="@mipmap/ic_launcher">
|
||||||
<activity
|
<activity
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.identity
|
package com.example.mobilefl
|
||||||
|
|
||||||
import io.flutter.embedding.android.FlutterActivity
|
import io.flutter.embedding.android.FlutterActivity
|
||||||
|
|
@ -1,43 +0,0 @@
|
|||||||
import 'dart:async';
|
|
||||||
|
|
||||||
enum CharacterType {
|
|
||||||
Survivor,
|
|
||||||
Hunter,
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class Character {
|
|
||||||
String name;
|
|
||||||
CharacterType type;
|
|
||||||
int level;
|
|
||||||
|
|
||||||
Character({required this.name, required this.type, this.level = 1});
|
|
||||||
|
|
||||||
Character.empty() : name = '', type = CharacterType.Survivor, level = 1;
|
|
||||||
|
|
||||||
String getInfo() {
|
|
||||||
return "Имя: $name, Тип: ${type.toString().split('.').last}, Уровень: $level";
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> levelUp() async {
|
|
||||||
await Future.delayed(const Duration(seconds: 1));
|
|
||||||
level++;
|
|
||||||
print("$name поднял(а) уровень до $level.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Survivor extends Character {
|
|
||||||
Survivor({required String name}) : super(name: name, type: CharacterType.Survivor);
|
|
||||||
|
|
||||||
void useAbility() {
|
|
||||||
print("$name использовал(а) свою способность.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Hunter extends Character {
|
|
||||||
Hunter({required String name}) : super(name: name, type: CharacterType.Hunter);
|
|
||||||
|
|
||||||
void useAbility() {
|
|
||||||
print("$name использовал(а) свою способность.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
|||||||
import 'character.dart';
|
|
||||||
import 'default_character.dart';
|
|
||||||
|
|
||||||
extension CharacterListExtension<T extends Character> on List<T> {
|
|
||||||
T findByName(String name) {
|
|
||||||
return firstWhere((character) => character.name == name,
|
|
||||||
orElse: () => DefaultCharacter() as T);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
import 'character.dart';
|
|
||||||
class DefaultCharacter extends Character {
|
|
||||||
DefaultCharacter() : super.empty();
|
|
||||||
}
|
|
130
lib/main.dart
130
lib/main.dart
@ -1,116 +1,70 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'character.dart';
|
|
||||||
import 'character_list_extension.dart';
|
|
||||||
import 'default_character.dart';
|
|
||||||
|
|
||||||
void main() => runApp(MyApp());
|
void main() {
|
||||||
|
runApp(const MyApp());
|
||||||
|
}
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class MyApp extends StatelessWidget {
|
||||||
@override
|
const MyApp({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
title: 'Identity V Characters',
|
title: 'Flutter Demo',
|
||||||
home: MyHomePage(title: 'Персонажи Identity V'),
|
theme: ThemeData(
|
||||||
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
|
||||||
|
useMaterial3: true,
|
||||||
|
),
|
||||||
|
home: const MyHomePage(title: 'Камчарова Ксения Алексеевна'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyHomePage extends StatefulWidget {
|
class MyHomePage extends StatefulWidget {
|
||||||
MyHomePage({Key? key, required this.title}) : super(key: key);
|
const MyHomePage({super.key, required this.title});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
final String title;
|
final String title;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_MyHomePageState createState() => _MyHomePageState();
|
State<MyHomePage> createState() => _MyHomePageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MyHomePageState extends State<MyHomePage> {
|
class _MyHomePageState extends State<MyHomePage> {
|
||||||
final List<Character> _characters = [];
|
int _counter = 0;
|
||||||
final _nameController = TextEditingController();
|
|
||||||
CharacterType _selectedType = CharacterType.Survivor; // По умолчанию - выживший
|
void _incrementCounter() {
|
||||||
|
setState(() {
|
||||||
|
_counter++;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(widget.title),
|
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
||||||
|
title: Text(widget.title),
|
||||||
),
|
),
|
||||||
body: Column(
|
body: Center(
|
||||||
children: [
|
child: Column(
|
||||||
Padding(
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
padding: const EdgeInsets.all(16.0),
|
children: <Widget>[
|
||||||
child: TextField(
|
const Text(
|
||||||
controller: _nameController,
|
'You have pushed the button this many times:',
|
||||||
decoration: InputDecoration(
|
|
||||||
labelText: 'Имя персонажа',
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
Text(
|
||||||
Padding(
|
'$_counter',
|
||||||
padding: const EdgeInsets.all(16.0),
|
style: Theme.of(context).textTheme.headlineMedium,
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Radio<CharacterType>(
|
|
||||||
value: CharacterType.Survivor,
|
|
||||||
groupValue: _selectedType,
|
|
||||||
onChanged: (value) {
|
|
||||||
setState(() {
|
|
||||||
_selectedType = value!;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Text('Выживший'),
|
|
||||||
Radio<CharacterType>(
|
|
||||||
value: CharacterType.Hunter,
|
|
||||||
groupValue: _selectedType,
|
|
||||||
onChanged: (value) {
|
|
||||||
setState(() {
|
|
||||||
_selectedType = value!;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Text('Охотник'),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
ElevatedButton(
|
),
|
||||||
onPressed: () {
|
|
||||||
final name = _nameController.text.trim();
|
|
||||||
if (name.isNotEmpty) {
|
|
||||||
setState(() {
|
|
||||||
_characters.add(
|
|
||||||
_selectedType == CharacterType.Survivor
|
|
||||||
? Survivor(name: name)
|
|
||||||
: Hunter(name: name),
|
|
||||||
);
|
|
||||||
_nameController.clear();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Text('Добавить персонажа'),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: ListView.builder(
|
|
||||||
itemCount: _characters.length,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
final character = _characters[index];
|
|
||||||
return ListTile(
|
|
||||||
title: Text(character.name),
|
|
||||||
subtitle: Text(character.getInfo()),
|
|
||||||
trailing: IconButton(
|
|
||||||
icon: Icon(Icons.delete),
|
|
||||||
onPressed: () {
|
|
||||||
setState(() {
|
|
||||||
_characters.removeAt(index);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
);
|
floatingActionButton: FloatingActionButton(
|
||||||
|
onPressed: _incrementCounter,
|
||||||
|
tooltip: 'Increment',
|
||||||
|
child: const Icon(Icons.add),
|
||||||
|
), );
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
name: identity
|
name: mobilefl
|
||||||
description: "A new Flutter project."
|
description: "A new Flutter project."
|
||||||
# The following line prevents the package from being accidentally published to
|
# The following line prevents the package from being accidentally published to
|
||||||
# pub.dev using `flutter pub publish`. This is preferred for private packages.
|
# pub.dev using `flutter pub publish`. This is preferred for private packages.
|
||||||
|
@ -8,12 +8,12 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
import 'package:identity/main.dart';
|
import 'package:mobilefl/main.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
||||||
// Build our app and trigger a frame.
|
// Build our app and trigger a frame.
|
||||||
await tester.pumpWidget(MyApp());
|
await tester.pumpWidget(const MyApp());
|
||||||
|
|
||||||
// Verify that our counter starts at 0.
|
// Verify that our counter starts at 0.
|
||||||
expect(find.text('0'), findsOneWidget);
|
expect(find.text('0'), findsOneWidget);
|
||||||
|
@ -23,13 +23,13 @@
|
|||||||
<!-- iOS meta tags & icons -->
|
<!-- iOS meta tags & icons -->
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||||
<meta name="apple-mobile-web-app-title" content="identity">
|
<meta name="apple-mobile-web-app-title" content="mobilefl">
|
||||||
<link rel="apple-touch-icon" href="icons/Icon-192.png">
|
<link rel="apple-touch-icon" href="icons/Icon-192.png">
|
||||||
|
|
||||||
<!-- Favicon -->
|
<!-- Favicon -->
|
||||||
<link rel="icon" type="image/png" href="favicon.png"/>
|
<link rel="icon" type="image/png" href="favicon.png"/>
|
||||||
|
|
||||||
<title>identity</title>
|
<title>mobilefl</title>
|
||||||
<link rel="manifest" href="manifest.json">
|
<link rel="manifest" href="manifest.json">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "identity",
|
"name": "mobilefl",
|
||||||
"short_name": "identity",
|
"short_name": "mobilefl",
|
||||||
"start_url": ".",
|
"start_url": ".",
|
||||||
"display": "standalone",
|
"display": "standalone",
|
||||||
"background_color": "#0175C2",
|
"background_color": "#0175C2",
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
# Project-level configuration.
|
# Project-level configuration.
|
||||||
cmake_minimum_required(VERSION 3.14)
|
cmake_minimum_required(VERSION 3.14)
|
||||||
project(identity LANGUAGES CXX)
|
project(mobilefl LANGUAGES CXX)
|
||||||
|
|
||||||
# The name of the executable created for the application. Change this to change
|
# The name of the executable created for the application. Change this to change
|
||||||
# the on-disk name of your application.
|
# the on-disk name of your application.
|
||||||
set(BINARY_NAME "identity")
|
set(BINARY_NAME "mobilefl")
|
||||||
|
|
||||||
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
|
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
|
||||||
# versions of CMake.
|
# versions of CMake.
|
||||||
|
@ -90,12 +90,12 @@ BEGIN
|
|||||||
BLOCK "040904e4"
|
BLOCK "040904e4"
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "CompanyName", "com.example" "\0"
|
VALUE "CompanyName", "com.example" "\0"
|
||||||
VALUE "FileDescription", "identity" "\0"
|
VALUE "FileDescription", "mobilefl" "\0"
|
||||||
VALUE "FileVersion", VERSION_AS_STRING "\0"
|
VALUE "FileVersion", VERSION_AS_STRING "\0"
|
||||||
VALUE "InternalName", "identity" "\0"
|
VALUE "InternalName", "mobilefl" "\0"
|
||||||
VALUE "LegalCopyright", "Copyright (C) 2024 com.example. All rights reserved." "\0"
|
VALUE "LegalCopyright", "Copyright (C) 2024 com.example. All rights reserved." "\0"
|
||||||
VALUE "OriginalFilename", "identity.exe" "\0"
|
VALUE "OriginalFilename", "mobilefl.exe" "\0"
|
||||||
VALUE "ProductName", "identity" "\0"
|
VALUE "ProductName", "mobilefl" "\0"
|
||||||
VALUE "ProductVersion", VERSION_AS_STRING "\0"
|
VALUE "ProductVersion", VERSION_AS_STRING "\0"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
|
@ -27,7 +27,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
|
|||||||
FlutterWindow window(project);
|
FlutterWindow window(project);
|
||||||
Win32Window::Point origin(10, 10);
|
Win32Window::Point origin(10, 10);
|
||||||
Win32Window::Size size(1280, 720);
|
Win32Window::Size size(1280, 720);
|
||||||
if (!window.Create(L"identity", origin, size)) {
|
if (!window.Create(L"mobilefl", origin, size)) {
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
window.SetQuitOnClose(true);
|
window.SetQuitOnClose(true);
|
||||||
|
Loading…
Reference in New Issue
Block a user