// Immutable List (zalecana - bezpieczna)
val owoce = listOf("jabłko", "gruszka", "wiśnia", "jabłko") // duplikaty dozwolone
println(owoce[1]) // gruszka
println(owoce.size) // 4
println(owoce.indexOf("wiśnia")) // 2
println(owoce.contains("banan")) // false
// Mutable List
val mutableOwoce = mutableListOf("banan", "winogrono")
mutableOwoce.add("pomarańcza") // dodaj na końcu
mutableOwoce.add(1, "kiwi") // dodaj na indeksie
mutableOwoce.remove("banan") // usuń wartość
mutableOwoce[0] = "ananas" // zmień
println(mutableOwoce) // [ananas, kiwi, winogrono, pomarańcza]
// Slicing i subList
println(owoce.subList(1, 3)) // [gruszka, wiśnia]
// Powszechne transformacje (styl funkcjonalny)
val duzeLitery = owoce.map { it.uppercase() } // wszystkie wielkimi literami
val dlugieZnaki = owoce.filter { it.length > 5 } // filtruj
val posortowane = owoce.sorted() // alfabetycznie
val sumaDlugosci = owoce.fold(0) { acc, owoc -> acc + owoc.length } // suma długości
println(duzeLitery) // [JABŁKO, GRUSZKA, WIŚNIA, JABŁKO]// Immutable Set
val unikalne = setOf(1, 2, 2, 3, 4) // 2 duplikat, zostaje jeden
println(unikalne) // [1, 2, 3, 4]
// Mutable Set
val mutableSet = mutableSetOf("czerwony", "zielony")
mutableSet.add("niebieski")
mutableSet.add("zielony") // nie doda
mutableSet.remove("czerwony")
// Operacje na zbiorach
val set1 = setOf(1, 2, 3)
val set2 = setOf(3, 4, 5)
println(set1 union set2) // [1, 2, 3, 4, 5]
println(set1 intersect set2) // [3]
println(set1 - set2) // [1, 2] (różnica)
// Członkostwo (bardzo szybkie)
println(3 in set1) // true// Immutable Map
val osoba = mapOf("imie" to "Mehmet", "wiek" to 35, "miasto" to "Ankara")
println(osoba["imie"]) // Mehmet
println(osoba.keys) // [imie, wiek, miasto]
println(osoba.values) // [Mehmet, 35, Ankara]
println(osoba.entries) // pary klucz-wartość
// Mutable Map
val mutableMap = mutableMapOf("pensja" to 5000)
mutableMap["departament"] = "IT" // dodaj/aktualizuj
mutableMap += "bonus" to 1000 // operator +
mutableMap -= "pensja" // usuń
// Bezpieczny dostęp
println(osoba.getOrDefault("email", "Brak")) // Brak
// Transformacje
val imionaDuze = osoba.mapKeys { it.key.uppercase() }
val wiekZwiekszony = osoba.mapValues { if (it.key == "wiek") it.value + 1 else it.value }
// Zagnieżdżona Map
val firma = mutableMapOf(
"pracownik1" to mapOf("imie" to "Ayşe", "pensja" to 6000),
"pracownik2" to mapOf("imie" to "Ali", "pensja" to 7000)
)
println(firma["pracownik1"]?.get("pensja")) // 6000val lazySeq = generateSequence(1) { it + 1 }.take(1000000).filter { it % 2 == 0 }
println(lazySeq.sum()) // Oblicza tylko gdy potrzebnefor ((klucz, wartosc) in osoba) {
println("$klucz: $wartosc")
}CytatFurnitureAR/
├── Models/
│ └── FurnitureEntity.swift
├── Views/
│ ├── ContentView.swift
│ ├── PlacementView.swift
│ └── ImmersiveView.swift
├── Components/
│ └── FurnitureComponent.swift
└── FurnitureARApp.swift
import RealityKit
import SwiftUI
struct FurnitureEntity: Entity, HasModel, HasAnchoring {
var model: ModelComponent?
init(usdzName: String) {
super.init()
guard let modelURL = Bundle.main.url(forResource: usdzName, withExtension: "usdz") else {
fatalError("Plik USDZ nie znaleziony: \(usdzName)")
}
do {
let model = try ModelEntity.loadModel(contentsOf: modelURL)
model.generateCollisionShapes(recursive: true)
model.components.set(CollisionComponent(shapes: [.generateBox(size: 1.0)]))
model.components.set(InputTargetComponent())
self.addChild(model)
self.model = model.components[ModelComponent.self]
} catch {
print("Błąd ładowania modelu: \(error)")
}
}
@MainActor required init() {
fatalError("init() has not been implemented")
}
}import SwiftUI
import RealityKit
import ARKit
struct PlacementView: View {
@State private var arView = ARView(frame: .zero)
@State private var selectedFurniture: String? = nil
@State private var placedEntities: [Entity] = []
var body: some View {
ZStack {
ARViewContainer(arView: $arView, placedEntities: $placedEntities)
.ignoresSafeArea()
VStack {
Spacer()
HStack(spacing: 20) {
ForEach(["sofa", "stół", "lampa"], id: \.self) { item in
Button {
selectedFurniture = item
} label: {
Text(item.capitalized)
.padding()
.background(Color.blue.opacity(0.8))
.clipShape(Capsule())
}
}
}
}
.padding(.bottom, 40)
}
.onAppear {
setupAR()
}
.gesture(
DragGesture()
.targetedToAnyEntity()
.onChanged { value in
value.entity.position = value.convert(value.location3D, from: .local, to: .scene)
}
)
.gesture(
TapGesture()
.targetedToAnyEntity()
.onEnded { value in
if let furniture = selectedFurniture {
let newEntity = FurnitureEntity(usdzName: furniture)
newEntity.position = value.convert(value.location3D, from: .local, to: .scene)
arView.scene.addAnchor(newEntity)
placedEntities.append(newEntity)
selectedFurniture = nil
}
}
)
}
func setupAR() {
let config = ARWorldTrackingConfiguration()
config.planeDetection = [.horizontal, .vertical]
config.environmentTexturing = .automatic
arView.session.run(config)
// Wizualizacja płaszczyzn
arView.debugOptions = [.showFeaturePoints, .showAnchorOrigins]
}
}
struct ARViewContainer: UIViewRepresentable {
@Binding var arView: ARView
@Binding var placedEntities: [Entity]
func makeUIView(context: Context) -> ARView {
return arView
}
func updateUIView(_ uiView: ARView, context: Context) {}
}import SwiftUI
import RealityKit
@main
struct FurnitureARApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
ImmersiveSpace(id: "ImmersiveFurniture") {
ImmersiveView()
}
.immersionStyle(selection: .constant(.mixed), in: .mixed)
}
}
struct ContentView: View {
@Environment(\.openImmersiveSpace) var openImmersiveSpace
var body: some View {
VStack(spacing: 40) {
Text("Wirtualne Umieszczanie Mebli")
.font(.largeTitle)
Button("Rozpocznij w Trybie Immersyjnym") {
Task {
await openImmersiveSpace(id: "ImmersiveFurniture")
}
}
.buttonStyle(.borderedProminent)
}
}
}
struct ImmersiveView: View {
var body: some View {
RealityView { content in
// Tutaj możesz dodać środowisko 360° lub dodatkowe entity
if let skybox = try? EnvironmentResource.load(named: "skybox") {
content.environment = skybox
}
// Przykładowy anchor
let anchor = AnchorEntity(world: [0, 0, -3])
anchor.addChild(FurnitureEntity(usdzName: "sofa"))
content.add(anchor)
}
}
}import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
int sayac = 0;
void arttir() {
setState(() {
sayac++;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text("Stateful Przykład")),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Licznik: $sayac",
style: const TextStyle(fontSize: 32),
),
ElevatedButton(
onPressed: arttir,
child: const Text("Zwiększ"),
),
],
),
),
),
);
}
}npm create vite@latest my-react-app-2025 -- --template react-ts
cd my-react-app-2025
npm install
npm install -D prettier prettier-plugin-react prettier-plugin-react-hooks prettier-config-prettier prettier-plugin-prettier prettier tailwindcss postcss autoprefixer
npx tailwindcss init -p/** @type {import('tailwindcss').Config} */
export default {
content: [
"index.html",
"src/**/*.js,ts,jsx,tsx",
],
darkMode: 'class',
theme: {
extend: {
fontFamily: {
sans: ['Inter', 'system-ui', 'sans-serif'],
},
colors: {
primary: {
500: '#6366f1',
600: '#4f46e5',
},
},
},
},
plugins: [],
}module.exports = {
env: {
browser: true,
es2021: true,
node: true,
},
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
'prettier'
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
plugins: ['react', '@typescript-eslint', 'prettier'],
rules: {
'react/react-in-jsx-scope': 'off',
'react/prop-types': 'off',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/no-explicit-any': 'warn',
'prettier/prettier': 'error',
'no-console': 'warn',
},
settings: {
react: {
version: 'detect',
},
},
};{
"semi": true,
"trailingComma": "es5",
"singleQuote": true,
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"bracketSpacing": true,
"arrowParens": "avoid"
}{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"]
}{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
},
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'
export default defineConfig({
plugins: [react()],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
server: {
port: 3000,
open: true,
},
})import { ButtonHTMLAttributes, ReactNode } from 'react';
import { cn } from '@utils/cn';
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
children: ReactNode;
variant?: 'primary' | 'secondary' | 'ghost';
}
export default function Button({
children,
variant = 'primary',
className,
...props
}: ButtonProps) {
return (
<button
className={cn(
'px-6 py-3 rounded-lg font-medium transition-all',
variant === 'primary' && 'bg-primary-600 text-white hover:bg-primary-700',
variant === 'secondary' && 'bg-gray-200 text-gray-900 hover:bg-gray-300',
variant === 'ghost' && 'text-primary-600 hover:bg-primary-50',
className
)}
{...props}
>
{children}
</button>
);
}import { clsx } from 'clsx';
import { twMerge } from 'tailwind-merge';
export function cn(...inputs: any[]) {
return twMerge(clsx(inputs));
}class Matematyka {
static int dodaj(int a, int b) {
return a + b;
}
}
void main() {
// Wywołanie metody statycznej bez tworzenia obiektu
int wynik = Matematyka.dodaj(5, 3);
print('Wynik: $wynik'); // Wynik: 8
}class FormatowanieTekstu {
static String doTytulu(String tekst) {
if (tekst.isEmpty) return tekst;
return tekst[0].toUpperCase() + tekst.substring(1).toLowerCase();
}
}
void main() {
String tekst = FormatowanieTekstu.doTytulu('flutter jest super');
print(tekst); // Wynik: Flutter jest super
}import 'package:flutter/material.dart';
class StyleApp {
static TextStyle naglowekStyl() {
return TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
color: Colors.blue,
);
}
}
class MojWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Text(
'Witaj w Flutterze!',
style: StyleApp.naglowekStyl(),
);
}
}import 'package:test/test.dart';
import 'main.dart';
void main() {
test('Test formatowania tekstu', () {
expect(FormatowanieTekstu.doTytulu('test'), equals('Test'));
expect(FormatowanieTekstu.doTytulu(''), equals(''));
});
}