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